From bd0e47060c193f97fd181a1be501afbc46e97736 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sat, 28 Oct 2017 10:15:10 +0800 Subject: [PATCH] Change customer model to partner --- app/Entities/BaseRepository.php | 8 +- .../Partners/{Customer.php => Partner.php} | 2 +- app/Entities/Payments/Payment.php | 4 +- app/Entities/Projects/Project.php | 9 +- app/Entities/Projects/ProjectsRepository.php | 4 +- app/Entities/Subscriptions/Subscription.php | 2 +- app/Exceptions/Handler.php | 8 +- .../Controllers/Partners/CustomersController.php | 104 -------------------- .../Controllers/Partners/PartnersController.php | 104 ++++++++++++++++++++ .../{CustomerPolicy.php => PartnerPolicy.php} | 28 +++--- app/Providers/AuthServiceProvider.php | 4 +- database/factories/ModelFactory.php | 8 +- .../{CustomerFactory.php => PartnerFactory.php} | 4 +- database/factories/PaymentFactory.php | 4 +- ...=> 2017_10_26_134455_create_partners_table.php} | 10 +- resources/lang/id/customer.php | 29 ------ resources/lang/id/partner.php | 29 ++++++ .../views/{customers => partners}/forms.blade.php | 40 ++++---- .../views/{customers => partners}/index.blade.php | 44 ++++----- routes/web.php | 2 +- tests/Feature/ManageCustomersTest.php | 108 --------------------- tests/Feature/ManagePartnersTest.php | 108 +++++++++++++++++++++ tests/Feature/ManageProjectsTest.php | 40 ++++---- tests/Feature/ManageSubscriptionsTest.php | 10 +- tests/Feature/Payments/ManagePaymentsTest.php | 8 +- .../Models/{CustomerTest.php => PartnerTest.php} | 8 +- tests/Unit/Models/PaymentTest.php | 4 +- tests/Unit/Models/ProjectTest.php | 13 ++- tests/Unit/Models/SubscriptionTest.php | 4 +- tests/Unit/Policies/CustomerPolicyTest.php | 43 -------- tests/Unit/Policies/PartnerPolicyTest.php | 43 ++++++++ 31 files changed, 419 insertions(+), 417 deletions(-) rename app/Entities/Partners/{Customer.php => Partner.php} (86%) delete mode 100644 app/Http/Controllers/Partners/CustomersController.php create mode 100644 app/Http/Controllers/Partners/PartnersController.php rename app/Policies/Partners/{CustomerPolicy.php => PartnerPolicy.php} (53%) rename database/factories/{CustomerFactory.php => PartnerFactory.php} (50%) rename database/migrations/{2017_10_26_134455_create_customers_table.php => 2017_10_26_134455_create_partners_table.php} (83%) delete mode 100644 resources/lang/id/customer.php create mode 100644 resources/lang/id/partner.php rename resources/views/{customers => partners}/forms.blade.php (56%) rename resources/views/{customers => partners}/index.blade.php (50%) delete mode 100644 tests/Feature/ManageCustomersTest.php create mode 100644 tests/Feature/ManagePartnersTest.php rename tests/Unit/Models/{CustomerTest.php => PartnerTest.php} (50%) delete mode 100644 tests/Unit/Policies/CustomerPolicyTest.php create mode 100644 tests/Unit/Policies/PartnerPolicyTest.php diff --git a/app/Entities/BaseRepository.php b/app/Entities/BaseRepository.php index b7fdc15..493ad6f 100755 --- a/app/Entities/BaseRepository.php +++ b/app/Entities/BaseRepository.php @@ -2,7 +2,7 @@ namespace App\Entities; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Projects\Feature; use App\Entities\Projects\Project; use App\Entities\Users\User; @@ -15,12 +15,12 @@ abstract class BaseRepository extends EloquentRepository public function getCustomersList() { - return Customer::orderBy('name')->pluck('name', 'id'); + return Partner::orderBy('name')->pluck('name', 'id'); } public function getCustomersAndVendorsList() { - return Customer::orderBy('name')->pluck('name', 'id'); + return Partner::orderBy('name')->pluck('name', 'id'); } public function getWorkersList() @@ -30,7 +30,7 @@ abstract class BaseRepository extends EloquentRepository public function getVendorsList() { - return Customer::orderBy('name')->pluck('name', 'id'); + return Partner::orderBy('name')->pluck('name', 'id'); } public function getProjectsList() diff --git a/app/Entities/Partners/Customer.php b/app/Entities/Partners/Partner.php similarity index 86% rename from app/Entities/Partners/Customer.php rename to app/Entities/Partners/Partner.php index 027eabb..d79fd8f 100644 --- a/app/Entities/Partners/Customer.php +++ b/app/Entities/Partners/Partner.php @@ -4,7 +4,7 @@ namespace App\Entities\Partners; use Illuminate\Database\Eloquent\Model; -class Customer extends Model +class Partner extends Model { protected $fillable = ['name', 'email', 'phone', 'pic', 'address', 'notes', 'is_active']; } diff --git a/app/Entities/Payments/Payment.php b/app/Entities/Payments/Payment.php index c63b388..843c5d2 100755 --- a/app/Entities/Payments/Payment.php +++ b/app/Entities/Payments/Payment.php @@ -2,7 +2,7 @@ namespace App\Entities\Payments; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Payments\PaymentPresenter; use App\Entities\Projects\Project; use Illuminate\Database\Eloquent\Model; @@ -23,7 +23,7 @@ class Payment extends Model public function partner() { - return $this->belongsTo(Customer::class, 'partner_id'); + return $this->belongsTo(Partner::class, 'partner_id'); } public function type() diff --git a/app/Entities/Projects/Project.php b/app/Entities/Projects/Project.php index 78735ef..fc63637 100755 --- a/app/Entities/Projects/Project.php +++ b/app/Entities/Projects/Project.php @@ -3,12 +3,11 @@ namespace App\Entities\Projects; use App\Entities\Invoices\Invoice; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Payments\Payment; use App\Entities\Projects\ProjectPresenter; use App\Entities\Projects\Task; use App\Entities\Subscriptions\Subscription; -use App\Entities\Users\User; use Illuminate\Database\Eloquent\Model; use Laracasts\Presenter\PresentableTrait; @@ -18,7 +17,7 @@ class Project extends Model use PresentableTrait; protected $presenter = ProjectPresenter::class; - protected $guarded = ['id', 'created_at', 'updated_at']; + protected $guarded = ['id', 'created_at', 'updated_at']; // protected $dates = ['start_date','end_date']; public function nameLink() @@ -63,7 +62,7 @@ class Project extends Model public function customer() { - return $this->belongsTo(Customer::class); + return $this->belongsTo(Partner::class); } public function cashInTotal() @@ -88,7 +87,7 @@ class Project extends Model foreach ($this->features as $feature) { $progress = $feature->tasks->avg('progress'); - $index = $totalPrice ? ($feature->price / $totalPrice) : 1; + $index = $totalPrice ? ($feature->price / $totalPrice) : 1; $overalProgress += $progress * $index; } diff --git a/app/Entities/Projects/ProjectsRepository.php b/app/Entities/Projects/ProjectsRepository.php index baeaa39..575fafb 100755 --- a/app/Entities/Projects/ProjectsRepository.php +++ b/app/Entities/Projects/ProjectsRepository.php @@ -3,7 +3,7 @@ namespace App\Entities\Projects; use App\Entities\BaseRepository; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use DB; /** @@ -61,7 +61,7 @@ class ProjectsRepository extends BaseRepository public function createNewCustomer($customerName, $customerEmail) { - $newCustomer = new Customer; + $newCustomer = new Partner; $newCustomer->name = $customerName; $newCustomer->email = $customerEmail; $newCustomer->save(); diff --git a/app/Entities/Subscriptions/Subscription.php b/app/Entities/Subscriptions/Subscription.php index b4a69f5..df01d27 100755 --- a/app/Entities/Subscriptions/Subscription.php +++ b/app/Entities/Subscriptions/Subscription.php @@ -19,7 +19,7 @@ class Subscription extends Model public function customer() { - return $this->belongsTo('App\Entities\Partners\Customer'); + return $this->belongsTo('App\Entities\Partners\Partner'); } public function status() diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 3c7602d..fcb8eb6 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -45,10 +45,13 @@ class Handler extends ExceptionHandler */ public function render($request, Exception $exception) { + // throw $exception; + if ($exception instanceof AuthorizationException) { - if ($request->expectsJson()) + if ($request->expectsJson()) { return response()->json(['error' => 'Forbidden Action.'], 403); + } flash()->error('Invalid access'); return redirect()->home(); @@ -56,8 +59,9 @@ class Handler extends ExceptionHandler if ($exception instanceof EntityNotFoundException) { - if ($request->expectsJson()) + if ($request->expectsJson()) { return response()->json(['error' => 'Data not found.'], 404); + } flash()->error('Data not found.'); return redirect()->home(); diff --git a/app/Http/Controllers/Partners/CustomersController.php b/app/Http/Controllers/Partners/CustomersController.php deleted file mode 100644 index a003c86..0000000 --- a/app/Http/Controllers/Partners/CustomersController.php +++ /dev/null @@ -1,104 +0,0 @@ -where('name', 'like', '%'.request('q').'%'); - })->paginate(25); - - if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { - $editableCustomer = Customer::find(request('id')); - } - - return view('customers.index', compact('customers', 'editableCustomer')); - } - - /** - * Store a newly created customer in storage. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ - public function store(Request $request) - { - $newCustomerData = $this->validate($request, [ - 'name' => 'required|max:60', - 'email' => 'nullable|email|unique:customers,email', - 'phone' => 'nullable|max:255', - 'pic' => 'nullable|max:255', - 'address' => 'nullable|max:255', - 'notes' => 'nullable|max:255', - ]); - - Customer::create($newCustomerData); - - flash(trans('customer.created'), 'success'); - - return redirect()->route('customers.index'); - } - - /** - * Update the specified customer in storage. - * - * @param \Illuminate\Http\Request $request - * @param \App\Entities\Partners\Customer $customer - * @return \Illuminate\Http\Response - */ - public function update(Request $request, Customer $customer) - { - $customerData = $this->validate($request, [ - 'name' => 'required|max:60', - 'email' => 'nullable|email|unique:customers,email,'.$customer->id, - 'phone' => 'nullable|max:255', - 'pic' => 'nullable|max:255', - 'address' => 'nullable|max:255', - 'notes' => 'nullable|max:255', - 'is_active' => 'required|boolean', - ]); - - $routeParam = request()->only('page', 'q'); - - $customer = $customer->update($customerData); - - flash(trans('customer.updated'), 'success'); - return redirect()->route('customers.index', $routeParam); - } - - /** - * Remove the specified customer from storage. - * - * @param \App\Entities\Partners\Customer $customer - * @return \Illuminate\Http\Response - */ - public function destroy(Customer $customer) - { - // TODO: user cannot delete customer that has been used in other table - $this->validate(request(), [ - 'customer_id' => 'required', - ]); - - $routeParam = request()->only('page', 'q'); - - if (request('customer_id') == $customer->id && $customer->delete()) { - flash(trans('customer.deleted'), 'warning'); - return redirect()->route('customers.index', $routeParam); - } - - flash(trans('customer.undeleted'), 'danger'); - return back(); - } -} diff --git a/app/Http/Controllers/Partners/PartnersController.php b/app/Http/Controllers/Partners/PartnersController.php new file mode 100644 index 0000000..ba56dbe --- /dev/null +++ b/app/Http/Controllers/Partners/PartnersController.php @@ -0,0 +1,104 @@ +where('name', 'like', '%'.request('q').'%'); + })->paginate(25); + + if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { + $editablePartner = Partner::find(request('id')); + } + + return view('partners.index', compact('partners', 'editablePartner')); + } + + /** + * Store a newly created partner in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $newPartnerData = $this->validate($request, [ + 'name' => 'required|max:60', + 'email' => 'nullable|email|unique:partners,email', + 'phone' => 'nullable|max:255', + 'pic' => 'nullable|max:255', + 'address' => 'nullable|max:255', + 'notes' => 'nullable|max:255', + ]); + + Partner::create($newPartnerData); + + flash(trans('partner.created'), 'success'); + + return redirect()->route('partners.index'); + } + + /** + * Update the specified partner in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Entities\Partners\Partner $partner + * @return \Illuminate\Http\Response + */ + public function update(Request $request, Partner $partner) + { + $partnerData = $this->validate($request, [ + 'name' => 'required|max:60', + 'email' => 'nullable|email|unique:partners,email,'.$partner->id, + 'phone' => 'nullable|max:255', + 'pic' => 'nullable|max:255', + 'address' => 'nullable|max:255', + 'notes' => 'nullable|max:255', + 'is_active' => 'required|boolean', + ]); + + $routeParam = request()->only('page', 'q'); + + $partner = $partner->update($partnerData); + + flash(trans('partner.updated'), 'success'); + return redirect()->route('partners.index', $routeParam); + } + + /** + * Remove the specified partner from storage. + * + * @param \App\Entities\Partners\Partner $partner + * @return \Illuminate\Http\Response + */ + public function destroy(Partner $partner) + { + // TODO: user cannot delete partner that has been used in other table + $this->validate(request(), [ + 'partner_id' => 'required', + ]); + + $routeParam = request()->only('page', 'q'); + + if (request('partner_id') == $partner->id && $partner->delete()) { + flash(trans('partner.deleted'), 'warning'); + return redirect()->route('partners.index', $routeParam); + } + + flash(trans('partner.undeleted'), 'danger'); + return back(); + } +} diff --git a/app/Policies/Partners/CustomerPolicy.php b/app/Policies/Partners/PartnerPolicy.php similarity index 53% rename from app/Policies/Partners/CustomerPolicy.php rename to app/Policies/Partners/PartnerPolicy.php index 20992f6..a428d60 100644 --- a/app/Policies/Partners/CustomerPolicy.php +++ b/app/Policies/Partners/PartnerPolicy.php @@ -2,11 +2,11 @@ namespace App\Policies\Partners; +use App\Entities\Partners\Partner; use App\Entities\Users\User; -use App\Entities\Partners\Customer; use Illuminate\Auth\Access\HandlesAuthorization; -class CustomerPolicy +class PartnerPolicy { use HandlesAuthorization; @@ -14,12 +14,12 @@ class CustomerPolicy * Determine whether the user can view the project. * * @param \App\Entities\Users\User $user - * @param \App\Entities\Partners\Customer $customer + * @param \App\Entities\Partners\Partner $partner * @return mixed */ - public function view(User $user, Customer $customer) + public function view(User $user, Partner $partner) { - // Update $user authorization to view $customer here. + // Update $user authorization to view $partner here. return true; } @@ -27,12 +27,12 @@ class CustomerPolicy * Determine whether the user can create projects. * * @param \App\Entities\Users\User $user - * @param \App\Entities\Partners\Customer $customer + * @param \App\Entities\Partners\Partner $partner * @return mixed */ - public function create(User $user, Customer $customer) + public function create(User $user, Partner $partner) { - // Update $user authorization to create $customer here. + // Update $user authorization to create $partner here. return true; } @@ -40,12 +40,12 @@ class CustomerPolicy * Determine whether the user can update the project. * * @param \App\Entities\Users\User $user - * @param \App\Entities\Partners\Customer $customer + * @param \App\Entities\Partners\Partner $partner * @return mixed */ - public function update(User $user, Customer $customer) + public function update(User $user, Partner $partner) { - // Update $user authorization to update $customer here. + // Update $user authorization to update $partner here. return true; } @@ -53,12 +53,12 @@ class CustomerPolicy * Determine whether the user can delete the project. * * @param \App\Entities\Users\User $user - * @param \App\Entities\Partners\Customer $customer + * @param \App\Entities\Partners\Partner $partner * @return mixed */ - public function delete(User $user, Customer $customer) + public function delete(User $user, Partner $partner) { - // Update $user authorization to delete $customer here. + // Update $user authorization to delete $partner here. return true; } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 73d1580..6e83131 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -14,8 +14,8 @@ class AuthServiceProvider extends ServiceProvider * @var array */ protected $policies = [ - 'App\Entities\Partners\Customer' => 'App\Policies\Partners\CustomerPolicy', - 'App\Entities\Users\Event' => 'App\Policies\EventPolicy', + 'App\Entities\Partners\Partner' => 'App\Policies\Partners\PartnerPolicy', + 'App\Entities\Users\Event' => 'App\Policies\EventPolicy', ]; /** diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index c1cc3d7..b65530d 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -1,7 +1,7 @@ define(Project::class, function (Faker\Generator $faker) { return factory(User::class)->create()->id; }, 'customer_id' => function () { - return factory(Customer::class)->create()->id; + return factory(Partner::class)->create()->id; }, ]; }); @@ -61,10 +61,10 @@ $factory->define(Subscription::class, function (Faker\Generator $faker) { 'due_date' => $startDate->addYears(1)->format('Y-m-d'), 'remark' => $faker->paragraph, 'customer_id' => function () { - return factory(Customer::class)->create()->id; + return factory(Partner::class)->create()->id; }, 'vendor_id' => function () { - return factory(Customer::class)->create()->id; + return factory(Partner::class)->create()->id; }, ]; }); diff --git a/database/factories/CustomerFactory.php b/database/factories/PartnerFactory.php similarity index 50% rename from database/factories/CustomerFactory.php rename to database/factories/PartnerFactory.php index 6047205..e37d1b8 100644 --- a/database/factories/CustomerFactory.php +++ b/database/factories/PartnerFactory.php @@ -1,9 +1,9 @@ define(Customer::class, function (Faker $faker) { +$factory->define(Partner::class, function (Faker $faker) { return [ 'name' => $faker->company, diff --git a/database/factories/PaymentFactory.php b/database/factories/PaymentFactory.php index c07d299..bd0b5be 100644 --- a/database/factories/PaymentFactory.php +++ b/database/factories/PaymentFactory.php @@ -1,6 +1,6 @@ define(Payment::class, function (Faker $faker) { return factory(User::class)->create()->id; }, 'partner_id' => function () { - return factory(Customer::class)->create()->id; + return factory(Partner::class)->create()->id; }, ]; }); diff --git a/database/migrations/2017_10_26_134455_create_customers_table.php b/database/migrations/2017_10_26_134455_create_partners_table.php similarity index 83% rename from database/migrations/2017_10_26_134455_create_customers_table.php rename to database/migrations/2017_10_26_134455_create_partners_table.php index f9e55a1..ed122fc 100644 --- a/database/migrations/2017_10_26_134455_create_customers_table.php +++ b/database/migrations/2017_10_26_134455_create_partners_table.php @@ -1,10 +1,10 @@ increments('id'); $table->string('name', 60); $table->string('email')->nullable()->unique(); @@ -33,6 +33,6 @@ class CreateCustomersTable extends Migration */ public function down() { - Schema::dropIfExists('customers'); + Schema::dropIfExists('partners'); } } diff --git a/resources/lang/id/customer.php b/resources/lang/id/customer.php deleted file mode 100644 index f7f0891..0000000 --- a/resources/lang/id/customer.php +++ /dev/null @@ -1,29 +0,0 @@ - 'Customer', - 'list' => 'Daftar Customer', - 'search' => 'Cari Customer', - 'not_found' => 'Customer tidak ditemukan', - 'empty' => 'Belum ada Customer', - 'back_to_show' => 'Kembali ke detail Customer', - 'back_to_index' => 'Kembali ke daftar Customer', - - // Actions - 'create' => 'Input Customer Baru', - 'created' => 'Input Customer baru telah berhasil.', - 'show' => 'Detail Customer', - 'edit' => 'Edit Customer', - 'update' => 'Update Customer', - 'updated' => 'Update data Customer telah berhasil.', - 'delete' => 'Hapus Customer', - 'delete_confirm' => 'Anda yakin akan menghapus Customer ini?', - 'deleted' => 'Hapus data Customer telah berhasil.', - 'undeleted' => 'Data Customer gagal dihapus.', - 'undeleteable' => 'Data Customer tidak dapat dihapus.', - - // Attributes - 'name' => 'Nama Customer', - 'description' => 'Deskripsi Customer', -]; diff --git a/resources/lang/id/partner.php b/resources/lang/id/partner.php new file mode 100644 index 0000000..0c1eddc --- /dev/null +++ b/resources/lang/id/partner.php @@ -0,0 +1,29 @@ + 'Partner', + 'list' => 'Daftar Partner', + 'search' => 'Cari Partner', + 'not_found' => 'Partner tidak ditemukan', + 'empty' => 'Belum ada Partner', + 'back_to_show' => 'Kembali ke detail Partner', + 'back_to_index' => 'Kembali ke daftar Partner', + + // Actions + 'create' => 'Input Partner Baru', + 'created' => 'Input Partner baru telah berhasil.', + 'show' => 'Detail Partner', + 'edit' => 'Edit Partner', + 'update' => 'Update Partner', + 'updated' => 'Update data Partner telah berhasil.', + 'delete' => 'Hapus Partner', + 'delete_confirm' => 'Anda yakin akan menghapus Partner ini?', + 'deleted' => 'Hapus data Partner telah berhasil.', + 'undeleted' => 'Data Partner gagal dihapus.', + 'undeleteable' => 'Data Partner tidak dapat dihapus.', + + // Attributes + 'name' => 'Nama Partner', + 'description' => 'Deskripsi Partner', +]; diff --git a/resources/views/customers/forms.blade.php b/resources/views/partners/forms.blade.php similarity index 56% rename from resources/views/customers/forms.blade.php rename to resources/views/partners/forms.blade.php index fb88d52..f9b0f53 100644 --- a/resources/views/customers/forms.blade.php +++ b/resources/views/partners/forms.blade.php @@ -1,17 +1,17 @@ @if (Request::get('action') == 'create') - {!! Form::open(['route' => 'customers.store']) !!} + {!! Form::open(['route' => 'partners.store']) !!} {!! FormField::text('name', ['required' => true]) !!} {!! FormField::email('email') !!} {!! FormField::text('phone') !!} {!! FormField::text('pic') !!} {!! FormField::textarea('address') !!} {!! FormField::textarea('notes') !!} - {!! Form::submit(trans('customer.create'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('customers.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }} + {!! Form::submit(trans('partner.create'), ['class' => 'btn btn-success']) !!} + {{ link_to_route('partners.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }} {!! Form::close() !!} @endif -@if (Request::get('action') == 'edit' && $editableCustomer) - {!! Form::model($editableCustomer, ['route' => ['customers.update', $editableCustomer->id],'method' => 'patch']) !!} +@if (Request::get('action') == 'edit' && $editablePartner) + {!! Form::model($editablePartner, ['route' => ['partners.update', $editablePartner->id],'method' => 'patch']) !!} {!! FormField::text('name', ['required' => true]) !!} {!! FormField::email('email') !!} {!! FormField::text('phone') !!} @@ -25,42 +25,42 @@ @if (request('page')) {{ Form::hidden('page', request('page')) }} @endif - {!! Form::submit(trans('customer.update'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('customers.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }} + {!! Form::submit(trans('partner.update'), ['class' => 'btn btn-success']) !!} + {{ link_to_route('partners.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }} {!! Form::close() !!} @endif -@if (Request::get('action') == 'delete' && $editableCustomer) +@if (Request::get('action') == 'delete' && $editablePartner)
-

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

+

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

- -

{{ $editableCustomer->name }}

+ +

{{ $editablePartner->name }}

-

{{ $editableCustomer->email }}

+

{{ $editablePartner->email }}

-

{{ $editableCustomer->phone }}

+

{{ $editablePartner->phone }}

-

{{ $editableCustomer->address }}

+

{{ $editablePartner->address }}

-

{{ $editableCustomer->is_active }}

+

{{ $editablePartner->is_active }}

-

{{ $editableCustomer->notes }}

- {!! $errors->first('customer_id', ':message') !!} +

{{ $editablePartner->notes }}

+ {!! $errors->first('partner_id', ':message') !!}

{{ trans('app.delete_confirm') }}
@endif diff --git a/resources/views/customers/index.blade.php b/resources/views/partners/index.blade.php similarity index 50% rename from resources/views/customers/index.blade.php rename to resources/views/partners/index.blade.php index 2fc5da9..06c05df 100644 --- a/resources/views/customers/index.blade.php +++ b/resources/views/partners/index.blade.php @@ -1,30 +1,30 @@ @extends('layouts.app') -@section('title', trans('customer.list')) +@section('title', trans('partner.list')) @section('content')

- {{ link_to_route('customers.index', trans('customer.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }} + {{ link_to_route('partners.index', trans('partner.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
- {{ trans('customer.list') }} - {{ trans('app.total') }} : {{ $customers->total() }} {{ trans('customer.customer') }} + {{ trans('partner.list') }} + {{ trans('app.total') }} : {{ $partners->total() }} {{ trans('partner.partner') }}

{{ Form::open(['method' => 'get','class' => 'form-inline']) }} - {!! FormField::text('q', ['value' => request('q'), 'label' => trans('customer.search'), 'class' => 'input-sm']) !!} - {{ Form::submit(trans('customer.search'), ['class' => 'btn btn-sm']) }} - {{ link_to_route('customers.index', trans('app.reset')) }} + {!! FormField::text('q', ['value' => request('q'), 'label' => trans('partner.search'), 'class' => 'input-sm']) !!} + {{ Form::submit(trans('partner.search'), ['class' => 'btn btn-sm']) }} + {{ link_to_route('partners.index', trans('app.reset')) }} {{ Form::close() }}
- + @@ -32,36 +32,36 @@ - @foreach($customers as $key => $customer) + @foreach($partners as $key => $partner) - - - - - + + + + + @endforeach
{{ trans('app.table_no') }}{{ trans('customer.name') }}{{ trans('partner.name') }} {{ trans('contact.email') }} {{ trans('contact.phone') }} {{ trans('app.status') }}
{{ $customers->firstItem() + $key }}{{ $customer->name }}{{ $customer->email }}{{ $customer->phone }}{{ $customer->is_active }}{{ $partners->firstItem() + $key }}{{ $partner->name }}{{ $partner->email }}{{ $partner->phone }}{{ $partner->is_active }} {!! link_to_route( - 'customers.index', + 'partners.index', trans('app.edit'), - ['action' => 'edit', 'id' => $customer->id] + Request::only('page', 'q'), - ['id' => 'edit-customer-' . $customer->id] + ['action' => 'edit', 'id' => $partner->id] + Request::only('page', 'q'), + ['id' => 'edit-partner-' . $partner->id] ) !!} | {!! link_to_route( - 'customers.index', + 'partners.index', trans('app.delete'), - ['action' => 'delete', 'id' => $customer->id] + Request::only('page', 'q'), - ['id' => 'del-customer-' . $customer->id] + ['action' => 'delete', 'id' => $partner->id] + Request::only('page', 'q'), + ['id' => 'del-partner-' . $partner->id] ) !!}
-
{{ $customers->appends(Request::except('page'))->render() }}
+
{{ $partners->appends(Request::except('page'))->render() }}
- @includeWhen(Request::has('action'), 'customers.forms') + @includeWhen(Request::has('action'), 'partners.forms')
@endsection diff --git a/routes/web.php b/routes/web.php index c91e747..03cfbb3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,4 +22,4 @@ Route::group(['middleware' => ['web', 'role:admin']], function () { Route::resource('backups', 'BackupsController', ['except' => ['create', 'show', 'edit']]); }); -Route::apiResource('customers', 'Partners\CustomersController'); +Route::apiResource('partners', 'Partners\PartnersController'); diff --git a/tests/Feature/ManageCustomersTest.php b/tests/Feature/ManageCustomersTest.php deleted file mode 100644 index 314a8be..0000000 --- a/tests/Feature/ManageCustomersTest.php +++ /dev/null @@ -1,108 +0,0 @@ -create(); - $customer2 = factory(Customer::class)->create(); - - $this->adminUserSigningIn(); - $this->visit(route('customers.index')); - $this->see($customer1->name); - $this->see($customer2->name); - } - - /** @test */ - public function user_can_create_a_customer() - { - $this->adminUserSigningIn(); - $this->visit(route('customers.index')); - - $this->click(trans('customer.create')); - $this->seePageIs(route('customers.index', ['action' => 'create'])); - - $this->submitForm(trans('customer.create'), [ - 'name' => 'Customer 1 name', - 'email' => 'customer1@mail.com', - 'phone' => '081234567890', - 'pic' => 'Nama PIC Customer', - 'address' => 'Alamat customer 1', - 'notes' => '', - ]); - - $this->seePageIs(route('customers.index')); - - $this->seeInDatabase('customers', [ - 'name' => 'Customer 1 name', - 'email' => 'customer1@mail.com', - 'phone' => '081234567890', - 'pic' => 'Nama PIC Customer', - 'address' => 'Alamat customer 1', - 'notes' => null, - ]); - } - - /** @test */ - public function user_can_edit_a_customer_within_search_query() - { - $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(['name' => 'Testing 123']); - - $this->visit(route('customers.index', ['q' => '123'])); - $this->click('edit-customer-'.$customer->id); - $this->seePageIs(route('customers.index', ['action' => 'edit', 'id' => $customer->id, 'q' => '123'])); - - $this->submitForm(trans('customer.update'), [ - 'name' => 'Customer 1 name', - 'email' => 'customer1@mail.com', - 'phone' => '081234567890', - 'pic' => 'Nama PIC Customer', - 'address' => 'Alamat customer 1', - 'notes' => '', - 'is_active' => 0, - ]); - - $this->seePageIs(route('customers.index', ['q' => '123'])); - - $this->seeInDatabase('customers', [ - 'name' => 'Customer 1 name', - 'email' => 'customer1@mail.com', - 'phone' => '081234567890', - 'pic' => 'Nama PIC Customer', - 'address' => 'Alamat customer 1', - 'notes' => null, - 'is_active' => 0, - ]); - } - - /** @test */ - public function user_can_delete_a_customer() - { - $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(); - - $this->visit(route('customers.index', [$customer->id])); - $this->click('del-customer-'.$customer->id); - $this->seePageIs(route('customers.index', ['action' => 'delete', 'id' => $customer->id])); - - $this->seeInDatabase('customers', [ - 'id' => $customer->id, - ]); - - $this->press(trans('app.delete_confirm_button')); - - $this->dontSeeInDatabase('customers', [ - 'id' => $customer->id, - ]); - } -} diff --git a/tests/Feature/ManagePartnersTest.php b/tests/Feature/ManagePartnersTest.php new file mode 100644 index 0000000..6771bd8 --- /dev/null +++ b/tests/Feature/ManagePartnersTest.php @@ -0,0 +1,108 @@ +create(); + $partner2 = factory(Partner::class)->create(); + + $this->adminUserSigningIn(); + $this->visit(route('partners.index')); + $this->see($partner1->name); + $this->see($partner2->name); + } + + /** @test */ + public function user_can_create_a_partner() + { + $this->adminUserSigningIn(); + $this->visit(route('partners.index')); + + $this->click(trans('partner.create')); + $this->seePageIs(route('partners.index', ['action' => 'create'])); + + $this->submitForm(trans('partner.create'), [ + 'name' => 'Partner 1 name', + 'email' => 'partner1@mail.com', + 'phone' => '081234567890', + 'pic' => 'Nama PIC Partner', + 'address' => 'Alamat partner 1', + 'notes' => '', + ]); + + $this->seePageIs(route('partners.index')); + + $this->seeInDatabase('partners', [ + 'name' => 'Partner 1 name', + 'email' => 'partner1@mail.com', + 'phone' => '081234567890', + 'pic' => 'Nama PIC Partner', + 'address' => 'Alamat partner 1', + 'notes' => null, + ]); + } + + /** @test */ + public function user_can_edit_a_partner_within_search_query() + { + $this->adminUserSigningIn(); + $partner = factory(Partner::class)->create(['name' => 'Testing 123']); + + $this->visit(route('partners.index', ['q' => '123'])); + $this->click('edit-partner-'.$partner->id); + $this->seePageIs(route('partners.index', ['action' => 'edit', 'id' => $partner->id, 'q' => '123'])); + + $this->submitForm(trans('partner.update'), [ + 'name' => 'Partner 1 name', + 'email' => 'partner1@mail.com', + 'phone' => '081234567890', + 'pic' => 'Nama PIC Partner', + 'address' => 'Alamat partner 1', + 'notes' => '', + 'is_active' => 0, + ]); + + $this->seePageIs(route('partners.index', ['q' => '123'])); + + $this->seeInDatabase('partners', [ + 'name' => 'Partner 1 name', + 'email' => 'partner1@mail.com', + 'phone' => '081234567890', + 'pic' => 'Nama PIC Partner', + 'address' => 'Alamat partner 1', + 'notes' => null, + 'is_active' => 0, + ]); + } + + /** @test */ + public function user_can_delete_a_partner() + { + $this->adminUserSigningIn(); + $partner = factory(Partner::class)->create(); + + $this->visit(route('partners.index', [$partner->id])); + $this->click('del-partner-'.$partner->id); + $this->seePageIs(route('partners.index', ['action' => 'delete', 'id' => $partner->id])); + + $this->seeInDatabase('partners', [ + 'id' => $partner->id, + ]); + + $this->press(trans('app.delete_confirm_button')); + + $this->dontSeeInDatabase('partners', [ + 'id' => $partner->id, + ]); + } +} diff --git a/tests/Feature/ManageProjectsTest.php b/tests/Feature/ManageProjectsTest.php index ca10c82..a574807 100644 --- a/tests/Feature/ManageProjectsTest.php +++ b/tests/Feature/ManageProjectsTest.php @@ -2,7 +2,7 @@ namespace Tests\Feature; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Payments\Payment; use App\Entities\Projects\Feature; use App\Entities\Projects\Project; @@ -12,17 +12,17 @@ use Tests\TestCase; class ManageProjectsTest extends TestCase { /** @test */ - public function admin_can_input_new_project_with_existing_customer() + public function admin_can_input_new_project_with_existing_partner() { - $user = $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(); + $user = $this->adminUserSigningIn(); + $partner = factory(Partner::class)->create(); $this->visit(route('projects.index')); $this->seePageIs(route('projects.index')); $this->click(trans('project.create')); $this->seePageIs(route('projects.create')); $this->type('Project Baru', 'name'); - $this->select($customer->id, 'customer_id'); + $this->select($partner->id, 'customer_id'); $this->type('2016-04-15', 'proposal_date'); $this->type('2000000', 'proposal_value'); $this->type('Deskripsi project baru', 'description'); @@ -34,7 +34,7 @@ class ManageProjectsTest extends TestCase } /** @test */ - public function admin_can_input_new_project_with_new_customer() + public function admin_can_input_new_project_with_new_partner() { $this->adminUserSigningIn(); @@ -53,21 +53,21 @@ class ManageProjectsTest extends TestCase $this->seePageIs(route('projects.create')); $this->notSeeInDatabase('projects', ['name' => 'Project Baru', 'proposal_value' => '2000000']); - $this->type('Customer Baru', 'customer_name'); - $this->type('email@customer.baru', 'customer_email'); + $this->type('Partner Baru', 'customer_name'); + $this->type('email@partner.baru', 'customer_email'); $this->press(trans('project.create')); $this->see(trans('project.created')); $this->see('Project Baru'); - $this->seeInDatabase('customers', [ - 'name' => 'Customer Baru', - 'email' => 'email@customer.baru', + $this->seeInDatabase('partners', [ + 'name' => 'Partner Baru', + 'email' => 'email@partner.baru', ]); - $newCustomer = Customer::whereName('Customer Baru')->whereEmail('email@customer.baru')->first(); + $newPartner = Partner::whereName('Partner Baru')->whereEmail('email@partner.baru')->first(); $this->seeInDatabase('projects', [ 'name' => 'Project Baru', 'proposal_value' => '2000000', - 'customer_id' => $newCustomer->id, + 'customer_id' => $newPartner->id, ]); } @@ -110,9 +110,9 @@ class ManageProjectsTest extends TestCase /** @test */ public function admin_can_edit_a_project() { - $user = $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(); - $project = factory(Project::class)->create(['owner_id' => $user->id]); + $user = $this->adminUserSigningIn(); + $partner = factory(Partner::class)->create(); + $project = factory(Project::class)->create(['owner_id' => $user->id]); $this->visit('projects/'.$project->id.'/edit'); $this->seePageIs('projects/'.$project->id.'/edit'); @@ -124,7 +124,7 @@ class ManageProjectsTest extends TestCase $this->type(2000000, 'proposal_value'); $this->type(2000000, 'project_value'); $this->select(4, 'status_id'); - $this->select($customer->id, 'customer_id'); + $this->select($partner->id, 'customer_id'); $this->type('Edit deskripsi project', 'description'); $this->press(trans('project.update')); @@ -134,7 +134,7 @@ class ManageProjectsTest extends TestCase 'proposal_date' => '2016-04-15', 'start_date' => '2016-04-25', 'end_date' => '2016-05-05', - 'customer_id' => $customer->id, + 'customer_id' => $partner->id, 'description' => 'Edit deskripsi project', ]); } @@ -144,14 +144,14 @@ class ManageProjectsTest extends TestCase { $user = $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(); + $partner = factory(Partner::class)->create(); $this->visit(route('projects.index')); $this->seePageIs(route('projects.index')); $this->click(trans('project.create')); $this->seePageIs(route('projects.create')); $this->type('', 'name'); - $this->select($customer->id, 'customer_id'); + $this->select($partner->id, 'customer_id'); $this->type('2016-04-15aa', 'proposal_date'); $this->type('', 'proposal_value'); $this->type('Deskripsi project baru', 'description'); diff --git a/tests/Feature/ManageSubscriptionsTest.php b/tests/Feature/ManageSubscriptionsTest.php index 7843e5d..c023980 100644 --- a/tests/Feature/ManageSubscriptionsTest.php +++ b/tests/Feature/ManageSubscriptionsTest.php @@ -2,7 +2,7 @@ namespace Tests\Feature; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Projects\Project; use App\Entities\Subscriptions\Subscription; use Tests\TestCase; @@ -13,9 +13,9 @@ class ManageSubscriptionsTest extends TestCase public function admin_can_entry_subscription() { $user = $this->adminUserSigningIn(); - $vendor = factory(Customer::class)->create(); + $vendor = factory(Partner::class)->create(); $project = factory(Project::class)->create(); - $customer = factory(Customer::class)->create(); + $customer = factory(Partner::class)->create(); $this->visit(route('subscriptions.index')); $this->click(trans('subscription.create')); @@ -53,10 +53,10 @@ class ManageSubscriptionsTest extends TestCase public function admin_can_edit_subscription_data() { $user = $this->adminUserSigningIn(); - $vendor = factory(Customer::class)->create(); + $vendor = factory(Partner::class)->create(); $eppCode = str_random(10); $project = factory(Project::class)->create(); - $customer = factory(Customer::class)->create(); + $customer = factory(Partner::class)->create(); $subscription = factory(Subscription::class)->create(['customer_id' => $customer->id, 'project_id' => $project->id]); diff --git a/tests/Feature/Payments/ManagePaymentsTest.php b/tests/Feature/Payments/ManagePaymentsTest.php index 61851b7..f40c46d 100644 --- a/tests/Feature/Payments/ManagePaymentsTest.php +++ b/tests/Feature/Payments/ManagePaymentsTest.php @@ -2,7 +2,7 @@ namespace Tests\Feature\Payments; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Payments\Payment; use App\Entities\Projects\Project; use Tests\TestCase; @@ -13,7 +13,7 @@ class ManagePaymentsTest extends TestCase public function admin_can_entry_project_an_income_payment() { $user = $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(); + $customer = factory(Partner::class)->create(); $project = factory(Project::class)->create(); $this->visit(route('payments.index')); @@ -44,7 +44,7 @@ class ManagePaymentsTest extends TestCase public function admin_can_entry_project_an_expanse_payment() { $user = $this->adminUserSigningIn(); - $vendor = factory(Customer::class)->create(); + $vendor = factory(Partner::class)->create(); $project = factory(Project::class)->create(); $this->visit(route('payments.index')); @@ -76,7 +76,7 @@ class ManagePaymentsTest extends TestCase public function admin_can_edit_payment_data() { $user = $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(); + $customer = factory(Partner::class)->create(); $project = factory(Project::class)->create(); $payment = factory(Payment::class)->create([ diff --git a/tests/Unit/Models/CustomerTest.php b/tests/Unit/Models/PartnerTest.php similarity index 50% rename from tests/Unit/Models/CustomerTest.php rename to tests/Unit/Models/PartnerTest.php index 2f02a4c..f8be877 100644 --- a/tests/Unit/Models/CustomerTest.php +++ b/tests/Unit/Models/PartnerTest.php @@ -2,18 +2,18 @@ namespace Tests\Unit\Models; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use Illuminate\Foundation\Testing\DatabaseMigrations; use Tests\TestCase as TestCase; -class CustomerTest extends TestCase +class PartnerTest extends TestCase { use DatabaseMigrations; /** @test */ public function it_has_name_attribute() { - $customer = factory(Customer::class)->create(['name' => 'Customer 1 name']); - $this->assertEquals('Customer 1 name', $customer->name); + $partner = factory(Partner::class)->create(['name' => 'Partner 1 name']); + $this->assertEquals('Partner 1 name', $partner->name); } } diff --git a/tests/Unit/Models/PaymentTest.php b/tests/Unit/Models/PaymentTest.php index 64f4647..480f431 100644 --- a/tests/Unit/Models/PaymentTest.php +++ b/tests/Unit/Models/PaymentTest.php @@ -2,7 +2,7 @@ namespace Tests\Unit\Models; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Payments\Payment; use Tests\TestCase; @@ -12,6 +12,6 @@ class PaymentTest extends TestCase public function it_has_partner_relation() { $payment = factory(Payment::class)->create(); - $this->assertTrue($payment->partner instanceof Customer); + $this->assertTrue($payment->partner instanceof Partner); } } diff --git a/tests/Unit/Models/ProjectTest.php b/tests/Unit/Models/ProjectTest.php index 74768bf..73f76c1 100644 --- a/tests/Unit/Models/ProjectTest.php +++ b/tests/Unit/Models/ProjectTest.php @@ -2,13 +2,12 @@ namespace Tests\Unit\Models; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Payments\Payment; use App\Entities\Projects\Feature; use App\Entities\Projects\Project; use App\Entities\Projects\Task; use App\Entities\Subscriptions\Subscription; -use App\Entities\Users\User; use Illuminate\Support\Collection; use Tests\TestCase; @@ -46,7 +45,7 @@ class ProjectTest extends TestCase { $project = factory(Project::class)->create(); $feature = factory(Feature::class)->create(['project_id' => $project->id, 'type_id' => 2]); - $tasks = factory(Task::class, 2)->create(['feature_id' => $feature->id]); + $tasks = factory(Task::class, 2)->create(['feature_id' => $feature->id]); $this->assertTrue($project->tasks instanceof Collection); $this->assertTrue($project->tasks->first() instanceof Task); } @@ -63,7 +62,7 @@ class ProjectTest extends TestCase /** @test */ public function a_project_has_many_subscriptions() { - $project = factory(Project::class)->create(); + $project = factory(Project::class)->create(); $subscription = factory(Subscription::class)->create(['project_id' => $project->id]); $this->assertTrue($project->subscriptions instanceof Collection); $this->assertTrue($project->subscriptions->first() instanceof Subscription); @@ -73,13 +72,13 @@ class ProjectTest extends TestCase public function a_project_belongs_to_a_customer() { $project = factory(Project::class)->create(); - $this->assertTrue($project->customer instanceof Customer); + $this->assertTrue($project->customer instanceof Partner); } /** @test */ public function a_project_has_cash_in_total_method() { - $project = factory(Project::class)->create(); + $project = factory(Project::class)->create(); $payments = factory(Payment::class, 2)->create(['project_id' => $project->id, 'in_out' => 1, 'amount' => 20000]); $this->assertEquals(40000, $project->cashInTotal()); } @@ -87,7 +86,7 @@ class ProjectTest extends TestCase /** @test */ public function a_project_has_cash_out_total_method() { - $project = factory(Project::class)->create(); + $project = factory(Project::class)->create(); $payments = factory(Payment::class, 2)->create(['project_id' => $project->id, 'in_out' => 0, 'amount' => 10000]); factory(Payment::class)->create(['project_id' => $project->id, 'in_out' => 1, 'amount' => 10000]); $this->assertEquals(20000, $project->cashOutTotal()); diff --git a/tests/Unit/Models/SubscriptionTest.php b/tests/Unit/Models/SubscriptionTest.php index 75ee115..88d2a88 100644 --- a/tests/Unit/Models/SubscriptionTest.php +++ b/tests/Unit/Models/SubscriptionTest.php @@ -2,7 +2,7 @@ namespace Tests\Unit\Models; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Partner; use App\Entities\Subscriptions\Subscription; use Tests\TestCase as TestCase; @@ -19,6 +19,6 @@ class SubscriptionTest extends TestCase public function it_has_customer_relation() { $subscription = factory(Subscription::class)->create(); - $this->assertTrue($subscription->customer instanceof Customer); + $this->assertTrue($subscription->customer instanceof Partner); } } diff --git a/tests/Unit/Policies/CustomerPolicyTest.php b/tests/Unit/Policies/CustomerPolicyTest.php deleted file mode 100644 index 6497d07..0000000 --- a/tests/Unit/Policies/CustomerPolicyTest.php +++ /dev/null @@ -1,43 +0,0 @@ -adminUserSigningIn(); - $this->assertTrue($user->can('create', new Customer)); - } - - /** @test */ - public function user_can_view_customer() - { - $user = $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(['name' => 'Customer 1 name']); - $this->assertTrue($user->can('view', $customer)); - } - - /** @test */ - public function user_can_update_customer() - { - $user = $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(['name' => 'Customer 1 name']); - $this->assertTrue($user->can('update', $customer)); - } - - /** @test */ - public function user_can_delete_customer() - { - $user = $this->adminUserSigningIn(); - $customer = factory(Customer::class)->create(['name' => 'Customer 1 name']); - $this->assertTrue($user->can('delete', $customer)); - } -} diff --git a/tests/Unit/Policies/PartnerPolicyTest.php b/tests/Unit/Policies/PartnerPolicyTest.php new file mode 100644 index 0000000..2ff19a6 --- /dev/null +++ b/tests/Unit/Policies/PartnerPolicyTest.php @@ -0,0 +1,43 @@ +adminUserSigningIn(); + $this->assertTrue($user->can('create', new Partner)); + } + + /** @test */ + public function user_can_view_partner() + { + $user = $this->adminUserSigningIn(); + $partner = factory(Partner::class)->create(['name' => 'Partner 1 name']); + $this->assertTrue($user->can('view', $partner)); + } + + /** @test */ + public function user_can_update_partner() + { + $user = $this->adminUserSigningIn(); + $partner = factory(Partner::class)->create(['name' => 'Partner 1 name']); + $this->assertTrue($user->can('update', $partner)); + } + + /** @test */ + public function user_can_delete_partner() + { + $user = $this->adminUserSigningIn(); + $partner = factory(Partner::class)->create(['name' => 'Partner 1 name']); + $this->assertTrue($user->can('delete', $partner)); + } +}