From 273520de5bc8ee563dca3c14119505f84bd4e80c Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Fri, 27 Oct 2017 22:53:45 +0800 Subject: [PATCH] Remove vendor entity --- app/Entities/BaseRepository.php | 9 +- app/Entities/Partners/Vendor.php | 10 --- app/Entities/Payments/Payment.php | 12 +-- app/Entities/Subscriptions/Subscription.php | 5 -- .../Subscriptions/SubscriptionsRepository.php | 24 ++--- .../Controllers/Partners/VendorsController.php | 100 --------------------- .../Controllers/Projects/ProjectsController.php | 23 +++-- app/Policies/Partners/VendorPolicy.php | 64 ------------- app/Providers/AuthServiceProvider.php | 5 +- database/factories/ModelFactory.php | 3 +- database/factories/PaymentFactory.php | 2 +- database/factories/VendorFactory.php | 11 --- .../2017_10_26_092017_create_vendors_table.php | 36 -------- resources/lang/id/vendor.php | 29 ------ resources/views/payments/index.blade.php | 1 - resources/views/subscriptions/index.blade.php | 2 +- resources/views/vendors/forms.blade.php | 60 ------------- resources/views/vendors/index.blade.php | 67 -------------- routes/web.php | 32 ++++--- tests/Feature/ManageSubscriptionsTest.php | 5 +- tests/Feature/ManageVendorsTest.php | 100 --------------------- tests/Feature/Payments/ManagePaymentsTest.php | 9 +- tests/Feature/Payments/PaymentSearchTest.php | 8 +- tests/Unit/Models/PaymentTest.php | 4 +- tests/Unit/Models/SubscriptionTest.php | 8 -- tests/Unit/Models/VendorTest.php | 19 ---- tests/Unit/Policies/VendorPolicyTest.php | 43 --------- 27 files changed, 60 insertions(+), 631 deletions(-) delete mode 100644 app/Entities/Partners/Vendor.php delete mode 100644 app/Http/Controllers/Partners/VendorsController.php delete mode 100644 app/Policies/Partners/VendorPolicy.php delete mode 100644 database/factories/VendorFactory.php delete mode 100644 database/migrations/2017_10_26_092017_create_vendors_table.php delete mode 100644 resources/lang/id/vendor.php delete mode 100644 resources/views/vendors/forms.blade.php delete mode 100644 resources/views/vendors/index.blade.php delete mode 100644 tests/Feature/ManageVendorsTest.php delete mode 100644 tests/Unit/Models/VendorTest.php delete mode 100644 tests/Unit/Policies/VendorPolicyTest.php diff --git a/app/Entities/BaseRepository.php b/app/Entities/BaseRepository.php index f15846d..b7fdc15 100755 --- a/app/Entities/BaseRepository.php +++ b/app/Entities/BaseRepository.php @@ -3,7 +3,6 @@ namespace App\Entities; use App\Entities\Partners\Customer; -use App\Entities\Partners\Vendor; use App\Entities\Projects\Feature; use App\Entities\Projects\Project; use App\Entities\Users\User; @@ -21,11 +20,7 @@ abstract class BaseRepository extends EloquentRepository public function getCustomersAndVendorsList() { - $partnerList = [ - 'Customer' => Customer::orderBy('name')->pluck('name', 'id')->all(), - 'Vendor' => Vendor::orderBy('name')->pluck('name', 'id')->all(), - ]; - return $partnerList; + return Customer::orderBy('name')->pluck('name', 'id'); } public function getWorkersList() @@ -35,7 +30,7 @@ abstract class BaseRepository extends EloquentRepository public function getVendorsList() { - return Vendor::orderBy('name')->pluck('name', 'id'); + return Customer::orderBy('name')->pluck('name', 'id'); } public function getProjectsList() diff --git a/app/Entities/Partners/Vendor.php b/app/Entities/Partners/Vendor.php deleted file mode 100644 index 0d4f51d..0000000 --- a/app/Entities/Partners/Vendor.php +++ /dev/null @@ -1,10 +0,0 @@ -belongsTo(Project::class); } - public function customer() - { - return $this->belongsTo(Customer::class, 'customer_id'); - } - public function partner() { - if ($this->in_out == 1) { - return $this->belongsTo(Customer::class, 'partner_id'); - } - - return $this->belongsTo(Vendor::class, 'partner_id'); + return $this->belongsTo(Customer::class, 'partner_id'); } public function type() diff --git a/app/Entities/Subscriptions/Subscription.php b/app/Entities/Subscriptions/Subscription.php index e62d649..b4a69f5 100755 --- a/app/Entities/Subscriptions/Subscription.php +++ b/app/Entities/Subscriptions/Subscription.php @@ -22,11 +22,6 @@ class Subscription extends Model return $this->belongsTo('App\Entities\Partners\Customer'); } - public function vendor() - { - return $this->belongsTo('App\Entities\Partners\Vendor', 'vendor_id'); - } - public function status() { return $this->status_id ? trans('app.active') : trans('app.in_active'); diff --git a/app/Entities/Subscriptions/SubscriptionsRepository.php b/app/Entities/Subscriptions/SubscriptionsRepository.php index 2cf6c72..fbb4616 100755 --- a/app/Entities/Subscriptions/SubscriptionsRepository.php +++ b/app/Entities/Subscriptions/SubscriptionsRepository.php @@ -5,8 +5,8 @@ namespace App\Entities\Subscriptions; use App\Entities\BaseRepository; /** -* Subscriptions Repository Class -*/ + * Subscriptions Repository Class + */ class SubscriptionsRepository extends BaseRepository { protected $model; @@ -16,16 +16,20 @@ class SubscriptionsRepository extends BaseRepository parent::__construct($model); } - public function getSubscriptions($q, $vendorId) + public function getSubscriptions($q, $customerId) { return $this->model->orderBy('due_date') - ->where(function($query) use ($q, $vendorId) { - if ($vendorId) - $query->where('vendor_id', $vendorId); - if ($q) - $query->where('domain_name','like','%' . $q . '%'); + ->where(function ($query) use ($q, $customerId) { + if ($customerId) { + $query->where('customer_id', $customerId); + } + + if ($q) { + $query->where('domain_name', 'like', '%'.$q.'%'); + } + }) - ->with('vendor') + ->with('customer') ->paginate($this->_paginate); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/Partners/VendorsController.php b/app/Http/Controllers/Partners/VendorsController.php deleted file mode 100644 index 581c9f4..0000000 --- a/app/Http/Controllers/Partners/VendorsController.php +++ /dev/null @@ -1,100 +0,0 @@ -where('name', 'like', '%'.request('q').'%'); - })->paginate(25); - - if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { - $editableVendor = Vendor::find(request('id')); - } - - return view('vendors.index', compact('vendors', 'editableVendor')); - } - - /** - * Store a newly created vendor in storage. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ - public function store(Request $request) - { - $newVendorData = $this->validate($request, [ - 'name' => 'required|max:60', - 'email' => 'nullable|email|unique:vendors,email', - 'phone' => 'nullable', - 'notes' => 'nullable|max:255', - ]); - - Vendor::create($newVendorData); - - flash(trans('vendor.created'), 'success'); - - return redirect()->route('vendors.index'); - } - - /** - * Update the specified vendor in storage. - * - * @param \Illuminate\Http\Request $request - * @param \App\Entities\Partners\Vendor $vendor - * @return \Illuminate\Http\Response - */ - public function update(Request $request, Vendor $vendor) - { - $vendorData = $this->validate($request, [ - 'name' => 'required|max:60', - 'email' => 'nullable|email|unique:vendors,email,'.$vendor->id, - 'phone' => 'nullable', - 'notes' => 'nullable|max:255', - 'is_active' => 'required|boolean', - ]); - - $routeParam = request()->only('page', 'q'); - - $vendor = $vendor->update($vendorData); - - flash(trans('vendor.updated'), 'success'); - return redirect()->route('vendors.index', $routeParam); - } - - /** - * Remove the specified vendor from storage. - * - * @param \App\Entities\Partners\Vendor $vendor - * @return \Illuminate\Http\Response - */ - public function destroy(Vendor $vendor) - { - // TODO: user cannot delete vendor that has been used in other table - $this->validate(request(), [ - 'vendor_id' => 'required', - ]); - - $routeParam = request()->only('page', 'q'); - - if (request('vendor_id') == $vendor->id && $vendor->delete()) { - flash(trans('vendor.deleted'), 'warning'); - return redirect()->route('vendors.index', $routeParam); - } - - flash(trans('vendor.undeleted'), 'danger'); - return back(); - } -} diff --git a/app/Http/Controllers/Projects/ProjectsController.php b/app/Http/Controllers/Projects/ProjectsController.php index 671a974..c5df08b 100755 --- a/app/Http/Controllers/Projects/ProjectsController.php +++ b/app/Http/Controllers/Projects/ProjectsController.php @@ -2,12 +2,11 @@ namespace App\Http\Controllers\Projects; +use App\Entities\Projects\ProjectsRepository; +use App\Http\Controllers\Controller; use App\Http\Requests\Projects\CreateRequest; -use App\Http\Requests\Projects\UpdateRequest; use App\Http\Requests\Projects\DeleteRequest; -use App\Http\Controllers\Controller; -use App\Entities\Projects\ProjectsRepository; - +use App\Http\Requests\Projects\UpdateRequest; use Illuminate\Http\Request; class ProjectsController extends Controller @@ -21,7 +20,7 @@ class ProjectsController extends Controller public function index(Request $request) { - $status = null; + $status = null; $statusId = $request->get('status'); if ($statusId) { $status = $this->repo->getStatusName($statusId); @@ -52,15 +51,15 @@ class ProjectsController extends Controller public function edit($projectId) { - $project = $this->repo->requireById($projectId); - $statuses = getProjectStatusesList(); + $project = $this->repo->requireById($projectId); + $statuses = getProjectStatusesList(); $customers = $this->repo->getCustomersList(); return view('projects.edit', compact('project', 'statuses', 'customers')); } public function update(UpdateRequest $request, $projectId) { - $project = $this->repo->update($request->except(['_method','_token']), $projectId); + $project = $this->repo->update($request->except(['_method', '_token']), $projectId); flash()->success(trans('project.updated')); return redirect()->route('projects.edit', $projectId); } @@ -85,7 +84,7 @@ class ProjectsController extends Controller public function features($projectId) { - $project = $this->repo->requireById($projectId); + $project = $this->repo->requireById($projectId); $features = $this->repo->getProjectFeatures($projectId); return view('projects.features', compact('project', 'features')); } @@ -99,8 +98,8 @@ class ProjectsController extends Controller public function featuresExport(Request $request, $projectId, $exportType = 'excel') { $featureType = $request->get('feature_type', 1); - $project = $this->repo->requireById($projectId); - $features = $this->repo->getProjectFeatures($projectId, $featureType); + $project = $this->repo->requireById($projectId); + $features = $this->repo->getProjectFeatures($projectId, $featureType); if ($exportType == 'excel') { return view('projects.features-export-excel', compact('project', 'features')); @@ -124,7 +123,7 @@ class ProjectsController extends Controller public function payments($projectId) { $project = $this->repo->requireById($projectId); - $project->load('payments.customer'); + $project->load('payments.partner'); return view('projects.payments', compact('project')); } diff --git a/app/Policies/Partners/VendorPolicy.php b/app/Policies/Partners/VendorPolicy.php deleted file mode 100644 index 1df1785..0000000 --- a/app/Policies/Partners/VendorPolicy.php +++ /dev/null @@ -1,64 +0,0 @@ - 'App\Policies\Partners\CustomerPolicy', - 'App\Entities\Partners\Vendor' => 'App\Policies\Partners\VendorPolicy', - 'App\Entities\Users\Event' => 'App\Policies\EventPolicy', + 'App\Entities\Users\Event' => 'App\Policies\EventPolicy', ]; /** diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index e5af5dc..c1cc3d7 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -2,7 +2,6 @@ use App\Entities\Invoices\Invoice; use App\Entities\Partners\Customer; -use App\Entities\Partners\Vendor; use App\Entities\Projects\Feature; use App\Entities\Projects\Project; use App\Entities\Projects\Task; @@ -65,7 +64,7 @@ $factory->define(Subscription::class, function (Faker\Generator $faker) { return factory(Customer::class)->create()->id; }, 'vendor_id' => function () { - return factory(Vendor::class)->create()->id; + return factory(Customer::class)->create()->id; }, ]; }); diff --git a/database/factories/PaymentFactory.php b/database/factories/PaymentFactory.php index 9c04037..c07d299 100644 --- a/database/factories/PaymentFactory.php +++ b/database/factories/PaymentFactory.php @@ -20,7 +20,7 @@ $factory->define(Payment::class, function (Faker $faker) { 'owner_id' => function () { return factory(User::class)->create()->id; }, - 'customer_id' => function () { + 'partner_id' => function () { return factory(Customer::class)->create()->id; }, ]; diff --git a/database/factories/VendorFactory.php b/database/factories/VendorFactory.php deleted file mode 100644 index c22d568..0000000 --- a/database/factories/VendorFactory.php +++ /dev/null @@ -1,11 +0,0 @@ -define(Vendor::class, function (Faker $faker) { - - return [ - 'name' => $faker->company, - ]; -}); diff --git a/database/migrations/2017_10_26_092017_create_vendors_table.php b/database/migrations/2017_10_26_092017_create_vendors_table.php deleted file mode 100644 index e2b3c62..0000000 --- a/database/migrations/2017_10_26_092017_create_vendors_table.php +++ /dev/null @@ -1,36 +0,0 @@ -increments('id'); - $table->string('name', 60); - $table->string('email')->nullable()->unique(); - $table->string('phone')->nullable(); - $table->string('notes')->nullable(); - $table->boolean('is_active')->default(1); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('vendors'); - } -} diff --git a/resources/lang/id/vendor.php b/resources/lang/id/vendor.php deleted file mode 100644 index 02bc099..0000000 --- a/resources/lang/id/vendor.php +++ /dev/null @@ -1,29 +0,0 @@ - 'Vendor', - 'list' => 'Daftar Vendor', - 'search' => 'Cari Vendor', - 'not_found' => 'Vendor tidak ditemukan', - 'empty' => 'Belum ada Vendor', - 'back_to_show' => 'Back to Vendor Detail', - 'back_to_index' => 'Kembali ke daftar Vendor', - - // Actions - 'create' => 'Input Vendor Baru', - 'created' => 'Input Vendor baru telah berhasil.', - 'show' => 'Detail Vendor', - 'edit' => 'Edit Vendor', - 'update' => 'Update Vendor', - 'updated' => 'Update data Vendor telah berhasil.', - 'delete' => 'Hapus Vendor', - 'delete_confirm' => 'Anda yakin akan menghapus Vendor ini?', - 'deleted' => 'Hapus data Vendor telah berhasil.', - 'undeleted' => 'Data Vendor gagal dihapus.', - 'undeleteable' => 'Data Vendor tidak dapat dihapus.', - - // Attributes - 'name' => 'Nama Vendor', - 'description' => 'Deskripsi Vendor', -]; diff --git a/resources/views/payments/index.blade.php b/resources/views/payments/index.blade.php index 6e76b38..b4fc60f 100755 --- a/resources/views/payments/index.blade.php +++ b/resources/views/payments/index.blade.php @@ -35,7 +35,6 @@ {{ $payment->present()->amount }} {{ $payment->description }} {{ $payment->partner->name }} - {{-- {{ $payment->partner }} --}} {!! link_to_route('payments.show', trans('app.show'), [$payment->id], ['class'=>'btn btn-info btn-xs']) !!} {!! link_to_route('payments.edit', trans('app.edit'), [$payment->id], ['class'=>'btn btn-warning btn-xs']) !!} diff --git a/resources/views/subscriptions/index.blade.php b/resources/views/subscriptions/index.blade.php index 864faa1..a43ca55 100755 --- a/resources/views/subscriptions/index.blade.php +++ b/resources/views/subscriptions/index.blade.php @@ -32,7 +32,7 @@ {{ $subscriptions->firstItem() + $key }} {{ $subscription->domain_name }} {{ $subscription->hosting_capacity }} - {{ $subscription->vendor->name }} + {{ $subscription->customer->name }} -

{{ trans('vendor.delete') }}

-
- -

{{ $editableVendor->name }}

- -

{{ $editableVendor->email }}

- -

{{ $editableVendor->phone }}

- -

{{ $editableVendor->is_active }}

- -

{{ $editableVendor->notes }}

- {!! $errors->first('vendor_id', ':message') !!} -
-
-
{{ trans('app.delete_confirm') }}
- - -@endif diff --git a/resources/views/vendors/index.blade.php b/resources/views/vendors/index.blade.php deleted file mode 100644 index 2071f35..0000000 --- a/resources/views/vendors/index.blade.php +++ /dev/null @@ -1,67 +0,0 @@ -@extends('layouts.app') - -@section('title', trans('vendor.list')) - -@section('content') -

-
- {{ link_to_route('vendors.index', trans('vendor.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }} -
- {{ trans('vendor.list') }} - {{ trans('app.total') }} : {{ $vendors->total() }} {{ trans('vendor.vendor') }} -

-
-
-
-
- {{ Form::open(['method' => 'get','class' => 'form-inline']) }} - {!! FormField::text('q', ['value' => request('q'), 'label' => trans('vendor.search'), 'class' => 'input-sm']) !!} - {{ Form::submit(trans('vendor.search'), ['class' => 'btn btn-sm']) }} - {{ link_to_route('vendors.index', trans('app.reset')) }} - {{ Form::close() }} -
- - - - - - - - - - - - - @foreach($vendors as $key => $vendor) - - - - - - - - - @endforeach - -
{{ trans('app.table_no') }}{{ trans('vendor.name') }}{{ trans('contact.email') }}{{ trans('contact.phone') }}{{ trans('app.status') }}{{ trans('app.action') }}
{{ $vendors->firstItem() + $key }}{{ $vendor->name }}{{ $vendor->email }}{{ $vendor->phone }}{{ $vendor->is_active }} - {!! link_to_route( - 'vendors.index', - trans('app.edit'), - ['action' => 'edit', 'id' => $vendor->id] + Request::only('page', 'q'), - ['id' => 'edit-vendor-' . $vendor->id] - ) !!} | - {!! link_to_route( - 'vendors.index', - trans('app.delete'), - ['action' => 'delete', 'id' => $vendor->id] + Request::only('page', 'q'), - ['id' => 'del-vendor-' . $vendor->id] - ) !!} -
-
{{ $vendors->appends(Request::except('page'))->render() }}
-
-
-
- @includeWhen(Request::has('action'), 'vendors.forms') -
-
-@endsection diff --git a/routes/web.php b/routes/web.php index db047bf..c91e747 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,27 +1,25 @@ ['web','role:admin']], function () { +Route::group(['middleware' => ['web', 'role:admin']], function () { /* * Backup Restore Database Routes */ - Route::post('backups/upload', ['as'=>'backups.upload', 'uses'=>'BackupsController@upload']); - Route::post('backups/{fileName}/restore', ['as'=>'backups.restore', 'uses'=>'BackupsController@restore']); - Route::get('backups/{fileName}/dl', ['as'=>'backups.download', 'uses'=>'BackupsController@download']); + Route::post('backups/upload', ['as' => 'backups.upload', 'uses' => 'BackupsController@upload']); + Route::post('backups/{fileName}/restore', ['as' => 'backups.restore', 'uses' => 'BackupsController@restore']); + Route::get('backups/{fileName}/dl', ['as' => 'backups.download', 'uses' => 'BackupsController@download']); Route::resource('backups', 'BackupsController', ['except' => ['create', 'show', 'edit']]); }); -Route::apiResource('vendors', 'Partners\VendorsController'); - Route::apiResource('customers', 'Partners\CustomersController'); diff --git a/tests/Feature/ManageSubscriptionsTest.php b/tests/Feature/ManageSubscriptionsTest.php index 7919e47..7843e5d 100644 --- a/tests/Feature/ManageSubscriptionsTest.php +++ b/tests/Feature/ManageSubscriptionsTest.php @@ -3,7 +3,6 @@ namespace Tests\Feature; use App\Entities\Partners\Customer; -use App\Entities\Partners\Vendor; use App\Entities\Projects\Project; use App\Entities\Subscriptions\Subscription; use Tests\TestCase; @@ -14,7 +13,7 @@ class ManageSubscriptionsTest extends TestCase public function admin_can_entry_subscription() { $user = $this->adminUserSigningIn(); - $vendor = factory(Vendor::class)->create(); + $vendor = factory(Customer::class)->create(); $project = factory(Project::class)->create(); $customer = factory(Customer::class)->create(); @@ -54,7 +53,7 @@ class ManageSubscriptionsTest extends TestCase public function admin_can_edit_subscription_data() { $user = $this->adminUserSigningIn(); - $vendor = factory(Vendor::class)->create(); + $vendor = factory(Customer::class)->create(); $eppCode = str_random(10); $project = factory(Project::class)->create(); $customer = factory(Customer::class)->create(); diff --git a/tests/Feature/ManageVendorsTest.php b/tests/Feature/ManageVendorsTest.php deleted file mode 100644 index 68b14cd..0000000 --- a/tests/Feature/ManageVendorsTest.php +++ /dev/null @@ -1,100 +0,0 @@ -create(); - $vendor2 = factory(Vendor::class)->create(); - - $this->adminUserSigningIn(); - $this->visit(route('vendors.index')); - $this->see($vendor1->name); - $this->see($vendor2->name); - } - - /** @test */ - public function user_can_create_a_vendor() - { - $this->adminUserSigningIn(); - $this->visit(route('vendors.index')); - - $this->click(trans('vendor.create')); - $this->seePageIs(route('vendors.index', ['action' => 'create'])); - - $this->submitForm(trans('vendor.create'), [ - 'name' => 'Vendor 1 name', - 'email' => 'vendor1@mail.com', - 'phone' => '081234567890', - 'notes' => '', - ]); - - $this->seePageIs(route('vendors.index')); - - $this->seeInDatabase('vendors', [ - 'name' => 'Vendor 1 name', - 'email' => 'vendor1@mail.com', - 'phone' => '081234567890', - 'notes' => null, - ]); - } - - /** @test */ - public function user_can_edit_a_vendor_within_search_query() - { - $this->adminUserSigningIn(); - $vendor = factory(Vendor::class)->create(['name' => 'Testing 123']); - - $this->visit(route('vendors.index', ['q' => '123'])); - $this->click('edit-vendor-'.$vendor->id); - $this->seePageIs(route('vendors.index', ['action' => 'edit', 'id' => $vendor->id, 'q' => '123'])); - - $this->submitForm(trans('vendor.update'), [ - 'name' => 'Vendor 1 name', - 'email' => 'vendor1@mail.com', - 'phone' => '081234567890', - 'notes' => '', - 'is_active' => 0, - ]); - - $this->seePageIs(route('vendors.index', ['q' => '123'])); - - $this->seeInDatabase('vendors', [ - 'name' => 'Vendor 1 name', - 'email' => 'vendor1@mail.com', - 'phone' => '081234567890', - 'notes' => null, - 'is_active' => 0, - ]); - } - - /** @test */ - public function user_can_delete_a_vendor() - { - $this->adminUserSigningIn(); - $vendor = factory(Vendor::class)->create(); - - $this->visit(route('vendors.index', [$vendor->id])); - $this->click('del-vendor-'.$vendor->id); - $this->seePageIs(route('vendors.index', ['action' => 'delete', 'id' => $vendor->id])); - - $this->seeInDatabase('vendors', [ - 'id' => $vendor->id, - ]); - - $this->press(trans('app.delete_confirm_button')); - - $this->dontSeeInDatabase('vendors', [ - 'id' => $vendor->id, - ]); - } -} diff --git a/tests/Feature/Payments/ManagePaymentsTest.php b/tests/Feature/Payments/ManagePaymentsTest.php index 7d87e5b..61851b7 100644 --- a/tests/Feature/Payments/ManagePaymentsTest.php +++ b/tests/Feature/Payments/ManagePaymentsTest.php @@ -3,7 +3,6 @@ namespace Tests\Feature\Payments; use App\Entities\Partners\Customer; -use App\Entities\Partners\Vendor; use App\Entities\Payments\Payment; use App\Entities\Projects\Project; use Tests\TestCase; @@ -45,7 +44,7 @@ class ManagePaymentsTest extends TestCase public function admin_can_entry_project_an_expanse_payment() { $user = $this->adminUserSigningIn(); - $vendor = factory(Vendor::class)->create(); + $vendor = factory(Customer::class)->create(); $project = factory(Project::class)->create(); $this->visit(route('payments.index')); @@ -80,7 +79,7 @@ class ManagePaymentsTest extends TestCase $customer = factory(Customer::class)->create(); $project = factory(Project::class)->create(); - $payment = factory(Payment::class, 'expanse')->create([ + $payment = factory(Payment::class)->create([ 'partner_id' => $customer->id, 'project_id' => $project->id, 'owner_id' => $user->id, @@ -110,7 +109,7 @@ class ManagePaymentsTest extends TestCase { $user = $this->adminUserSigningIn(); - $payment = factory(Payment::class, 'expanse')->create(['owner_id' => $user->id]); + $payment = factory(Payment::class)->create(['owner_id' => $user->id]); $this->visit(route('payments.index')); $this->click(trans('app.edit')); $this->click(trans('payment.delete')); @@ -125,7 +124,7 @@ class ManagePaymentsTest extends TestCase $user = $this->adminUserSigningIn(); $project = factory(Project::class)->create(['owner_id' => $user->id]); - $payment = factory(Payment::class, 'expanse')->create(['project_id' => $project->id, 'owner_id' => $user->id]); + $payment = factory(Payment::class)->create(['project_id' => $project->id, 'owner_id' => $user->id]); $this->visit(route('payments.index')); $this->click(trans('app.show')); diff --git a/tests/Feature/Payments/PaymentSearchTest.php b/tests/Feature/Payments/PaymentSearchTest.php index cc69f30..d68cd39 100644 --- a/tests/Feature/Payments/PaymentSearchTest.php +++ b/tests/Feature/Payments/PaymentSearchTest.php @@ -13,8 +13,8 @@ class PaymentSearchTest extends TestCase { $admin = $this->adminUserSigningIn(); $project = factory(Project::class)->create(['name' => 'Project']); - $payment = factory(Payment::class, 'expanse')->create(['owner_id' => $admin->id, 'project_id' => $project->id]); - $unShownPayment = factory(Payment::class, 'expanse')->create(['owner_id' => $admin->id]); + $payment = factory(Payment::class)->create(['owner_id' => $admin->id, 'project_id' => $project->id]); + $unShownPayment = factory(Payment::class)->create(['owner_id' => $admin->id]); $this->visit(route('payments.index')); $this->submitForm(trans('app.search'), [ @@ -31,8 +31,8 @@ class PaymentSearchTest extends TestCase public function partner_find_payment_by_customer_id() { $admin = $this->adminUserSigningIn(); - $payment = factory(Payment::class, 'expanse')->create(['owner_id' => $admin->id]); - $unShownPayment = factory(Payment::class, 'expanse')->create(['owner_id' => $admin->id]); + $payment = factory(Payment::class)->create(['owner_id' => $admin->id]); + $unShownPayment = factory(Payment::class)->create(['owner_id' => $admin->id]); $this->visit(route('payments.index')); $this->submitForm(trans('app.search'), [ diff --git a/tests/Unit/Models/PaymentTest.php b/tests/Unit/Models/PaymentTest.php index 8b7e6da..64f4647 100644 --- a/tests/Unit/Models/PaymentTest.php +++ b/tests/Unit/Models/PaymentTest.php @@ -9,9 +9,9 @@ use Tests\TestCase; class PaymentTest extends TestCase { /** @test */ - public function it_has_customer_relation() + public function it_has_partner_relation() { $payment = factory(Payment::class)->create(); - $this->assertTrue($payment->customer instanceof Customer); + $this->assertTrue($payment->partner instanceof Customer); } } diff --git a/tests/Unit/Models/SubscriptionTest.php b/tests/Unit/Models/SubscriptionTest.php index 09e50b2..75ee115 100644 --- a/tests/Unit/Models/SubscriptionTest.php +++ b/tests/Unit/Models/SubscriptionTest.php @@ -3,7 +3,6 @@ namespace Tests\Unit\Models; use App\Entities\Partners\Customer; -use App\Entities\Partners\Vendor; use App\Entities\Subscriptions\Subscription; use Tests\TestCase as TestCase; @@ -22,11 +21,4 @@ class SubscriptionTest extends TestCase $subscription = factory(Subscription::class)->create(); $this->assertTrue($subscription->customer instanceof Customer); } - - /** @test */ - public function it_has_vendor_relation() - { - $subscription = factory(Subscription::class)->create(); - $this->assertTrue($subscription->vendor instanceof Vendor); - } } diff --git a/tests/Unit/Models/VendorTest.php b/tests/Unit/Models/VendorTest.php deleted file mode 100644 index 4f968bd..0000000 --- a/tests/Unit/Models/VendorTest.php +++ /dev/null @@ -1,19 +0,0 @@ -create(['name' => 'Vendor 1 name']); - $this->assertEquals('Vendor 1 name', $vendor->name); - } -} diff --git a/tests/Unit/Policies/VendorPolicyTest.php b/tests/Unit/Policies/VendorPolicyTest.php deleted file mode 100644 index b423d73..0000000 --- a/tests/Unit/Policies/VendorPolicyTest.php +++ /dev/null @@ -1,43 +0,0 @@ -adminUserSigningIn(); - $this->assertTrue($user->can('create', new Vendor)); - } - - /** @test */ - public function user_can_view_vendor() - { - $user = $this->adminUserSigningIn(); - $vendor = factory(Vendor::class)->create(['name' => 'Vendor 1 name']); - $this->assertTrue($user->can('view', $vendor)); - } - - /** @test */ - public function user_can_update_vendor() - { - $user = $this->adminUserSigningIn(); - $vendor = factory(Vendor::class)->create(['name' => 'Vendor 1 name']); - $this->assertTrue($user->can('update', $vendor)); - } - - /** @test */ - public function user_can_delete_vendor() - { - $user = $this->adminUserSigningIn(); - $vendor = factory(Vendor::class)->create(['name' => 'Vendor 1 name']); - $this->assertTrue($user->can('delete', $vendor)); - } -}