From 5d41645bbb07a75481bf39f5577e3ac45d2e1c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 11:54:34 +0300 Subject: [PATCH 01/11] added export/ bulk action export and import feature test for items.. --- tests/Feature/Common/ItemsTest.php | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/Feature/Common/ItemsTest.php b/tests/Feature/Common/ItemsTest.php index 0f6559199..eb696e0ca 100644 --- a/tests/Feature/Common/ItemsTest.php +++ b/tests/Feature/Common/ItemsTest.php @@ -2,8 +2,11 @@ namespace Tests\Feature\Common; +use App\Exports\Common\Items as Export; use App\Jobs\Common\CreateItem; use App\Models\Common\Item; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; use Tests\Feature\FeatureTestCase; class ItemsTest extends FeatureTestCase @@ -82,6 +85,69 @@ class ItemsTest extends FeatureTestCase $this->assertSoftDeleted('items', $request); } + public function testItShouldExportItems() + { + $count = 5; + Item::factory()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->get(route('items.export')) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.items', 2)) . '.xlsx', + function (Export $export) use ($count) { + // Assert that the correct export is downloaded. + return $export->sheets()['items']->collection()->count() === $count; + } + ); + } + + public function testItShouldExportSelectedItems() + { + $count = 5; + $items = Item::factory()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->post( + route('bulk-actions.action', ['group' => 'common', 'type' => 'items']), + ['handle' => 'export', 'selected' => [$items->random()->id]] + ) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.items', 2)) . '.xlsx', + function (Export $export) { + return $export->sheets()['items']->collection()->count() === 1; + } + ); + } + + public function testItShouldImportItems() + { + \Excel::fake(); + + $this->loginAs() + ->post( + route('items.import'), + [ + 'import' => UploadedFile::fake()->createWithContent( + 'items.xlsx', + File::get(public_path('files/import/items.xlsx')) + ), + ] + ) + ->assertStatus(200); + + \Excel::assertImported('items.xlsx'); + + $this->assertFlashLevel('success'); + } + public function getRequest() { return Item::factory()->enabled()->raw(); From fff6029af3c290936795870116058d07504335a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 12:16:57 +0300 Subject: [PATCH 02/11] added export/ bulk action export and import feature test for bills.. --- tests/Feature/Purchases/BillsTest.php | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/Feature/Purchases/BillsTest.php b/tests/Feature/Purchases/BillsTest.php index b7e3a5e93..10a7866bc 100644 --- a/tests/Feature/Purchases/BillsTest.php +++ b/tests/Feature/Purchases/BillsTest.php @@ -2,8 +2,11 @@ namespace Tests\Feature\Purchases; +use App\Exports\Purchases\Bills as Export; use App\Jobs\Document\CreateDocument; use App\Models\Document\Document; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; use Tests\Feature\FeatureTestCase; class BillsTest extends FeatureTestCase @@ -104,6 +107,69 @@ class BillsTest extends FeatureTestCase ]); } + public function testItShouldExportBills() + { + $count = 5; + Document::factory()->bill()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->get(route('bills.export')) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.bills', 2)) . '.xlsx', + function (Export $export) use ($count) { + // Assert that the correct export is downloaded. + return $export->sheets()['bills']->collection()->count() === $count; + } + ); + } + + public function testItShouldExportSelectedBills() + { + $count = 5; + $bills = Document::factory()->bill()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->post( + route('bulk-actions.action', ['group' => 'purchases', 'type' => 'bills']), + ['handle' => 'export', 'selected' => [$bills->random()->id]] + ) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.bills', 2)) . '.xlsx', + function (Export $export) { + return $export->sheets()['bills']->collection()->count() === 1; + } + ); + } + + public function testItShouldImportBills() + { + \Excel::fake(); + + $this->loginAs() + ->post( + route('bills.import'), + [ + 'import' => UploadedFile::fake()->createWithContent( + 'bills.xlsx', + File::get(public_path('files/import/bills.xlsx')) + ), + ] + ) + ->assertStatus(200); + + \Excel::assertImported('bills.xlsx'); + + $this->assertFlashLevel('success'); + } + public function getRequest($recurring = false) { $factory = Document::factory(); From d7bd69eb5f2c2606add962eec97c74357b6f122d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 12:25:03 +0300 Subject: [PATCH 03/11] added export/ bulk action export and import feature test for payments.. --- tests/Feature/Purchases/PaymentsTest.php | 66 ++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/Feature/Purchases/PaymentsTest.php b/tests/Feature/Purchases/PaymentsTest.php index 8cc680296..11a6ea6ab 100644 --- a/tests/Feature/Purchases/PaymentsTest.php +++ b/tests/Feature/Purchases/PaymentsTest.php @@ -2,8 +2,11 @@ namespace Tests\Feature\Purchases; +use App\Exports\Purchases\Payments as Export; use App\Jobs\Banking\CreateTransaction; use App\Models\Banking\Transaction; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; use Tests\Feature\FeatureTestCase; class PaymentsTest extends FeatureTestCase @@ -82,6 +85,69 @@ class PaymentsTest extends FeatureTestCase $this->assertSoftDeleted('transactions', $request); } + public function testItShouldExportPayments() + { + $count = 5; + Transaction::factory()->expense()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->get(route('payments.export')) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.payments', 2)) . '.xlsx', + function (Export $export) use ($count) { + // Assert that the correct export is downloaded. + return $export->collection()->count() === $count; + } + ); + } + + public function testItShouldExportSelectedPayments() + { + $count = 5; + $payments = Transaction::factory()->expense()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->post( + route('bulk-actions.action', ['group' => 'purchases', 'type' => 'payments']), + ['handle' => 'export', 'selected' => [$payments->random()->id]] + ) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.payments', 2)) . '.xlsx', + function (Export $export) { + return $export->collection()->count() === 1; + } + ); + } + + public function testItShouldImportPayments() + { + \Excel::fake(); + + $this->loginAs() + ->post( + route('payments.import'), + [ + 'import' => UploadedFile::fake()->createWithContent( + 'payments.xlsx', + File::get(public_path('files/import/payments.xlsx')) + ), + ] + ) + ->assertStatus(200); + + \Excel::assertImported('payments.xlsx'); + + $this->assertFlashLevel('success'); + } + public function getRequest() { return Transaction::factory()->expense()->raw(); From a94c9dc9c5881520801a20f9422050cf744057b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 12:31:00 +0300 Subject: [PATCH 04/11] added export/ bulk action export and import feature test for vendors.. --- tests/Feature/Purchases/VendorsTest.php | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/Feature/Purchases/VendorsTest.php b/tests/Feature/Purchases/VendorsTest.php index ccb2cdda0..8de9be0ce 100644 --- a/tests/Feature/Purchases/VendorsTest.php +++ b/tests/Feature/Purchases/VendorsTest.php @@ -2,8 +2,11 @@ namespace Tests\Feature\Purchases; +use App\Exports\Common\Contacts as Export; use App\Jobs\Common\CreateContact; use App\Models\Common\Contact; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; use Tests\Feature\FeatureTestCase; class VendorsTest extends FeatureTestCase @@ -96,6 +99,70 @@ class VendorsTest extends FeatureTestCase $this->assertSoftDeleted('contacts', $request); } + public function testItShouldExportVendors() + { + $count = 5; + Contact::factory()->vendor()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->get(route('vendors.export')) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.vendors', 2)) . '.xlsx', + function (Export $export) use ($count) { + // Assert that the correct export is downloaded. + return $export->collection()->count() === $count; + } + ); + } + + public function testItShouldExportSelectedVendors() + { + $count = 5; + $vendors = Contact::factory()->vendor()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->post( + route('bulk-actions.action', ['group' => 'purchases', 'type' => 'vendors']), + ['handle' => 'export', 'selected' => [$vendors->random()->id]] + ) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.vendors', 2)) . '.xlsx', + function (Export $export) { + return $export->collection()->count() === 1; + } + ); + } + + public function testItShouldImportVendors() + { + \Excel::fake(); + + $this->loginAs() + ->post( + route('vendors.import'), + [ + 'import' => UploadedFile::fake()->createWithContent( + 'vendors.xlsx', + File::get(public_path('files/import/vendors.xlsx')) + ), + ] + ) + ->assertStatus(200); + + \Excel::assertImported('vendors.xlsx'); + + $this->assertFlashLevel('success'); + } + + public function getRequest() { return Contact::factory()->vendor()->enabled()->raw(); From eab1ccc60fb065f5ffe0392e3af2075e1bb55e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 13:07:05 +0300 Subject: [PATCH 05/11] fixed vendor test --- tests/Feature/Purchases/VendorsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/Purchases/VendorsTest.php b/tests/Feature/Purchases/VendorsTest.php index 8de9be0ce..9d1ed8001 100644 --- a/tests/Feature/Purchases/VendorsTest.php +++ b/tests/Feature/Purchases/VendorsTest.php @@ -2,7 +2,7 @@ namespace Tests\Feature\Purchases; -use App\Exports\Common\Contacts as Export; +use App\Exports\Purchases\Vendors as Export; use App\Jobs\Common\CreateContact; use App\Models\Common\Contact; use Illuminate\Http\UploadedFile; From 053fb1a7bae83a956bc0611e7e1267afe2b3b627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 13:09:56 +0300 Subject: [PATCH 06/11] added export/ bulk action export and import feature test for customers.. --- tests/Feature/Sales/CustomersTest.php | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/Feature/Sales/CustomersTest.php b/tests/Feature/Sales/CustomersTest.php index 9e04fcdf2..0c6a908fc 100644 --- a/tests/Feature/Sales/CustomersTest.php +++ b/tests/Feature/Sales/CustomersTest.php @@ -2,9 +2,12 @@ namespace Tests\Feature\Sales; +use App\Exports\Sales\Customers as Export; use App\Jobs\Common\CreateContact; use App\Models\Auth\User; use App\Models\Common\Contact; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; use Tests\Feature\FeatureTestCase; class CustomersTest extends FeatureTestCase @@ -123,6 +126,69 @@ class CustomersTest extends FeatureTestCase return Contact::factory()->customer()->enabled()->raw(); } + public function testItShouldExportCustomers() + { + $count = 5; + Contact::factory()->customer()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->get(route('customers.export')) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.customers', 2)) . '.xlsx', + function (Export $export) use ($count) { + // Assert that the correct export is downloaded. + return $export->collection()->count() === $count; + } + ); + } + + public function testItShouldExportSelectedCustomers() + { + $count = 5; + $customers = Contact::factory()->customer()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->post( + route('bulk-actions.action', ['group' => 'purchases', 'type' => 'customers']), + ['handle' => 'export', 'selected' => [$customers->random()->id]] + ) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.customers', 2)) . '.xlsx', + function (Export $export) { + return $export->collection()->count() === 1; + } + ); + } + + public function testItShouldImportCustomers() + { + \Excel::fake(); + + $this->loginAs() + ->post( + route('customers.import'), + [ + 'import' => UploadedFile::fake()->createWithContent( + 'customers.xlsx', + File::get(public_path('files/import/customers.xlsx')) + ), + ] + ) + ->assertStatus(200); + + \Excel::assertImported('customers.xlsx'); + + $this->assertFlashLevel('success'); + } + public function getRequestWithUser() { $password = $this->faker->password; From 1d5ce19c039e6649af70f2b12857a52c36a2d10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 13:12:32 +0300 Subject: [PATCH 07/11] styling.. --- tests/Feature/Purchases/VendorsTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Feature/Purchases/VendorsTest.php b/tests/Feature/Purchases/VendorsTest.php index 9d1ed8001..f96c57145 100644 --- a/tests/Feature/Purchases/VendorsTest.php +++ b/tests/Feature/Purchases/VendorsTest.php @@ -162,7 +162,6 @@ class VendorsTest extends FeatureTestCase $this->assertFlashLevel('success'); } - public function getRequest() { return Contact::factory()->vendor()->enabled()->raw(); From b626c763601e91cbc630be16762aeef1fa2df59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 13:13:02 +0300 Subject: [PATCH 08/11] added export/ bulk action export and import feature test for invoices.. --- tests/Feature/Sales/CustomersTest.php | 2 +- tests/Feature/Sales/InvoicesTest.php | 66 +++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/tests/Feature/Sales/CustomersTest.php b/tests/Feature/Sales/CustomersTest.php index 0c6a908fc..abb932adf 100644 --- a/tests/Feature/Sales/CustomersTest.php +++ b/tests/Feature/Sales/CustomersTest.php @@ -155,7 +155,7 @@ class CustomersTest extends FeatureTestCase $this->loginAs() ->post( - route('bulk-actions.action', ['group' => 'purchases', 'type' => 'customers']), + route('bulk-actions.action', ['group' => 'sales', 'type' => 'customers']), ['handle' => 'export', 'selected' => [$customers->random()->id]] ) ->assertStatus(200); diff --git a/tests/Feature/Sales/InvoicesTest.php b/tests/Feature/Sales/InvoicesTest.php index e58dd0052..5ead4eaa9 100644 --- a/tests/Feature/Sales/InvoicesTest.php +++ b/tests/Feature/Sales/InvoicesTest.php @@ -2,8 +2,11 @@ namespace Tests\Feature\Sales; +use App\Exports\Sales\Invoices as Export; use App\Jobs\Document\CreateDocument; use App\Models\Document\Document; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; use Tests\Feature\FeatureTestCase; class InvoicesTest extends FeatureTestCase @@ -115,6 +118,69 @@ class InvoicesTest extends FeatureTestCase ]); } + public function testItShouldExportInvoices() + { + $count = 5; + Document::factory()->invoice()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->get(route('invoices.export')) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.invoices', 2)) . '.xlsx', + function (Export $export) use ($count) { + // Assert that the correct export is downloaded. + return $export->sheets()['invoices']->collection()->count() === $count; + } + ); + } + + public function testItShouldExportSelectedInvoices() + { + $count = 5; + $invoices = Document::factory()->invoice()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->post( + route('bulk-actions.action', ['group' => 'sales', 'type' => 'invoices']), + ['handle' => 'export', 'selected' => [$invoices->random()->id]] + ) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.invoices', 2)) . '.xlsx', + function (Export $export) { + return $export->sheets()['invoices']->collection()->count() === 1; + } + ); + } + + public function testItShouldImportInvoices() + { + \Excel::fake(); + + $this->loginAs() + ->post( + route('invoices.import'), + [ + 'import' => UploadedFile::fake()->createWithContent( + 'invoices.xlsx', + File::get(public_path('files/import/invoices.xlsx')) + ), + ] + ) + ->assertStatus(200); + + \Excel::assertImported('invoices.xlsx'); + + $this->assertFlashLevel('success'); + } + public function getRequest($recurring = false) { $factory = Document::factory(); From 95e88e04f8319826f4518c2aab5b63668aaf2ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 13:15:05 +0300 Subject: [PATCH 09/11] added export/ bulk action export and import feature test for revenues.. --- tests/Feature/Sales/RevenuesTest.php | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/Feature/Sales/RevenuesTest.php b/tests/Feature/Sales/RevenuesTest.php index 9b5b4a45f..38ebf6766 100644 --- a/tests/Feature/Sales/RevenuesTest.php +++ b/tests/Feature/Sales/RevenuesTest.php @@ -2,8 +2,11 @@ namespace Tests\Feature\Sales; +use App\Exports\Sales\Revenues as Export; use App\Jobs\Banking\CreateTransaction; use App\Models\Banking\Transaction; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; use Tests\Feature\FeatureTestCase; class RevenuesTest extends FeatureTestCase @@ -82,6 +85,69 @@ class RevenuesTest extends FeatureTestCase $this->assertSoftDeleted('transactions', $request); } + public function testItShouldExportRevenues() + { + $count = 5; + Transaction::factory()->income()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->get(route('revenues.export')) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.revenues', 2)) . '.xlsx', + function (Export $export) use ($count) { + // Assert that the correct export is downloaded. + return $export->collection()->count() === $count; + } + ); + } + + public function testItShouldExportSelectedRevenues() + { + $count = 5; + $revenues = Transaction::factory()->income()->count($count)->create(); + + \Excel::fake(); + + $this->loginAs() + ->post( + route('bulk-actions.action', ['group' => 'sales', 'type' => 'revenues']), + ['handle' => 'export', 'selected' => [$revenues->random()->id]] + ) + ->assertStatus(200); + + \Excel::assertDownloaded( + \Str::filename(trans_choice('general.revenues', 2)) . '.xlsx', + function (Export $export) { + return $export->collection()->count() === 1; + } + ); + } + + public function testItShouldImportRevenues() + { + \Excel::fake(); + + $this->loginAs() + ->post( + route('revenues.import'), + [ + 'import' => UploadedFile::fake()->createWithContent( + 'revenues.xlsx', + File::get(public_path('files/import/revenues.xlsx')) + ), + ] + ) + ->assertStatus(200); + + \Excel::assertImported('revenues.xlsx'); + + $this->assertFlashLevel('success'); + } + public function getRequest() { return Transaction::factory()->income()->raw(); From 46fdbc5d8a1d7afff843eaad9fa9fe09cc94033b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 13:38:33 +0300 Subject: [PATCH 10/11] fixed styling.. --- tests/Feature/Sales/CustomersTest.php | 172 +++++++++++++------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/tests/Feature/Sales/CustomersTest.php b/tests/Feature/Sales/CustomersTest.php index abb932adf..56acf0901 100644 --- a/tests/Feature/Sales/CustomersTest.php +++ b/tests/Feature/Sales/CustomersTest.php @@ -12,118 +12,113 @@ use Tests\Feature\FeatureTestCase; class CustomersTest extends FeatureTestCase { - public function testItShouldSeeCustomerListPage() - { - $this->loginAs() - ->get(route('customers.index')) - ->assertStatus(200) - ->assertSeeText(trans_choice('general.customers', 2)); - } + public function testItShouldSeeCustomerListPage() + { + $this->loginAs() + ->get(route('customers.index')) + ->assertStatus(200) + ->assertSeeText(trans_choice('general.customers', 2)); + } - public function testItShouldSeeCustomerCreatePage() - { - $this->loginAs() - ->get(route('customers.create')) - ->assertStatus(200) - ->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.customers', 1)])); - } + public function testItShouldSeeCustomerCreatePage() + { + $this->loginAs() + ->get(route('customers.create')) + ->assertStatus(200) + ->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.customers', 1)])); + } - public function testItShouldCreateCustomer() - { - $request = $this->getRequest(); + public function testItShouldCreateCustomer() + { + $request = $this->getRequest(); - $this->loginAs() - ->post(route('customers.store'), $request) - ->assertStatus(200); + $this->loginAs() + ->post(route('customers.store'), $request) + ->assertStatus(200); - $this->assertFlashLevel('success'); + $this->assertFlashLevel('success'); $this->assertDatabaseHas('contacts', $request); - } + } - public function testItShouldCreateCustomerWithUser() - { + public function testItShouldCreateCustomerWithUser() + { $request = $this->getRequestWithUser(); - $this->loginAs() - ->post(route('customers.store'), $request) - ->assertStatus(200); + $this->loginAs() + ->post(route('customers.store'), $request) + ->assertStatus(200); - $this->assertFlashLevel('success'); + $this->assertFlashLevel('success'); - $user = User::where('email', $request['email'])->first(); + $user = User::where('email', $request['email'])->first(); - $this->assertNotNull($user); - $this->assertEquals($request['email'], $user->email); - } + $this->assertNotNull($user); + $this->assertEquals($request['email'], $user->email); + } - public function testItShouldSeeCustomerDetailPage() - { - $request = $this->getRequest(); + public function testItShouldSeeCustomerDetailPage() + { + $request = $this->getRequest(); - $customer = $this->dispatch(new CreateContact($request)); + $customer = $this->dispatch(new CreateContact($request)); - $this->loginAs() - ->get(route('customers.show', $customer->id)) - ->assertStatus(200) - ->assertSee($customer->email); - } + $this->loginAs() + ->get(route('customers.show', $customer->id)) + ->assertStatus(200) + ->assertSee($customer->email); + } - public function testItShouldSeeCustomerUpdatePage() - { - $request = $this->getRequest(); + public function testItShouldSeeCustomerUpdatePage() + { + $request = $this->getRequest(); - $customer = $this->dispatch(new CreateContact($request)); + $customer = $this->dispatch(new CreateContact($request)); - $this->loginAs() - ->get(route('customers.edit', $customer->id)) - ->assertStatus(200) - ->assertSee($customer->email); - } + $this->loginAs() + ->get(route('customers.edit', $customer->id)) + ->assertStatus(200) + ->assertSee($customer->email); + } - public function testItShouldUpdateCustomer() - { - $request = $this->getRequest(); + public function testItShouldUpdateCustomer() + { + $request = $this->getRequest(); - $customer = $this->dispatch(new CreateContact($request)); + $customer = $this->dispatch(new CreateContact($request)); $request['email'] = $this->faker->safeEmail; - $this->loginAs() - ->patch(route('customers.update', $customer->id), $request) - ->assertStatus(200) - ->assertSee($request['email']); + $this->loginAs() + ->patch(route('customers.update', $customer->id), $request) + ->assertStatus(200) + ->assertSee($request['email']); - $this->assertFlashLevel('success'); + $this->assertFlashLevel('success'); $this->assertDatabaseHas('contacts', $request); - } + } - public function testItShouldDeleteCustomer() - { + public function testItShouldDeleteCustomer() + { $request = $this->getRequest(); - $customer = $this->dispatch(new CreateContact($request)); + $customer = $this->dispatch(new CreateContact($request)); - $this->loginAs() - ->delete(route('customers.destroy', $customer->id)) - ->assertStatus(200); + $this->loginAs() + ->delete(route('customers.destroy', $customer->id)) + ->assertStatus(200); - $this->assertFlashLevel('success'); + $this->assertFlashLevel('success'); $this->assertSoftDeleted('contacts', $request); - } + } - public function testItShouldNotDeleteCustomerIfHasRelations() - { - $this->assertTrue(true); - //TODO : This will write after done invoice and revenues tests. - } - - public function getRequest() + public function testItShouldNotDeleteCustomerIfHasRelations() { - return Contact::factory()->customer()->enabled()->raw(); + $this->assertTrue(true); + //TODO : This will write after done invoice and revenues tests. } public function testItShouldExportCustomers() @@ -189,15 +184,20 @@ class CustomersTest extends FeatureTestCase $this->assertFlashLevel('success'); } - public function getRequestWithUser() - { - $password = $this->faker->password; + public function getRequest() + { + return Contact::factory()->customer()->enabled()->raw(); + } - return $this->getRequest() + [ - 'create_user' => 'true', - 'locale' => 'en-GB', - 'password' => $password, - 'password_confirmation' => $password, - ]; - } + public function getRequestWithUser() + { + $password = $this->faker->password; + + return $this->getRequest() + [ + 'create_user' => 'true', + 'locale' => 'en-GB', + 'password' => $password, + 'password_confirmation' => $password, + ]; + } } From 463d89a4e2c024b3d893a02c3c28869f41d3eaa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 12 Feb 2021 18:10:20 +0300 Subject: [PATCH 11/11] customer test fixed export issue.. this issue reason https://github.com/akaunting/akaunting/blob/b5300e416c1e330e4dfa9fa60ff22abc5682c920/database/seeds/TestCompany.php#L76 --- tests/Feature/Sales/CustomersTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Feature/Sales/CustomersTest.php b/tests/Feature/Sales/CustomersTest.php index 56acf0901..ddc78c1e6 100644 --- a/tests/Feature/Sales/CustomersTest.php +++ b/tests/Feature/Sales/CustomersTest.php @@ -112,7 +112,6 @@ class CustomersTest extends FeatureTestCase $this->assertFlashLevel('success'); $this->assertSoftDeleted('contacts', $request); - } public function testItShouldNotDeleteCustomerIfHasRelations() @@ -136,7 +135,7 @@ class CustomersTest extends FeatureTestCase \Str::filename(trans_choice('general.customers', 2)) . '.xlsx', function (Export $export) use ($count) { // Assert that the correct export is downloaded. - return $export->collection()->count() === $count; + return $export->collection()->count() === $count + 1; } ); }