diff --git a/tests/Feature/Account/AccountEmailQuotaTest.php b/tests/Feature/Account/AccountEmailQuotaTest.php index 3d0c0cfc3968..d7027a134c1f 100644 --- a/tests/Feature/Account/AccountEmailQuotaTest.php +++ b/tests/Feature/Account/AccountEmailQuotaTest.php @@ -53,7 +53,7 @@ class AccountEmailQuotaTest extends TestCase ]); $hash = \Illuminate\Support\Str::random(32); - + $user = User::factory()->create([ 'account_id' => $account->id, 'confirmation_code' => $hash, diff --git a/tests/Feature/ActivityApiTest.php b/tests/Feature/ActivityApiTest.php index d74f05be3705..806385295331 100644 --- a/tests/Feature/ActivityApiTest.php +++ b/tests/Feature/ActivityApiTest.php @@ -26,7 +26,7 @@ class ActivityApiTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -35,7 +35,7 @@ class ActivityApiTest extends TestCase $this->withoutMiddleware( ThrottleRequests::class ); - + $this->withoutExceptionHandling(); } @@ -286,7 +286,7 @@ class ActivityApiTest extends TestCase public function testActivityEntity() { - + $invoice = $this->company->invoices()->first(); $invoice->service()->markSent()->markPaid()->markDeleted()->handleRestore()->save(); @@ -298,11 +298,11 @@ class ActivityApiTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/activities/entity', $data); - + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/activities/entity', $data); + $response->assertStatus(200); diff --git a/tests/Feature/ApplePayDomainMerchantUrlTest.php b/tests/Feature/ApplePayDomainMerchantUrlTest.php index 173d007bda2e..cc3485bfab60 100644 --- a/tests/Feature/ApplePayDomainMerchantUrlTest.php +++ b/tests/Feature/ApplePayDomainMerchantUrlTest.php @@ -26,7 +26,7 @@ class ApplePayDomainMerchantUrlTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -43,12 +43,12 @@ class ApplePayDomainMerchantUrlTest extends TestCase $this->markTestSkipped('Skip test no company gateways installed'); // } - $config = new \stdClass; + $config = new \stdClass(); $config->publishableKey = 'pk_test'; $config->apiKey = 'sk_test'; $config->appleDomainVerification = 'merchant_id'; - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $this->company->id; $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; diff --git a/tests/Feature/Bank/BankTransactionRuleTest.php b/tests/Feature/Bank/BankTransactionRuleTest.php index 047b7505576b..9cd606962629 100644 --- a/tests/Feature/Bank/BankTransactionRuleTest.php +++ b/tests/Feature/Bank/BankTransactionRuleTest.php @@ -26,7 +26,7 @@ class BankTransactionRuleTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -41,7 +41,7 @@ class BankTransactionRuleTest extends TestCase public function testMatchCreditOnInvoiceNumber() { - + $bi = BankIntegration::factory()->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, @@ -154,7 +154,7 @@ class BankTransactionRuleTest extends TestCase 'applies_to' => 'DEBIT', 'client_id' => $this->client->id, 'vendor_id' => $this->vendor->id, - 'category_id' =>$this->expense_category->id, + 'category_id' => $this->expense_category->id, 'rules' => [ [ 'search_key' => 'description', @@ -167,7 +167,7 @@ class BankTransactionRuleTest extends TestCase $bt = $bt->refresh(); $debit_rules = $bt->company->debit_rules(); - + $bt->service()->processRules(); $bt = $bt->fresh(); @@ -175,7 +175,7 @@ class BankTransactionRuleTest extends TestCase $this->assertNotNull($bt->expense_id); // $this->assertNotNull($bt->expense->category_id); // $this->assertNotNull($bt->expense->vendor_id); - + $bt = null; } @@ -222,7 +222,7 @@ class BankTransactionRuleTest extends TestCase $response->assertStatus(200); - + } public function testMatchingBankTransactionExpenseAmountLessThanEqualTo() @@ -258,8 +258,8 @@ class BankTransactionRuleTest extends TestCase ] ] ]); - - + + $bt->company->refresh(); $bt->refresh()->service()->processRules(); @@ -268,7 +268,7 @@ class BankTransactionRuleTest extends TestCase $this->assertNotNull($bt->expense_id); - $bt=null; + $bt = null; } @@ -305,7 +305,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 99 ]); - + $bt->service()->processRules(); @@ -347,7 +347,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 101 ]); - + $bt->refresh()->service()->processRules(); @@ -390,7 +390,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 101 ]); - + $bt->service()->processRules(); @@ -432,7 +432,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 100 ]); - + $bt->service()->processRules(); @@ -475,7 +475,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 100 ]); - + $bt = $bt->refresh(); $bt->service()->processRules(); @@ -520,7 +520,7 @@ class BankTransactionRuleTest extends TestCase ] ]); - + $bt->load('company'); $bt->service()->processRules(); @@ -564,7 +564,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 100 ]); - + $bt->service()->processRules(); @@ -608,7 +608,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 100 ]); - + $bt->service()->processRules(); @@ -651,7 +651,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 100 ]); - + $bt->service()->processRules(); @@ -694,7 +694,7 @@ class BankTransactionRuleTest extends TestCase 'base_type' => 'DEBIT', 'amount' => 100 ]); - + $bt->service()->processRules(); @@ -735,7 +735,7 @@ class BankTransactionRuleTest extends TestCase 'description' => 'Wall', 'base_type' => 'DEBIT', ]); - + $bt->service()->processRules(); @@ -776,7 +776,7 @@ class BankTransactionRuleTest extends TestCase 'description' => 'WallABy', 'base_type' => 'DEBIT', ]); - + $bt->service()->processRules(); @@ -822,7 +822,7 @@ class BankTransactionRuleTest extends TestCase // 'base_type' => 'CREDIT', // 'amount' => 100 // ]); - + // $bt->service()->processRules(); diff --git a/tests/Feature/Bank/BankTransactionTest.php b/tests/Feature/Bank/BankTransactionTest.php index 68d820fc9a62..33cab2824513 100644 --- a/tests/Feature/Bank/BankTransactionTest.php +++ b/tests/Feature/Bank/BankTransactionTest.php @@ -29,7 +29,7 @@ class BankTransactionTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -59,7 +59,7 @@ class BankTransactionTest extends TestCase $bt->base_type = 'DEBIT'; $bt->save(); - + $bi2 = BankIntegrationFactory::create($this->company->id, $this->user->id, $this->account->id); $bi2->bank_account_name = "Bank2"; $bi2->save(); @@ -86,7 +86,7 @@ class BankTransactionTest extends TestCase $arr = $response->json(); $transaction_count = count($arr['data']); - + $this->assertGreaterThan(1, $transaction_count); $response = $this->withHeaders([ @@ -216,7 +216,7 @@ class BankTransactionTest extends TestCase $response->assertStatus(200); $this->assertNotNull($e2->refresh()->transaction_id); - + $this->assertEquals("{$this->expense->hashed_id},{$e->hashed_id},{$e2->hashed_id}", $bt->fresh()->expense_id); $expense_repo = app('App\Repositories\ExpenseRepository'); @@ -475,7 +475,7 @@ class BankTransactionTest extends TestCase public function testMatchBankTransactionsValidationShouldFail() { $data = []; - + $data['transactions'][] = [ 'bad_key' => 10, ]; diff --git a/tests/Feature/Bank/YodleeBankTransactionTest.php b/tests/Feature/Bank/YodleeBankTransactionTest.php index fb658ed9bb60..8bf4bd5613f5 100644 --- a/tests/Feature/Bank/YodleeBankTransactionTest.php +++ b/tests/Feature/Bank/YodleeBankTransactionTest.php @@ -23,7 +23,7 @@ class YodleeBankTransactionTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -80,7 +80,7 @@ class YodleeBankTransactionTest extends TestCase $bank_transaction = BankTransaction::where('company_id', $this->company->id)->first(); $bank_transaction->description = "super-funk-123"; $bank_transaction->save(); - + $this->assertNotNull($this->invoice); $this->assertNotNull($bank_transaction); diff --git a/tests/Feature/BankIntegrationApiTest.php b/tests/Feature/BankIntegrationApiTest.php index 616cecaf0bca..8e4ba332aace 100644 --- a/tests/Feature/BankIntegrationApiTest.php +++ b/tests/Feature/BankIntegrationApiTest.php @@ -29,8 +29,8 @@ class BankIntegrationApiTest extends TestCase use MockAccountData; protected $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/BankTransactionApiTest.php b/tests/Feature/BankTransactionApiTest.php index 5664fbceebc7..c4e5ad3fe3f7 100644 --- a/tests/Feature/BankTransactionApiTest.php +++ b/tests/Feature/BankTransactionApiTest.php @@ -33,7 +33,7 @@ class BankTransactionApiTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -48,7 +48,7 @@ class BankTransactionApiTest extends TestCase public function testBankTransactionCreate() { - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -129,7 +129,7 @@ class BankTransactionApiTest extends TestCase public function testBankTransactionUnlink() { BankTransaction::truncate(); - + $bi = BankIntegration::factory()->create([ 'account_id' => $this->account->id, 'company_id' => $this->company->id, @@ -149,7 +149,7 @@ class BankTransactionApiTest extends TestCase 'expense_id' => "{$this->expense->hashed_id},{$e->hashed_id}", 'invoice_ids' => $this->invoice->hashed_id, ]); - + $e->transaction_id = $bank_transaction->id; $e->save(); diff --git a/tests/Feature/BankTransactionRuleApiTest.php b/tests/Feature/BankTransactionRuleApiTest.php index 843b6241cbb5..1d9483835412 100644 --- a/tests/Feature/BankTransactionRuleApiTest.php +++ b/tests/Feature/BankTransactionRuleApiTest.php @@ -28,7 +28,7 @@ class BankTransactionRuleApiTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/BaseApiTest.php b/tests/Feature/BaseApiTest.php index 9eb2594c07fe..1debe9673cba 100644 --- a/tests/Feature/BaseApiTest.php +++ b/tests/Feature/BaseApiTest.php @@ -104,7 +104,7 @@ class BaseApiTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -161,7 +161,7 @@ class BaseApiTest extends TestCase $user_id = $owner_user->id; - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $owner_user->id; $company_token->company_id = $company->id; $company_token->account_id = $this->account->id; @@ -186,7 +186,7 @@ class BaseApiTest extends TestCase $this->low_token = \Illuminate\Support\Str::random(64); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $lower_permission_user->id; $company_token->company_id = $this->company->id; $company_token->account_id = $this->account->id; @@ -326,7 +326,7 @@ class BaseApiTest extends TestCase 'company_id' => $company->id, ]); - $gs = new GroupSetting; + $gs = new GroupSetting(); $gs->name = 'Test'; $gs->company_id = $client->company_id; $gs->settings = ClientSettings::buildClientSettings($company->settings, $client->settings); @@ -372,7 +372,7 @@ class BaseApiTest extends TestCase 'company_id' => $company->id, ]); - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $company->id; $cg->user_id = $user_id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; @@ -397,7 +397,7 @@ class BaseApiTest extends TestCase // } - + /** * Tests admin/owner facing routes respond with the correct status and/or data set */ diff --git a/tests/Feature/CancelInvoiceTest.php b/tests/Feature/CancelInvoiceTest.php index d895ac3926ce..4fd846da243e 100644 --- a/tests/Feature/CancelInvoiceTest.php +++ b/tests/Feature/CancelInvoiceTest.php @@ -29,7 +29,7 @@ class CancelInvoiceTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/ClassificationTest.php b/tests/Feature/ClassificationTest.php index 9f9544f2219d..65c7d07f7062 100644 --- a/tests/Feature/ClassificationTest.php +++ b/tests/Feature/ClassificationTest.php @@ -25,7 +25,7 @@ class ClassificationTest extends TestCase use DatabaseTransactions; use MockUnitData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Client/ClientMergeTest.php b/tests/Feature/Client/ClientMergeTest.php index a11ca2d0fcd5..4e997066ff65 100644 --- a/tests/Feature/Client/ClientMergeTest.php +++ b/tests/Feature/Client/ClientMergeTest.php @@ -38,7 +38,7 @@ class ClientMergeTest extends TestCase private $primary_contact; public $faker; - + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/ClientApiTest.php b/tests/Feature/ClientApiTest.php index 5748217a1432..97050e68546b 100644 --- a/tests/Feature/ClientApiTest.php +++ b/tests/Feature/ClientApiTest.php @@ -46,7 +46,7 @@ class ClientApiTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -74,7 +74,7 @@ class ClientApiTest extends TestCase "action" => "bulk_update", "ids" => Client::where('company_id', $this->company->id)->get()->pluck("hashed_id") ]; - + $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, ])->postJson("/api/v1/clients/bulk", $data); @@ -88,7 +88,7 @@ class ClientApiTest extends TestCase public function testCountryCodeValidation() { - + $data = [ 'name' => 'name of client', 'country_code' => 'USA', @@ -128,14 +128,14 @@ class ClientApiTest extends TestCase ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(200); - + $this->assertEquals($this->company->settings->country_id, $arr['data']['country_id']); } public function testIdNumberPutValidation() { - + $data = [ 'name' => 'name of client', 'country_id' => '840', @@ -147,7 +147,7 @@ class ClientApiTest extends TestCase ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(200); - + $data = [ 'name' => 'name of client', 'country_id' => '840', @@ -175,7 +175,7 @@ class ClientApiTest extends TestCase public function testNumberPutValidation() { - + $data = [ 'name' => 'name of client', 'country_id' => '840', @@ -187,7 +187,7 @@ class ClientApiTest extends TestCase ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(200); - + $data = [ 'name' => 'name of client', 'country_id' => '840', @@ -223,13 +223,13 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/clients/",$data) + ])->postJson("/api/v1/clients/", $data) ->assertStatus(200); $arr = $response->json(); $this->assertEquals("x-1-11", $arr['data']['number']); - + $data = [ 'name' => 'name of client', 'country_id' => '840', @@ -274,7 +274,7 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->putJson("/api/v1/clients/".$this->client->hashed_id,$data) + ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(200); $arr = $response->json(); @@ -292,7 +292,7 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->putJson("/api/v1/clients/".$this->client->hashed_id,$data) + ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(422); } @@ -307,7 +307,7 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/clients/",$data) + ])->postJson("/api/v1/clients/", $data) ->assertStatus(422); } @@ -322,12 +322,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/clients/",$data) + ])->postJson("/api/v1/clients/", $data) ->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $this->assertEquals("8", $arr['data']['country_id']); + $this->assertEquals("8", $arr['data']['country_id']); } @@ -342,12 +342,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/clients/",$data) + ])->postJson("/api/v1/clients/", $data) ->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $this->assertEquals("2", $arr['data']['settings']['currency_id']); + $this->assertEquals("2", $arr['data']['settings']['currency_id']); } @@ -362,12 +362,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->putJson("/api/v1/clients/".$this->client->hashed_id,$data) + ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $this->assertEquals("2", $arr['data']['settings']['currency_id']); + $this->assertEquals("2", $arr['data']['settings']['currency_id']); } @@ -382,12 +382,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->putJson("/api/v1/clients/".$this->client->hashed_id,$data) + ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $this->assertEquals("1", $arr['data']['settings']['currency_id']); + $this->assertEquals("1", $arr['data']['settings']['currency_id']); } @@ -402,12 +402,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->putJson("/api/v1/clients/".$this->client->hashed_id,$data) + ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); + $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); } @@ -422,12 +422,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->putJson("/api/v1/clients/".$this->client->hashed_id,$data) + ])->putJson("/api/v1/clients/".$this->client->hashed_id, $data) ->assertStatus(422); - $arr = $response->json(); + $arr = $response->json(); - // $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); + // $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); } @@ -442,12 +442,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/clients",$data) + ])->postJson("/api/v1/clients", $data) ->assertStatus(422); - $arr = $response->json(); + $arr = $response->json(); - // $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); + // $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); } @@ -462,12 +462,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/clients",$data) + ])->postJson("/api/v1/clients", $data) ->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); + $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); } @@ -480,12 +480,12 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/clients",$data) + ])->postJson("/api/v1/clients", $data) ->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); + $this->assertEquals($this->company->settings->currency_id, $arr['data']['settings']['currency_id']); } @@ -498,7 +498,7 @@ class ClientApiTest extends TestCase $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/clients",$data) + ])->postJson("/api/v1/clients", $data) ->assertStatus(200); } @@ -548,7 +548,7 @@ class ClientApiTest extends TestCase 'X-API-TOKEN' => $this->token, ])->putJson("/api/v1/clients/{$this->client->hashed_id}", $data) ->assertStatus(422); - + $data = [ 'name' => 'name of client', 'documents' => [], @@ -563,13 +563,13 @@ class ClientApiTest extends TestCase public function testClientDocumentQuery() { - + $d = \App\Models\Document::factory()->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, ]); - $this->invoice->documents()->save($d); + $this->invoice->documents()->save($d); $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, @@ -612,7 +612,7 @@ class ClientApiTest extends TestCase $arr = $response->json(); $this->assertCount(3, $arr['data']); - + $d = \App\Models\Document::factory()->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, @@ -654,7 +654,7 @@ class ClientApiTest extends TestCase 'user_id' => $this->user->id, ]); - + $e = \App\Models\Expense::factory()->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, @@ -675,29 +675,29 @@ class ClientApiTest extends TestCase $this->assertCount(6, $arr['data']); -$d = \App\Models\Document::factory()->create([ - 'company_id' => $this->company->id, - 'user_id' => $this->user->id, -]); + $d = \App\Models\Document::factory()->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + ]); -$t = \App\Models\Task::factory()->create([ - 'company_id' => $this->company->id, - 'user_id' => $this->user->id, - 'client_id' => $this->client->id, -]); + $t = \App\Models\Task::factory()->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'client_id' => $this->client->id, + ]); -$t->documents()->save($d); + $t->documents()->save($d); -$response = $this->withHeaders([ - 'X-API-TOKEN' => $this->token, -])->postJson("/api/v1/clients/{$this->client->hashed_id}/documents") -->assertStatus(200); + $response = $this->withHeaders([ + 'X-API-TOKEN' => $this->token, + ])->postJson("/api/v1/clients/{$this->client->hashed_id}/documents") + ->assertStatus(200); -$arr = $response->json(); + $arr = $response->json(); -$this->assertCount(7, $arr['data']); + $this->assertCount(7, $arr['data']); @@ -733,7 +733,7 @@ $this->assertCount(7, $arr['data']); $different_company_token = \Illuminate\Support\Str::random(64); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $user->id; $company_token->company_id = $company->id; $company_token->account_id = $account->id; @@ -801,7 +801,7 @@ $this->assertCount(7, $arr['data']); 'action' => 'archive', 'ids' => $this->client->hashed_id - + ]; $v = $this->app['validator']->make($data, $rules); @@ -830,13 +830,13 @@ $this->assertCount(7, $arr['data']); $this->assertTrue($response->headers->get('content-type') == 'application/pdf'); - + } public function testClientStatementEmail() { $response = null; - + $data = [ 'client_id' => $this->client->hashed_id, 'start_date' => '2000-01-01', @@ -846,11 +846,11 @@ $this->assertCount(7, $arr['data']); 'status' => 'paid', ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/client_statement?send_email=true', $data); - + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/client_statement?send_email=true', $data); + $response->assertJson([ 'message' => ctrans('texts.email_queued'), @@ -931,7 +931,7 @@ $this->assertCount(7, $arr['data']); public function testClientSettingsSave() { - $std = new \stdClass; + $std = new \stdClass(); $std->entity = 'App\\Models\\Client'; $std->currency_id = 3; @@ -945,7 +945,7 @@ $this->assertCount(7, $arr['data']); public function testClientSettingsSave2() { - $std = new \stdClass; + $std = new \stdClass(); $std->entity = 'App\\Models\\Client'; $std->industry_id = ''; $std->size_id = ''; @@ -1022,7 +1022,7 @@ $this->assertCount(7, $arr['data']); $repository = app()->make($repository_name); $repository->import_mode = true; - $_syn_request_class = new $request_name; + $_syn_request_class = new $request_name(); $_syn_request_class->setContainer(app()); $_syn_request_class->initialize($data); $_syn_request_class->prepareForValidation(); @@ -1123,10 +1123,10 @@ $this->assertCount(7, $arr['data']); $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); $response->assertStatus(200); @@ -1156,11 +1156,11 @@ $this->assertCount(7, $arr['data']); $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); - + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); + $response->assertStatus(200); $arr = $response->json(); @@ -1178,10 +1178,10 @@ $this->assertCount(7, $arr['data']); $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); $response->assertStatus(200); @@ -1201,10 +1201,10 @@ $this->assertCount(7, $arr['data']); $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); $response->assertStatus(200); @@ -1224,10 +1224,10 @@ $this->assertCount(7, $arr['data']); $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); $response->assertStatus(200); @@ -1242,10 +1242,10 @@ $this->assertCount(7, $arr['data']); $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); $response->assertStatus(200); } @@ -1259,10 +1259,10 @@ $this->assertCount(7, $arr['data']); $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); $response->assertStatus(200); @@ -1280,7 +1280,7 @@ $this->assertCount(7, $arr['data']); 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/clients/', $data); - + $response->assertStatus(200); } @@ -1399,7 +1399,7 @@ $this->assertCount(7, $arr['data']); $response = $this->withHeaders([ 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/clients/bulk?action=archive', $data); - + $response->assertStatus(200); $arr = $response->json(); $this->assertNotNull($arr['data'][0]['archived_at']); diff --git a/tests/Feature/ClientDeletedInvoiceCreationTest.php b/tests/Feature/ClientDeletedInvoiceCreationTest.php index 20a562514fd0..ce14b2db89b7 100644 --- a/tests/Feature/ClientDeletedInvoiceCreationTest.php +++ b/tests/Feature/ClientDeletedInvoiceCreationTest.php @@ -29,7 +29,7 @@ class ClientDeletedInvoiceCreationTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/ClientGatewayTokenApiTest.php b/tests/Feature/ClientGatewayTokenApiTest.php index 11b089b10d37..df9ee7f6d9cb 100644 --- a/tests/Feature/ClientGatewayTokenApiTest.php +++ b/tests/Feature/ClientGatewayTokenApiTest.php @@ -32,8 +32,8 @@ class ClientGatewayTokenApiTest extends TestCase protected $faker; protected CompanyGateway $cg; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); @@ -87,7 +87,7 @@ class ClientGatewayTokenApiTest extends TestCase //disable ach here $json_config = json_decode(config('ninja.testvars.stripe')); - $this->cg = new CompanyGateway; + $this->cg = new CompanyGateway(); $this->cg->company_id = $this->company->id; $this->cg->user_id = $this->user->id; $this->cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; diff --git a/tests/Feature/ClientModelTest.php b/tests/Feature/ClientModelTest.php index b95d35db75e3..cd8e21918e21 100644 --- a/tests/Feature/ClientModelTest.php +++ b/tests/Feature/ClientModelTest.php @@ -27,7 +27,7 @@ class ClientModelTest extends TestCase use MockAccountData; use DatabaseTransactions; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -41,8 +41,9 @@ class ClientModelTest extends TestCase $this->markTestSkipped('Skip test no company gateways installed'); } - if(CompanyGateway::count() == 0) + if(CompanyGateway::count() == 0) { $this->markTestSkipped('Skip test no company gateways installed'); + } } @@ -51,7 +52,7 @@ class ClientModelTest extends TestCase $this->invoice->amount = 10; $this->invoice->balance = 10; - $this->invoice->status_id=2; + $this->invoice->status_id = 2; $this->invoice->date = now()->subDays(2); $this->invoice->due_date = now()->addDays(2); $this->invoice->save(); @@ -61,7 +62,7 @@ class ClientModelTest extends TestCase 'user_id' => $this->user->id, ]); - + $cd2 = Client::factory()->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, @@ -106,7 +107,7 @@ class ClientModelTest extends TestCase $response->assertStatus(200); $arr = $response->json(); - $this->assertEquals($invoice_count+2, count($arr['data'])); + $this->assertEquals($invoice_count + 2, count($arr['data'])); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), @@ -168,7 +169,7 @@ class ClientModelTest extends TestCase public function testPaymentMethodsWithCreditsEnforced() { - + $payment_methods = $this->client->service()->getPaymentMethods(40); $this->assertGreaterThan(0, CompanyGateway::count()); diff --git a/tests/Feature/ClientPortal/CreditsTest.php b/tests/Feature/ClientPortal/CreditsTest.php index 9f3f0e88fb65..afea354bf358 100644 --- a/tests/Feature/ClientPortal/CreditsTest.php +++ b/tests/Feature/ClientPortal/CreditsTest.php @@ -25,22 +25,23 @@ use App\Utils\Traits\AppSetup; use Faker\Factory; use Illuminate\Foundation\Testing\DatabaseTransactions; use Livewire\Livewire; -use function now; use Tests\TestCase; +use function now; + class CreditsTest extends TestCase { use DatabaseTransactions; use AppSetup; private $faker; - + protected function setUp(): void { parent::setUp(); $this->faker = Factory::create(); - + } public function testShowingOnlyCreditsWithDueDateLessOrEqualToNow() diff --git a/tests/Feature/ClientPortal/InvoicesTest.php b/tests/Feature/ClientPortal/InvoicesTest.php index 581dbf1d2405..7a039b25a244 100644 --- a/tests/Feature/ClientPortal/InvoicesTest.php +++ b/tests/Feature/ClientPortal/InvoicesTest.php @@ -31,7 +31,7 @@ class InvoicesTest extends TestCase use AppSetup; public $faker; - + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/ClientPresenterTest.php b/tests/Feature/ClientPresenterTest.php index 22e6d132ef68..1f03f69146bb 100644 --- a/tests/Feature/ClientPresenterTest.php +++ b/tests/Feature/ClientPresenterTest.php @@ -24,7 +24,7 @@ class ClientPresenterTest extends TestCase use MockAccountData; use DatabaseTransactions; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index 44514d00f220..0aa7fd42bfe0 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -49,8 +49,8 @@ class ClientTest extends TestCase public $faker; public $client_id; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); @@ -105,8 +105,8 @@ class ClientTest extends TestCase $this->assertEquals($gs->id, $c->group_settings_id); }); - foreach($arr['data'] as $client_response){ - + foreach($arr['data'] as $client_response) { + $this->assertEquals($gs->hashed_id, $client_response['group_settings_id']); } } @@ -128,14 +128,14 @@ class ClientTest extends TestCase $this->company->saveSettings($settings, $this->company); - $client_exchange_rate = round($c->setExchangeRate(),2); + $client_exchange_rate = round($c->setExchangeRate(), 2); $aud_currency = Currency::find(12); $eur_currency = Currency::find(3); $synthetic_exchange = $aud_currency->exchange_rate / $eur_currency->exchange_rate; - $this->assertEquals($client_exchange_rate, round($synthetic_exchange,2)); + $this->assertEquals($client_exchange_rate, round($synthetic_exchange, 2)); } @@ -235,7 +235,7 @@ class ClientTest extends TestCase 'company_id' => $this->company->id, 'email' => '' ]); - + $this->assertEquals(2, $c->contacts->count()); $this->assertEquals(3, $c1->contacts->count()); @@ -254,7 +254,7 @@ class ClientTest extends TestCase { $line_items = []; - for ($x=0; $x<$number; $x++) { + for ($x = 0; $x < $number; $x++) { $item = InvoiceItemFactory::create(); $item->quantity = 1; $item->cost = 10; @@ -570,7 +570,7 @@ class ClientTest extends TestCase 'is_locked' => 0, ]); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $user->id; $company_token->company_id = $company->id; $company_token->account_id = $account->id; @@ -625,7 +625,7 @@ class ClientTest extends TestCase 'is_locked' => 0, ]); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $user->id; $company_token->company_id = $company->id; $company_token->account_id = $account->id; diff --git a/tests/Feature/CompanyGatewayApiTest.php b/tests/Feature/CompanyGatewayApiTest.php index 9af80c664c5f..e2690a00e8a8 100644 --- a/tests/Feature/CompanyGatewayApiTest.php +++ b/tests/Feature/CompanyGatewayApiTest.php @@ -34,7 +34,7 @@ class CompanyGatewayApiTest extends TestCase use MockAccountData; use CompanyGatewayFeesAndLimitsSaver; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -164,7 +164,7 @@ class CompanyGatewayApiTest extends TestCase public function testCompanyGatewayFeesAndLimitsSuccess() { - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee = (array) $fee; @@ -224,7 +224,7 @@ class CompanyGatewayApiTest extends TestCase public function testCompanyGatewayFeesAndLimitsFails() { - $fee_and_limit['bank_transfer'] = new FeesAndLimits; + $fee_and_limit['bank_transfer'] = new FeesAndLimits(); $fee_and_limit['bank_transfer']->adjust_fee_percent = 10; @@ -250,7 +250,7 @@ class CompanyGatewayApiTest extends TestCase 'max_limit' => 2, ]; - $fal = (array) new FeesAndLimits; + $fal = (array) new FeesAndLimits(); $new_arr = array_replace($fal, $arr); @@ -261,7 +261,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeeAmountCalcuation() { //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}} - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee->fee_amount = 10; // $fee->fee_percent = 2; // $fee->fee_tax_name1 = 'GST'; @@ -294,7 +294,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeePercentCalcuation() { //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}} - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); //$fee->fee_amount = 10; $fee->fee_percent = 2; // $fee->fee_tax_name1 = 'GST'; @@ -327,7 +327,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeePercentAndAmountCalcuation() { //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}} - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee->fee_amount = 10; $fee->fee_percent = 2; // $fee->fee_tax_name1 = 'GST'; @@ -360,7 +360,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeePercentAndAmountCalcuationOneHundredPercent() { //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}} - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee->fee_amount = 0; $fee->fee_percent = 100; $fee->adjust_fee_percent = false; @@ -393,7 +393,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeePercentAndAmountCalcuationOneHundredPercentVariationOne() { - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee->fee_amount = 0; $fee->fee_percent = 10; @@ -424,7 +424,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeePercentAndAmountAndTaxCalcuation() { //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}} - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee->fee_amount = 10; // $fee->fee_percent = 2; $fee->fee_tax_name1 = 'GST'; @@ -457,7 +457,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeePercentAndAmountAndTaxCalcuationInclusiveTaxes() { //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}} - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee->fee_amount = 10; // $fee->fee_percent = 2; $fee->fee_tax_name1 = 'GST'; @@ -490,7 +490,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeePercentAndAmountAndDoubleTaxCalcuation() { //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}} - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee->fee_amount = 10; // $fee->fee_percent = 2; $fee->fee_tax_name1 = 'GST'; @@ -525,7 +525,7 @@ class CompanyGatewayApiTest extends TestCase public function testFeesAndLimitsFeePercentAndAmountAndDoubleTaxCalcuationWithFeeCap() { //{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}} - $fee = new FeesAndLimits; + $fee = new FeesAndLimits(); $fee->fee_amount = 10; // $fee->fee_percent = 2; $fee->fee_tax_name1 = 'GST'; diff --git a/tests/Feature/CompanyGatewayResolutionTest.php b/tests/Feature/CompanyGatewayResolutionTest.php index 238ededc477a..2a85d84dd2ff 100644 --- a/tests/Feature/CompanyGatewayResolutionTest.php +++ b/tests/Feature/CompanyGatewayResolutionTest.php @@ -35,7 +35,7 @@ class CompanyGatewayResolutionTest extends TestCase public $cg1; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -55,7 +55,7 @@ class CompanyGatewayResolutionTest extends TestCase $this->withoutExceptionHandling(); - CompanyGateway::query()->withTrashed()->cursor()->each(function ($cg){ + CompanyGateway::query()->withTrashed()->cursor()->each(function ($cg) { $cg->forceDelete(); }); @@ -91,7 +91,7 @@ class CompanyGatewayResolutionTest extends TestCase //disable ach here $json_config = json_decode(config('ninja.testvars.stripe')); - $this->cg = new CompanyGateway; + $this->cg = new CompanyGateway(); $this->cg->company_id = $this->company->id; $this->cg->user_id = $this->user->id; $this->cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; @@ -148,7 +148,7 @@ class CompanyGatewayResolutionTest extends TestCase CompanyGateway::query()->withTrashed()->cursor()->each(function ($cg) { $cg->forceDelete(); }); - + Credit::query()->withTrashed()->cursor()->each(function ($c) { $c->forceDelete(); }); @@ -185,7 +185,7 @@ class CompanyGatewayResolutionTest extends TestCase //disable ach here $json_config = json_decode(config('ninja.testvars.stripe')); - $this->cg = new CompanyGateway; + $this->cg = new CompanyGateway(); $this->cg->company_id = $this->company->id; $this->cg->user_id = $this->user->id; $this->cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; @@ -237,7 +237,7 @@ class CompanyGatewayResolutionTest extends TestCase //disable ach here $json_config = json_decode(config('ninja.testvars.stripe')); - $this->cg = new CompanyGateway; + $this->cg = new CompanyGateway(); $this->cg->company_id = $this->company->id; $this->cg->user_id = $this->user->id; $this->cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; diff --git a/tests/Feature/CompanyGatewayTest.php b/tests/Feature/CompanyGatewayTest.php index cefb2baeaf97..ba5f891acf99 100644 --- a/tests/Feature/CompanyGatewayTest.php +++ b/tests/Feature/CompanyGatewayTest.php @@ -30,7 +30,7 @@ class CompanyGatewayTest extends TestCase use DatabaseTransactions; // use RefreshDatabase; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -50,7 +50,7 @@ class CompanyGatewayTest extends TestCase public function testSetConfigFields() { $company_gateway = CompanyGateway::first(); - + $this->assertNotNull($company_gateway->getConfig()); $company_gateway->setConfigField('test', 'test'); @@ -80,7 +80,7 @@ class CompanyGatewayTest extends TestCase $data[1]['fee_cap'] = 0; $data[1]['is_enabled'] = true; - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $this->company->id; $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; @@ -152,7 +152,7 @@ class CompanyGatewayTest extends TestCase $data[1]['fee_cap'] = 0; $data[1]['is_enabled'] = true; - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $this->company->id; $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; @@ -191,7 +191,7 @@ class CompanyGatewayTest extends TestCase $data[1]['fee_cap'] = 0; $data[1]['is_enabled'] = true; - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $this->company->id; $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; @@ -237,7 +237,7 @@ class CompanyGatewayTest extends TestCase $data[1]['fee_cap'] = 0; $data[1]['is_enabled'] = true; - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $this->company->id; $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; @@ -285,7 +285,7 @@ class CompanyGatewayTest extends TestCase $data[1]['fee_cap'] = 0; $data[1]['is_enabled'] = true; - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $this->company->id; $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; diff --git a/tests/Feature/CompanySettingsTest.php b/tests/Feature/CompanySettingsTest.php index f2316e60b27b..255f5fb3d088 100644 --- a/tests/Feature/CompanySettingsTest.php +++ b/tests/Feature/CompanySettingsTest.php @@ -8,6 +8,7 @@ * * @license https://www.elastic.co/licensing/elastic-license */ + namespace Tests\Feature; use App\DataMapper\CompanySettings; @@ -31,7 +32,7 @@ class CompanySettingsTest extends TestCase use MockAccountData; // use RefreshDatabase; - public function setUp() :void + public function setUp(): void { parent::setUp(); @@ -81,7 +82,7 @@ class CompanySettingsTest extends TestCase $this->company->saveSettings($settings, $this->company); $response = false; - + try { $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 4814cc676c30..b6ca9508ec2f 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -37,7 +37,7 @@ class CompanyTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/CompanyTokenApiTest.php b/tests/Feature/CompanyTokenApiTest.php index bb31a1f9f9f1..66de08b0e224 100644 --- a/tests/Feature/CompanyTokenApiTest.php +++ b/tests/Feature/CompanyTokenApiTest.php @@ -31,7 +31,7 @@ class CompanyTokenApiTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/CreditTest.php b/tests/Feature/CreditTest.php index 40e4409e08f0..03164404818c 100644 --- a/tests/Feature/CreditTest.php +++ b/tests/Feature/CreditTest.php @@ -29,7 +29,7 @@ class CreditTest extends TestCase use MockAccountData; public $faker; - + protected function setUp(): void { parent::setUp(); @@ -83,7 +83,7 @@ class CreditTest extends TestCase $i->service()->markSent()->save(); $this->assertEquals(100, $i->balance); - + $i->service()->markPaid()->save(); $i = $i->fresh(); $c = $c->fresh(); @@ -92,11 +92,11 @@ class CreditTest extends TestCase $this->assertEquals(0, $c->balance); $this->assertEquals(100, $c->paid_to_date); - + $i->service()->handleReversal()->save(); - - - $data = $i->toArray(); + + + $data = $i->toArray(); $data['invoice_id'] = $i->hashed_id; $data['user_id'] = $this->encodePrimaryKey($i->user_id); $data['client_id'] = $this->encodePrimaryKey($i->client_id); @@ -122,7 +122,7 @@ class CreditTest extends TestCase $this->assertEquals(0, $i->balance); $this->assertEquals(100, $c->credit_balance); $this->assertEquals(0, $c->paid_to_date); - + $credit->service()->deleteCredit()->save(); $c = $c->fresh(); @@ -169,7 +169,7 @@ class CreditTest extends TestCase ], 'status_id' => 1, ]); - + $i->save(); $i->calc()->getInvoice(); @@ -193,7 +193,7 @@ class CreditTest extends TestCase 'status_id' => 1, ]); - + $cr->calc()->getCredit(); $cr->service()->markSent()->save(); @@ -253,10 +253,10 @@ class CreditTest extends TestCase $this->assertEquals(0, $c->balance); $p = \App\Models\Payment::find($this->decodePrimaryKey($p_id)); - + $this->assertEquals(0, $p->amount); $this->assertEquals(0, $p->applied); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -281,7 +281,7 @@ class CreditTest extends TestCase $this->assertEquals(100, $c->balance); $this->assertEquals(0, $c->paid_to_date); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -291,7 +291,7 @@ class CreditTest extends TestCase $cr = $cr->fresh(); - $this->assertEquals(true, $cr->is_deleted); + $this->assertEquals(true, $cr->is_deleted); $this->assertEquals(100, $c->balance); $this->assertEquals(0, $c->paid_to_date); @@ -384,7 +384,7 @@ class CreditTest extends TestCase $response->assertStatus(200); $arr = $response->json(); $this->assertCount(1, $arr['data']); - + $c->status_id = Credit::STATUS_APPLIED; $c->amount = 20; $c->balance = 20; diff --git a/tests/Feature/DeleteInvoiceTest.php b/tests/Feature/DeleteInvoiceTest.php index 7828aa827dd7..deae43cb0cf2 100644 --- a/tests/Feature/DeleteInvoiceTest.php +++ b/tests/Feature/DeleteInvoiceTest.php @@ -31,7 +31,7 @@ class DeleteInvoiceTest extends TestCase use MockAccountData; use MakesHash; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/DesignApiTest.php b/tests/Feature/DesignApiTest.php index 06bbc8e04a6c..1fc71867c5d7 100644 --- a/tests/Feature/DesignApiTest.php +++ b/tests/Feature/DesignApiTest.php @@ -34,7 +34,7 @@ class DesignApiTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -62,7 +62,7 @@ class DesignApiTest extends TestCase ->where('is_template', true) ->where('company_id', $this->company->id) ->whereRaw('FIND_IN_SET( ? ,entities)', [$searchable]); - + $this->assertEquals(1, $q->count()); $response = $this->withHeaders([ @@ -105,7 +105,7 @@ class DesignApiTest extends TestCase $q = Design::query() ->where('is_template', true) ->whereRaw('FIND_IN_SET( ? ,entities)', [$searchable]); - + $this->assertEquals(0, $q->count()); $design = DesignFactory::create($this->company->id, $this->user->id); @@ -119,7 +119,7 @@ class DesignApiTest extends TestCase $q = Design::query() ->where('is_template', true) ->whereRaw('FIND_IN_SET( ? ,entities)', [$searchable]); - + $this->assertEquals(0, $q->count()); @@ -132,7 +132,7 @@ class DesignApiTest extends TestCase $design->is_template = true; $design->name = 'Test Template'; $design->save(); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -141,7 +141,7 @@ class DesignApiTest extends TestCase $response->assertStatus(200); $arr = $response->json(); - + $this->assertCount(1, $arr['data']); } @@ -151,7 +151,7 @@ class DesignApiTest extends TestCase $design->is_template = true; $design->name = 'Test Template'; $design->save(); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -160,7 +160,7 @@ class DesignApiTest extends TestCase $response->assertStatus(200); $arr = $response->json(); - + $this->assertCount(11, $arr['data']); $response = $this->withHeaders([ @@ -171,7 +171,7 @@ class DesignApiTest extends TestCase $response->assertStatus(200); $arr = $response->json(); - + $this->assertCount(12, $arr['data']); diff --git a/tests/Feature/DocumentsApiTest.php b/tests/Feature/DocumentsApiTest.php index 4537019e37ae..e5fedcc35bbc 100644 --- a/tests/Feature/DocumentsApiTest.php +++ b/tests/Feature/DocumentsApiTest.php @@ -32,7 +32,7 @@ class DocumentsApiTest extends TestCase protected $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -47,7 +47,7 @@ class DocumentsApiTest extends TestCase public function testDocumentFilters() { - Document::query()->withTrashed()->cursor()->each(function ($d){ + Document::query()->withTrashed()->cursor()->each(function ($d) { $d->forceDelete(); }); @@ -73,7 +73,7 @@ class DocumentsApiTest extends TestCase public function testDocumentFilters2() { - Document::query()->withTrashed()->cursor()->each(function ($d){ + Document::query()->withTrashed()->cursor()->each(function ($d) { $d->forceDelete(); }); @@ -98,7 +98,7 @@ class DocumentsApiTest extends TestCase public function testDocumentFilters3() { - Document::query()->withTrashed()->cursor()->each(function ($d){ + Document::query()->withTrashed()->cursor()->each(function ($d) { $d->forceDelete(); }); @@ -114,9 +114,9 @@ class DocumentsApiTest extends TestCase 'user_id' => $this->user->id, 'client_id' => $this->client->id, ]); - + $t->documents()->save($d); - + $dd = Document::factory()->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, @@ -141,7 +141,7 @@ class DocumentsApiTest extends TestCase ])->get("/api/v1/documents?client_id={$this->client->hashed_id}&filter=craycray"); $response->assertStatus(200); - + $this->assertCount(0, $response->json()['data']); $response = $this->withHeaders([ diff --git a/tests/Feature/EInvoice/FacturaeTest.php b/tests/Feature/EInvoice/FacturaeTest.php index 33fd81d67eaf..d1752aeff074 100644 --- a/tests/Feature/EInvoice/FacturaeTest.php +++ b/tests/Feature/EInvoice/FacturaeTest.php @@ -24,7 +24,7 @@ class FacturaeTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/EInvoice/FatturaPATest.php b/tests/Feature/EInvoice/FatturaPATest.php index 0fc34a2e52d3..bb9b0e6c983c 100644 --- a/tests/Feature/EInvoice/FatturaPATest.php +++ b/tests/Feature/EInvoice/FatturaPATest.php @@ -42,7 +42,7 @@ class FatturaPATest extends TestCase $this->makeTestData(); - + // $this->markTestSkipped('prevent running in CI'); $this->withoutMiddleware( @@ -60,20 +60,20 @@ class FatturaPATest extends TestCase $settings->state = 'PA'; // $settings->state = 'Perugia'; - $settings->postal_code = '61030'; + $settings->postal_code = '61030'; $settings->country_id = '380'; $settings->currency_id = '3'; $settings->vat_number = '01234567890'; $settings->id_number = ''; - $company = Company::factory()->create([ + $company = Company::factory()->create([ 'account_id' => $this->account->id, 'settings' => $settings, ]); $client_settings = ClientSettings::defaults(); $client_settings->currency_id = '3'; - + $client = Client::factory()->create([ 'company_id' => $company->id, 'user_id' => $this->user->id, @@ -88,14 +88,14 @@ class FatturaPATest extends TestCase 'settings' => $client_settings, ]); - $item = new InvoiceItem; + $item = new InvoiceItem(); $item->product_key = "Product Key"; $item->notes = "Product Description"; $item->cost = 10; $item->quantity = 10; $item->tax_rate1 = 22; $item->tax_name1 = 'IVA'; - + $invoice = Invoice::factory()->create([ 'company_id' => $company->id, 'user_id' => $this->user->id, @@ -110,7 +110,7 @@ class FatturaPATest extends TestCase 'tax_name2' => '', 'tax_name3' => '', 'line_items' => [$item], - 'number' => 'ITA-'.rand(1000,100000) + 'number' => 'ITA-'.rand(1000, 100000) ]); $invoice->service()->markSent()->save(); @@ -126,11 +126,12 @@ class FatturaPATest extends TestCase $this->assertInstanceOf(FatturaElettronicaBody::class, $fe->FatturaElettronicaBody[0]); $this->assertInstanceOf(FatturaElettronicaHeader::class, $fe->FatturaElettronicaHeader); - $e = new EInvoice; + $e = new EInvoice(); $errors = $e->validate($fe); - if(count($errors) > 0) + if(count($errors) > 0) { nlog($errors); + } $this->assertCount(0, $errors); diff --git a/tests/Feature/EInvoice/PeppolTest.php b/tests/Feature/EInvoice/PeppolTest.php index 1da831158519..060116bbd386 100644 --- a/tests/Feature/EInvoice/PeppolTest.php +++ b/tests/Feature/EInvoice/PeppolTest.php @@ -60,7 +60,7 @@ class PeppolTest extends TestCase $settings = CompanySettings::defaults(); $settings->address1 = 'Dudweilerstr. 34b'; - $settings->city = 'Ost Alessa'; + $settings->city = 'Ost Alessa'; $settings->state = 'Bayern'; $settings->postal_code = '98060'; $settings->vat_number = 'DE923356489'; @@ -68,11 +68,11 @@ class PeppolTest extends TestCase $settings->currency_id = '3'; $einvoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice(); - + $fib = new FinancialInstitutionBranch(); $fib->ID = "DEUTDEMMXXX"; //BIC $fib->Name = 'Deutsche Bank'; - + $pfa = new PayeeFinancialAccount(); $pfa->ID = 'DE89370400440532013000'; $pfa->Name = 'PFA-NAME'; @@ -83,10 +83,10 @@ class PeppolTest extends TestCase $pfa->FinancialInstitutionBranch = $fib; $pm = new PaymentMeans(); - $pm->PayeeFinancialAccount = $pfa; + $pm->PayeeFinancialAccount = $pfa; $einvoice->PaymentMeans[] = $pm; - $stub = new \stdClass; + $stub = new \stdClass(); $stub->Invoice = $einvoice; $company = Company::factory()->create([ @@ -94,7 +94,7 @@ class PeppolTest extends TestCase 'settings' => $settings, 'e_invoice' => $stub, ]); - + $cu = CompanyUserFactory::create($this->user->id, $company->id, $this->account->id); $cu->is_owner = true; $cu->is_admin = true; @@ -118,7 +118,7 @@ class PeppolTest extends TestCase 'settings' => $client_settings, ]); - + $item = new InvoiceItem(); $item->product_key = "Product Key"; $item->notes = "Product Description"; @@ -181,7 +181,7 @@ class PeppolTest extends TestCase $settings = CompanySettings::defaults(); $settings->address1 = 'Dudweilerstr. 34b'; - $settings->city = 'Ost Alessa'; + $settings->city = 'Ost Alessa'; $settings->state = 'Bayern'; $settings->postal_code = '98060'; $settings->vat_number = 'DE923356489'; @@ -189,11 +189,11 @@ class PeppolTest extends TestCase $settings->currency_id = '3'; $einvoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice(); - + $fib = new FinancialInstitutionBranch(); $fib->ID = "DEUTDEMMXXX"; //BIC $fib->Name = 'Deutsche Bank'; - + $pfa = new PayeeFinancialAccount(); $pfa->ID = 'DE89370400440532013000'; $pfa->Name = 'PFA-NAME'; @@ -204,10 +204,10 @@ class PeppolTest extends TestCase $pfa->FinancialInstitutionBranch = $fib; $pm = new PaymentMeans(); - $pm->PayeeFinancialAccount = $pfa; + $pm->PayeeFinancialAccount = $pfa; $einvoice->PaymentMeans[] = $pm; - + $stub = new \stdClass(); $stub->Invoice = $einvoice; @@ -240,7 +240,7 @@ class PeppolTest extends TestCase 'settings' => $client_settings, ]); - + $item = new InvoiceItem(); $item->product_key = "Product Key"; $item->notes = "Product Description"; @@ -315,7 +315,7 @@ class PeppolTest extends TestCase 'account_id' => $this->account->id, 'settings' => $settings, ]); - + $cu = CompanyUserFactory::create($this->user->id, $company->id, $this->account->id); $cu->is_owner = true; @@ -384,7 +384,7 @@ class PeppolTest extends TestCase $json = $e->encode($fe, 'json'); $this->assertNotNull($json); - + $decode = $e->decode('Peppol', $json, 'json'); $this->assertInstanceOf(\InvoiceNinja\EInvoice\Models\Peppol\Invoice::class, $decode); diff --git a/tests/Feature/EntityPaidToDateTest.php b/tests/Feature/EntityPaidToDateTest.php index 912617e6c787..0c34440db6ad 100644 --- a/tests/Feature/EntityPaidToDateTest.php +++ b/tests/Feature/EntityPaidToDateTest.php @@ -31,7 +31,7 @@ class EntityPaidToDateTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/ExpenseApiTest.php b/tests/Feature/ExpenseApiTest.php index e6319f092847..ccaa75fcbd59 100644 --- a/tests/Feature/ExpenseApiTest.php +++ b/tests/Feature/ExpenseApiTest.php @@ -33,8 +33,8 @@ class ExpenseApiTest extends TestCase use MockAccountData; public $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); @@ -78,7 +78,7 @@ class ExpenseApiTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->putJson('/api/v1/expenses/'.$arr['data']['id'], $data); - + $arr = $response->json(); $response->assertStatus(200); @@ -89,8 +89,8 @@ class ExpenseApiTest extends TestCase public function testExpensePutWithVendorStatus() { - - + + $data = [ 'vendor_id' => $this->vendor->hashed_id, @@ -105,7 +105,7 @@ class ExpenseApiTest extends TestCase $arr = $response->json(); $response->assertStatus(200); - + $this->assertEquals($this->vendor->hashed_id, $arr['data']['vendor_id']); @@ -144,7 +144,7 @@ class ExpenseApiTest extends TestCase 'user_id' => $this->user->id, 'transaction_id' => $bt->id, ]); - + $this->assertNotNull($e->transaction_id); $expense_repo = app('App\Repositories\ExpenseRepository'); @@ -343,7 +343,7 @@ class ExpenseApiTest extends TestCase ])->post('/api/v1/expenses/bulk', $data); $arr = $response->json(); - + $this->assertEquals($ec->hashed_id, $arr['data'][0]['category_id']); $response = $this->withHeaders([ diff --git a/tests/Feature/ExpenseCategoryApiTest.php b/tests/Feature/ExpenseCategoryApiTest.php index 4a8d4f63ece2..97f18e3a6c0e 100644 --- a/tests/Feature/ExpenseCategoryApiTest.php +++ b/tests/Feature/ExpenseCategoryApiTest.php @@ -28,7 +28,7 @@ class ExpenseCategoryApiTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ArDetailReportTest.php b/tests/Feature/Export/ArDetailReportTest.php index eadc71efd349..cd8c4368bb30 100644 --- a/tests/Feature/Export/ArDetailReportTest.php +++ b/tests/Feature/Export/ArDetailReportTest.php @@ -34,7 +34,7 @@ class ArDetailReportTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ArSummaryReportTest.php b/tests/Feature/Export/ArSummaryReportTest.php index 874ecc6a6f01..367138e00482 100644 --- a/tests/Feature/Export/ArSummaryReportTest.php +++ b/tests/Feature/Export/ArSummaryReportTest.php @@ -32,7 +32,7 @@ class ArSummaryReportTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ClientBalanceReportTest.php b/tests/Feature/Export/ClientBalanceReportTest.php index 9e995147f4f8..5604d3b4e52d 100644 --- a/tests/Feature/Export/ClientBalanceReportTest.php +++ b/tests/Feature/Export/ClientBalanceReportTest.php @@ -32,7 +32,7 @@ class ClientBalanceReportTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ClientCsvTest.php b/tests/Feature/Export/ClientCsvTest.php index 5361b946b532..dc5a3f834d6e 100644 --- a/tests/Feature/Export/ClientCsvTest.php +++ b/tests/Feature/Export/ClientCsvTest.php @@ -24,7 +24,7 @@ class ClientCsvTest extends TestCase use MakesHash; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ClientSalesReportTest.php b/tests/Feature/Export/ClientSalesReportTest.php index 98820c7bce9d..6acb55403dc2 100644 --- a/tests/Feature/Export/ClientSalesReportTest.php +++ b/tests/Feature/Export/ClientSalesReportTest.php @@ -32,7 +32,7 @@ class ClientSalesReportTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ExportCsvTest.php b/tests/Feature/Export/ExportCsvTest.php index ef2c268fd7d6..d23402b1f0d5 100644 --- a/tests/Feature/Export/ExportCsvTest.php +++ b/tests/Feature/Export/ExportCsvTest.php @@ -27,7 +27,7 @@ class ExportCsvTest extends TestCase use MakesHash; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ProductSalesReportTest.php b/tests/Feature/Export/ProductSalesReportTest.php index 8e86dd4c8f72..85df92bc534c 100644 --- a/tests/Feature/Export/ProductSalesReportTest.php +++ b/tests/Feature/Export/ProductSalesReportTest.php @@ -36,7 +36,7 @@ class ProductSalesReportTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ProfitAndLossReportTest.php b/tests/Feature/Export/ProfitAndLossReportTest.php index 56d634e1beb4..968737569a72 100644 --- a/tests/Feature/Export/ProfitAndLossReportTest.php +++ b/tests/Feature/Export/ProfitAndLossReportTest.php @@ -37,7 +37,7 @@ class ProfitAndLossReportTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ReportApiTest.php b/tests/Feature/Export/ReportApiTest.php index 9e021bcc8461..9715b91e1ad8 100644 --- a/tests/Feature/Export/ReportApiTest.php +++ b/tests/Feature/Export/ReportApiTest.php @@ -23,10 +23,10 @@ class ReportApiTest extends TestCase { use MakesHash; use MockAccountData; - + public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/ReportCsvGenerationTest.php b/tests/Feature/Export/ReportCsvGenerationTest.php index 315e9b6fa86c..000a80e80fa8 100644 --- a/tests/Feature/Export/ReportCsvGenerationTest.php +++ b/tests/Feature/Export/ReportCsvGenerationTest.php @@ -42,7 +42,7 @@ class ReportCsvGenerationTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -53,7 +53,7 @@ class ReportCsvGenerationTest extends TestCase ); $this->withoutExceptionHandling(); - + Invoice::withTrashed()->cursor()->each(function ($i) { $i->forceDelete();}); $this->buildData(); @@ -225,7 +225,7 @@ class ReportCsvGenerationTest extends TestCase $this->token = \Illuminate\Support\Str::random(64); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $this->user->id; $company_token->company_id = $this->company->id; $company_token->account_id = $this->account->id; @@ -270,12 +270,12 @@ class ReportCsvGenerationTest extends TestCase { Invoice::factory()->count(5)->create( [ - 'client_id'=> $this->client->id, + 'client_id' => $this->client->id, 'company_id' => $this->company->id, 'user_id' => $this->user->id ] ); - + $data = [ 'date_range' => 'all', 'report_keys' => ['invoice.number','client.name', 'contact.email'], @@ -308,7 +308,7 @@ class ReportCsvGenerationTest extends TestCase $report_keys = ['invoice.number','client.name', 'invoice.amount']; $array = array_merge($report_keys, array_diff($forced, $report_keys)); - + $this->assertEquals('client.name', $array[1]); $report_keys = ['invoice.number','invoice.amount']; @@ -325,7 +325,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post(config('ninja.app_url')."/api/v1/exports/preview/{$hash}"); - + return $response; } @@ -372,7 +372,7 @@ class ReportCsvGenerationTest extends TestCase $item->product_key = 'batman'; $line_items = []; - + $line_items[] = $item; $item = InvoiceItemFactory::create(); $item->product_key = 'bob the builder'; @@ -395,7 +395,7 @@ class ReportCsvGenerationTest extends TestCase $q->orWhereJsonContains('line_items', ['product_key' => $product]); } }); - + $this->assertEquals(1, $query->count()); $query = Invoice::query(); @@ -433,9 +433,9 @@ class ReportCsvGenerationTest extends TestCase ); $this->assertEquals(1, $q->count()); - + $q->forceDelete(); - + Invoice::factory()->create( [ 'company_id' => $this->company->id, @@ -480,7 +480,7 @@ class ReportCsvGenerationTest extends TestCase public function testVendorCsvGeneration() { - + $vendor = \App\Models\Vendor::factory()->create( [ @@ -509,7 +509,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/vendors', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -517,7 +517,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); $this->assertEquals('Vendor 1', $this->getFirstValueByColumn($csv, 'Vendor Name')); @@ -545,7 +545,7 @@ class ReportCsvGenerationTest extends TestCase $data = $export->returnJson(); $this->assertNotNull($data); - + $this->assertEquals('Vendor Name', $this->traverseJson($data, 'columns.9.display_value')); $this->assertEquals('vendor', $this->traverseJson($data, '0.0.entity')); $this->assertEquals('address1', $this->traverseJson($data, '0.0.id')); @@ -557,7 +557,7 @@ class ReportCsvGenerationTest extends TestCase public function testVendorCustomColumnCsvGeneration() { - + \App\Models\Vendor::query()->cursor()->each(function ($t) { $t->forceDelete(); }); @@ -591,7 +591,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/vendors', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -599,7 +599,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -683,7 +683,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/tasks', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -691,10 +691,10 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); -// nlog($csv); + // nlog($csv); $this->assertEquals(3600, $this->getFirstValueByColumn($csv, 'Task Duration')); $this->assertEquals('test1', $this->getFirstValueByColumn($csv, 'Task Description')); $this->assertEquals('16/Jul/2023', $this->getFirstValueByColumn($csv, 'Task Start Date')); @@ -752,7 +752,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -789,7 +789,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/tasks', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -797,7 +797,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); $this->assertEquals(3600, $this->getFirstValueByColumn($csv, 'Task Duration')); @@ -838,7 +838,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/products', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -846,7 +846,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -920,7 +920,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/payments', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -928,7 +928,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); // nlog($csv); @@ -940,7 +940,7 @@ class ReportCsvGenerationTest extends TestCase $this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name')); $this->assertEquals(0, $this->getFirstValueByColumn($csv, 'Client Balance')); $this->assertEquals(100, $this->getFirstValueByColumn($csv, 'Client Paid to Date')); - + $export = new PaymentExport($this->company, $data); $data = $export->returnJson(); @@ -975,7 +975,7 @@ class ReportCsvGenerationTest extends TestCase ])->post('/api/v1/reports/payments', $data)->assertStatus(200); - + $data = [ 'date_range' => 'all', 'report_keys' => array_merge(["payment.amount","payment.date"], $this->all_invoice_report_keys), @@ -994,7 +994,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -1023,7 +1023,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/payments', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1031,7 +1031,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -1040,7 +1040,7 @@ class ReportCsvGenerationTest extends TestCase $this->assertEquals(0, $this->getFirstValueByColumn($csv, 'Payment Refunded')); $this->assertEquals('2020-01-01', $this->getFirstValueByColumn($csv, 'Payment Date')); $this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Payment Transaction Reference')); - + } @@ -1057,7 +1057,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/clients', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1065,12 +1065,12 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); $reader = Reader::createFromString($csv); $reader->setHeaderOffset(0); - + $res = $reader->fetchColumnByName('Street'); $res = iterator_to_array($res, true); @@ -1096,7 +1096,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/clients', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1104,7 +1104,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -1163,7 +1163,7 @@ class ReportCsvGenerationTest extends TestCase public function testCreditCustomColumnsCsvGeneration() { - + Credit::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -1189,7 +1189,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/credits', $data); - + $response->assertStatus(200); $arr = $response->json(); $hash = $arr['message']; @@ -1221,7 +1221,7 @@ class ReportCsvGenerationTest extends TestCase public function testInvoiceCustomColumnsCsvGeneration() { - + \App\Models\Invoice::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -1247,7 +1247,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/invoices', $data); - + $response->assertStatus(200); $arr = $response->json(); $hash = $arr['message']; @@ -1282,10 +1282,10 @@ class ReportCsvGenerationTest extends TestCase ])->post('/api/v1/reports/invoices', $data)->assertStatus(200); } - + public function testRecurringInvoiceCustomColumnsCsvGeneration() { - + \App\Models\RecurringInvoice::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -1312,7 +1312,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/recurring_invoices', $data); - + $response->assertStatus(200); $arr = $response->json(); $hash = $arr['message']; @@ -1340,7 +1340,7 @@ class ReportCsvGenerationTest extends TestCase public function testRecurringInvoiceColumnsCsvGeneration() { - + \App\Models\RecurringInvoice::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -1367,7 +1367,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/recurring_invoices', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1375,7 +1375,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); $this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Recurring Invoice Invoice Number')); @@ -1387,7 +1387,7 @@ class ReportCsvGenerationTest extends TestCase public function testInvoiceItemsCustomColumnsCsvGeneration() { - + \App\Models\Invoice::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -1431,7 +1431,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/invoice_items', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1495,7 +1495,7 @@ class ReportCsvGenerationTest extends TestCase public function testQuoteItemsCustomColumnsCsvGeneration() { - + $q = \App\Models\Quote::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -1539,7 +1539,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/quote_items', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1547,7 +1547,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -1625,7 +1625,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); $this->assertEquals('100', $this->getFirstValueByColumn($csv, 'Purchase Order Amount')); @@ -1640,7 +1640,7 @@ class ReportCsvGenerationTest extends TestCase public function testPurchaseOrderItemsCustomColumnsCsvGeneration() { - + $vendor = \App\Models\Vendor::factory()->create( [ @@ -1695,7 +1695,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/purchase_order_items', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1703,7 +1703,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -1723,7 +1723,7 @@ class ReportCsvGenerationTest extends TestCase public function testQuoteCustomColumnsCsvGeneration() { - + \App\Models\Quote::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -1749,7 +1749,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/quotes', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1757,7 +1757,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -1813,7 +1813,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/invoices', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1821,7 +1821,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); $this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name')); @@ -1844,7 +1844,7 @@ class ReportCsvGenerationTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/reports/contacts', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -1852,13 +1852,13 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); $reader = Reader::createFromString($csv); $reader->setHeaderOffset(0); - + $res = $reader->fetchColumnByName('Contact First Name'); $res = iterator_to_array($res, true); @@ -1887,7 +1887,7 @@ class ReportCsvGenerationTest extends TestCase { $reader = Reader::createFromString($csv); $reader->setHeaderOffset(0); - + $res = $reader->fetchColumnByName($column); $res = iterator_to_array($res, true); @@ -1931,7 +1931,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -2025,7 +2025,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -2107,7 +2107,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); @@ -2190,7 +2190,7 @@ class ReportCsvGenerationTest extends TestCase $hash = $arr['message']; $response = $this->poll($hash); - + $csv = $response->body(); $this->assertEquals('100', $this->getFirstValueByColumn($csv, 'Quote Amount')); @@ -2251,7 +2251,7 @@ class ReportCsvGenerationTest extends TestCase $this->assertEquals('Public', $this->getFirstValueByColumn($csv, 'Expense Public Notes')); $this->assertEquals('Private', $this->getFirstValueByColumn($csv, 'Expense Private Notes')); $this->assertEquals($this->user->present()->name(), $this->getFirstValueByColumn($csv, 'Expense User')); - + $data = [ 'date_range' => 'all', 'report_keys' => $this->all_client_report_keys, @@ -2314,7 +2314,7 @@ class ReportCsvGenerationTest extends TestCase $this->assertEquals('Vendor 1', $this->getFirstValueByColumn($csv, 'Vendor Name')); $this->assertEquals('100', $this->getFirstValueByColumn($csv, 'Expense Amount')); $this->assertEquals('USD', $this->getFirstValueByColumn($csv, 'Expense Currency')); - + } diff --git a/tests/Feature/Export/ReportPreviewTest.php b/tests/Feature/Export/ReportPreviewTest.php index 0b858f039a76..336c9a739157 100644 --- a/tests/Feature/Export/ReportPreviewTest.php +++ b/tests/Feature/Export/ReportPreviewTest.php @@ -65,7 +65,7 @@ class ReportPreviewTest extends TestCase 'company_id' => $this->company->id, 'user_id' => $this->user->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -97,7 +97,7 @@ class ReportPreviewTest extends TestCase 'user_id' => $this->user->id, 'client_id' => $this->client->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -129,7 +129,7 @@ class ReportPreviewTest extends TestCase 'user_id' => $this->user->id, 'vendor_id' => $this->vendor->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -150,7 +150,7 @@ class ReportPreviewTest extends TestCase $r = Cache::pull('123'); $this->assertNotNull($r); - + //nlog($r); } @@ -162,7 +162,7 @@ class ReportPreviewTest extends TestCase 'user_id' => $this->user->id, 'client_id' => $this->client->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -183,7 +183,7 @@ class ReportPreviewTest extends TestCase $r = Cache::pull('123'); $this->assertNotNull($r); - + //nlog($r); } @@ -196,7 +196,7 @@ class ReportPreviewTest extends TestCase 'user_id' => $this->user->id, 'client_id' => $this->client->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -217,7 +217,7 @@ class ReportPreviewTest extends TestCase $r = Cache::pull('123'); $this->assertNotNull($r); - + //nlog($r); } @@ -231,7 +231,7 @@ class ReportPreviewTest extends TestCase 'user_id' => $this->user->id, 'vendor_id' => $this->vendor->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -262,7 +262,7 @@ class ReportPreviewTest extends TestCase 'user_id' => $this->user->id, 'client_id' => $this->client->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -293,7 +293,7 @@ class ReportPreviewTest extends TestCase 'user_id' => $this->user->id, 'client_id' => $this->client->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -323,7 +323,7 @@ class ReportPreviewTest extends TestCase 'company_id' => $this->company->id, 'user_id' => $this->user->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -355,7 +355,7 @@ class ReportPreviewTest extends TestCase 'documentable_type' => Client::class, 'documentable_id' => $this->client->id, ]); - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -476,7 +476,7 @@ class ReportPreviewTest extends TestCase public function testCreditExportPreview() { - + $data = [ 'send_email' => false, 'date_range' => 'all', @@ -491,7 +491,7 @@ class ReportPreviewTest extends TestCase $r = Cache::pull('123'); $this->assertNotNull($r); - + } public function testCreditPreview() @@ -509,6 +509,6 @@ class ReportPreviewTest extends TestCase ])->postJson('/api/v1/reports/credits?output=json', $data) ->assertStatus(200); - + } } diff --git a/tests/Feature/Export/TaxSummaryReportTest.php b/tests/Feature/Export/TaxSummaryReportTest.php index 9d60f3022aaa..5ea14d8762b4 100644 --- a/tests/Feature/Export/TaxSummaryReportTest.php +++ b/tests/Feature/Export/TaxSummaryReportTest.php @@ -32,7 +32,7 @@ class TaxSummaryReportTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Export/UserSalesReportTest.php b/tests/Feature/Export/UserSalesReportTest.php index 76253abac29a..a5bf0d6e12db 100644 --- a/tests/Feature/Export/UserSalesReportTest.php +++ b/tests/Feature/Export/UserSalesReportTest.php @@ -34,7 +34,7 @@ class UserSalesReportTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/FilterApiTest.php b/tests/Feature/FilterApiTest.php index ee350234d84e..98222f3604ae 100644 --- a/tests/Feature/FilterApiTest.php +++ b/tests/Feature/FilterApiTest.php @@ -25,7 +25,7 @@ class FilterApiTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/GoCardlessInstantBankPaymentTest.php b/tests/Feature/GoCardlessInstantBankPaymentTest.php index 96383eaaec6e..db1b68ecfd61 100644 --- a/tests/Feature/GoCardlessInstantBankPaymentTest.php +++ b/tests/Feature/GoCardlessInstantBankPaymentTest.php @@ -97,7 +97,7 @@ class GoCardlessInstantBankPaymentTest extends TestCase ]; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -125,8 +125,8 @@ class GoCardlessInstantBankPaymentTest extends TestCase public function testInvoiceDelayedNotificationPayment() { - $gocardlesspayment = new \stdClass; - $links = new \stdClass; + $gocardlesspayment = new \stdClass(); + $links = new \stdClass(); $links->mandate = "my_mandate"; $gocardlesspayment->links = $links; $gocardlesspayment->id = "gocardless_payment_id"; @@ -172,7 +172,7 @@ class GoCardlessInstantBankPaymentTest extends TestCase $this->assertEquals($invoice->balance, $test_invoice_object->amount); - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $this->company->id; $cg->user_id = $this->user->id; $cg->gateway_key = 'b9886f9257f0c6ee7c302f1c74475f6c'; diff --git a/tests/Feature/GroupSettingTest.php b/tests/Feature/GroupSettingTest.php index fb03abcc2984..0a0f2e8c4aa8 100644 --- a/tests/Feature/GroupSettingTest.php +++ b/tests/Feature/GroupSettingTest.php @@ -41,7 +41,7 @@ class GroupSettingTest extends TestCase public function testCastingMagic() { - $settings = new \stdClass; + $settings = new \stdClass(); $settings->currency_id = '1'; $settings->tax_name1 = ''; $settings->tax_rate1 = 0; @@ -51,7 +51,7 @@ class GroupSettingTest extends TestCase $this->assertEquals("", $settings->tax_name1); $settings = null; - $settings = new \stdClass; + $settings = new \stdClass(); $settings->currency_id = '1'; $settings->tax_name1 = "1"; $settings->tax_rate1 = 0; @@ -63,7 +63,7 @@ class GroupSettingTest extends TestCase $settings = $s->cast($settings)->toArray(); $this->assertEquals("1", $settings['tax_name1']); - $settings = new \stdClass; + $settings = new \stdClass(); $settings->currency_id = '1'; $settings->tax_name1 = []; $settings->tax_rate1 = 0; @@ -75,9 +75,9 @@ class GroupSettingTest extends TestCase $settings = $s->cast($settings)->toArray(); $this->assertEquals("", $settings['tax_name1']); - $settings = new \stdClass; + $settings = new \stdClass(); $settings->currency_id = '1'; - $settings->tax_name1 = new \stdClass; + $settings->tax_name1 = new \stdClass(); $settings->tax_rate1 = 0; $settings = $s->cast($settings)->toObject(); @@ -94,7 +94,7 @@ class GroupSettingTest extends TestCase public function testTaxNameInGroupFilters() { - $settings = new \stdClass; + $settings = new \stdClass(); $settings->currency_id = '1'; $settings->tax_name1 = ''; $settings->tax_rate1 = 0; @@ -110,17 +110,17 @@ class GroupSettingTest extends TestCase ])->postJson('/api/v1/group_settings', $data); $response->assertStatus(200); - + $arr = $response->json(); $this->assertEquals("", (string)null); $this->assertNotNull($arr['data']['settings']['tax_name1']); } - + public function testAddGroupFilters() { - $settings = new \stdClass; + $settings = new \stdClass(); $settings->currency_id = '1'; $data = [ @@ -156,7 +156,7 @@ class GroupSettingTest extends TestCase public function testAddGroupSettings() { - $settings = new \stdClass; + $settings = new \stdClass(); $settings->currency_id = '1'; $data = [ @@ -179,7 +179,7 @@ class GroupSettingTest extends TestCase public function testArchiveGroupSettings() { - $settings = new \stdClass; + $settings = new \stdClass(); $settings->currency_id = '1'; $data = [ diff --git a/tests/Feature/Http/Controllers/ImportQuickbooksControllerTest.php b/tests/Feature/Http/Controllers/ImportQuickbooksControllerTest.php index 45403b124be5..aeaf01aa12a1 100644 --- a/tests/Feature/Http/Controllers/ImportQuickbooksControllerTest.php +++ b/tests/Feature/Http/Controllers/ImportQuickbooksControllerTest.php @@ -27,11 +27,12 @@ class ImportQuickbooksControllerTest extends TestCase private $mock; private $state; - - protected function setUp(): void { + + protected function setUp(): void + { parent::setUp(); - + $this->markTestSkipped("no bueno"); $this->state = Str::random(4); @@ -45,7 +46,7 @@ class ImportQuickbooksControllerTest extends TestCase public function testAuthorize(): void { - + $this->mock->shouldReceive('getState')->andReturn($this->state); $this->mock->shouldReceive('getAuthorizationCodeURL')->andReturn('https://example.com'); $this->mock->shouldReceive("getOAuth2LoginHelper")->andReturn($this->mock); @@ -53,7 +54,7 @@ class ImportQuickbooksControllerTest extends TestCase Cache::spy(); Cache::shouldReceive('get') ->with($token = $this->company->company_key) - ->andReturn( ['company_key' => $token, 'id' => $this->company->id]); + ->andReturn(['company_key' => $token, 'id' => $this->company->id]); Cache::shouldReceive('has') ->andReturn(true); // Perform the test @@ -67,7 +68,7 @@ class ImportQuickbooksControllerTest extends TestCase { $token = ['company_key' => $this->company->company_key, 'id' => $this->company->id] ; - $this->mock->shouldReceive('getAccessToken')->andReturn(Mockery::mock(stdClass::class,function(MockInterface $mock){ + $this->mock->shouldReceive('getAccessToken')->andReturn(Mockery::mock(stdClass::class, function (MockInterface $mock) { $mock->shouldReceive('getAccessToken')->andReturn('abcdefg'); $mock->shouldReceive('getRefreshToken')->andReturn('abcdefghi'); $mock->shouldReceive('getAccessTokenExpiresAt')->andReturn(3600); @@ -75,7 +76,7 @@ class ImportQuickbooksControllerTest extends TestCase })); $this->mock->shouldReceive("getOAuth2LoginHelper")->andReturn($this->mock); $this->mock->shouldReceive('exchangeAuthorizationCodeForToken')->once(); - + Cache::spy(); Cache::shouldReceive('has') ->andReturn(true); @@ -87,29 +88,29 @@ class ImportQuickbooksControllerTest extends TestCase Cache::shouldHaveReceived('put')->once()->with($token['company_key'], 'abcdefg', 3600); - $this->mock->shouldHaveReceived('exchangeAuthorizationCodeForToken')->once()->with(123456,12345678); + $this->mock->shouldHaveReceived('exchangeAuthorizationCodeForToken')->once()->with(123456, 12345678); } public function testImport(): void { - // Cache::spy(); + // Cache::spy(); //Bus::fake(); $data = $this->setUpTestData('customers'); $count = count($data); $this->mock->shouldReceive('Query')->andReturnUsing( - function($val, $s = 1, $max = 1000) use ($count, $data) { - if(stristr($val, 'count')) { - return $count; - } - - return Arr::take($data,$max); + function ($val, $s = 1, $max = 1000) use ($count, $data) { + if(stristr($val, 'count')) { + return $count; } - ); - + + return Arr::take($data, $max); + } + ); + // Perform the test $response = $this->actingAs($this->user)->withHeaders([ 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/import/quickbooks',[ + ])->post('/api/v1/import/quickbooks', [ 'import_types' => ['client'] ]); $response->assertStatus(200); @@ -118,11 +119,13 @@ class ImportQuickbooksControllerTest extends TestCase //Bus::assertDispatched(\App\Jobs\Import\QuickbooksIngest::class); } - protected function setUpTestData($file) { + protected function setUpTestData($file) + { $data = json_decode( - file_get_contents(base_path("tests/Mock/Quickbooks/Data/$file.json")),true + file_get_contents(base_path("tests/Mock/Quickbooks/Data/$file.json")), + true ); - + return $data; } } diff --git a/tests/Feature/Import/CSV/BaseTransformerTest.php b/tests/Feature/Import/CSV/BaseTransformerTest.php index 0e7611aa3c49..53260aa11d1a 100644 --- a/tests/Feature/Import/CSV/BaseTransformerTest.php +++ b/tests/Feature/Import/CSV/BaseTransformerTest.php @@ -32,7 +32,7 @@ class BaseTransformerTest extends TestCase use MakesHash; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Import/CSV/TaskImportTest.php b/tests/Feature/Import/CSV/TaskImportTest.php index 1ff603f694a5..194da39e5d5c 100644 --- a/tests/Feature/Import/CSV/TaskImportTest.php +++ b/tests/Feature/Import/CSV/TaskImportTest.php @@ -92,7 +92,7 @@ class TaskImportTest extends TestCase $task = Task::where('company_id', $this->company->id)->where('number', 'x1234')->first(); $this->assertNotNull($task); $this->assertEquals(1998, $task->calcDuration()); - + $time_log = json_decode($task->time_log); foreach($time_log as $log) { @@ -109,7 +109,7 @@ class TaskImportTest extends TestCase $this->assertTrue($log[3]); } - + } @@ -119,7 +119,7 @@ class TaskImportTest extends TestCase Task::query() ->where('company_id', $this->company->id) ->forceDelete(); - + $this->assertEquals(0, Task::withTrashed()->where('company_id', $this->company->id)->count()); /*Need to import clients first*/ diff --git a/tests/Feature/Import/ImportCompanyTest.php b/tests/Feature/Import/ImportCompanyTest.php index 593f742794b1..f894b8027554 100644 --- a/tests/Feature/Import/ImportCompanyTest.php +++ b/tests/Feature/Import/ImportCompanyTest.php @@ -68,12 +68,12 @@ class ImportCompanyTest extends TestCase public $ids; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); Artisan::call('db:seed'); - + $this->withoutMiddleware( ThrottleRequests::class ); @@ -93,7 +93,7 @@ class ImportCompanyTest extends TestCase $backup_json_file_zip = base_path().'/tests/Feature/Import/backup.zip'; - $zip = new \ZipArchive; + $zip = new \ZipArchive(); $res = $zip->open($backup_json_file_zip); if ($res === true) { $zip->extractTo(sys_get_temp_dir()); @@ -117,7 +117,7 @@ class ImportCompanyTest extends TestCase { $backup_json_file_zip = base_path().'/tests/Feature/Import/backup.zip'; - $zip = new \ZipArchive; + $zip = new \ZipArchive(); $res = $zip->open($backup_json_file_zip); if ($res === true) { @@ -423,7 +423,7 @@ class ImportCompanyTest extends TestCase $this->genericImport( Vendor::class, ['user_id', 'assigned_user_id', 'company_id', 'id', 'hashed_id'], - [['users' => 'user_id'], ['users' =>'assigned_user_id']], + [['users' => 'user_id'], ['users' => 'assigned_user_id']], 'vendors', 'number' ); @@ -437,7 +437,7 @@ class ImportCompanyTest extends TestCase $this->genericImport( Project::class, ['user_id', 'assigned_user_id', 'company_id', 'id', 'hashed_id', 'client_id'], - [['users' => 'user_id'], ['users' =>'assigned_user_id'], ['clients' => 'client_id']], + [['users' => 'user_id'], ['users' => 'assigned_user_id'], ['clients' => 'client_id']], 'projects', 'number' ); @@ -453,7 +453,7 @@ class ImportCompanyTest extends TestCase $this->genericNewClassImport( Product::class, ['user_id', 'company_id', 'hashed_id', 'id'], - [['users' => 'user_id'], ['users' =>'assigned_user_id'], ['vendors' => 'vendor_id'], ['projects' => 'project_id']], + [['users' => 'user_id'], ['users' => 'assigned_user_id'], ['vendors' => 'vendor_id'], ['projects' => 'project_id']], 'products' ); $this->assertEquals(1, Product::count()); @@ -1149,7 +1149,7 @@ class ImportCompanyTest extends TestCase return $this->ids[$resource]["{$old}"]; } - protected function tearDown() :void + protected function tearDown(): void { $backup_json_file = sys_get_temp_dir().'/backup/backup.json'; diff --git a/tests/Feature/Import/Invoicely/InvoicelyTest.php b/tests/Feature/Import/Invoicely/InvoicelyTest.php index 5869ad21d2e7..f066a538c0e6 100644 --- a/tests/Feature/Import/Invoicely/InvoicelyTest.php +++ b/tests/Feature/Import/Invoicely/InvoicelyTest.php @@ -155,7 +155,7 @@ class InvoicelyTest extends TestCase $base_transformer = new BaseTransformer($this->company); - + $this->assertTrue($base_transformer->hasInvoice('INV-1')); $invoice_id = $base_transformer->getInvoiceId('INV-1'); diff --git a/tests/Feature/Import/Quickbooks/QuickbooksTest.php b/tests/Feature/Import/Quickbooks/QuickbooksTest.php index 98f75ae3b5ce..b4869f334d61 100644 --- a/tests/Feature/Import/Quickbooks/QuickbooksTest.php +++ b/tests/Feature/Import/Quickbooks/QuickbooksTest.php @@ -18,7 +18,6 @@ use Illuminate\Support\Str; use ReflectionClass; use Illuminate\Support\Facades\Auth; - class QuickbooksTest extends TestCase { use MakesHash; @@ -31,24 +30,24 @@ class QuickbooksTest extends TestCase protected function setUp(): void { parent::setUp(); - + $this->markTestSkipped("NO BUENO"); $this->withoutMiddleware(ThrottleRequests::class); config(['database.default' => config('ninja.db.default')]); $this->makeTestData(); - // + // $this->withoutExceptionHandling(); Auth::setUser($this->user); - + } public function testImportCallsGetDataOnceForClient() { - $data = (json_decode( file_get_contents( base_path('tests/Feature/Import/customers.json') ), true))['Customer']; + $data = (json_decode(file_get_contents(base_path('tests/Feature/Import/customers.json')), true))['Customer']; $hash = Str::random(32); Cache::put($hash.'-client', base64_encode(json_encode($data)), 360); - $quickbooks = Mockery::mock(Quickbooks::class,[[ + $quickbooks = Mockery::mock(Quickbooks::class, [[ 'hash' => $hash, 'column_map' => ['client' => ['mapping' => []]], 'skip_header' => true, @@ -60,7 +59,7 @@ class QuickbooksTest extends TestCase ->andReturn($data); // Mocking the dependencies used within the client method - + $quickbooks->import('client'); $this->assertArrayHasKey('clients', $quickbooks->entity_count); @@ -68,19 +67,19 @@ class QuickbooksTest extends TestCase $base_transformer = new BaseTransformer($this->company); $this->assertTrue($base_transformer->hasClient('Sonnenschein Family Store')); - $contact = $base_transformer->getClient('Amy\'s Bird Sanctuary',''); - $contact = Client::where('name','Amy\'s Bird Sanctuary')->first(); - $this->assertEquals('(650) 555-3311',$contact->phone); - $this->assertEquals('Birds@Intuit.com',$contact->contacts()->first()->email); + $contact = $base_transformer->getClient('Amy\'s Bird Sanctuary', ''); + $contact = Client::where('name', 'Amy\'s Bird Sanctuary')->first(); + $this->assertEquals('(650) 555-3311', $contact->phone); + $this->assertEquals('Birds@Intuit.com', $contact->contacts()->first()->email); } public function testImportCallsGetDataOnceForProducts() { - $data = (json_decode( file_get_contents( base_path('tests/Feature/Import/items.json') ), true))['Item']; + $data = (json_decode(file_get_contents(base_path('tests/Feature/Import/items.json')), true))['Item']; $hash = Str::random(32); Cache::put($hash.'-item', base64_encode(json_encode($data)), 360); - $quickbooks = Mockery::mock(Quickbooks::class,[[ + $quickbooks = Mockery::mock(Quickbooks::class, [[ 'hash' => $hash, 'column_map' => ['item' => ['mapping' => []]], 'skip_header' => true, @@ -92,7 +91,7 @@ class QuickbooksTest extends TestCase ->andReturn($data); // Mocking the dependencies used within the client method - + $quickbooks->import('product'); $this->assertArrayHasKey('products', $quickbooks->entity_count); @@ -100,17 +99,17 @@ class QuickbooksTest extends TestCase $base_transformer = new BaseTransformer($this->company); $this->assertTrue($base_transformer->hasProduct('Gardening')); - $product = Product::where('product_key','Pest Control')->first(); - $this->assertGreaterThanOrEqual( 35, $product->price); + $product = Product::where('product_key', 'Pest Control')->first(); + $this->assertGreaterThanOrEqual(35, $product->price); $this->assertLessThanOrEqual(0, $product->quantity); } public function testImportCallsGetDataOnceForInvoices() { - $data = (json_decode( file_get_contents( base_path('tests/Feature/Import/invoices.json') ), true))['Invoice']; + $data = (json_decode(file_get_contents(base_path('tests/Feature/Import/invoices.json')), true))['Invoice']; $hash = Str::random(32); Cache::put($hash.'-invoice', base64_encode(json_encode($data)), 360); - $quickbooks = Mockery::mock(Quickbooks::class,[[ + $quickbooks = Mockery::mock(Quickbooks::class, [[ 'hash' => $hash, 'column_map' => ['invoice' => ['mapping' => []]], 'skip_header' => true, @@ -125,10 +124,10 @@ class QuickbooksTest extends TestCase $this->assertGreaterThan(0, $quickbooks->entity_count['invoices']); $base_transformer = new BaseTransformer($this->company); $this->assertTrue($base_transformer->hasInvoice(1007)); - $invoice = Invoice::where('number',1012)->first(); - $data = collect($data)->where('DocNumber','1012')->first(); - $this->assertGreaterThanOrEqual( $data['TotalAmt'], $invoice->amount); - $this->assertEquals( count($data['Line']) - 1 , count((array)$invoice->line_items)); + $invoice = Invoice::where('number', 1012)->first(); + $data = collect($data)->where('DocNumber', '1012')->first(); + $this->assertGreaterThanOrEqual($data['TotalAmt'], $invoice->amount); + $this->assertEquals(count($data['Line']) - 1, count((array)$invoice->line_items)); } diff --git a/tests/Feature/Inventory/InventoryManagementTest.php b/tests/Feature/Inventory/InventoryManagementTest.php index eef347d8b0a6..1f67e25bc33f 100644 --- a/tests/Feature/Inventory/InventoryManagementTest.php +++ b/tests/Feature/Inventory/InventoryManagementTest.php @@ -28,7 +28,7 @@ class InventoryManagementTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -62,7 +62,7 @@ class InventoryManagementTest extends TestCase $invoice->company->track_inventory = true; $invoice->push(); - $invoice_item = new InvoiceItem; + $invoice_item = new InvoiceItem(); $invoice_item->type_id = 1; $invoice_item->product_key = $product->product_key; $invoice_item->notes = $product->notes; @@ -95,7 +95,7 @@ class InventoryManagementTest extends TestCase $invoice->service()->markDeleted()->save(); $invoice->is_deleted = true; $invoice->save(); - + $this->assertEquals(100, $product->fresh()->in_stock_quantity); $invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($data['data']['id'])); diff --git a/tests/Feature/InvitationTest.php b/tests/Feature/InvitationTest.php index 597f90cee7d8..bccb8636657b 100644 --- a/tests/Feature/InvitationTest.php +++ b/tests/Feature/InvitationTest.php @@ -35,7 +35,7 @@ class InvitationTest extends TestCase use DatabaseTransactions; // use RefreshDatabase; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/InvoiceAmountPaymentTest.php b/tests/Feature/InvoiceAmountPaymentTest.php index 51edeaf5b7f3..c86dcedbaa00 100644 --- a/tests/Feature/InvoiceAmountPaymentTest.php +++ b/tests/Feature/InvoiceAmountPaymentTest.php @@ -27,7 +27,7 @@ class InvoiceAmountPaymentTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/InvoiceEmailTest.php b/tests/Feature/InvoiceEmailTest.php index d3d973b0a681..6e1f3f8ff116 100644 --- a/tests/Feature/InvoiceEmailTest.php +++ b/tests/Feature/InvoiceEmailTest.php @@ -34,7 +34,7 @@ class InvoiceEmailTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -56,7 +56,7 @@ class InvoiceEmailTest extends TestCase $this->assertTrue(strpos($email, '@example.com') !== false); } - + public function testClientEmailHistory() { @@ -83,7 +83,7 @@ class InvoiceEmailTest extends TestCase ], ] ]; - + $system_log->save(); @@ -131,7 +131,7 @@ class InvoiceEmailTest extends TestCase ], ] ]; - + $system_log->save(); $data = [ @@ -166,18 +166,18 @@ class InvoiceEmailTest extends TestCase $data = [ "body" => "hey what's up", "entity" => 'invoice', - "entity_id"=> $this->invoice->hashed_id, - "subject"=> 'Reminder $number', - "template"=> "first_custom" + "entity_id" => $this->invoice->hashed_id, + "subject" => 'Reminder $number', + "template" => "first_custom" ]; $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/emails', $data); - + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/emails', $data); + $response->assertStatus(422); @@ -194,10 +194,10 @@ class InvoiceEmailTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/emails', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/emails', $data); $response->assertStatus(200); @@ -256,7 +256,7 @@ class InvoiceEmailTest extends TestCase if ($invitation->contact->send_email && $invitation->contact->email) { EmailEntity::dispatch($invitation, $invitation->company); - + Bus::assertDispatched(EmailEntity::class); } @@ -287,7 +287,7 @@ class InvoiceEmailTest extends TestCase if ($invitation->contact->send_email && $invitation->contact->email) { EmailEntity::dispatch($invitation, $invitation->company); - + Bus::assertDispatched(EmailEntity::class); } @@ -313,7 +313,7 @@ class InvoiceEmailTest extends TestCase if ($invitation->contact->send_email && $invitation->contact->email) { EmailEntity::dispatch($invitation, $invitation->company); - + Bus::assertDispatched(EmailEntity::class); } diff --git a/tests/Feature/InvoiceLinkTasksTest.php b/tests/Feature/InvoiceLinkTasksTest.php index 72a084fe93b3..325ada761c5e 100644 --- a/tests/Feature/InvoiceLinkTasksTest.php +++ b/tests/Feature/InvoiceLinkTasksTest.php @@ -27,7 +27,7 @@ class InvoiceLinkTasksTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index ff0c79bf41c1..9e3d9e970ac5 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -39,7 +39,7 @@ class InvoiceTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -84,7 +84,7 @@ class InvoiceTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/invoices?mark_sent=true',$data) + ])->postJson('/api/v1/invoices?mark_sent=true', $data) ->assertStatus(200); $arr = $response->json(); @@ -212,7 +212,7 @@ class InvoiceTest extends TestCase 'company_id' => $this->company->id, 'client_id' => $this->client->id, ]); - + $invoice = [ 'status_id' => 1, 'number' => 'dfdfd', @@ -298,7 +298,7 @@ class InvoiceTest extends TestCase 'X-API-TOKEN' => $this->token, ])->get('/api/v1/invoices?date_range=1971-01-01,1971-01-03', ) ->assertStatus(200); - + $arr = $response->json(); $this->assertCount(10, $arr['data']); diff --git a/tests/Feature/Jobs/Import/QuickbooksIngestTest.php b/tests/Feature/Jobs/Import/QuickbooksIngestTest.php index 0882d28c5b37..74677969abb5 100644 --- a/tests/Feature/Jobs/Import/QuickbooksIngestTest.php +++ b/tests/Feature/Jobs/Import/QuickbooksIngestTest.php @@ -31,15 +31,15 @@ class QuickbooksIngestTest extends TestCase $this->makeTestData(); $this->withoutExceptionHandling(); Auth::setUser($this->user); - + } - + /** * A basic feature test example. */ public function testCanQuickbooksIngest(): void { - $data = (json_decode( file_get_contents( base_path('tests/Feature/Import/customers.json') ), true))['Customer']; + $data = (json_decode(file_get_contents(base_path('tests/Feature/Import/customers.json')), true))['Customer']; $hash = Str::random(32); Cache::put($hash.'-client', base64_encode(json_encode($data)), 360); QuickbooksIngest::dispatch([ @@ -47,7 +47,7 @@ class QuickbooksIngestTest extends TestCase 'column_map' => ['client' => ['mapping' => []]], 'skip_header' => true, 'import_types' => ['client'], - ], $this->company )->handle(); + ], $this->company)->handle(); $this->assertTrue(Client::withTrashed()->where(['company_id' => $this->company->id, 'name' => "Freeman Sporting Goods"])->exists()); } } diff --git a/tests/Feature/LiveDesignTest.php b/tests/Feature/LiveDesignTest.php index ddc81a68e143..3e6d24bb75c2 100644 --- a/tests/Feature/LiveDesignTest.php +++ b/tests/Feature/LiveDesignTest.php @@ -28,7 +28,7 @@ class LiveDesignTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -37,7 +37,7 @@ class LiveDesignTest extends TestCase $this->withoutMiddleware( ThrottleRequests::class ); - + if (config('ninja.testvars.travis') !== false) { $this->markTestSkipped('Skip test for Travis'); } @@ -59,7 +59,7 @@ class LiveDesignTest extends TestCase $engine = new HtmlEngine($ii); $this->assertNotNull($engine); - + $data = $engine->generateLabelsAndValues(); $this->assertIsArray($data); @@ -87,7 +87,7 @@ class LiveDesignTest extends TestCase $d = Design::find(1); - + $data = [ 'entity_type' => 'invoice', 'settings_type' => 'company', @@ -99,7 +99,7 @@ class LiveDesignTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/live_design/', $data); - + $response->assertStatus(200); } diff --git a/tests/Feature/LoadTest.php b/tests/Feature/LoadTest.php index d884c17824f6..a1dcdae8aab2 100644 --- a/tests/Feature/LoadTest.php +++ b/tests/Feature/LoadTest.php @@ -46,7 +46,7 @@ class LoadTest extends TestCase public int $count = 1; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -74,7 +74,7 @@ class LoadTest extends TestCase ]); } - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $user->id; $company_token->company_id = $company->id; $company_token->account_id = $account->id; diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php index 1f4273ef24fa..b328c02b49f0 100644 --- a/tests/Feature/LoginTest.php +++ b/tests/Feature/LoginTest.php @@ -29,7 +29,7 @@ class LoginTest extends TestCase { use DatabaseTransactions; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); Session::start(); @@ -155,7 +155,7 @@ class LoginTest extends TestCase $account->default_company_id = $company->id; $account->save(); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $user->id; $company_token->company_id = $company->id; $company_token->account_id = $account->id; @@ -187,9 +187,9 @@ class LoginTest extends TestCase ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - ])->postJson('/api/v1/login', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + ])->postJson('/api/v1/login', $data); $arr = $response->json(); diff --git a/tests/Feature/MaxAmountTest.php b/tests/Feature/MaxAmountTest.php index e69610b0f02d..badc55e26a4b 100644 --- a/tests/Feature/MaxAmountTest.php +++ b/tests/Feature/MaxAmountTest.php @@ -32,7 +32,7 @@ class MaxAmountTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -41,7 +41,7 @@ class MaxAmountTest extends TestCase $this->withoutMiddleware( ThrottleRequests::class ); - + } public function testInvoiceMaxAmount() @@ -65,7 +65,7 @@ class MaxAmountTest extends TestCase $response->assertStatus(422); $i = Invoice::factory()->create($data); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -96,7 +96,7 @@ class MaxAmountTest extends TestCase $response->assertStatus(422); $i = Credit::factory()->create($data); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -127,7 +127,7 @@ class MaxAmountTest extends TestCase $response->assertStatus(422); $i = Quote::factory()->create($data); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -136,7 +136,7 @@ class MaxAmountTest extends TestCase $response->assertStatus(422); } -public function testPurchaseOrderMaxAmount() + public function testPurchaseOrderMaxAmount() { $item = new InvoiceItem(); $item->cost = 10000000000000000; @@ -157,7 +157,7 @@ public function testPurchaseOrderMaxAmount() $response->assertStatus(422); $i = PurchaseOrder::factory()->create($data); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -188,7 +188,7 @@ public function testPurchaseOrderMaxAmount() $response->assertStatus(422); $i = RecurringInvoice::factory()->create($data); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, diff --git a/tests/Feature/MigrationTest.php b/tests/Feature/MigrationTest.php index e6efa9082c87..17c897de80f0 100644 --- a/tests/Feature/MigrationTest.php +++ b/tests/Feature/MigrationTest.php @@ -29,7 +29,7 @@ class MigrationTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/MultiPaymentDeleteTest.php b/tests/Feature/MultiPaymentDeleteTest.php index 1b73e583495e..0a8d28f70330 100644 --- a/tests/Feature/MultiPaymentDeleteTest.php +++ b/tests/Feature/MultiPaymentDeleteTest.php @@ -31,11 +31,12 @@ use Tests\TestCase; */ class MultiPaymentDeleteTest extends TestCase { - use DatabaseTransactions, MakesHash; + use DatabaseTransactions; + use MakesHash; private $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -63,7 +64,7 @@ class MultiPaymentDeleteTest extends TestCase $cu->is_admin = true; $cu->save(); - $token = new CompanyToken; + $token = new CompanyToken(); $token->user_id = $user->id; $token->company_id = $company->id; $token->account_id = $account->id; diff --git a/tests/Feature/Ninja/PlanTest.php b/tests/Feature/Ninja/PlanTest.php index a468152c6466..9f96440d0375 100644 --- a/tests/Feature/Ninja/PlanTest.php +++ b/tests/Feature/Ninja/PlanTest.php @@ -32,7 +32,7 @@ class PlanTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -92,8 +92,8 @@ class PlanTest extends TestCase public function testLicense() { $this->markTestSkipped(); - - $license = new License; + + $license = new License(); $license->license_key = "1234"; $license->product_id = "3"; $license->email = 'test@gmail.com'; @@ -104,9 +104,9 @@ class PlanTest extends TestCase $response = $this->get("/claim_license?license_key=1234&product_id=3") ->assertStatus(200); - + $response = $this->get("/claim_license?license_key=12345&product_id=3") ->assertStatus(400); - + } } diff --git a/tests/Feature/Notify/NotificationTest.php b/tests/Feature/Notify/NotificationTest.php index d4edd155156d..a868ddcddb96 100644 --- a/tests/Feature/Notify/NotificationTest.php +++ b/tests/Feature/Notify/NotificationTest.php @@ -34,15 +34,15 @@ class NotificationTest extends TestCase use MockAccountData; protected $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); $this->withoutMiddleware( ThrottleRequests::class ); - + $this->makeTestData(); } @@ -56,7 +56,7 @@ class NotificationTest extends TestCase 'confirmation_code' => uniqid("st", true), ]); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $u->id; $company_token->company_id = $this->company->id; $company_token->account_id = $this->account->id; @@ -76,7 +76,7 @@ class NotificationTest extends TestCase $company_user = CompanyUser::where('user_id', $u->id)->where('company_id', $this->company->id)->first(); - $notifications = new \stdClass; + $notifications = new \stdClass(); $notifications->email = ["invoice_late_user","quote_approved_user"]; $company_user->update(['notifications' => (array)$notifications]); @@ -106,7 +106,7 @@ class NotificationTest extends TestCase public function testNotificationFound() { - $notifications = new \stdClass; + $notifications = new \stdClass(); $notifications->email = ["inventory_all"]; $this->user->company_users()->where('company_id', $this->company->id)->update(['notifications' => (array)$notifications]); @@ -130,7 +130,7 @@ class NotificationTest extends TestCase public function testAllNotificationsFires() { - $notifications = new \stdClass; + $notifications = new \stdClass(); $notifications->email = ["all_notifications"]; $p = Product::factory()->create([ @@ -146,7 +146,7 @@ class NotificationTest extends TestCase public function testAllNotificationsFiresForUser() { - $notifications = new \stdClass; + $notifications = new \stdClass(); $notifications->email = ["all_user_notifications"]; $p = Product::factory()->create([ @@ -168,7 +168,7 @@ class NotificationTest extends TestCase 'confirmation_code' => uniqid("st", true), ]); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $u->id; $company_token->company_id = $this->company->id; $company_token->account_id = $this->account->id; @@ -192,7 +192,7 @@ class NotificationTest extends TestCase ]); - $notifications = new \stdClass; + $notifications = new \stdClass(); $notifications->email = ["all_user_notifications"]; $this->user->company_users()->where('company_id', $this->company->id)->update(['notifications' => (array)$notifications]); @@ -210,7 +210,7 @@ class NotificationTest extends TestCase $cu->save(); $methods = $this->findUserEntityNotificationType($p, $cu, ["all_notifications"]); - + $this->assertCount(1, $methods); $notifications = []; diff --git a/tests/Feature/PayPal/WebhookTest.php b/tests/Feature/PayPal/WebhookTest.php index e454d9c804bf..564db074b1a8 100644 --- a/tests/Feature/PayPal/WebhookTest.php +++ b/tests/Feature/PayPal/WebhookTest.php @@ -29,14 +29,14 @@ class WebhookTest extends TestCase use MockAccountData; private $webhook_string = '{"id":"WH-8WP702374D398111T-81807959NA3371206","event_version":"1.0","create_time":"2023-12-13T08:36:03.961Z","resource_type":"checkout-order","resource_version":"2.0","event_type":"CHECKOUT.ORDER.COMPLETED","summary":"Checkout Order Completed","resource":{"update_time":"2023-12-13T08:35:27Z","create_time":"2023-12-13T08:35:18Z","purchase_units":[{"reference_id":"default","amount":{"currency_code":"USD","value":"1285.13","breakdown":{"item_total":{"currency_code":"USD","value":"1285.13"}}},"payee":{"merchant_id":"KDCGGYWFNWTAN"},"payment_instruction":{"disbursement_mode":"INSTANT"},"description":"Invoice Number# fq30028","custom_id":"xLqrlFTUHJONFhSDhSUZBp0ckeZnpdFq","invoice_id":"fq30028","soft_descriptor":"NOVEMBER 6","items":[{"name":"Invoice Number# fq30028","unit_amount":{"currency_code":"USD","value":"1285.13"},"quantity":"1","description":"Ut totam facilis.Ut totam facilis.Ut totam facilis."}],"shipping":{"name":{"full_name":"John Doe"},"address":{"address_line_1":"1 Main St","admin_area_2":"San Jose","admin_area_1":"CA","postal_code":"95131","country_code":"US"}},"payments":{"captures":[{"id":"40A1323403146010F","status":"COMPLETED","amount":{"currency_code":"USD","value":"1285.13"},"final_capture":true,"disbursement_mode":"INSTANT","seller_protection":{"status":"ELIGIBLE","dispute_categories":["ITEM_NOT_RECEIVED","UNAUTHORIZED_TRANSACTION"]},"seller_receivable_breakdown":{"gross_amount":{"currency_code":"USD","value":"1285.13"},"paypal_fee":{"currency_code":"USD","value":"45.34"},"net_amount":{"currency_code":"USD","value":"1239.79"}},"invoice_id":"fq30028","custom_id":"xLqrlFTUHJONFhSDhSUZBp0ckeZnpdFq","links":[{"href":"https:\\/\\/api.sandbox.paypal.com\\/v2\\/payments\\/captures\\/40A1323403146010F","rel":"self","method":"GET"},{"href":"https:\\/\\/api.sandbox.paypal.com\\/v2\\/payments\\/captures\\/40A1323403146010F\\/refund","rel":"refund","method":"POST"},{"href":"https:\\/\\/api.sandbox.paypal.com\\/v2\\/checkout\\/orders\\/5WX67707S1265192L","rel":"up","method":"GET"}],"create_time":"2023-12-13T08:35:27Z","update_time":"2023-12-13T08:35:27Z"}]}}],"links":[{"href":"https:\\/\\/api.sandbox.paypal.com\\/v2\\/checkout\\/orders\\/5WX67707S1265192L","rel":"self","method":"GET"}],"id":"5WX67707S1265192L","payment_source":{"paypal":{"email_address":"sb-0kvkf26397832@personal.example.com","account_id":"4X5WHWAP5GQ3Y","account_status":"VERIFIED","name":{"given_name":"John","surname":"Doe"},"address":{"address_line_1":"62158","address_line_2":"341 Colton Canyon","admin_area_2":"Port Lisandro","admin_area_1":"New Jersey","postal_code":"08127","country_code":"GR"}}},"intent":"CAPTURE","payer":{"name":{"given_name":"John","surname":"Doe"},"email_address":"sb-0kvkf26397832@personal.example.com","payer_id":"4X5WHWAP5GQ3Y","address":{"address_line_1":"62158","address_line_2":"341 Colton Canyon","admin_area_2":"Port Lisandro","admin_area_1":"New Jersey","postal_code":"08127","country_code":"GR"}},"status":"COMPLETED"},"links":[{"href":"https:\\/\\/api.sandbox.paypal.com\\/v1\\/notifications\\/webhooks-events\\/WH-8WP702374D398111T-81807959NA3371206","rel":"self","method":"GET"},{"href":"https:\\/\\/api.sandbox.paypal.com\\/v1\\/notifications\\/webhooks-events\\/WH-8WP702374D398111T-81807959NA3371206\\/resend","rel":"resend","method":"POST"}],"q":"\\/api\\/v1\\/ppcp\\/webhook"}'; - + private string $merchant_id = 'KDCGGYWFNWTAN'; private string $invoice_number = 'fq30028'; private float $amount = 1285.13; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -45,7 +45,7 @@ class WebhookTest extends TestCase $this->withoutMiddleware( ThrottleRequests::class ); - + } public function testWebhooks() @@ -82,7 +82,7 @@ class WebhookTest extends TestCase 'is_recurring' => false, ]; - $payment_hash = new PaymentHash; + $payment_hash = new PaymentHash(); $payment_hash->hash = Str::random(32); $payment_hash->data = $hash_data; $payment_hash->fee_total = 0; @@ -113,7 +113,7 @@ class WebhookTest extends TestCase private function buildGateway() { - $config = new \stdClass; + $config = new \stdClass(); $config->merchantId = $this->merchant_id; $config->status = 'activated'; $config->consent = 'true'; @@ -122,7 +122,7 @@ class WebhookTest extends TestCase $config->returnMessage = 'true'; $config->paymentsReceivable = 'Yes'; - $cg = new CompanyGateway; + $cg = new CompanyGateway(); $cg->company_id = $this->company->id; $cg->user_id = $this->user->id; $cg->gateway_key = '80af24a6a691230bbec33e930ab40666'; @@ -133,12 +133,12 @@ class WebhookTest extends TestCase $cg->config = encrypt($config); $cg->save(); - $fees_and_limits = new stdClass; - $fees_and_limits->{3} = new FeesAndLimits; + $fees_and_limits = new stdClass(); + $fees_and_limits->{3} = new FeesAndLimits(); $cg->fees_and_limits = $fees_and_limits; $cg->save(); return $cg; } -} \ No newline at end of file +} diff --git a/tests/Feature/PaymentLink/PaymentLinkTest.php b/tests/Feature/PaymentLink/PaymentLinkTest.php index de5755c177c8..f9e96ffa1eb9 100644 --- a/tests/Feature/PaymentLink/PaymentLinkTest.php +++ b/tests/Feature/PaymentLink/PaymentLinkTest.php @@ -110,7 +110,7 @@ class PaymentLinkTest extends TestCase $price = $target->link_service()->calculateUpgradePriceV2($recurring_invoice, $target); - $refund = round($invoice->paid_to_date*$ratio,2); + $refund = round($invoice->paid_to_date * $ratio, 2); $this->assertEquals(($target->price - $refund), $price); diff --git a/tests/Feature/PaymentTermsApiTest.php b/tests/Feature/PaymentTermsApiTest.php index b089ac75e4f0..017974d04c11 100644 --- a/tests/Feature/PaymentTermsApiTest.php +++ b/tests/Feature/PaymentTermsApiTest.php @@ -31,7 +31,7 @@ class PaymentTermsApiTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/PaymentTest.php b/tests/Feature/PaymentTest.php index 075fa4f67aaa..89aff184f10e 100644 --- a/tests/Feature/PaymentTest.php +++ b/tests/Feature/PaymentTest.php @@ -44,7 +44,7 @@ class PaymentTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -64,7 +64,7 @@ class PaymentTest extends TestCase public function testIdempotencyTrigger() { - + $data = [ 'amount' => 5, 'client_id' => $this->client->hashed_id, @@ -84,7 +84,7 @@ class PaymentTest extends TestCase ])->postJson('/api/v1/payments/', $data); $response->assertStatus(200); - + sleep(1); $response = $this->withHeaders([ @@ -99,7 +99,7 @@ class PaymentTest extends TestCase public function testInvoicesValidationProp() { - + $data = [ 'amount' => 5, 'client_id' => $this->client->hashed_id, @@ -119,7 +119,7 @@ class PaymentTest extends TestCase ])->postJson('/api/v1/payments/', $data); $response->assertStatus(422); - + } public function testClientIdValidation() @@ -131,7 +131,7 @@ class PaymentTest extends TestCase 'status_id' => Payment::STATUS_COMPLETED, 'amount' => 100 ]); - + $data = [ 'date' => now()->addDay()->format('Y-m-d') @@ -195,7 +195,7 @@ class PaymentTest extends TestCase $i->calc()->getInvoice()->service()->markSent()->save(); $this->assertGreaterThan(0, $i->balance); - + $data = [ 'amount' => 5, @@ -220,7 +220,7 @@ class PaymentTest extends TestCase $payment_id = $response->json()['data']['id']; $payment = Payment::find($this->decodePrimaryKey($payment_id)); - + $this->assertNotNull($payment); $data = [ @@ -272,7 +272,7 @@ class PaymentTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->putJson('/api/v1/payments/'.$payment->hashed_id, $data); - + $response->assertStatus(200); } @@ -305,7 +305,7 @@ class PaymentTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->putJson('/api/v1/payments/'.$payment->hashed_id, $data); - + $response->assertStatus(422); } @@ -358,7 +358,7 @@ class PaymentTest extends TestCase 'client_id' => $this->client->id, 'date' => '2023-01-02', ]); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -435,12 +435,12 @@ class PaymentTest extends TestCase ]; $response = false; - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/payments/', $data); - + $response->assertStatus(422); // $this->assertFalse($response); @@ -482,7 +482,7 @@ class PaymentTest extends TestCase { $Payment = Payment::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); $Payment->name = \Illuminate\Support\Str::random(54); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -550,7 +550,7 @@ class PaymentTest extends TestCase public function testStorePaymentWithClientId() { - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -607,7 +607,7 @@ class PaymentTest extends TestCase $payment_id = $arr['data']['id']; $payment = Payment::with('invoices')->find($this->decodePrimaryKey($payment_id)); - + $this->assertNotNull($payment); $this->assertNotNull($payment->invoices()); $this->assertEquals(1, $payment->invoices->count()); @@ -616,7 +616,7 @@ class PaymentTest extends TestCase public function testStorePaymentWithNoInvoiecs() { - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -656,14 +656,14 @@ class PaymentTest extends TestCase ])->postJson('/api/v1/payments?include=invoices', $data); $response->assertStatus(200); - + } public function testPartialPaymentAmount() { $invoice = null; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -704,7 +704,7 @@ class PaymentTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/payments?include=invoices', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -722,7 +722,7 @@ class PaymentTest extends TestCase $this->assertEquals($pivot_invoice->partial, 0); $this->assertEquals($pivot_invoice->amount, 10.0000); $this->assertEquals($pivot_invoice->balance, 8.0000); - + } public function testPaymentGreaterThanPartial() @@ -945,7 +945,7 @@ class PaymentTest extends TestCase { $invoice = null; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1011,7 +1011,7 @@ class PaymentTest extends TestCase { $invoice = null; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1070,7 +1070,7 @@ class PaymentTest extends TestCase { $invoice = null; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1135,7 +1135,7 @@ class PaymentTest extends TestCase { $invoice = null; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1240,7 +1240,7 @@ class PaymentTest extends TestCase { $invoice = null; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1295,7 +1295,7 @@ class PaymentTest extends TestCase public function testStorePaymentWithNoAmountField() { - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1361,7 +1361,7 @@ class PaymentTest extends TestCase public function testStorePaymentWithZeroAmountField() { - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1420,7 +1420,7 @@ class PaymentTest extends TestCase public function testPaymentForInvoicesFromDifferentClients() { - $client1 = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client1 = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client1->id, @@ -1429,7 +1429,7 @@ class PaymentTest extends TestCase ]); - $client2 = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client2 = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client2->id, @@ -1496,7 +1496,7 @@ class PaymentTest extends TestCase public function testPaymentWithSameInvoiceMultipleTimes() { - $client1 = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client1 = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client1->id, @@ -1536,20 +1536,20 @@ class PaymentTest extends TestCase ]; - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/payments?include=invoices', $data); - + $response->assertStatus(422); - + } public function testStorePaymentWithCredits() { - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1620,7 +1620,7 @@ class PaymentTest extends TestCase $payment_id = $arr['data']['id']; $payment = Payment::find($this->decodePrimaryKey($payment_id)); - + $this->assertNotNull($payment); $this->assertNotNull($payment->invoices()); $this->assertEquals(1, $payment->invoices()->count()); @@ -1632,7 +1632,7 @@ class PaymentTest extends TestCase $settings = ClientSettings::defaults(); $settings->currency_id = '2'; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1693,7 +1693,7 @@ class PaymentTest extends TestCase { $invoice = null; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1778,7 +1778,7 @@ class PaymentTest extends TestCase { $invoice = null; - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -1842,7 +1842,7 @@ class PaymentTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/payments/refund', $data); - + $arr = $response->json(); @@ -1872,7 +1872,7 @@ class PaymentTest extends TestCase 'date' => '2020/12/12', 'number' => 'duplicate', ]; -sleep(1); + sleep(1); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), @@ -1880,7 +1880,7 @@ sleep(1); ])->postJson('/api/v1/payments', $data); $response->assertStatus(200); -sleep(1); + sleep(1); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, diff --git a/tests/Feature/PaymentV2Test.php b/tests/Feature/PaymentV2Test.php index 23ae16586b67..87a3b5f70dd7 100644 --- a/tests/Feature/PaymentV2Test.php +++ b/tests/Feature/PaymentV2Test.php @@ -37,8 +37,8 @@ class PaymentV2Test extends TestCase use MockAccountData; public $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); @@ -130,7 +130,7 @@ class PaymentV2Test extends TestCase public function testStorePaymentWithCreditsThenDeletingInvoices() { - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id, 'balance' => 20, 'paid_to_date' => 0]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id, 'balance' => 20, 'paid_to_date' => 0]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -192,10 +192,10 @@ class PaymentV2Test extends TestCase $response = null; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments?include=invoices', $data); $arr = $response->json(); @@ -258,7 +258,7 @@ class PaymentV2Test extends TestCase public function testStorePaymentWithCreditsThenDeletingInvoicesAndThenPayments() { - $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id, 'balance' => 100, 'paid_to_date' => 0]); + $client = Client::factory()->create(['company_id' => $this->company->id, 'user_id' => $this->user->id, 'balance' => 100, 'paid_to_date' => 0]); ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $client->id, @@ -329,10 +329,10 @@ class PaymentV2Test extends TestCase $response = null; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments?include=invoices', $data); $arr = $response->json(); @@ -352,7 +352,7 @@ class PaymentV2Test extends TestCase $this->assertEquals(0, $credit->balance); $invoice = $invoice->fresh(); - + //delete the invoice $data = [ diff --git a/tests/Feature/Payments/AutoUnappliedPaymentTest.php b/tests/Feature/Payments/AutoUnappliedPaymentTest.php index eb6b4ee683d3..18784b90b624 100644 --- a/tests/Feature/Payments/AutoUnappliedPaymentTest.php +++ b/tests/Feature/Payments/AutoUnappliedPaymentTest.php @@ -36,7 +36,7 @@ class AutoUnappliedPaymentTest extends TestCase use DatabaseTransactions; use MockUnitData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -56,7 +56,7 @@ class AutoUnappliedPaymentTest extends TestCase public function testUnappliedPaymentsAreEnabled() { - + $settings = ClientSettings::defaults(); $settings->use_unapplied_payment = 'always'; @@ -82,7 +82,7 @@ class AutoUnappliedPaymentTest extends TestCase 'user_id' => $this->user->id, 'client_id' => $client->id, 'amount' => 100, - 'applied' => 0, + 'applied' => 0, 'refunded' => 0, 'status_id' => Payment::STATUS_COMPLETED, 'is_deleted' => 0, @@ -94,10 +94,9 @@ class AutoUnappliedPaymentTest extends TestCase // nlog($invoice->balance); - try{ + try { $invoice->service()->autoBill()->save(); - } - catch(\Exception $e){ + } catch(\Exception $e) { } @@ -110,7 +109,7 @@ class AutoUnappliedPaymentTest extends TestCase $this->assertEquals($payment->applied, $invoice->paid_to_date); $this->assertGreaterThan(2, $invoice->status_id); $this->assertGreaterThan(0, $payment->applied); - + // $this->assertEquals(Invoice::STATUS_PAID, $invoice->status_id); // $this->assertEquals(0, $invoice->balance); @@ -119,7 +118,7 @@ class AutoUnappliedPaymentTest extends TestCase public function testUnappliedPaymentsAreDisabled() { - + $settings = ClientSettings::defaults(); $settings->use_unapplied_payment = 'off'; @@ -146,7 +145,7 @@ class AutoUnappliedPaymentTest extends TestCase 'user_id' => $this->user->id, 'client_id' => $client->id, 'amount' => 100, - 'applied' => 0, + 'applied' => 0, 'refunded' => 0, 'status_id' => Payment::STATUS_COMPLETED ]); @@ -154,12 +153,11 @@ class AutoUnappliedPaymentTest extends TestCase $invoice->service()->markSent()->save(); $this->assertGreaterThan(0, $invoice->balance); - + try { $invoice->service()->autoBill()->save(); - } - catch(\Exception $e) { - + } catch(\Exception $e) { + } $invoice = $invoice->fresh(); @@ -177,4 +175,4 @@ class AutoUnappliedPaymentTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Feature/Payments/CreditPaymentTest.php b/tests/Feature/Payments/CreditPaymentTest.php index 5f8cf0963771..26aed0eea083 100644 --- a/tests/Feature/Payments/CreditPaymentTest.php +++ b/tests/Feature/Payments/CreditPaymentTest.php @@ -35,7 +35,7 @@ class CreditPaymentTest extends TestCase use DatabaseTransactions; use MockUnitData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -86,10 +86,10 @@ class CreditPaymentTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); $response->assertStatus(200); @@ -163,7 +163,7 @@ class CreditPaymentTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/payments/', $data); - + $response->assertStatus(200); $arr = $response->json(); diff --git a/tests/Feature/Payments/DeletePaymentTest.php b/tests/Feature/Payments/DeletePaymentTest.php index 6d87757d4464..4d1cbac865e1 100644 --- a/tests/Feature/Payments/DeletePaymentTest.php +++ b/tests/Feature/Payments/DeletePaymentTest.php @@ -29,7 +29,7 @@ class DeletePaymentTest extends TestCase use DatabaseTransactions; use MockUnitData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -80,7 +80,7 @@ class DeletePaymentTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/payments/', $data); - + $response->assertStatus(200); $arr = $response->json(); diff --git a/tests/Feature/Payments/StorePaymentValidationTest.php b/tests/Feature/Payments/StorePaymentValidationTest.php index 4f7f1cb5449e..b82cf7dba6e1 100644 --- a/tests/Feature/Payments/StorePaymentValidationTest.php +++ b/tests/Feature/Payments/StorePaymentValidationTest.php @@ -29,7 +29,7 @@ class StorePaymentValidationTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -74,10 +74,10 @@ class StorePaymentValidationTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); $response->assertStatus(200); } @@ -95,10 +95,10 @@ class StorePaymentValidationTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); $response->assertStatus(422); @@ -116,10 +116,10 @@ class StorePaymentValidationTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); $response->assertStatus(200); @@ -147,10 +147,10 @@ class StorePaymentValidationTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); $response->assertStatus(200); } @@ -176,10 +176,10 @@ class StorePaymentValidationTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); $response->assertStatus(422); } diff --git a/tests/Feature/Payments/UnappliedPaymentDeleteTest.php b/tests/Feature/Payments/UnappliedPaymentDeleteTest.php index 3431273c863b..687ea37b61ec 100644 --- a/tests/Feature/Payments/UnappliedPaymentDeleteTest.php +++ b/tests/Feature/Payments/UnappliedPaymentDeleteTest.php @@ -30,8 +30,8 @@ class UnappliedPaymentDeleteTest extends TestCase use MakesHash; use DatabaseTransactions; use MockUnitData; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); @@ -178,10 +178,10 @@ class UnappliedPaymentDeleteTest extends TestCase $response = null; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments', $data); $arr = $response->json(); diff --git a/tests/Feature/Payments/UnappliedPaymentRefundTest.php b/tests/Feature/Payments/UnappliedPaymentRefundTest.php index b710be70fec2..0ea04e34c199 100644 --- a/tests/Feature/Payments/UnappliedPaymentRefundTest.php +++ b/tests/Feature/Payments/UnappliedPaymentRefundTest.php @@ -28,7 +28,7 @@ class UnappliedPaymentRefundTest extends TestCase use DatabaseTransactions; use MockUnitData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/PdfMaker/ExampleIntegrationTest.php b/tests/Feature/PdfMaker/ExampleIntegrationTest.php index 8c567ff58e67..84badb305923 100644 --- a/tests/Feature/PdfMaker/ExampleIntegrationTest.php +++ b/tests/Feature/PdfMaker/ExampleIntegrationTest.php @@ -20,7 +20,8 @@ use Tests\TestCase; class ExampleIntegrationTest extends TestCase { - use MakesInvoiceValues, MockAccountData; + use MakesInvoiceValues; + use MockAccountData; protected function setUp(): void { diff --git a/tests/Feature/PhpOffice/CsvConversionTest.php b/tests/Feature/PhpOffice/CsvConversionTest.php index 9a308878c2b8..63dd5a6e6827 100644 --- a/tests/Feature/PhpOffice/CsvConversionTest.php +++ b/tests/Feature/PhpOffice/CsvConversionTest.php @@ -16,7 +16,6 @@ use Tests\TestCase; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; - class CsvConversionTest extends TestCase { protected function setUp(): void @@ -26,29 +25,27 @@ class CsvConversionTest extends TestCase public function testExample() { - - $spreadsheet = new Spreadsheet(); - $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); - /* Set CSV parsing options */ + $spreadsheet = new Spreadsheet(); + $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); - $reader->setDelimiter(','); - // $reader->setEnclosure('"'); - $reader->setSheetIndex(0); + /* Set CSV parsing options */ - /* Load a CSV file and save as a XLS */ + $reader->setDelimiter(','); + // $reader->setEnclosure('"'); + $reader->setSheetIndex(0); - $spreadsheet = $reader->load(base_path().'/tests/Feature/Import/expenses.csv'); - $writer = new Xlsx($spreadsheet); - $writer->save(storage_path('/test.xlsx')); + /* Load a CSV file and save as a XLS */ - $spreadsheet->disconnectWorksheets(); + $spreadsheet = $reader->load(base_path().'/tests/Feature/Import/expenses.csv'); + $writer = new Xlsx($spreadsheet); + $writer->save(storage_path('/test.xlsx')); - $this->assertTrue(file_exists(storage_path('/test.xlsx'))); - unlink(storage_path('/test.xlsx')); + $spreadsheet->disconnectWorksheets(); + + $this->assertTrue(file_exists(storage_path('/test.xlsx'))); + unlink(storage_path('/test.xlsx')); } } - - diff --git a/tests/Feature/PingTest.php b/tests/Feature/PingTest.php index 8c6df4cf9f2c..26ac9b2a11ae 100644 --- a/tests/Feature/PingTest.php +++ b/tests/Feature/PingTest.php @@ -25,7 +25,7 @@ class PingTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); $this->makeTestData(); diff --git a/tests/Feature/PreviewTest.php b/tests/Feature/PreviewTest.php index 0338e6b2a056..0710a7d3599a 100644 --- a/tests/Feature/PreviewTest.php +++ b/tests/Feature/PreviewTest.php @@ -25,7 +25,7 @@ class PreviewTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/ProductTest.php b/tests/Feature/ProductTest.php index e2b4c7a9cca3..d39634b2f118 100644 --- a/tests/Feature/ProductTest.php +++ b/tests/Feature/ProductTest.php @@ -33,8 +33,8 @@ class ProductTest extends TestCase use MockAccountData; protected $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); @@ -147,7 +147,7 @@ class ProductTest extends TestCase ])->post('/api/v1/products/bulk', $update) ->assertStatus(200); } catch(\Exception $e) { - + } $p = $p->fresh(); diff --git a/tests/Feature/ProjectApiTest.php b/tests/Feature/ProjectApiTest.php index 8b3e054daa93..48df7e863297 100644 --- a/tests/Feature/ProjectApiTest.php +++ b/tests/Feature/ProjectApiTest.php @@ -34,7 +34,7 @@ class ProjectApiTest extends TestCase protected $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -66,7 +66,7 @@ class ProjectApiTest extends TestCase $arr = $response->json(); $this->assertEquals(0, $arr['data']['task_rate']); - + } public function testCreateProjectWithNullTaskRate2() @@ -109,7 +109,7 @@ class ProjectApiTest extends TestCase $arr = $response->json(); $this->assertEquals(10, $arr['data']['task_rate']); - + } public function testCreateProjectWithNullTaskRate5() @@ -155,7 +155,7 @@ class ProjectApiTest extends TestCase $arr = $response->json(); $this->assertEquals(10, $arr['data']['task_rate']); - + } public function testProjectIncludesZeroCount() @@ -185,7 +185,7 @@ class ProjectApiTest extends TestCase 'project_id' => $this->project->id, ]); - + $e = Expense::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -193,7 +193,7 @@ class ProjectApiTest extends TestCase 'project_id' => $this->project->id, ]); - + $q = Quote::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, diff --git a/tests/Feature/PurchaseOrderTest.php b/tests/Feature/PurchaseOrderTest.php index bbdb22dd134f..ceb2f4850b4c 100644 --- a/tests/Feature/PurchaseOrderTest.php +++ b/tests/Feature/PurchaseOrderTest.php @@ -37,7 +37,7 @@ class PurchaseOrderTest extends TestCase protected function setUp(): void { parent::setUp(); - + $this->faker = \Faker\Factory::create(); $this->makeTestData(); @@ -57,9 +57,9 @@ class PurchaseOrderTest extends TestCase $this->assertEquals($expense->project_id, $this->project->id); $this->assertEquals($expense->client_id, $p->project->client_id); - + } - + public function testPurchaseOrderHistory() { @@ -67,7 +67,7 @@ class PurchaseOrderTest extends TestCase event(new PurchaseOrderWasCreated($this->purchase_order, $this->company, Ninja::eventVars($this->company, $this->user))); $ar = new ActivityRepository(); - $fields = new \stdClass; + $fields = new \stdClass(); $fields->user_id = $this->purchase_order->user_id; $fields->vendor_id = $this->purchase_order->vendor_id; $fields->company_id = $this->purchase_order->company_id; @@ -126,7 +126,7 @@ class PurchaseOrderTest extends TestCase $data = [ - 'ids' =>[$po->hashed_id], + 'ids' => [$po->hashed_id], 'action' => 'archive', ]; @@ -137,7 +137,7 @@ class PurchaseOrderTest extends TestCase ->assertStatus(200); $data = [ - 'ids' =>[$po->hashed_id], + 'ids' => [$po->hashed_id], 'action' => 'restore', ]; @@ -148,7 +148,7 @@ class PurchaseOrderTest extends TestCase ->assertStatus(200); $data = [ - 'ids' =>[$po->hashed_id], + 'ids' => [$po->hashed_id], 'action' => 'delete', ]; @@ -160,7 +160,7 @@ class PurchaseOrderTest extends TestCase $data = [ - 'ids' =>[$po->hashed_id], + 'ids' => [$po->hashed_id], 'action' => 'restore', ]; @@ -172,7 +172,7 @@ class PurchaseOrderTest extends TestCase $data = [ - 'ids' =>[], + 'ids' => [], 'action' => 'archive', ]; @@ -183,7 +183,7 @@ class PurchaseOrderTest extends TestCase ->assertStatus(302); $data = [ - 'ids' =>[$po->hashed_id], + 'ids' => [$po->hashed_id], 'action' => '', ]; @@ -195,7 +195,7 @@ class PurchaseOrderTest extends TestCase $data = [ - 'ids' =>[$po->hashed_id], + 'ids' => [$po->hashed_id], 'action' => 'molly', ]; diff --git a/tests/Feature/QuoteReminderTest.php b/tests/Feature/QuoteReminderTest.php index d5d1837fcb3f..8962a45a1d2e 100644 --- a/tests/Feature/QuoteReminderTest.php +++ b/tests/Feature/QuoteReminderTest.php @@ -42,7 +42,7 @@ class QuoteReminderTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -71,7 +71,7 @@ class QuoteReminderTest extends TestCase public $token; public $cu; - + public $invoice; private function buildData($settings = null) @@ -112,7 +112,7 @@ class QuoteReminderTest extends TestCase $this->token = \Illuminate\Support\Str::random(64); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $this->user->id; $company_token->company_id = $this->company->id; $company_token->account_id = $this->account->id; @@ -162,12 +162,12 @@ class QuoteReminderTest extends TestCase public function testNullReminder() { - + $settings = $this->company->settings; $settings->enable_quote_reminder1 = false; $settings->quote_schedule_reminder1 = ''; $settings->quote_num_days_reminder1 = 1; - + $this->buildData(($settings)); $this->quote->date = now()->subMonths(2)->format('Y-m-d'); @@ -185,12 +185,12 @@ class QuoteReminderTest extends TestCase public function testBeforeValidReminder() { - + $settings = $this->company->settings; $settings->enable_quote_reminder1 = true; $settings->quote_schedule_reminder1 = 'before_valid_until_date'; $settings->quote_num_days_reminder1 = 1; - + $this->buildData(($settings)); $this->quote->date = now()->addMonth()->format('Y-m-d'); diff --git a/tests/Feature/QuoteTest.php b/tests/Feature/QuoteTest.php index bc646a21dfdc..ed7b2ed87123 100644 --- a/tests/Feature/QuoteTest.php +++ b/tests/Feature/QuoteTest.php @@ -37,7 +37,7 @@ class QuoteTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -69,7 +69,7 @@ class QuoteTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/quotes', $data); - + $arr = $response->json(); // nlog($arr); @@ -95,7 +95,7 @@ class QuoteTest extends TestCase $arr = $response->json(); $this->assertEmpty($arr['data']['due_date']); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -128,7 +128,7 @@ class QuoteTest extends TestCase $arr = $response->json(); $this->assertNotEmpty($arr['data']['due_date']); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -191,7 +191,7 @@ class QuoteTest extends TestCase $response->assertStatus(200); $arr = $response->json(); - + $this->assertEquals(now()->addDay()->format('Y-m-d'), $arr['data']['due_date']); $this->assertEquals(now()->format('Y-m-d'), $arr['data']['partial_due_date']); $this->assertEquals(1, $arr['data']['partial']); @@ -215,7 +215,7 @@ class QuoteTest extends TestCase 'client_id' => $c->id, 'status_id' => 2, 'date' => now(), - 'line_items' =>[ + 'line_items' => [ [ 'type_id' => '2', 'cost' => 200, @@ -249,7 +249,7 @@ class QuoteTest extends TestCase $t = $p->tasks()->where('description', 'Test200')->first(); $this->assertEquals(200, $t->rate); - + $t = $p->tasks()->where('description', 'Test100')->first(); $this->assertEquals(100, $t->rate); diff --git a/tests/Feature/RecurringExpenseApiTest.php b/tests/Feature/RecurringExpenseApiTest.php index 6a302c3b49fa..2b0e8f1f9a6e 100644 --- a/tests/Feature/RecurringExpenseApiTest.php +++ b/tests/Feature/RecurringExpenseApiTest.php @@ -34,7 +34,7 @@ class RecurringExpenseApiTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -135,7 +135,7 @@ class RecurringExpenseApiTest extends TestCase 'client_id' => $this->client->hashed_id, 'number' => '123321', 'frequency_id' => 5, - 'remaining_cycles' =>5, + 'remaining_cycles' => 5, 'currency_id' => 34545435425 ]; @@ -155,7 +155,7 @@ class RecurringExpenseApiTest extends TestCase 'client_id' => $this->client->hashed_id, 'number' => '123321', 'frequency_id' => 5, - 'remaining_cycles' =>5, + 'remaining_cycles' => 5, 'currency_id' => 1 ]; @@ -175,7 +175,7 @@ class RecurringExpenseApiTest extends TestCase 'client_id' => $this->client->hashed_id, 'number' => '123321', 'frequency_id' => 5, - 'remaining_cycles' =>5, + 'remaining_cycles' => 5, 'currency_id' => null ]; @@ -183,7 +183,7 @@ class RecurringExpenseApiTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/recurring_expenses?start=true', $data); - + $data = $response->json(); $response->assertStatus(200); @@ -199,7 +199,7 @@ class RecurringExpenseApiTest extends TestCase 'client_id' => $this->client->hashed_id, 'number' => '123321', 'frequency_id' => 5, - 'remaining_cycles' =>5, + 'remaining_cycles' => 5, 'currency_id' => "" ]; @@ -207,7 +207,7 @@ class RecurringExpenseApiTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/recurring_expenses?start=true', $data); - + $data = $response->json(); $response->assertStatus(200); @@ -423,7 +423,7 @@ class RecurringExpenseApiTest extends TestCase 'client_id' => $this->client->hashed_id, 'number' => '123321', 'frequency_id' => 5, - 'remaining_cycles' =>5, + 'remaining_cycles' => 5, ]; $response = $this->withHeaders([ diff --git a/tests/Feature/RecurringInvoiceTest.php b/tests/Feature/RecurringInvoiceTest.php index 81fc73a9fa64..8bdb96067dd7 100644 --- a/tests/Feature/RecurringInvoiceTest.php +++ b/tests/Feature/RecurringInvoiceTest.php @@ -44,7 +44,7 @@ class RecurringInvoiceTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -68,14 +68,14 @@ class RecurringInvoiceTest extends TestCase 'frequency_id' => 5, 'next_send_date' => '0001-01-01', ]; - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/recurring_invoices', $data) ->assertStatus(422); - } + } public function testLinkingSubscription() { @@ -106,11 +106,11 @@ class RecurringInvoiceTest extends TestCase ])->postJson('/api/v1/recurring_invoices/bulk', $data) ->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $r = $r->fresh(); + $r = $r->fresh(); - $this->assertEquals($s2->id, $r->subscription_id); + $this->assertEquals($s2->id, $r->subscription_id); } @@ -200,7 +200,7 @@ class RecurringInvoiceTest extends TestCase ->assertStatus(200); $arr = $response->json(); - + $this->assertEquals(now()->startOfDay(), $arr['data']['next_send_date']); } diff --git a/tests/Feature/RecurringInvoicesCronTest.php b/tests/Feature/RecurringInvoicesCronTest.php index 0e446febfe0e..6a11f484abb0 100644 --- a/tests/Feature/RecurringInvoicesCronTest.php +++ b/tests/Feature/RecurringInvoicesCronTest.php @@ -26,7 +26,7 @@ class RecurringInvoicesCronTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/RecurringQuoteTest.php b/tests/Feature/RecurringQuoteTest.php index eabcd39741ba..913ec9efff8a 100644 --- a/tests/Feature/RecurringQuoteTest.php +++ b/tests/Feature/RecurringQuoteTest.php @@ -31,8 +31,8 @@ class RecurringQuoteTest extends TestCase use MockAccountData; public $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/RecurringQuotesTest.php b/tests/Feature/RecurringQuotesTest.php index 93fdbe9f738a..655bad239bc8 100644 --- a/tests/Feature/RecurringQuotesTest.php +++ b/tests/Feature/RecurringQuotesTest.php @@ -34,7 +34,7 @@ class RecurringQuotesTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/RefundTest.php b/tests/Feature/RefundTest.php index f64d0aecaf19..1637024a2345 100644 --- a/tests/Feature/RefundTest.php +++ b/tests/Feature/RefundTest.php @@ -42,7 +42,7 @@ class RefundTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -82,7 +82,7 @@ class RefundTest extends TestCase $payment_id = $arr['data']['id']; - $item = new InvoiceItem; + $item = new InvoiceItem(); $item->cost = 300; $item->quantity = 1; @@ -250,12 +250,12 @@ class RefundTest extends TestCase $response = false; - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/payments/refund', $data); - + $arr = $response->json(); @@ -352,7 +352,7 @@ class RefundTest extends TestCase 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/payments/refund', $data); $response->assertStatus(422); - + } /** @@ -792,7 +792,7 @@ class RefundTest extends TestCase 'balance' => 1000, ]); - $item = new InvoiceItem; + $item = new InvoiceItem(); $item->cost = 1000; $item->quantity = 1; @@ -825,9 +825,9 @@ class RefundTest extends TestCase $this->assertNotNull($c); $this->assertEquals(2, $c->status_id); -$this->assertEquals($cl->id, $c->client_id); + $this->assertEquals($cl->id, $c->client_id); -$this->assertEquals($cl->id, $i->client_id); + $this->assertEquals($cl->id, $i->client_id); $data = [ 'amount' => 900, @@ -872,7 +872,7 @@ $this->assertEquals($cl->id, $i->client_id); ], ] ]; - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -883,10 +883,10 @@ $this->assertEquals($cl->id, $i->client_id); $arr = $response->json(); $this->assertEquals(0, $arr['data']['refunded']); - + $this->assertEquals(10, $c->fresh()->balance); $this->assertEquals(10, $i->fresh()->balance); - + } public function testRefundsWithSplitCreditAndPaymentRefund() @@ -956,7 +956,7 @@ $this->assertEquals($cl->id, $i->client_id); ], ] ]; - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -967,10 +967,10 @@ $this->assertEquals($cl->id, $i->client_id); $arr = $response->json(); $this->assertEquals(100, $arr['data']['refunded']); - + $this->assertEquals(100, $c->fresh()->balance); $this->assertEquals(200, $i->fresh()->balance); - + $this->assertEquals(900, $payment->fresh()->amount); $this->assertEquals(900, $payment->fresh()->applied); $this->assertEquals(100, $payment->fresh()->refunded); diff --git a/tests/Feature/ReminderTest.php b/tests/Feature/ReminderTest.php index ec7186bd9457..884714621f5c 100644 --- a/tests/Feature/ReminderTest.php +++ b/tests/Feature/ReminderTest.php @@ -42,7 +42,7 @@ class ReminderTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -71,7 +71,7 @@ class ReminderTest extends TestCase public $token; public $cu; - + public $invoice; private function buildData($settings = null) @@ -112,7 +112,7 @@ class ReminderTest extends TestCase $this->token = \Illuminate\Support\Str::random(64); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $this->user->id; $company_token->company_id = $this->company->id; $company_token->account_id = $this->account->id; @@ -215,11 +215,11 @@ class ReminderTest extends TestCase $this->assertEquals('2024-03-15', $invoice->due_date); $this->assertEquals('2024-03-06', $invoice->next_send_date->format('Y-m-d')); - // //day five: schedule send time 7am UTC + // //day five: schedule send time 7am UTC $this->travelTo(now()->addDays(5)->startOfDay()); $this->assertEquals('2024-03-06', now()->format('Y-m-d')); - - + + $x = false; do { @@ -228,14 +228,13 @@ class ReminderTest extends TestCase $invoice = $invoice->fresh(); $x = (bool)$invoice->reminder1_sent; - } - while($x === false); + } while($x === false); $this->assertNotNull($invoice->reminder_last_sent); //check next send date is on day "10" $this->assertEquals(now()->addDays(5), $invoice->next_send_date); - + $this->travelTo(now()->copy()->addDays(5)->startOfDay()->addHours(5)); $this->assertEquals('2024-03-11', now()->format('Y-m-d')); @@ -277,9 +276,9 @@ class ReminderTest extends TestCase //endless reminders $this->assertEquals(now()->addDays(14), $invoice->next_send_date); - + $this->travelTo(now()->addDays(14)->startOfDay()); - + $this->assertEquals('2024-03-30', now()->format('Y-m-d')); $x = false; @@ -293,14 +292,14 @@ class ReminderTest extends TestCase } while($x === false); - + $this->assertEquals(now()->addDays(14), $invoice->next_send_date); - } + } public function testForUtcEdgeCaseOnTheFirstOfMonth() { - + $this->travelTo(Carbon::parse('2024-03-01')->startOfDay()); $this->invoice->status_id = 2; @@ -338,8 +337,8 @@ class ReminderTest extends TestCase public function testReminderInThePast() { - - $translations = new \stdClass; + + $translations = new \stdClass(); $translations->late_fee_added = "Fee added :date"; $settings = $this->company->settings; @@ -377,7 +376,7 @@ class ReminderTest extends TestCase public function testsForTranslationsInReminders() { - $translations = new \stdClass; + $translations = new \stdClass(); $translations->late_fee_added = "Fee added :date"; $settings = $this->company->settings; @@ -412,7 +411,7 @@ class ReminderTest extends TestCase $this->assertEquals(now()->addSeconds($this->client->timezone_offset())->format('Y-m-d'), $this->invoice->date); $this->assertNotNull($this->invoice->next_send_date); $this->assertEquals(now()->addDay()->addSeconds($this->client->timezone_offset())->format('Y-m-d 00:00:00'), $this->invoice->next_send_date); - + $this->travelTo(now()->addDay()->startOfDay()->addHour()); (new ReminderJob())->handle(); @@ -489,7 +488,7 @@ class ReminderTest extends TestCase $this->invoice->client->settings = $client_settings; $this->invoice->push(); - + $this->invoice = $this->invoice->service()->markSent()->save(); $this->invoice->service()->setReminder($client_settings)->save(); @@ -502,16 +501,16 @@ class ReminderTest extends TestCase $travel_date = Carbon::parse($this->invoice->next_send_date); $x = false; - for($x=0; $x<50; $x++) { + for($x = 0; $x < 50; $x++) { (new ReminderJob())->handle(); if(now()->gt($travel_date) && !$x) { - + $this->assertNotNull($this->invoice->reminder1_sent); $this->assertNotNull($this->invoice->reminder_last_sent); - $x=true; + $x = true; } @@ -632,7 +631,7 @@ class ReminderTest extends TestCase $this->invoice->service()->setReminder()->save(); $next_send_date = Carbon::parse($this->invoice->next_send_date); - + // nlog($next_send_date->format('Y-m-d h:i:s')); $calculatedReminderDate = Carbon::parse($this->invoice->due_date)->subDays(2)->addSeconds($this->invoice->client->timezone_offset()); diff --git a/tests/Feature/ReverseInvoiceTest.php b/tests/Feature/ReverseInvoiceTest.php index 491610676536..e3404029d278 100644 --- a/tests/Feature/ReverseInvoiceTest.php +++ b/tests/Feature/ReverseInvoiceTest.php @@ -36,7 +36,7 @@ class ReverseInvoiceTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Scheduler/ScheduleEntityTest.php b/tests/Feature/Scheduler/ScheduleEntityTest.php index df627c02505a..9aa319fb7e76 100644 --- a/tests/Feature/Scheduler/ScheduleEntityTest.php +++ b/tests/Feature/Scheduler/ScheduleEntityTest.php @@ -27,9 +27,9 @@ class ScheduleEntityTest extends TestCase { use MakesHash; use MockAccountData; - + public $faker; - + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Scheduler/SchedulerTest.php b/tests/Feature/Scheduler/SchedulerTest.php index 7c0a4d446faa..4ab67cb80149 100644 --- a/tests/Feature/Scheduler/SchedulerTest.php +++ b/tests/Feature/Scheduler/SchedulerTest.php @@ -107,12 +107,12 @@ class SchedulerTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/task_schedulers', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/task_schedulers', $data); - $response->assertStatus(200); + $response->assertStatus(200); $arr = $response->json(); @@ -125,7 +125,7 @@ class SchedulerTest extends TestCase $this->assertNotNull($scheduler); $export = (new EmailReport($scheduler))->run(); - + // nlog($scheduler->fresh()->toArray()); $this->assertEquals(now()->startOfDay()->addMonthNoOverflow()->format('Y-m-d'), $scheduler->next_run->format('Y-m-d')); @@ -150,12 +150,12 @@ class SchedulerTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/task_schedulers', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/task_schedulers', $data); - $response->assertStatus(200); + $response->assertStatus(200); $arr = $response->json(); @@ -238,7 +238,7 @@ class SchedulerTest extends TestCase public function testSchedulerGet3() { - + $scheduler = SchedulerFactory::create($this->company->id, $this->user->id); $scheduler->name = "hello"; $scheduler->save(); @@ -264,7 +264,7 @@ class SchedulerTest extends TestCase public function testSchedulerGet2() { - + $scheduler = SchedulerFactory::create($this->company->id, $this->user->id); $response = $this->withHeaders([ @@ -439,7 +439,7 @@ class SchedulerTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/task_schedulers', $data); - + $response->assertStatus(200); $data = $response->json(); @@ -497,9 +497,9 @@ class SchedulerTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/task_schedulers', $data); - + $response->assertStatus(200); - + $data = [ 'name' => 'A single Client', 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, @@ -522,7 +522,7 @@ class SchedulerTest extends TestCase ])->postJson('/api/v1/task_schedulers', $data); $response->assertStatus(200); - + $data = [ 'name' => 'An invalid Client', @@ -552,7 +552,7 @@ class SchedulerTest extends TestCase public function testCalculateNextRun() { $scheduler = SchedulerFactory::create($this->company->id, $this->user->id); - + $data = [ 'name' => 'A test statement scheduler', 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, @@ -582,7 +582,7 @@ class SchedulerTest extends TestCase $this->travelTo(Carbon::parse('2023-01-01')); $scheduler = SchedulerFactory::create($this->company->id, $this->user->id); - + $data = [ 'name' => 'A test statement scheduler', 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, @@ -617,7 +617,7 @@ class SchedulerTest extends TestCase public function testCalculateStatementProperties() { $scheduler = SchedulerFactory::create($this->company->id, $this->user->id); - + $data = [ 'name' => 'A test statement scheduler', 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, @@ -770,7 +770,7 @@ class SchedulerTest extends TestCase 'name' => 'A different Name', 'frequency_id' => 5, 'next_run' => now()->addDays(2)->format('Y-m-d'), - 'template' =>'client_statement', + 'template' => 'client_statement', 'parameters' => [], ]; @@ -788,7 +788,7 @@ class SchedulerTest extends TestCase 'name' => 'A different Name', 'frequency_id' => 5, 'next_run' => now()->addDays(2)->format('Y-m-d'), - 'template' =>'client_statement', + 'template' => 'client_statement', 'parameters' => [], ]; diff --git a/tests/Feature/Search/SearchApiTest.php b/tests/Feature/Search/SearchApiTest.php index 5a8318f46335..ac60a6d1a5fe 100644 --- a/tests/Feature/Search/SearchApiTest.php +++ b/tests/Feature/Search/SearchApiTest.php @@ -25,7 +25,7 @@ class SearchApiTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -34,7 +34,7 @@ class SearchApiTest extends TestCase $this->withoutMiddleware( ThrottleRequests::class ); - + $this->withoutExceptionHandling(); } @@ -43,7 +43,7 @@ class SearchApiTest extends TestCase { $response = false; - + $data = []; $response = $this->withHeaders([ @@ -54,7 +54,7 @@ class SearchApiTest extends TestCase $response->assertStatus(200); nlog($response->json()); - + } } diff --git a/tests/Feature/Shop/ShopInvoiceTest.php b/tests/Feature/Shop/ShopInvoiceTest.php index 197b94f987f5..33a24a78dfe0 100644 --- a/tests/Feature/Shop/ShopInvoiceTest.php +++ b/tests/Feature/Shop/ShopInvoiceTest.php @@ -29,7 +29,7 @@ class ShopInvoiceTest extends TestCase use MockAccountData; protected $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/SubscriptionApiTest.php b/tests/Feature/SubscriptionApiTest.php index 9bf1dd030f37..1f7cdd6a4982 100644 --- a/tests/Feature/SubscriptionApiTest.php +++ b/tests/Feature/SubscriptionApiTest.php @@ -96,7 +96,7 @@ class SubscriptionApiTest extends TestCase 'company_id' => $c2->id, 'user_id' => $this->user->id, ]); - + $i = Invoice::factory()->create([ 'company_id' => $c2->id, 'user_id' => $this->user->id, @@ -161,7 +161,7 @@ class SubscriptionApiTest extends TestCase $this->assertEquals('Australia/Sydney', $timezone_now->timezoneName); $this->travelTo($timezone_now->copy()->startOfDay()->subHour()); - + $i = false; //Capture companies within the window of 00:00 and 00:30 @@ -179,11 +179,11 @@ class SubscriptionApiTest extends TestCase ->get(); } - + $this->assertFalse($i); $this->travelTo($timezone_now->copy()->startOfDay()); - + if(now()->gte($timezone_now->copy()->startOfDay()) && now()->lt($timezone_now->copy()->startOfDay()->addMinutes(30))) { $i = Invoice::query() @@ -308,12 +308,12 @@ class SubscriptionApiTest extends TestCase 'client_id' => $this->client->id, ]); - + $s = Subscription::factory() ->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, - + ]); $data = [ @@ -346,12 +346,12 @@ class SubscriptionApiTest extends TestCase 'client_id' => $this->client->id, ]); - + $s = Subscription::factory() ->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, - + ]); $data = [ @@ -374,7 +374,7 @@ class SubscriptionApiTest extends TestCase $this->assertEquals($s->id, $i->subscription_id); } - + public function testSubscriptionFilter() { $response = $this->withHeaders([ @@ -413,7 +413,7 @@ class SubscriptionApiTest extends TestCase 'company_id' => $this->company->id, 'user_id' => $this->user->id, ]); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), diff --git a/tests/Feature/SystemLogApiTest.php b/tests/Feature/SystemLogApiTest.php index 53d57b21073c..a4748bce16f3 100644 --- a/tests/Feature/SystemLogApiTest.php +++ b/tests/Feature/SystemLogApiTest.php @@ -27,7 +27,7 @@ class SystemLogApiTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/TaskApiTest.php b/tests/Feature/TaskApiTest.php index 2db1a6db9f6b..97085fcbb8bb 100644 --- a/tests/Feature/TaskApiTest.php +++ b/tests/Feature/TaskApiTest.php @@ -35,7 +35,7 @@ class TaskApiTest extends TestCase private $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -72,7 +72,7 @@ class TaskApiTest extends TestCase /*Flag which helps us know if there is a NEXT timelog*/ $next = false; /* If there are more than 1 time log in the array, ensure the last timestamp is not zero*/ - if (count($new_array) >1 && $array[1] == 0) { + if (count($new_array) > 1 && $array[1] == 0) { return false; } @@ -81,10 +81,10 @@ class TaskApiTest extends TestCase if ($array[0] > $array[1] && $array[1] != 0) { return false; } - + /* Find the next time log value - if it exists */ - if (array_key_exists($key+1, $new_array)) { - $next = $new_array[$key+1]; + if (array_key_exists($key + 1, $new_array)) { + $next = $new_array[$key + 1]; } /* check the next time log and ensure the start time is GREATER than the end time of the previous record */ @@ -94,7 +94,7 @@ class TaskApiTest extends TestCase /* Get the last row of the timelog*/ $last_row = end($new_array); - + /*If the last value is NOT zero, ensure start time is not GREATER than the endtime */ if ($last_row[1] != 0 && $last_row[0] > $last_row[1]) { return false; @@ -128,12 +128,12 @@ class TaskApiTest extends TestCase $response->assertStatus(200); $arr = $response->json(); - + } public function testRoundingViaApi() { - + $data = [ 'client_id' => $this->client->hashed_id, 'description' => 'Test Task', @@ -179,7 +179,7 @@ class TaskApiTest extends TestCase [1680715620,1680722820,"",true], [1,1680737460,"",true] ]; - + $key_values = array_column($logs, 0); array_multisort($key_values, SORT_ASC, $logs); @@ -192,8 +192,8 @@ class TaskApiTest extends TestCase public function testTaskDivisionByZero() { $data = [ - "rate" => 0, - "time_log" => '[[1719350900,1719352700,"",true]]', + "rate" => 0, + "time_log" => '[[1719350900,1719352700,"",true]]', ]; $response = $this->withHeaders([ @@ -207,7 +207,7 @@ class TaskApiTest extends TestCase public function testRequestRuleParsing() { - + $data = [ 'client_id' => $this->client->hashed_id, 'description' => 'Test Task', @@ -247,7 +247,7 @@ class TaskApiTest extends TestCase } public function testUserFilters() { - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -291,7 +291,7 @@ class TaskApiTest extends TestCase public function testEmptyTimeLogArray() { - + $data = [ 'client_id' => $this->client->id, 'user_id' => $this->user->id, @@ -355,7 +355,7 @@ class TaskApiTest extends TestCase public function testFaultyTimeLogArray() { - + $data = [ 'client_id' => $this->client->id, 'user_id' => $this->user->id, @@ -370,7 +370,7 @@ class TaskApiTest extends TestCase ])->postJson("/api/v1/tasks", $data); $response->assertStatus(422); - + } public function testTaskClientRateSet() @@ -423,7 +423,7 @@ class TaskApiTest extends TestCase public function testTaskProjectRateSet() { - + $p = Project::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -454,7 +454,7 @@ class TaskApiTest extends TestCase public function testStatusSet() { - + $data = [ 'client_id' => $this->client->id, 'user_id' => $this->user->id, @@ -490,7 +490,7 @@ class TaskApiTest extends TestCase public function testMultiSortArray() { - + $logs = [ [1680035007,1680036807,"",true], ]; @@ -515,7 +515,7 @@ class TaskApiTest extends TestCase } public function testStartStopSanity() { - + $task = Task::factory()->create([ 'client_id' => $this->client->id, 'user_id' => $this->user->id, @@ -814,7 +814,7 @@ class TaskApiTest extends TestCase $arr = $response->json(); $response->assertStatus(200); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, @@ -866,7 +866,7 @@ class TaskApiTest extends TestCase // $arr = $response->json(); // $response->assertStatus(200); - + // $response = $this->withHeaders([ // 'X-API-SECRET' => config('ninja.api_secret'), diff --git a/tests/Feature/TaskStatusApiTest.php b/tests/Feature/TaskStatusApiTest.php index 71c069f24c0f..c454e4cca246 100644 --- a/tests/Feature/TaskStatusApiTest.php +++ b/tests/Feature/TaskStatusApiTest.php @@ -31,7 +31,7 @@ class TaskStatusApiTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -50,15 +50,15 @@ class TaskStatusApiTest extends TestCase 'company_id' => $this->company->id, 'user_id' => $this->user->id ]); - - + + $t = TaskStatus::where('company_id', '=', $this->company->id)->orderBy('id', 'desc'); - + $this->assertEquals(10, $t->count()); $task_status = $t->first(); $id = $task_status->id; - + $data = [ 'status_order' => 1, @@ -72,7 +72,7 @@ class TaskStatusApiTest extends TestCase $t = TaskStatus::where('company_id', '=', $this->company->id)->orderBy('status_order', 'asc')->first(); $this->assertEquals($id, $t->id); - + } public function testTaskStatusGetFilter() diff --git a/tests/Feature/TaxRateApiTest.php b/tests/Feature/TaxRateApiTest.php index f52f48745d36..c52b801ef223 100644 --- a/tests/Feature/TaxRateApiTest.php +++ b/tests/Feature/TaxRateApiTest.php @@ -31,8 +31,8 @@ class TaxRateApiTest extends TestCase use MockAccountData; public $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Template/TemplateTest.php b/tests/Feature/Template/TemplateTest.php index 2e14773a77cf..c700d5a83106 100644 --- a/tests/Feature/Template/TemplateTest.php +++ b/tests/Feature/Template/TemplateTest.php @@ -206,7 +206,7 @@ class TemplateTest extends TestCase private string $stack = '
'; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -215,12 +215,12 @@ class TemplateTest extends TestCase $this->withoutMiddleware( ThrottleRequests::class ); - + } public function testLintingSuccess() { - + $ts = new TemplateService(); $twig = $ts->twig; @@ -236,7 +236,7 @@ class TemplateTest extends TestCase public function testLintingFailure() { - + $ts = new TemplateService(); $twig = $ts->twig; @@ -253,7 +253,7 @@ class TemplateTest extends TestCase public function testPurchaseOrderDataParse() { $data = []; - + $p = \App\Models\PurchaseOrder::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -272,7 +272,7 @@ class TemplateTest extends TestCase public function testTaskDataParse() { $data = []; - + $p = \App\Models\Task::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -291,7 +291,7 @@ class TemplateTest extends TestCase public function testQuoteDataParse() { $data = []; - + $p = \App\Models\Quote::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -311,7 +311,7 @@ class TemplateTest extends TestCase public function testProjectDataParse() { $data = []; - + $p = Project::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id, @@ -366,7 +366,7 @@ class TemplateTest extends TestCase $tm->init(); $variables = $tm->variables[0]; - + $ts = new TemplateService(); $x = $ts->setTemplate($partials) ->setCompany($this->company) @@ -448,7 +448,7 @@ class TemplateTest extends TestCase $this->assertIsArray($data); $start = microtime(true); - + \DB::enableQueryLog(); $invoices = Invoice::with('client', 'payments.client', 'payments.paymentables', 'payments.credits', 'credits.client') @@ -529,7 +529,7 @@ class TemplateTest extends TestCase { $data = []; - + $credits = $payment->credits->map(function ($credit) use ($payment) { return [ 'credit' => $credit->number, @@ -592,7 +592,7 @@ class TemplateTest extends TestCase ], 'paymentables' => $pivot, ]; - + return $data; @@ -637,7 +637,7 @@ class TemplateTest extends TestCase shuffle($rand); $p->type_id = $rand[0]; $p->save(); - + }); }); @@ -650,13 +650,13 @@ class TemplateTest extends TestCase $design->body .= $this->payments_body; $replicated_design->design = $design; $replicated_design->is_custom = true; - $replicated_design->is_template =true; + $replicated_design->is_template = true; $replicated_design->entities = 'client'; $replicated_design->save(); $data['invoices'] = $invoices; $ts = $replicated_design->service()->build($data); - + $this->assertNotNull($ts->getHtml()); } @@ -688,7 +688,7 @@ class TemplateTest extends TestCase $data['invoices'] = collect([$this->invoice, $i2]); $ts = $replicated_design->service()->build($data); - + // nlog("results = "); // nlog($ts->getHtml()); $this->assertNotNull($ts->getHtml()); @@ -721,7 +721,7 @@ class TemplateTest extends TestCase $data['invoices'] = collect([$this->invoice, $i2]); $ts = $replicated_design->service()->build($data); - + // nlog("results = "); // nlog($ts->getHtml()); $this->assertNotNull($ts->getHtml()); @@ -743,7 +743,7 @@ class TemplateTest extends TestCase $data['invoices'] = collect([$this->invoice]); $ts = $replicated_design->service()->build($data); - + // nlog("results = "); // nlog($ts->getHtml()); $this->assertNotNull($ts->getHtml()); @@ -822,7 +822,7 @@ class TemplateTest extends TestCase public function testTemplateGeneration() { $entity_obj = $this->invoice; - + $design = new Design(); $design->design = json_decode(json_encode($this->invoice->company->settings->pdf_variables), true); $design->name = 'test'; @@ -832,7 +832,7 @@ class TemplateTest extends TestCase $design->user_id = $this->invoice->user_id; $design->company_id = $this->invoice->company_id; - $design_object = new \stdClass; + $design_object = new \stdClass(); $design_object->includes = ''; $design_object->header = ''; $design_object->body = $this->body; @@ -857,7 +857,7 @@ class TemplateTest extends TestCase 'custom_partials' => json_decode(json_encode($design->design), true), ]; $template = new PdfMakerDesign(PdfDesignModel::CUSTOM, $options); - + $variables = $html->generateLabelsAndValues(); $state = [ @@ -891,7 +891,7 @@ class TemplateTest extends TestCase $this->assertNotNull($html); $this->assertStringContainsStringIgnoringCase($this->company->settings->name, $html); - + // nlog("Twig Solo Gen Time: ". $end - $start); } diff --git a/tests/Feature/UpdateExchangeRatesTest.php b/tests/Feature/UpdateExchangeRatesTest.php index a645200d31a6..51afacc5ef94 100644 --- a/tests/Feature/UpdateExchangeRatesTest.php +++ b/tests/Feature/UpdateExchangeRatesTest.php @@ -29,13 +29,14 @@ class UpdateExchangeRatesTest extends TestCase use DatabaseTransactions; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); - if(empty(config('ninja.currency_converter_api_key'))) + if(empty(config('ninja.currency_converter_api_key'))) { $this->markTestSkipped("no currency key set"); - + } + } public function testExchangeRate() @@ -54,7 +55,7 @@ class UpdateExchangeRatesTest extends TestCase }); $this->assertEquals($currency_api->rates->GBP, $gbp_currency->exchange_rate); - + } public function testExchangeRateConversion() diff --git a/tests/Feature/UpdatePaymentTest.php b/tests/Feature/UpdatePaymentTest.php index 6f08d348fec8..66af4067f756 100644 --- a/tests/Feature/UpdatePaymentTest.php +++ b/tests/Feature/UpdatePaymentTest.php @@ -35,7 +35,7 @@ class UpdatePaymentTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -72,7 +72,7 @@ class UpdatePaymentTest extends TestCase }); $payment->paymentables()->each(function ($pivot) { - + $this->assertTrue(Carbon::createFromTimestamp($pivot->created_at)->eq(now()->startOfDay()->subMonth())); }); diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index 39f944374156..f1a9e799f756 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -40,7 +40,7 @@ class UserTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -208,7 +208,7 @@ class UserTest extends TestCase $response->assertStatus(200); $this->assertCount(1, $response->json()['data']); - + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $company_token->token, @@ -447,7 +447,7 @@ class UserTest extends TestCase 'X-API-TOKEN' => $this->token, 'X-API-PASSWORD' => 'ALongAndBriliantPassword', ])->postJson('/api/v1/users?include=company_user', $data); - + $response->assertStatus(200); $arr = $response->json(); @@ -480,7 +480,7 @@ class UserTest extends TestCase 'account_id' => $this->account->id, ]); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $this->user->id; $company_token->company_id = $company2->id; $company_token->account_id = $this->account->id; diff --git a/tests/Feature/VendorApiTest.php b/tests/Feature/VendorApiTest.php index 961439949c1d..cabdad09fabd 100644 --- a/tests/Feature/VendorApiTest.php +++ b/tests/Feature/VendorApiTest.php @@ -34,7 +34,7 @@ class VendorApiTest extends TestCase public $faker; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -76,12 +76,12 @@ class VendorApiTest extends TestCase $this->assertNull($v->last_login); $this->assertNull($vc->last_login); - + Event::fake(); event(new VendorContactLoggedIn($vc, $this->company, Ninja::eventVars())); Event::assertDispatched(VendorContactLoggedIn::class); - + } public function testVendorLocale() @@ -159,12 +159,12 @@ class VendorApiTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->putJson("/api/v1/vendors/{$id}", $data); - + $response->assertStatus(200); $arr = $response->json(); $this->assertEquals('3', $arr['data']['language_id']); - + } public function testAddVendorLanguage422() @@ -178,7 +178,7 @@ class VendorApiTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/vendors', $data)->assertStatus(422); - + } @@ -196,7 +196,7 @@ class VendorApiTest extends TestCase $response->assertStatus(200); $arr = $response->json(); - + $this->assertEquals('1', $arr['data']['language_id']); } @@ -381,7 +381,7 @@ class VendorApiTest extends TestCase 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/vendors/', $data) ->assertStatus(422); - + } public function testVendorGet() diff --git a/tests/Feature/WebhookAPITest.php b/tests/Feature/WebhookAPITest.php index 7a2766aa24de..fc59c60b1c45 100644 --- a/tests/Feature/WebhookAPITest.php +++ b/tests/Feature/WebhookAPITest.php @@ -29,8 +29,8 @@ class WebhookAPITest extends TestCase use MockAccountData; protected $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); @@ -47,7 +47,7 @@ class WebhookAPITest extends TestCase public function testWebhookRetry() { - + $data = [ 'target_url' => 'http://hook.com', 'event_id' => 1, //create client @@ -73,7 +73,7 @@ class WebhookAPITest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->postJson("/api/v1/webhooks/".$arr['data']['id']."/retry", $data); - + $response->assertStatus(200); } diff --git a/tests/Integration/CheckCacheTest.php b/tests/Integration/CheckCacheTest.php index 37335c535514..e13b4d7a62b6 100644 --- a/tests/Integration/CheckCacheTest.php +++ b/tests/Integration/CheckCacheTest.php @@ -24,7 +24,7 @@ class CheckCacheTest extends TestCase use MockAccountData; use DatabaseTransactions; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Integration/CheckLockedInvoiceValidationTest.php b/tests/Integration/CheckLockedInvoiceValidationTest.php index b9a7095d208c..30c8c5c0b1f6 100644 --- a/tests/Integration/CheckLockedInvoiceValidationTest.php +++ b/tests/Integration/CheckLockedInvoiceValidationTest.php @@ -25,7 +25,7 @@ class CheckLockedInvoiceValidationTest extends TestCase use MockAccountData; use DatabaseTransactions; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Integration/CheckRemindersTest.php b/tests/Integration/CheckRemindersTest.php index e4b2583f6a78..d6422d71e3c4 100644 --- a/tests/Integration/CheckRemindersTest.php +++ b/tests/Integration/CheckRemindersTest.php @@ -25,7 +25,7 @@ class CheckRemindersTest extends TestCase use MockAccountData; use DatabaseTransactions; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Integration/CompanyLedgerTest.php b/tests/Integration/CompanyLedgerTest.php index ca0d8abf30da..2e37078dca82 100644 --- a/tests/Integration/CompanyLedgerTest.php +++ b/tests/Integration/CompanyLedgerTest.php @@ -37,7 +37,7 @@ class CompanyLedgerTest extends TestCase use DatabaseTransactions; use MakesHash; use AppSetup; - + public $company; public $client; @@ -49,15 +49,15 @@ class CompanyLedgerTest extends TestCase public $account; public $faker; - - protected function setUp() :void + + protected function setUp(): void { parent::setUp(); $this->withoutExceptionHandling(); $this->artisan('db:seed --force'); - + $this->faker = \Faker\Factory::create(); $fake_email = $this->faker->email(); @@ -91,7 +91,7 @@ class CompanyLedgerTest extends TestCase $user = User::whereEmail($fake_email)->first(); - + if (! $user) { $user = User::factory()->create([ 'email' => $fake_email, @@ -109,7 +109,7 @@ class CompanyLedgerTest extends TestCase $this->token = \Illuminate\Support\Str::random(64); - $company_token = new CompanyToken; + $company_token = new CompanyToken(); $company_token->user_id = $user->id; $company_token->company_id = $this->company->id; $company_token->account_id = $this->account->id; @@ -170,7 +170,7 @@ class CompanyLedgerTest extends TestCase // $i->service()->markSent()->save(); // $i = $i->fresh(); - + // // \Illuminate\Support\Facades\Bus::fake(); // // \Illuminate\Support\Facades\Bus::assertDispatched(UpdateLedger::class); @@ -190,7 +190,7 @@ class CompanyLedgerTest extends TestCase // $cl = CompanyLedger::where('client_id', $i->client_id) // ->orderBy('id', 'desc') // ->first(); - + // $cl = $i->company_ledger()->orderBy('id','desc')->first(); // (new UpdateLedger($cl->id, $i->amount, $i->company->company_key, $i->company->db))->handle(); // $cl = $cl->fresh(); @@ -284,10 +284,10 @@ class CompanyLedgerTest extends TestCase 'date' => '2020/12/11', ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); $acc = $response->json(); diff --git a/tests/Integration/ContainerTest.php b/tests/Integration/ContainerTest.php index c125c3f17088..610b2db5bf9f 100644 --- a/tests/Integration/ContainerTest.php +++ b/tests/Integration/ContainerTest.php @@ -22,7 +22,7 @@ class ContainerTest extends TestCase { use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Integration/DTO/AccountSummaryTest.php b/tests/Integration/DTO/AccountSummaryTest.php index 52ec5b6ebd84..b703b1ca3d3e 100644 --- a/tests/Integration/DTO/AccountSummaryTest.php +++ b/tests/Integration/DTO/AccountSummaryTest.php @@ -18,53 +18,52 @@ use Tests\TestCase; */ class AccountSummaryTest extends TestCase { - private $data = [ [ - "CONTAINER"=> "bank", - "providerAccountId"=> 330, - "accountName"=> "Business Acct", - "accountStatus"=> "ACTIVE", - "accountNumber"=> "1012", - "aggregationSource"=> "USER", - "isAsset"=> true, - "balance"=> [ - "currency"=> "AUD", - "amount"=> 44.98, + "CONTAINER" => "bank", + "providerAccountId" => 330, + "accountName" => "Business Acct", + "accountStatus" => "ACTIVE", + "accountNumber" => "1012", + "aggregationSource" => "USER", + "isAsset" => true, + "balance" => [ + "currency" => "AUD", + "amount" => 44.98, ], - "id"=> 19315, - "includeInNetWorth"=> true, - "providerId"=> "3857", - "providerName"=> "Bank", - "isManual"=> false, - "availableBalance"=> [ - "currency"=> "AUD", - "amount"=> 34.98, + "id" => 19315, + "includeInNetWorth" => true, + "providerId" => "3857", + "providerName" => "Bank", + "isManual" => false, + "availableBalance" => [ + "currency" => "AUD", + "amount" => 34.98, ], - "currentBalance"=> [ - "currency"=> "AUD", - "amount"=> 344.98, + "currentBalance" => [ + "currency" => "AUD", + "amount" => 344.98, ], - "accountType"=> "CHECKING", - "displayedName"=> "after David", - "createdDate"=> "2023-01-10T08=>29=>07Z", - "classification"=> "", - "lastUpdated"=> "2023-08-01T23=>50=>13Z", - "nickname"=> "Busines Acct", - "bankTransferCode"=> [ + "accountType" => "CHECKING", + "displayedName" => "after David", + "createdDate" => "2023-01-10T08=>29=>07Z", + "classification" => "", + "lastUpdated" => "2023-08-01T23=>50=>13Z", + "nickname" => "Busines Acct", + "bankTransferCode" => [ [ - "id"=> "062", - "type"=> "BSB", + "id" => "062", + "type" => "BSB", ], ], - "dataset"=> [ + "dataset" => [ [ - "name"=> "BASIC_AGG_DATA", - "additionalStatus"=> "AVAILABLE_DATA_RETRIEVED", - "updateEligibility"=> "ALLOW_UPDATE", - "lastUpdated"=> "2023-08-01T23=>49=>53Z", - "lastUpdateAttempt"=> "2023-08-01T23=>49=>53Z", - "nextUpdateScheduled"=> "2023-08-03T14=>45=>14Z", + "name" => "BASIC_AGG_DATA", + "additionalStatus" => "AVAILABLE_DATA_RETRIEVED", + "updateEligibility" => "ALLOW_UPDATE", + "lastUpdated" => "2023-08-01T23=>49=>53Z", + "lastUpdateAttempt" => "2023-08-01T23=>49=>53Z", + "nextUpdateScheduled" => "2023-08-03T14=>45=>14Z", ], ], ] @@ -72,50 +71,50 @@ class AccountSummaryTest extends TestCase private $bad_data = [ [ - "CONTAINER"=> "bank", - "providerAccountId"=> 10090, - "accountName"=> "Business Trans Acct", + "CONTAINER" => "bank", + "providerAccountId" => 10090, + "accountName" => "Business Trans Acct", // "accountStatus"=> "ACTIVE", - "accountNumber"=> "4402", - "aggregationSource"=> "USER", - "isAsset"=> true, - "balance"=> [ - "currency"=> "AUD", - "amount"=> 34.98, + "accountNumber" => "4402", + "aggregationSource" => "USER", + "isAsset" => true, + "balance" => [ + "currency" => "AUD", + "amount" => 34.98, ], - "id"=> 19315, - "includeInNetWorth"=> true, - "providerId"=> "37", - "providerName"=> "Bank", - "isManual"=> false, + "id" => 19315, + "includeInNetWorth" => true, + "providerId" => "37", + "providerName" => "Bank", + "isManual" => false, // "availableBalance"=> [ // "currency"=> "AUD", // "amount"=> 7.98, // ], - "currentBalance"=> [ - "currency"=> "AUD", - "amount"=> 344.98, + "currentBalance" => [ + "currency" => "AUD", + "amount" => 344.98, ], - "accountType"=> "CHECKING", - "displayedName"=> "after David", - "createdDate"=> "2023-01-10T08=>29=>07Z", - "classification"=> "SMALL_BUSINESS", - "lastUpdated"=> "2023-08-01T23=>50=>13Z", - "nickname"=> "Busines Acct", - "bankTransferCode"=> [ + "accountType" => "CHECKING", + "displayedName" => "after David", + "createdDate" => "2023-01-10T08=>29=>07Z", + "classification" => "SMALL_BUSINESS", + "lastUpdated" => "2023-08-01T23=>50=>13Z", + "nickname" => "Busines Acct", + "bankTransferCode" => [ [ - "id"=> "060", - "type"=> "BSB", + "id" => "060", + "type" => "BSB", ], ], - "dataset"=> [ + "dataset" => [ [ - "name"=> "BASIC_AGG_DATA", - "additionalStatus"=> "AVAILABLE_DATA_RETRIEVED", - "updateEligibility"=> "ALLOW_UPDATE", - "lastUpdated"=> "2023-08-01T23=>49=>53Z", - "lastUpdateAttempt"=> "2023-08-01T23=>49=>53Z", - "nextUpdateScheduled"=> "2023-08-03T14=>45=>14Z", + "name" => "BASIC_AGG_DATA", + "additionalStatus" => "AVAILABLE_DATA_RETRIEVED", + "updateEligibility" => "ALLOW_UPDATE", + "lastUpdated" => "2023-08-01T23=>49=>53Z", + "lastUpdateAttempt" => "2023-08-01T23=>49=>53Z", + "nextUpdateScheduled" => "2023-08-03T14=>45=>14Z", ], ], ] @@ -123,7 +122,7 @@ class AccountSummaryTest extends TestCase - protected function setUp() :void + protected function setUp(): void { parent::setUp(); } @@ -131,40 +130,40 @@ class AccountSummaryTest extends TestCase public function testTransformRefactor() { - $dto = $this->transformSummary($this->data[0]); - $this->assertEquals($dto->id, 19315); - $this->assertEquals($dto->provider_account_id, 330); - $this->assertEquals($dto->account_type, $this->data[0]['CONTAINER'] ?? ''); - $this->assertEquals($dto->account_status, $this->data[0]['accountStatus'] ?? ''); - $this->assertEquals($dto->account_number, $this->data[0]['accountNumber'] ?? ''); - $this->assertEquals($dto->provider_account_id, $this->data[0]['providerAccountId'] ?? ''); - $this->assertEquals($dto->provider_id, $this->data[0]['providerId'] ?? ''); - $this->assertEquals($dto->provider_name, $this->data[0]['providerName'] ?? ''); - $this->assertEquals($dto->nickname, $this->data[0]['nickname'] ?? ''); - $this->assertEquals($dto->account_name, $this->data[0]['accountName'] ?? ''); - $this->assertEquals($dto->current_balance, $this->data[0]['currentBalance']['amount'] ?? 0); - $this->assertEquals($dto->account_currency, $this->data[0]['currentBalance']['currency'] ?? 0); + $dto = $this->transformSummary($this->data[0]); + $this->assertEquals($dto->id, 19315); + $this->assertEquals($dto->provider_account_id, 330); + $this->assertEquals($dto->account_type, $this->data[0]['CONTAINER'] ?? ''); + $this->assertEquals($dto->account_status, $this->data[0]['accountStatus'] ?? ''); + $this->assertEquals($dto->account_number, $this->data[0]['accountNumber'] ?? ''); + $this->assertEquals($dto->provider_account_id, $this->data[0]['providerAccountId'] ?? ''); + $this->assertEquals($dto->provider_id, $this->data[0]['providerId'] ?? ''); + $this->assertEquals($dto->provider_name, $this->data[0]['providerName'] ?? ''); + $this->assertEquals($dto->nickname, $this->data[0]['nickname'] ?? ''); + $this->assertEquals($dto->account_name, $this->data[0]['accountName'] ?? ''); + $this->assertEquals($dto->current_balance, $this->data[0]['currentBalance']['amount'] ?? 0); + $this->assertEquals($dto->account_currency, $this->data[0]['currentBalance']['currency'] ?? 0); - $dto_array = (array)$dto; + $dto_array = (array)$dto; - $this->assertEquals($dto_array['id'], 19315); - $this->assertEquals($dto_array['provider_account_id'], 330); - $this->assertEquals($dto_array['account_type'], $this->data[0]['CONTAINER'] ?? ''); - $this->assertEquals($dto_array['account_status'], $this->data[0]['accountStatus'] ?? ''); - $this->assertEquals($dto_array['account_number'], $this->data[0]['accountNumber'] ?? ''); - $this->assertEquals($dto_array['provider_account_id'], $this->data[0]['providerAccountId'] ?? ''); - $this->assertEquals($dto_array['provider_id'], $this->data[0]['providerId'] ?? ''); - $this->assertEquals($dto_array['provider_name'], $this->data[0]['providerName'] ?? ''); - $this->assertEquals($dto_array['nickname'], $this->data[0]['nickname'] ?? ''); - $this->assertEquals($dto_array['account_name'], $this->data[0]['accountName'] ?? ''); - $this->assertEquals($dto_array['current_balance'], $this->data[0]['currentBalance']['amount'] ?? 0); - $this->assertEquals($dto_array['account_currency'], $this->data[0]['currentBalance']['currency'] ?? 0); + $this->assertEquals($dto_array['id'], 19315); + $this->assertEquals($dto_array['provider_account_id'], 330); + $this->assertEquals($dto_array['account_type'], $this->data[0]['CONTAINER'] ?? ''); + $this->assertEquals($dto_array['account_status'], $this->data[0]['accountStatus'] ?? ''); + $this->assertEquals($dto_array['account_number'], $this->data[0]['accountNumber'] ?? ''); + $this->assertEquals($dto_array['provider_account_id'], $this->data[0]['providerAccountId'] ?? ''); + $this->assertEquals($dto_array['provider_id'], $this->data[0]['providerId'] ?? ''); + $this->assertEquals($dto_array['provider_name'], $this->data[0]['providerName'] ?? ''); + $this->assertEquals($dto_array['nickname'], $this->data[0]['nickname'] ?? ''); + $this->assertEquals($dto_array['account_name'], $this->data[0]['accountName'] ?? ''); + $this->assertEquals($dto_array['current_balance'], $this->data[0]['currentBalance']['amount'] ?? 0); + $this->assertEquals($dto_array['account_currency'], $this->data[0]['currentBalance']['currency'] ?? 0); } private function transformSummary($summary) { - $dto = new \stdClass; + $dto = new \stdClass(); $dto->id = $summary['id'] ?? 0; $dto->account_type = $summary['CONTAINER'] ?? ''; diff --git a/tests/Integration/DownloadHistoricalInvoiceTest.php b/tests/Integration/DownloadHistoricalInvoiceTest.php index 2389b0206ae1..a56a7cd56acc 100644 --- a/tests/Integration/DownloadHistoricalInvoiceTest.php +++ b/tests/Integration/DownloadHistoricalInvoiceTest.php @@ -28,7 +28,7 @@ class DownloadHistoricalInvoiceTest extends TestCase use DatabaseTransactions; use MakesHash; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -115,7 +115,7 @@ class DownloadHistoricalInvoiceTest extends TestCase { $activity_repo = new ActivityRepository(); - $obj = new \stdClass; + $obj = new \stdClass(); $obj->invoice_id = $this->invoice->id; $obj->user_id = $this->invoice->user_id; $obj->company_id = $this->company->id; diff --git a/tests/Integration/Einvoice/Fact1Test.php b/tests/Integration/Einvoice/Fact1Test.php index 3bd189187cb8..2b611cc3f474 100644 --- a/tests/Integration/Einvoice/Fact1Test.php +++ b/tests/Integration/Einvoice/Fact1Test.php @@ -91,8 +91,8 @@ class FACT1Test extends TestCase $settings = ClientSettings::defaults(); $settings->currency_id = '42'; -//VAT -//19% + //VAT + //19% $client = Client::factory() ->create([ 'user_id' => $this->user->id, @@ -118,7 +118,7 @@ class FACT1Test extends TestCase $items = []; - $item = new InvoiceItem; + $item = new InvoiceItem(); $item->cost = 10; $item->quantity = 10; $item->tax_name1 = 'VAT'; @@ -130,16 +130,16 @@ class FACT1Test extends TestCase 'user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $client->id, - 'number' => 'INV-'.rand(1000,1000000), + 'number' => 'INV-'.rand(1000, 1000000), 'line_items' => [$item], 'due_date' => now()->addDays(20)->format('Y-m-d'), 'status_id' => 1, 'discount' => 0, ]); - + $_invoice->service()->markSent()->save(); $calc = $_invoice->calc(); - + $invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice(); $invoice->UBLVersionID = '2.1'; $invoice->CustomizationID = 'urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.1'; @@ -152,18 +152,18 @@ class FACT1Test extends TestCase $asp = new AccountingSupplierParty(); $party = new Party(); - + $party_identification = new PartyIdentification(); $party_identification->ID = 'company_id_number'; $party->PartyIdentification[] = $party_identification; - + $sp_address = new PostalAddress(); $sp_address->StreetName = $this->company->settings->address1; $sp_address->CityName = 'SECTOR2'; $sp_address->CountrySubentity = 'RO-B'; $country = new Country(); - $country->IdentificationCode='RO'; + $country->IdentificationCode = 'RO'; $sp_address->Country = $country; $party->PostalAddress = $sp_address; @@ -237,7 +237,7 @@ class FACT1Test extends TestCase $tc->ID = "S"; $taxable = $this->getTaxable($_invoice); - + $taxable_amount = new TaxableAmount(); $taxable_amount->amount = $taxable; $taxable_amount->currencyID = $_invoice->client->currency()->code; @@ -247,9 +247,9 @@ class FACT1Test extends TestCase $tax_sub_total->TaxCategory = $tc; $tax_sub_total->TaxableAmount = $taxable_amount; $taxtotal->TaxSubtotal[] = $tax_sub_total; - + $invoice->TaxTotal[] = $taxtotal; - + $lmt = new LegalMonetaryTotal(); $lea = new LineExtensionAmount(); @@ -258,35 +258,34 @@ class FACT1Test extends TestCase $lmt->LineExtensionAmount = $lea; - $tea = new TaxExclusiveAmount; + $tea = new TaxExclusiveAmount(); $tea->amount = $taxable; $tea->currencyID = $_invoice->client->currency()->code; $lmt->TaxExclusiveAmount = $tea; - $tia = new TaxInclusiveAmount; + $tia = new TaxInclusiveAmount(); $tia->amount = $_invoice->amount; $tia->currencyID = $_invoice->client->currency()->code; $lmt->TaxInclusiveAmount = $tia; - $pa = new PayableAmount; + $pa = new PayableAmount(); $pa->amount = $_invoice->amount; $pa->currencyID = $_invoice->client->currency()->code; $lmt->PayableAmount = $pa; $invoice->LegalMonetaryTotal = $lmt; - foreach($_invoice->line_items as $key => $item) - { + foreach($_invoice->line_items as $key => $item) { - $invoice_line = new InvoiceLine; + $invoice_line = new InvoiceLine(); $invoice_line->ID = $key++; $iq = new InvoicedQuantity(); $iq->amount = $item->cost; $iq->unitCode = 'H87'; - + $invoice_line->InvoicedQuantity = $iq; $invoice_line->Note = substr($item->notes, 0, 200); @@ -294,7 +293,7 @@ class FACT1Test extends TestCase $ctc = new ClassifiedTaxCategory(); $ctc->ID = 'S'; - $i = new Item; + $i = new Item(); $i->Description = $item->notes; $i->Name = $item->product_key; @@ -311,7 +310,7 @@ class FACT1Test extends TestCase $invoice_line->Item = $i; - $lea = new LineExtensionAmount; + $lea = new LineExtensionAmount(); $lea->amount = $item->line_total; $lea->currencyID = $_invoice->client->currency()->code; @@ -327,7 +326,7 @@ class FACT1Test extends TestCase $lea = new LineExtensionAmount(); $lea->amount = $item->line_total; $lea->currencyID = $_invoice->client->currency()->code; - + $invoice_line->LineExtensionAmount = $lea; $invoice->InvoiceLine[] = $invoice_line; @@ -375,7 +374,7 @@ class FACT1Test extends TestCase $discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory); $normalizer = new ObjectNormalizer($classMetadataFactory, $metadataAwareNameConverter, null, $propertyInfo); - + $normalizers = [ new DateTimeNormalizer(), $normalizer, new ArrayDenormalizer() , ]; $encoders = [$encoder, new JsonEncoder()]; $serializer = new Serializer($normalizers, $encoders); @@ -385,7 +384,7 @@ class FACT1Test extends TestCase // AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES => true, ]; - + // $invoice = $normalizer->normalize($invoice, 'json', $n_context); // echo print_r($invoice); // $invoice = $serializer->serialize($invoice, 'xml', $n_context); diff --git a/tests/Integration/Einvoice/Storecove/StorecoveTest.php b/tests/Integration/Einvoice/Storecove/StorecoveTest.php index 32c373d70647..155bcb3a1a3c 100644 --- a/tests/Integration/Einvoice/Storecove/StorecoveTest.php +++ b/tests/Integration/Einvoice/Storecove/StorecoveTest.php @@ -37,34 +37,35 @@ class StorecoveTest extends TestCase $this->makeTestData(); - if (config('ninja.testvars.travis') !== false || !config('ninja.storecove_api_key')) + if (config('ninja.testvars.travis') !== false || !config('ninja.storecove_api_key')) { $this->markTestSkipped("do not run in CI"); + } } // public function testCreateLegalEntity() // { - // $data = [ - // 'acts_as_receiver' => true, - // 'acts_as_sender' => true, - // 'advertisements' => ['invoice'], - // 'city' => $this->company->settings->city, - // 'country' => 'DE', - // 'county' => $this->company->settings->state, - // 'line1' => $this->company->settings->address1, - // 'line2' => $this->company->settings->address2, - // 'party_name' => $this->company->present()->name(), - // 'tax_registered' => true, - // 'tenant_id' => $this->company->company_key, - // 'zip' => $this->company->settings->postal_code, - // 'peppol_identifiers' => [ - // 'scheme' => 'DE:VAT', - // 'id' => 'DE:VAT' - // ], - // ]; + // $data = [ + // 'acts_as_receiver' => true, + // 'acts_as_sender' => true, + // 'advertisements' => ['invoice'], + // 'city' => $this->company->settings->city, + // 'country' => 'DE', + // 'county' => $this->company->settings->state, + // 'line1' => $this->company->settings->address1, + // 'line2' => $this->company->settings->address2, + // 'party_name' => $this->company->present()->name(), + // 'tax_registered' => true, + // 'tenant_id' => $this->company->company_key, + // 'zip' => $this->company->settings->postal_code, + // 'peppol_identifiers' => [ + // 'scheme' => 'DE:VAT', + // 'id' => 'DE:VAT' + // ], + // ]; - // $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove(); - // $r = $sc->createLegalEntity($data, $this->company); + // $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove(); + // $r = $sc->createLegalEntity($data, $this->company); // $this->assertIsArray($r); @@ -72,12 +73,12 @@ class StorecoveTest extends TestCase // public function testAddPeppolIdentifier() // { - + // $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove(); // $r = $sc->addIdentifier(291394, "DE923356489", "DE:VAT"); // nlog($r); - + // } // public function testUpdateLegalEntity() @@ -96,306 +97,306 @@ class StorecoveTest extends TestCase // nlog($r); // } -/* - public function testGetLegalEntity() - { - - $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove(); - $r = $sc->getLegalEntity(290868); + /* + public function testGetLegalEntity() + { - $this->assertIsArray($r); + $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove(); + $r = $sc->getLegalEntity(290868); - } + $this->assertIsArray($r); - public function testSendDocument() - { + } - $x = ' - -