31 changed files with 419 additions and 417 deletions
-
8app/Entities/BaseRepository.php
-
2app/Entities/Partners/Partner.php
-
4app/Entities/Payments/Payment.php
-
9app/Entities/Projects/Project.php
-
4app/Entities/Projects/ProjectsRepository.php
-
2app/Entities/Subscriptions/Subscription.php
-
8app/Exceptions/Handler.php
-
104app/Http/Controllers/Partners/CustomersController.php
-
104app/Http/Controllers/Partners/PartnersController.php
-
28app/Policies/Partners/PartnerPolicy.php
-
4app/Providers/AuthServiceProvider.php
-
8database/factories/ModelFactory.php
-
4database/factories/PartnerFactory.php
-
4database/factories/PaymentFactory.php
-
10database/migrations/2017_10_26_134455_create_partners_table.php
-
29resources/lang/id/customer.php
-
29resources/lang/id/partner.php
-
40resources/views/partners/forms.blade.php
-
44resources/views/partners/index.blade.php
-
2routes/web.php
-
108tests/Feature/ManageCustomersTest.php
-
108tests/Feature/ManagePartnersTest.php
-
40tests/Feature/ManageProjectsTest.php
-
10tests/Feature/ManageSubscriptionsTest.php
-
8tests/Feature/Payments/ManagePaymentsTest.php
-
8tests/Unit/Models/PartnerTest.php
-
4tests/Unit/Models/PaymentTest.php
-
13tests/Unit/Models/ProjectTest.php
-
4tests/Unit/Models/SubscriptionTest.php
-
43tests/Unit/Policies/CustomerPolicyTest.php
-
43tests/Unit/Policies/PartnerPolicyTest.php
@ -1,104 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Controllers\Partners; |
|
||||
|
|
||||
use App\Entities\Partners\Customer; |
|
||||
use App\Http\Controllers\Controller; |
|
||||
use Illuminate\Http\Request; |
|
||||
|
|
||||
class CustomersController extends Controller |
|
||||
{ |
|
||||
/** |
|
||||
* Display a listing of the customer. |
|
||||
* |
|
||||
* @return \Illuminate\Http\Response |
|
||||
*/ |
|
||||
public function index() |
|
||||
{ |
|
||||
$editableCustomer = null; |
|
||||
$customers = Customer::where(function ($query) { |
|
||||
$query->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(); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,104 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Controllers\Partners; |
||||
|
|
||||
|
use App\Entities\Partners\Partner; |
||||
|
use App\Http\Controllers\Controller; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class PartnersController extends Controller |
||||
|
{ |
||||
|
/** |
||||
|
* Display a listing of the partner. |
||||
|
* |
||||
|
* @return \Illuminate\Http\Response |
||||
|
*/ |
||||
|
public function index() |
||||
|
{ |
||||
|
$editablePartner = null; |
||||
|
$partners = Partner::where(function ($query) { |
||||
|
$query->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(); |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,9 @@ |
|||||
<?php |
<?php |
||||
|
|
||||
use App\Entities\Partners\Customer; |
|
||||
|
use App\Entities\Partners\Partner; |
||||
use Faker\Generator as Faker; |
use Faker\Generator as Faker; |
||||
|
|
||||
$factory->define(Customer::class, function (Faker $faker) { |
|
||||
|
$factory->define(Partner::class, function (Faker $faker) { |
||||
|
|
||||
return [ |
return [ |
||||
'name' => $faker->company, |
'name' => $faker->company, |
||||
@ -1,29 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
return [ |
|
||||
// Labels
|
|
||||
'customer' => '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', |
|
||||
]; |
|
||||
@ -0,0 +1,29 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
// Labels
|
||||
|
'partner' => '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', |
||||
|
]; |
||||
@ -1,108 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace Tests\Feature; |
|
||||
|
|
||||
use App\Entities\Partners\Customer; |
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations; |
|
||||
use Tests\TestCase as TestCase; |
|
||||
|
|
||||
class ManageCustomersTest extends TestCase |
|
||||
{ |
|
||||
use DatabaseMigrations; |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_see_customer_list_in_customer_index_page() |
|
||||
{ |
|
||||
$customer1 = factory(Customer::class)->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, |
|
||||
]); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,108 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Feature; |
||||
|
|
||||
|
use App\Entities\Partners\Partner; |
||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations; |
||||
|
use Tests\TestCase as TestCase; |
||||
|
|
||||
|
class ManagePartnersTest extends TestCase |
||||
|
{ |
||||
|
use DatabaseMigrations; |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_see_partner_list_in_partner_index_page() |
||||
|
{ |
||||
|
$partner1 = factory(Partner::class)->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, |
||||
|
]); |
||||
|
} |
||||
|
} |
||||
@ -1,43 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace Tests\Unit\Policies; |
|
||||
|
|
||||
use App\Entities\Partners\Customer; |
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations; |
|
||||
use Tests\TestCase as TestCase; |
|
||||
|
|
||||
class CustomerTest extends TestCase |
|
||||
{ |
|
||||
use DatabaseMigrations; |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_create_customer() |
|
||||
{ |
|
||||
$user = $this->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)); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,43 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Unit\Policies; |
||||
|
|
||||
|
use App\Entities\Partners\Partner; |
||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations; |
||||
|
use Tests\TestCase as TestCase; |
||||
|
|
||||
|
class PartnerTest extends TestCase |
||||
|
{ |
||||
|
use DatabaseMigrations; |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_create_partner() |
||||
|
{ |
||||
|
$user = $this->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)); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue