php-cs-fix for tests

This commit is contained in:
David Bomba
2025-10-29 11:13:52 +11:00
parent 6f1ebf57a9
commit b08c575b35
266 changed files with 2211 additions and 1997 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -17,7 +18,6 @@ use Illuminate\Validation\ValidationException;
use Tests\MockAccountData;
use Tests\TestCase;
class ActivityApiTest extends TestCase
{
use DatabaseTransactions;

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*

View File

@@ -45,7 +45,7 @@ class BankTransactionRuleTest extends TestCase
$this->markTestSkipped('ignore');
}
public function testNewCreditMatchingRulesInvoiceStartsWith()
public function testNewCreditMatchingRulesInvoiceStartsWith()
{
$bi = BankIntegration::factory()->create([
@@ -55,7 +55,7 @@ class BankTransactionRuleTest extends TestCase
]);
$hash = Str::random(32);
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -115,7 +115,7 @@ class BankTransactionRuleTest extends TestCase
]);
$hash = Str::random(32);
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -175,7 +175,7 @@ class BankTransactionRuleTest extends TestCase
]);
$hash = Str::random(32);
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -236,7 +236,7 @@ class BankTransactionRuleTest extends TestCase
]);
$hash = Str::random(32);
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -295,7 +295,7 @@ class BankTransactionRuleTest extends TestCase
]);
$hash = Str::random(32);
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -352,7 +352,7 @@ class BankTransactionRuleTest extends TestCase
]);
$hash = Str::random(32);
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -392,7 +392,7 @@ class BankTransactionRuleTest extends TestCase
(new ProcessBankRules($bt))->run();
$bt = $bt->fresh();
$bt = $bt->fresh();
$this->assertEquals(BankTransaction::STATUS_MATCHED, $bt->status_id);
$this->assertNotNull($p->id);
@@ -410,7 +410,7 @@ $bt = $bt->fresh();
]);
$hash = md5(time());
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -450,7 +450,7 @@ $bt = $bt->fresh();
(new ProcessBankRules($bt))->run();
$bt = $bt->fresh();
$bt = $bt->fresh();
$this->assertEquals(BankTransaction::STATUS_MATCHED, $bt->status_id);
$this->assertNotNull($p->id);
@@ -468,7 +468,7 @@ $bt = $bt->fresh();
]);
$hash = md5(time());
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -508,7 +508,7 @@ $bt = $bt->fresh();
(new ProcessBankRules($bt))->run();
$bt = $bt->fresh();
$bt = $bt->fresh();
$this->assertEquals(BankTransaction::STATUS_MATCHED, $bt->status_id);
$this->assertNotNull($p->id);
@@ -526,7 +526,7 @@ $bt = $bt->fresh();
]);
$hash = Str::random(32);
$rand_amount = rand(1000,10000000);
$rand_amount = rand(1000, 10000000);
$bt = BankTransaction::factory()->create([
'bank_integration_id' => $bi->id,
@@ -566,7 +566,7 @@ $bt = $bt->fresh();
(new ProcessBankRules($bt))->run();
$bt = $bt->fresh();
$bt = $bt->fresh();
$this->assertEquals(BankTransaction::STATUS_MATCHED, $bt->status_id);
$this->assertNotNull($p->id);

View File

@@ -43,10 +43,10 @@ class BankTransactionTest extends TestCase
public function testBankIntegrationFilters()
{
BankTransaction::where('company_id', $this->company->id)
->cursor()->each(function($bt){
->cursor()->each(function ($bt) {
$bt->forceDelete();
});
$bi = BankIntegrationFactory::create($this->company->id, $this->user->id, $this->account->id);
$bi->bank_account_name = "Bank1";
$bi->save();
@@ -133,7 +133,7 @@ class BankTransactionTest extends TestCase
$this->assertCount(2, $arr['data']);
$bi2->delete();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -18,7 +19,6 @@ use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
class BankIntegrationApiTest extends TestCase
{
use MakesHash;

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -21,7 +22,6 @@ use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
class BankTransactionApiTest extends TestCase
{
use MakesHash;

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -18,7 +19,6 @@ use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
class BankTransactionRuleApiTest extends TestCase
{
use MakesHash;

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -19,7 +20,6 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\MockAccountData;
use Tests\TestCase;
class CancelInvoiceTest extends TestCase
{
use MakesHash;

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -17,7 +18,7 @@ use Tests\MockUnitData;
use Tests\TestCase;
/**
*
*
*/
class ClassificationTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -43,7 +44,7 @@ class ClientApiTest extends TestCase
public $faker;
public $settings;
protected function setUp(): void
{
parent::setUp();

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -20,7 +21,6 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ClientGatewayTokenApiTest extends TestCase
{
use MakesHash;
@@ -100,7 +100,7 @@ class ClientGatewayTokenApiTest extends TestCase
public function testCompanyGatewaySettableOnToken()
{
$data = [
'client_id' => $this->client->hashed_id,
'company_gateway_id' => $this->cg->hashed_id,
@@ -198,14 +198,12 @@ class ClientGatewayTokenApiTest extends TestCase
$arr = $response->json();
$this->assertCount(2,$arr['data']['gateway_tokens']);
foreach($arr['data']['gateway_tokens'] as $token)
{
if($token['id'] == $t1){
$this->assertCount(2, $arr['data']['gateway_tokens']);
foreach ($arr['data']['gateway_tokens'] as $token) {
if ($token['id'] == $t1) {
$this->assertTrue($token['is_default']);
}
else {
} else {
$this->assertFalse($token['is_default']);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -37,7 +38,7 @@ 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');
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -16,7 +17,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Models\Presenters\ClientPresenter
*/
class ClientPresenterTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -37,7 +38,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
*
*
* App\Http\Controllers\ClientController
*/
class ClientTest extends TestCase
@@ -169,7 +170,7 @@ 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']);
}
@@ -206,7 +207,7 @@ class ClientTest extends TestCase
public function testClientIsPrimaryScalarTransform()
{
$data = [
'address1' => '105 Drive',
'address2' => '122',
'city' => 'NoRoses',
@@ -226,7 +227,7 @@ class ClientTest extends TestCase
'private_notes' => 'DMARC Client | Tenant ID: 45 | Team Name: Targas',
'state' => 'Gauteng',
'vat_number' => 'VAT: 33'
];
$response = $this->withHeaders([
@@ -687,16 +688,16 @@ class ClientTest extends TestCase
];
// try {
$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);
// } catch (ValidationException $e) {
// $message = json_decode($e->validator->getMessageBag(), 1);
// $this->assertNotNull($message);
// }
$response->assertStatus(422);
$response->assertStatus(422);
}
public function testCreatingClientAndContacts()
@@ -781,10 +782,10 @@ class ClientTest extends TestCase
$response = null;
// try {
$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);
// } catch (ValidationException $e) {
// $message = json_decode($e->validator->getMessageBag(), 1);
// $this->assertNotNull($message);
@@ -805,10 +806,10 @@ class ClientTest extends TestCase
$response = null;
// try {
$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);
// } catch (ValidationException $e) {
// $message = json_decode($e->validator->getMessageBag(), 1);
// }
@@ -832,10 +833,10 @@ class ClientTest extends TestCase
$response = null;
// try {
$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);
// } catch (ValidationException $e) {
// $message = json_decode($e->validator->getMessageBag(), 1);
// $this->assertNotNull($message);
@@ -869,10 +870,10 @@ class ClientTest extends TestCase
$response = null;
// try {
$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);
// } catch (ValidationException $e) {
// $message = json_decode($e->validator->getMessageBag(), 1);
// $this->assertNotNull($message);
@@ -903,10 +904,10 @@ class ClientTest extends TestCase
$response = null;
// try {
$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);
// } catch (ValidationException $e) {
// $message = json_decode($e->validator->getMessageBag(), 1);
// $this->assertNotNull($message);
@@ -938,10 +939,10 @@ class ClientTest extends TestCase
$response = null;
// try {
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/clients/'.$this->client->hashed_id, $data);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/clients/'.$this->client->hashed_id, $data);
// } catch (ValidationException $e) {
// $message = json_decode($e->validator->getMessageBag(), 1);
// $this->assertNotNull($message);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Models\CompanyGateway
*/
class CompanyGatewayApiTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -23,7 +24,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class CompanyGatewayResolutionTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -21,7 +22,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Models\CompanyGateway
*/
class CompanyGatewayTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -22,7 +23,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Utils\Traits\CompanySettingsSaver
*/
class CompanySettingsTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -27,7 +28,7 @@ use App\Http\Middleware\PasswordProtection;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
*
*
* App\Http\Controllers\CompanyController
*/
class CompanyTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -22,7 +23,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\TokenController
*/
class CompanyTokenApiTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -53,7 +54,7 @@ class CreditTest extends TestCase
'balance' => 0,
'paid_to_date' => 0,
]);
$ii = new InvoiceItem();
$ii->cost = 100;
$ii->quantity = 1;
@@ -79,7 +80,7 @@ class CreditTest extends TestCase
$repo = new InvoiceRepository();
$repo->save([], $i);
$i = $i->calc()->getInvoice();
$i = $i->service()->markPaid()->save(); //paid
@@ -122,7 +123,7 @@ class CreditTest extends TestCase
'id' => $payment->hashed_id,
'amount' => 100,
'date' => '2020/12/12',
'invoices' => [
[
'invoice_id' => $i->hashed_id,
@@ -146,7 +147,7 @@ class CreditTest extends TestCase
$this->assertEquals(\App\Models\Payment::STATUS_REFUNDED, $payment->status_id);
$this->assertEquals(0, $credit->balance);
$this->assertEquals(Credit::STATUS_APPLIED, $credit->status_id);
$this->assertEquals(0, $client->paid_to_date);
$this->assertEquals(0, $client->balance);
@@ -163,7 +164,7 @@ class CreditTest extends TestCase
$this->assertEquals(0, $client->paid_to_date);
$this->assertEquals(0, $client->balance);
$this->assertEquals(0, $credit->balance);
$this->assertEquals(Credit::STATUS_APPLIED, $credit->status_id);
}
@@ -175,7 +176,7 @@ class CreditTest extends TestCase
'balance' => 0,
'paid_to_date' => 0,
]);
$ii = new InvoiceItem();
$ii->cost = 100;
$ii->quantity = 1;
@@ -201,7 +202,7 @@ class CreditTest extends TestCase
$repo = new InvoiceRepository();
$repo->save([], $i);
$i = $i->calc()->getInvoice();
$i = $i->service()->markPaid()->save();
@@ -233,7 +234,7 @@ class CreditTest extends TestCase
$i = $i->fresh();
$this->assertEquals(\App\Models\Invoice::STATUS_REVERSED, $i->status_id);
$client = $i->client;
$this->assertEquals(100, $client->credit_balance);
@@ -253,14 +254,14 @@ class CreditTest extends TestCase
public function testPartialAmountWithPartialCreditAndPaymentDeletedBalance()
{
$c = Client::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'balance' => 0,
'paid_to_date' => 0,
]);
$ii = new InvoiceItem();
$ii->cost = 100;
$ii->quantity = 1;
@@ -286,7 +287,7 @@ class CreditTest extends TestCase
$repo = new InvoiceRepository();
$repo->save([], $i);
$i = $i->calc()->getInvoice();
$i = $i->service()->markSent()->save();
@@ -319,7 +320,7 @@ class CreditTest extends TestCase
$this->assertEquals(100, $cr->balance);
$this->assertEquals(100, $cr->amount);
$data = [
'date' => '2020/12/12',
'client_id' => $c->hashed_id,
@@ -370,14 +371,14 @@ class CreditTest extends TestCase
public function testCreditReversalScenarioInvoicePartiallyPaid()
{
$c = Client::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'balance' => 0,
'paid_to_date' => 0,
]);
$ii = new InvoiceItem();
$ii->cost = 100;
$ii->quantity = 1;
@@ -409,7 +410,7 @@ class CreditTest extends TestCase
$i->service()->applyPaymentAmount(50, 'test');
$i->refresh();
$this->assertEquals(50, $i->balance);
$this->assertEquals(100, $i->amount);
@@ -417,14 +418,14 @@ class CreditTest extends TestCase
$credit_array['invoice_id'] = $i->hashed_id;
$credit_array['client_id'] = $c->hashed_id;
unset($credit_array['backup']);
$ii = new InvoiceItem();
$ii->cost = 50;
$ii->quantity = 1;
$ii->product_key = 'xx';
$ii->notes = 'yy';
$credit_array['line_items'] = [];
$credit_array['line_items'][] = (array)$ii;
@@ -452,14 +453,14 @@ class CreditTest extends TestCase
public function testCreditReversalScenarioInvoicePaidInFull()
{
$c = Client::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'balance' => 0,
'paid_to_date' => 0,
]);
$ii = new InvoiceItem();
$ii->cost = 100;
$ii->quantity = 1;
@@ -491,7 +492,7 @@ class CreditTest extends TestCase
$i->service()->applyPaymentAmount(100, 'test');
$i->refresh();
$this->assertEquals(0, $i->balance);
$this->assertEquals(100, $i->amount);
$this->assertEquals(4, $i->status_id);
@@ -501,7 +502,7 @@ class CreditTest extends TestCase
$credit_array['client_id'] = $c->hashed_id;
unset($credit_array['backup']);
$ii = new InvoiceItem();
$ii->cost = 100;
$ii->quantity = 1;
@@ -509,8 +510,8 @@ class CreditTest extends TestCase
$ii->notes = 'yy';
$credit_array['line_items'] = [];
$credit_array['line_items'][] = (array)$ii;
$credit_array['line_items'] = [];
$credit_array['line_items'][] = (array)$ii;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@@ -738,7 +739,7 @@ $credit_array['line_items'][] = (array)$ii;
$this->assertEquals(100, $cr->paid_to_date);
$this->assertEquals(4, $i->status_id);
$this->assertEquals(100, $c->paid_to_date);
$this->assertEquals(0, $c->balance);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -23,7 +24,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class DeleteInvoiceTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -27,7 +28,7 @@ use Illuminate\Support\Facades\Session;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
*
*
* App\Http\Controllers\DesignController
*/
class DesignApiTest extends TestCase
@@ -86,7 +87,7 @@ class DesignApiTest extends TestCase
$response->assertStatus(200);
$new_design_truth_test = Invoice::where('company_id', $this->company->id)->orderBy('id','asc')->where('design_id', 7)->exists();
$new_design_truth_test = Invoice::where('company_id', $this->company->id)->orderBy('id', 'asc')->where('design_id', 7)->exists();
$this->assertTrue($new_design_truth_test);
@@ -113,7 +114,7 @@ class DesignApiTest extends TestCase
////////////////////////////////////////////
// Group Settings
$gs = GroupSettingFactory::create($this->company->id, $this->user->id);
$settings = $gs->settings;
$settings->invoice_design_id = $this->encodePrimaryKey(4);
@@ -195,7 +196,7 @@ class DesignApiTest extends TestCase
$response->assertStatus(200);
$new_design_truth_test = Quote::where('company_id', $this->company->id)->orderBy('id','asc')->where('design_id', 7)->exists();
$new_design_truth_test = Quote::where('company_id', $this->company->id)->orderBy('id', 'asc')->where('design_id', 7)->exists();
$this->assertTrue($new_design_truth_test);
@@ -222,7 +223,7 @@ class DesignApiTest extends TestCase
////////////////////////////////////////////
// Group Settings
$gs = GroupSettingFactory::create($this->company->id, $this->user->id);
$settings = $gs->settings;
$settings->quote_design_id = $this->encodePrimaryKey(4);
@@ -304,7 +305,7 @@ class DesignApiTest extends TestCase
$response->assertStatus(200);
$new_design_truth_test = Credit::where('company_id', $this->company->id)->orderBy('id','asc')->where('design_id', 7)->exists();
$new_design_truth_test = Credit::where('company_id', $this->company->id)->orderBy('id', 'asc')->where('design_id', 7)->exists();
$this->assertTrue($new_design_truth_test);
@@ -331,7 +332,7 @@ class DesignApiTest extends TestCase
////////////////////////////////////////////
// Group Settings
$gs = GroupSettingFactory::create($this->company->id, $this->user->id);
$settings = $gs->settings;
$settings->credit_design_id = $this->encodePrimaryKey(4);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -21,7 +22,7 @@ use Illuminate\Support\Facades\Session;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
*
*
* App\Http\Controllers\DocumentController
*/
class DocumentsApiTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -17,7 +18,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class EInvoiceApiTest extends TestCase
{
@@ -28,7 +29,7 @@ class EInvoiceApiTest extends TestCase
{
parent::setUp();
if(!config('ninja.storecove_api_key')) {
if (!config('ninja.storecove_api_key')) {
$this->markTestSkipped('Storecove API key not set');
}
@@ -45,7 +46,7 @@ class EInvoiceApiTest extends TestCase
'entity' => 'invoice',
'entity_id' => $this->invoice->hashed_id
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -57,7 +58,7 @@ class EInvoiceApiTest extends TestCase
public function testValidationOnRoutes()
{
$data = [
'entity' => 'invoiceBLAH',
'entity_id' => $this->invoice->hashed_id
@@ -74,7 +75,7 @@ class EInvoiceApiTest extends TestCase
public function testValidationOnRoutes2()
{
$data = [
'entity' => 'invoice',
'entity_id' => 'ddf8hjdfh8'
@@ -88,4 +89,4 @@ class EInvoiceApiTest extends TestCase
$response->assertStatus(422);
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -17,7 +18,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class FacturaeTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -29,7 +30,7 @@ use InvoiceNinja\EInvoice\Models\FatturaPA\FatturaElettronicaBodyType\FatturaEle
use InvoiceNinja\EInvoice\Models\FatturaPA\FatturaElettronicaHeaderType\FatturaElettronicaHeader;
/**
*
*
*/
class FatturaPATest extends TestCase
{
@@ -129,9 +130,9 @@ class FatturaPATest extends TestCase
$e = new EInvoice();
$errors = $e->validate($fe);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}

View File

@@ -18,7 +18,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class PeppolApiTest extends TestCase
{
@@ -30,7 +30,7 @@ class PeppolApiTest extends TestCase
parent::setUp();
// if (!config('ninja.storecove_api_key')) {
$this->markTestSkipped('Storecove API key not set');
$this->markTestSkipped('Storecove API key not set');
// }
$this->makeTestData();

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -48,13 +49,13 @@ class PeppolTest extends TestCase
protected int $iterations = 10;
public $faker;
protected function setUp(): void
{
parent::setUp();
if (config('ninja.testvars.travis') !== false) {
$this->markTestSkipped('Skip test for GH Actions');
}
@@ -68,9 +69,9 @@ class PeppolTest extends TestCase
);
}
private function setupTestData(array $params = []): array
private function setupTestData(array $params = []): array
{
$settings = CompanySettings::defaults();
$settings->vat_number = $params['company_vat'] ?? 'DE123456789';
$settings->country_id = Country::where('iso_3166_2', 'DE')->first()->id;
@@ -134,7 +135,7 @@ class PeppolTest extends TestCase
/** @var ClientContact $contact */
$contact = ClientContact::factory()->create([
'client_id' => $client->id,
'company_id' =>$client->company_id,
'company_id' => $client->company_id,
'user_id' => $client->user_id,
'first_name' => $this->faker->firstName(),
'last_name' => $this->faker->lastName(),
@@ -162,16 +163,15 @@ class PeppolTest extends TestCase
'status_id' => Invoice::STATUS_DRAFT,
]);
$items = $invoice->line_items;
foreach($items as &$item)
{
$item->tax_name2 = '';
$item->tax_rate2 = 0;
$item->tax_name3 = '';
$item->tax_rate3 = 0;
$item->uses_inclusive_taxes = false;
foreach ($items as &$item) {
$item->tax_name2 = '';
$item->tax_rate2 = 0;
$item->tax_name3 = '';
$item->tax_rate3 = 0;
$item->uses_inclusive_taxes = false;
}
unset($item);
@@ -186,7 +186,7 @@ class PeppolTest extends TestCase
public function testInvoicePeriodValidation()
{
$scenario = [
'company_vat' => 'DE923356489',
'company_country' => 'DE',
@@ -214,7 +214,7 @@ class PeppolTest extends TestCase
'EndDate' => 'boop',
'Description' => 'Mustafa',
'HelterSkelter' => 'sif'
]
]
]
]
];
@@ -223,12 +223,12 @@ class PeppolTest extends TestCase
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/invoices/'.$invoice->hashed_id, $data);
$response->assertStatus(422);
}
public function testInvoiceValidationWithSmallDiscount()
public function testInvoiceValidationWithSmallDiscount()
{
$scenario = [
'company_vat' => 'DE923356489',
@@ -243,7 +243,7 @@ class PeppolTest extends TestCase
'is_tax_exempt' => false,
];
$entity_data = $this->setupTestData($scenario);
$invoice = $entity_data['invoice'];
@@ -251,11 +251,11 @@ class PeppolTest extends TestCase
$invoice->is_amount_discount = true;
$invoice->discount = 0;
$invoice->uses_inclusive_taxes = false;
$item = new InvoiceItem();
$item->quantity = 1;
$item->cost = 10000;
$item->product_key = 'test';
$item->product_key = 'test';
$item->notes = 'Description';
$item->is_amount_discount = true;
$item->discount = 1;
@@ -300,7 +300,7 @@ class PeppolTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/einvoice/validateEntity', $data);
if($response->getStatusCode() !== 200){
if ($response->getStatusCode() !== 200) {
$p = new Peppol($invoice);
nlog($p->run()->toXml());
@@ -313,7 +313,7 @@ class PeppolTest extends TestCase
}
public function testEntityValidationFailsForInvoiceViaInvoice()
public function testEntityValidationFailsForInvoiceViaInvoice()
{
$scenario = [
'company_vat' => 'DE923356489',
@@ -328,7 +328,7 @@ class PeppolTest extends TestCase
'is_tax_exempt' => false,
];
$entity_data = $this->setupTestData($scenario);
$invoice = $entity_data['invoice'];
@@ -352,7 +352,7 @@ class PeppolTest extends TestCase
}
public function testEntityValidationFailsForClientViaClient()
public function testEntityValidationFailsForClientViaClient()
{
$scenario = [
'company_vat' => 'DE923356489',
@@ -367,7 +367,7 @@ class PeppolTest extends TestCase
'is_tax_exempt' => false,
];
$entity_data = $this->setupTestData($scenario);
$invoice = $entity_data['invoice'];
@@ -390,7 +390,7 @@ class PeppolTest extends TestCase
}
public function testEntityValidationFailsForClientViaInvoice()
public function testEntityValidationFailsForClientViaInvoice()
{
$scenario = [
'company_vat' => 'DE923356489',
@@ -442,7 +442,7 @@ class PeppolTest extends TestCase
'is_tax_exempt' => false,
];
$entity_data = $this->setupTestData($scenario);
$invoice = $entity_data['invoice'];
@@ -479,7 +479,7 @@ class PeppolTest extends TestCase
'is_tax_exempt' => false,
];
$entity_data = $this->setupTestData($scenario);
$invoice = $entity_data['invoice'];
@@ -503,7 +503,7 @@ class PeppolTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/einvoice/validateEntity', $data);
if($response->getStatusCode() !== 422){
if ($response->getStatusCode() !== 422) {
$p = new Peppol($invoice);
nlog($p->run()->toXml());
@@ -530,7 +530,7 @@ class PeppolTest extends TestCase
'is_tax_exempt' => false,
];
$entity_data = $this->setupTestData($scenario);
$invoice = $entity_data['invoice'];
@@ -571,7 +571,7 @@ class PeppolTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/einvoice/validateEntity', $data);
if($response->getStatusCode() !== 200){
if ($response->getStatusCode() !== 200) {
$p = new Peppol($invoice);
nlog($p->run()->toXml());
@@ -661,8 +661,7 @@ class PeppolTest extends TestCase
],
];
foreach($scenarios as $scenario)
{
foreach ($scenarios as $scenario) {
$data = $this->setupTestData($scenario);
$invoice = $data['invoice'];
@@ -705,17 +704,17 @@ class PeppolTest extends TestCase
$this->assertCount(0, $validator->getErrors());
}
for($x=0; $x< $this->iterations; $x++){
for ($x = 0; $x < $this->iterations; $x++) {
$scenario = $scenarios[0];
$data = $this->setupTestData($scenario);
$invoice = $data['invoice'];
$invoice = $invoice->calc()->getInvoice();
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$invoice->e_invoice = [
@@ -767,7 +766,7 @@ class PeppolTest extends TestCase
$invoice = $data['invoice'];
$invoice = $invoice->calc()->getInvoice();
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
@@ -911,7 +910,7 @@ class PeppolTest extends TestCase
$peppol->setInvoiceDefaults();
$peppol->run();
nlog($peppol->toXml());
// nlog($peppol->toObject());
@@ -927,7 +926,7 @@ class PeppolTest extends TestCase
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}
@@ -992,7 +991,7 @@ class PeppolTest extends TestCase
$client_settings = ClientSettings::defaults();
$client_settings->currency_id = '3';
$client_settings->enable_e_invoice = true;
$client = Client::factory()->create([
'company_id' => $company->id,
'user_id' => $this->user->id,
@@ -1041,7 +1040,7 @@ class PeppolTest extends TestCase
]);
$invoice = $invoice->calc()->getInvoice();
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
@@ -1056,7 +1055,7 @@ class PeppolTest extends TestCase
$peppol->setInvoiceDefaults();
$peppol->run();
// $peppol->toJson()->toXml();
// nlog($peppol->toObject());
@@ -1072,7 +1071,7 @@ class PeppolTest extends TestCase
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}
@@ -1174,7 +1173,7 @@ class PeppolTest extends TestCase
]);
$invoice = $invoice->calc()->getInvoice();
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
@@ -1186,7 +1185,7 @@ class PeppolTest extends TestCase
$peppol->setInvoiceDefaults();
$peppol->run();
// $peppol->toJson()->toXml();
// nlog($peppol->toObject());
@@ -1202,7 +1201,7 @@ class PeppolTest extends TestCase
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}
@@ -1210,7 +1209,7 @@ class PeppolTest extends TestCase
}
public function testDeInvoiceLevelAndItemLevelPercentageDiscount()
public function testDeInvoiceLevelAndItemLevelPercentageDiscount()
{
$settings = CompanySettings::defaults();
@@ -1311,7 +1310,7 @@ class PeppolTest extends TestCase
]);
$invoice = $invoice->calc()->getInvoice();
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
@@ -1331,13 +1330,13 @@ class PeppolTest extends TestCase
$e = new EInvoice();
$xml = $e->encode($de_invoice, 'xml');
$this->assertNotNull($xml);
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($xml);
nlog($errors);
}
@@ -1346,17 +1345,16 @@ class PeppolTest extends TestCase
$xml = $peppol->toXml();
try{
try {
$processor = new \Saxon\SaxonProcessor();
}
catch(\Throwable $e){
} catch (\Throwable $e) {
$this->markTestSkipped('saxon not installed');
}
$validator = new XsltDocumentValidator($xml);
$validator->validate();
if(count($validator->getErrors()) >0){
if (count($validator->getErrors()) > 0) {
nlog($xml);
nlog($validator->getErrors());
}
@@ -1366,7 +1364,7 @@ class PeppolTest extends TestCase
}
public function testDeInvoiceLevelPercentageDiscount()
public function testDeInvoiceLevelPercentageDiscount()
{
$settings = CompanySettings::defaults();
@@ -1487,13 +1485,13 @@ class PeppolTest extends TestCase
$e = new EInvoice();
$xml = $e->encode($de_invoice, 'xml');
$this->assertNotNull($xml);
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($xml);
nlog($errors);
}
@@ -1502,17 +1500,16 @@ class PeppolTest extends TestCase
$xml = $peppol->toXml();
try{
try {
$processor = new \Saxon\SaxonProcessor();
}
catch(\Throwable $e){
} catch (\Throwable $e) {
$this->markTestSkipped('saxon not installed');
}
$validator = new XsltDocumentValidator($xml);
$validator->validate();
if(count($validator->getErrors()) >0){
if (count($validator->getErrors()) > 0) {
nlog($xml);
nlog($validator->getErrors());
}
@@ -1645,7 +1642,7 @@ class PeppolTest extends TestCase
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}
@@ -1653,20 +1650,18 @@ class PeppolTest extends TestCase
$xml = $peppol->toXml();
try{
try {
$processor = new \Saxon\SaxonProcessor();
}
catch(\Throwable $e){
} catch (\Throwable $e) {
$this->markTestSkipped('saxon not installed');
}
$validator = new XsltDocumentValidator($xml);
$validator->validate();
if(count($validator->getErrors()) > 0)
{
if (count($validator->getErrors()) > 0) {
nlog($xml);
nlog($validator->getErrors());
}
@@ -1776,7 +1771,7 @@ class PeppolTest extends TestCase
]);
$invoice = $invoice->calc()->getInvoice();
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
@@ -1798,7 +1793,7 @@ class PeppolTest extends TestCase
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}
@@ -1806,20 +1801,18 @@ class PeppolTest extends TestCase
$xml = $peppol->toXml();
try{
try {
$processor = new \Saxon\SaxonProcessor();
}
catch(\Throwable $e){
} catch (\Throwable $e) {
$this->markTestSkipped('saxon not installed');
}
$validator = new XsltDocumentValidator($xml);
$validator->validate();
if(count($validator->getErrors()) > 0)
{
if (count($validator->getErrors()) > 0) {
nlog($xml);
nlog($validator->getErrors());
}
@@ -1945,7 +1938,7 @@ class PeppolTest extends TestCase
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}
@@ -2047,7 +2040,7 @@ class PeppolTest extends TestCase
]);
$invoice = $invoice->calc()->getInvoice();
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
@@ -2069,7 +2062,7 @@ class PeppolTest extends TestCase
$errors = $e->validate($de_invoice);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}
@@ -2178,7 +2171,7 @@ class PeppolTest extends TestCase
$errors = $e->validate($fe);
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog($errors);
}

View File

@@ -26,7 +26,7 @@ class InvoicePeriodTest extends TestCase
}
public function testEInvoicePeriodValidationPasses()
{
@@ -38,11 +38,11 @@ class InvoicePeriodTest extends TestCase
[
'StartDate' => '2025-01-01',
'EndDate' => '2025-01-01',
]
]
]
]
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -56,9 +56,9 @@ class InvoicePeriodTest extends TestCase
public function testERecurringInvoicePeriodValidationPasses()
{
$data = $this->recurring_invoice->toArray();
$data['client_id'] = $this->client->hashed_id;
$data['e_invoice'] = [
'Invoice' => [
@@ -67,18 +67,18 @@ class InvoicePeriodTest extends TestCase
'StartDate' => '2025-01-01',
'EndDate' => '2025-01-01',
'Description' => 'first day of this month|last day of this month'
]
]
]
]
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/recurring_invoices/'.$this->recurring_invoice->hashed_id, $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertEquals($arr['data']['e_invoice']['Invoice']['InvoicePeriod'][0]['Description'], 'first day of this month|last day of this month');
@@ -105,7 +105,7 @@ class InvoicePeriodTest extends TestCase
]
]
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,

View File

@@ -30,7 +30,7 @@ class CreateRequestTest extends TestCase
'tenant_id' => 'testcompanykey',
'classification' => 'individual',
'id_number' => 'xx',
];
$this->request->initialize($data);

View File

@@ -71,8 +71,9 @@ class RemoveTaxIdentifierRequestTest extends TestCase
$validator = Validator::make($data, $this->request->rules());
if(!$validator->passes())
if (!$validator->passes()) {
nlog($validator->errors());
}
$this->assertFalse($validator->passes());
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -93,7 +94,7 @@ class VerifactuApiTest extends TestCase
// $invoice->backup->document_type = 'F1';
// $invoice->backup->adjustable_amount = 121;
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
@@ -132,9 +133,9 @@ class VerifactuApiTest extends TestCase
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/group_settings/'.$gs->hashed_id, $data);
nlog($response->json());
nlog($response->json());
$response->assertStatus(422);
}
public function test_store_group_settings_with_locked_invoices()
@@ -160,7 +161,7 @@ class VerifactuApiTest extends TestCase
])->postJson('/api/v1/group_settings', $data);
$response->assertStatus(422);
}
public function test_update_company_settings_with_locked_invoices()
@@ -176,7 +177,7 @@ class VerifactuApiTest extends TestCase
$settings->lock_invoices = 'off';
$data = $this->company->toArray();
$data['settings'] = (array) $settings;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -213,7 +214,7 @@ class VerifactuApiTest extends TestCase
$response->assertStatus(422);
}
public function test_staged_full_cancellation_generates_correct_status()
{
$settings = $this->company->settings;
@@ -226,7 +227,7 @@ class VerifactuApiTest extends TestCase
$invoice = $this->buildData();
$this->assertTrue($invoice->verifactuEnabled());
$item = new InvoiceItem();
$item->quantity = 1;
$item->product_key = 'product_1';
@@ -299,7 +300,7 @@ class VerifactuApiTest extends TestCase
$this->assertCount(2, $invoice->backup->child_invoice_ids);
$this->assertEquals(Invoice::STATUS_CANCELLED, $invoice->status_id);
}
@@ -352,7 +353,7 @@ class VerifactuApiTest extends TestCase
])->postJson('/api/v1/invoices/bulk', $data);
$response->assertStatus(200);
$arr = $response->json();
$invoice = $invoice->fresh();
@@ -463,31 +464,31 @@ class VerifactuApiTest extends TestCase
$response->assertStatus(422);
//Test Validation to catch illegal cancellation amounts
$item = new InvoiceItem();
$item->quantity = 1;
$item->product_key = 'product_1';
$item->notes = 'Product 1';
$item->cost = 51;
$item->discount = 0;
$item->tax_rate1 = 21;
$item->tax_name1 = 'IVA';
$item->tax_name2 = 'IRPF';
$item->tax_rate2 = -15;
$data = $invoice->toArray();
$data['modified_invoice_id'] = $invoice->hashed_id;
$data['client_id'] = $this->client->hashed_id;
$data['line_items'] = [$item];
unset($data['number']);
$data['backup'] = null;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/invoices', $data);
$response->assertStatus(422);
//Test Validation to catch illegal cancellation amounts
$item = new InvoiceItem();
$item->quantity = 1;
$item->product_key = 'product_1';
$item->notes = 'Product 1';
$item->cost = 51;
$item->discount = 0;
$item->tax_rate1 = 21;
$item->tax_name1 = 'IVA';
$item->tax_name2 = 'IRPF';
$item->tax_rate2 = -15;
$data = $invoice->toArray();
$data['modified_invoice_id'] = $invoice->hashed_id;
$data['client_id'] = $this->client->hashed_id;
$data['line_items'] = [$item];
unset($data['number']);
$data['backup'] = null;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/invoices', $data);
$response->assertStatus(422);
}
public function test_delete_validation_for_parent_fails_correctly()
@@ -549,7 +550,7 @@ class VerifactuApiTest extends TestCase
public function test_archive_invoice_with_no_parent()
{
$settings = $this->company->settings;
$settings->e_invoice_type = 'VERIFACTU';
$settings->is_locked = 'when_sent';
@@ -569,7 +570,7 @@ class VerifactuApiTest extends TestCase
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/invoices/bulk', $data);
$response->assertStatus(200);
@@ -588,7 +589,7 @@ class VerifactuApiTest extends TestCase
public function test_delete_invoice_with_parent()
{
$settings = $this->company->settings;
$settings->e_invoice_type = 'VERIFACTU';
@@ -621,12 +622,12 @@ class VerifactuApiTest extends TestCase
$this->assertEquals('R1', $arr['data']['backup']['document_type']);
$this->assertEquals($invoice->hashed_id, $arr['data']['backup']['parent_invoice_id']);
$invoice = $invoice->fresh();
$this->assertEquals('F1', $invoice->backup->document_type);
$this->assertCount(1, $invoice->backup->child_invoice_ids);
$data = [
'action' => 'delete',
'ids' => [$invoice->hashed_id]
@@ -636,14 +637,14 @@ class VerifactuApiTest extends TestCase
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/invoices/bulk', $data);
$response->assertStatus(422);
}
public function test_delete_invoice_with_no_parent()
{
$settings = $this->company->settings;
$settings->e_invoice_type = 'VERIFACTU';
@@ -655,7 +656,7 @@ class VerifactuApiTest extends TestCase
$this->assertEquals('F1', $invoice->backup->document_type);
$this->assertFalse($invoice->is_deleted);
$data = [
'action' => 'delete',
'ids' => [$invoice->hashed_id]
@@ -665,7 +666,7 @@ class VerifactuApiTest extends TestCase
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/invoices/bulk', $data);
$response->assertStatus(422);
@@ -680,7 +681,7 @@ class VerifactuApiTest extends TestCase
])->postJson('/api/v1/invoices/bulk', $data);
$response->assertStatus(422);
}
}
public function test_credits_never_exceed_original_invoice9()
@@ -695,7 +696,7 @@ class VerifactuApiTest extends TestCase
$invoice = $this->buildData();
$invoice->service()->markSent()->save();
$this->assertEquals(121, $invoice->amount);
$this->assertEquals(121, $invoice->amount);
$data = $invoice->toArray();
unset($data['client']);
@@ -729,7 +730,7 @@ class VerifactuApiTest extends TestCase
$invoice = $this->buildData();
$invoice->service()->markSent()->save();
$this->assertEquals(121, $invoice->amount);
$this->assertEquals(121, $invoice->amount);
$data = $invoice->toArray();
unset($data['client']);
@@ -771,7 +772,7 @@ class VerifactuApiTest extends TestCase
$data['verifactu_modified'] = true;
$data['modified_invoice_id'] = $invoice->hashed_id;
$data['number'] = null;
$data['line_items'] = [[
'quantity' => -1,
'cost' => 50,
@@ -815,7 +816,7 @@ class VerifactuApiTest extends TestCase
$invoice->service()->markSent()->save();
$this->assertEquals(121, $invoice->amount);
$invoice->line_items = [[
'quantity' => -1,
'cost' => 10,
@@ -834,7 +835,7 @@ class VerifactuApiTest extends TestCase
$data['verifactu_modified'] = true;
$data['modified_invoice_id'] = $invoice->hashed_id;
$data['number'] = null;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -879,7 +880,7 @@ class VerifactuApiTest extends TestCase
$invoice->service()->markSent()->save();
$this->assertEquals(121, $invoice->amount);
$invoice->line_items = [[
'quantity' => -5,
'cost' => 100,
@@ -897,7 +898,7 @@ class VerifactuApiTest extends TestCase
$data['verifactu_modified'] = true;
$data['modified_invoice_id'] = $invoice->hashed_id;
$data['number'] = null;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -920,7 +921,7 @@ class VerifactuApiTest extends TestCase
$invoice->service()->markSent()->save();
$this->assertEquals(121, $invoice->amount);
$data = $invoice->toArray();
unset($data['client']);
@@ -958,7 +959,7 @@ class VerifactuApiTest extends TestCase
$invoice = $this->buildData();
$invoice->service()->markSent()->save();
$invoice->line_items = [];
$invoice->discount = 500;
$invoice->is_amount_discount = true;
@@ -968,7 +969,7 @@ class VerifactuApiTest extends TestCase
$data['verifactu_modified'] = true;
$data['modified_invoice_id'] = $invoice->hashed_id;
$data['number'] = null;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -988,9 +989,9 @@ class VerifactuApiTest extends TestCase
$invoice = $this->buildData();
$invoice->service()->markSent()->save();
$invoice->line_items = [];
$invoice->discount = 500;
$invoice->is_amount_discount = true;
@@ -999,7 +1000,7 @@ class VerifactuApiTest extends TestCase
$data['verifactu_modified'] = true;
$data['modified_invoice_id'] = $invoice->hashed_id;
$data['number'] = null;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -1021,7 +1022,7 @@ class VerifactuApiTest extends TestCase
$invoice = $this->buildData();
$invoice->service()->markSent()->save();
// $invoice->line_items = [];
$invoice->discount = 5;
$invoice->is_amount_discount = true;
@@ -1031,7 +1032,7 @@ class VerifactuApiTest extends TestCase
$data['verifactu_modified'] = true;
$data['modified_invoice_id'] = $invoice->hashed_id;
$data['number'] = null;
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -1042,7 +1043,7 @@ class VerifactuApiTest extends TestCase
public function test_verifactu_amount_check()
{
$settings = $this->company->settings;
$settings->e_invoice_type = 'VERIFACTU';
@@ -1068,7 +1069,7 @@ class VerifactuApiTest extends TestCase
public function test_create_modification_invoice()
{
$this->assertEquals(10, $this->client->balance);
$settings = $this->company->settings;
@@ -1079,13 +1080,13 @@ class VerifactuApiTest extends TestCase
$invoice = $this->buildData();
$invoice->service()->markSent()->save();
$this->assertEquals(121, $invoice->amount);
$this->assertEquals(121, $invoice->balance);
$this->assertEquals(131, $this->client->fresh()->balance);
$invoice2 = $this->buildData();
$items = $invoice2->line_items;
$items[] = $items[0];
$invoice2->line_items = $items;
@@ -1094,7 +1095,7 @@ class VerifactuApiTest extends TestCase
$invoice2->service()->markSent()->save();
$this->assertEquals(373, $this->client->fresh()->balance);
$data = $invoice2->toArray();
$data['verifactu_modified'] = true;
$data['modified_invoice_id'] = $invoice->hashed_id;
@@ -1113,7 +1114,8 @@ class VerifactuApiTest extends TestCase
public function test_create_modification_invoice_validation_fails()
{
$invoice = $this->buildData();;
$invoice = $this->buildData();
;
$data = $invoice->toArray();
$data['verifactu_modified'] = true;
@@ -1124,12 +1126,13 @@ class VerifactuApiTest extends TestCase
])->postJson('/api/v1/invoices', $data);
$response->assertStatus(422);
}
public function test_create_modification_invoice_validation_fails2()
{
$invoice = $this->buildData();;
$invoice = $this->buildData();
;
$data = $invoice->toArray();
$data['verifactu_modified'] = true;
@@ -1141,12 +1144,13 @@ class VerifactuApiTest extends TestCase
])->postJson('/api/v1/invoices', $data);
$response->assertStatus(422);
}
public function test_create_modification_invoice_validation_fails3()
{
$invoice = $this->buildData();;
$invoice = $this->buildData();
;
$invoice2 = $this->buildData();
$invoice2->service()->markPaid()->save();
@@ -1161,7 +1165,7 @@ class VerifactuApiTest extends TestCase
])->postJson('/api/v1/invoices', $data);
$response->assertStatus(422);
}
public function test_create_modification_invoice_validation_fails4()
@@ -1173,7 +1177,8 @@ class VerifactuApiTest extends TestCase
$this->company->settings = $settings;
$this->company->save();
$invoice = $this->buildData();;
$invoice = $this->buildData();
;
$invoice2 = $this->buildData();
$invoice2->service()->markSent()->save();
@@ -1190,7 +1195,7 @@ class VerifactuApiTest extends TestCase
])->postJson('/api/v1/invoices', $data);
$response->assertStatus(422);
}
public function test_cancel_invoice_response()
@@ -1253,7 +1258,7 @@ class VerifactuApiTest extends TestCase
public function test_restore_invoice_validation()
{
$settings = $this->company->settings;
$settings->e_invoice_type = 'VERIFACTU';
@@ -1267,7 +1272,7 @@ class VerifactuApiTest extends TestCase
'action' => 'delete',
'ids' => [$invoice->hashed_id]
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -1290,11 +1295,11 @@ class VerifactuApiTest extends TestCase
$response->assertStatus(422);
}
public function test_restore_invoice_that_is_archived()
{
$settings = $this->company->settings;
$settings->e_invoice_type = 'VERIFACTU';
@@ -1303,12 +1308,12 @@ class VerifactuApiTest extends TestCase
$invoice = $this->buildData();
$invoice->service()->markSent()->save();
$data = [
'action' => 'archive',
'ids' => [$invoice->hashed_id]
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -1319,7 +1324,7 @@ class VerifactuApiTest extends TestCase
$arr = $response->json();
$this->assertFalse($arr['data'][0]['is_deleted']);
$data = [
'action' => 'restore',
'ids' => [$invoice->hashed_id]
@@ -1348,7 +1353,7 @@ class VerifactuApiTest extends TestCase
}
Config::set('ninja.environment', 'hosted');
$settings = $this->company->settings;
$settings->e_invoice_type = 'VERIFACTU';
$this->company->settings = $settings;
@@ -1376,4 +1381,4 @@ class VerifactuApiTest extends TestCase
$this->assertEquals($arr['data']['settings']['e_invoice_type'], 'VERIFACTU');
$this->assertEquals($arr['data']['settings']['lock_invoices'], 'when_sent');
}
}
}

View File

@@ -16,15 +16,15 @@ class VerifactuDocumentValidatorTest extends TestCase
$mockError = new \LibXMLError();
$mockError->line = 12;
$mockError->message = 'Element \'{https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd}Desglose\': Missing child element(s). Expected is ( {https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd}DetalleDesglose ).';
// Use reflection to test the private method
$validator = new VerifactuDocumentValidator('<xml></xml>');
$reflection = new \ReflectionClass($validator);
$formatMethod = $reflection->getMethod('formatXsdError');
$formatMethod->setAccessible(true);
$formattedError = $formatMethod->invoke($validator, $mockError);
// The formatted error should be more readable
$this->assertStringContainsString('Line 12:', $formattedError);
$this->assertStringContainsString('Missing required child element:', $formattedError);
@@ -41,9 +41,9 @@ class VerifactuDocumentValidatorTest extends TestCase
$reflection = new \ReflectionClass($validator);
$contextMethod = $reflection->getMethod('getErrorContext');
$contextMethod->setAccessible(true);
$context = $contextMethod->invoke($validator, 'Missing child element: DetalleDesglose');
$this->assertStringContainsString('Desglose (Tax Breakdown)', $context);
$this->assertStringContainsString('DetalleDesglose (Tax Detail)', $context);
$this->assertStringContainsString('requires', $context);
@@ -58,9 +58,9 @@ class VerifactuDocumentValidatorTest extends TestCase
$reflection = new \ReflectionClass($validator);
$suggestionMethod = $reflection->getMethod('getErrorSuggestion');
$suggestionMethod->setAccessible(true);
$suggestion = $suggestionMethod->invoke($validator, 'Missing child element: DetalleDesglose');
$this->assertStringContainsString('Add a DetalleDesglose element', $suggestion);
$this->assertStringContainsString('Example:', $suggestion);
$this->assertStringContainsString('<DetalleDesglose>', $suggestion);
@@ -72,11 +72,11 @@ class VerifactuDocumentValidatorTest extends TestCase
public function test_error_summary_provides_clear_overview()
{
$validator = new VerifactuDocumentValidator('<xml></xml>');
// Initially no errors
$summary = $validator->getErrorSummary();
$this->assertEquals('Document validation passed successfully.', $summary);
// Add some mock errors
$reflection = new \ReflectionClass($validator);
$errorsProperty = $reflection->getProperty('errors');
@@ -85,7 +85,7 @@ class VerifactuDocumentValidatorTest extends TestCase
'xsd' => ['Error 1', 'Error 2'],
'structure' => ['Error 3']
]);
$summary = $validator->getErrorSummary();
$this->assertStringContainsString('Validation failed with 3 total error(s):', $summary);
$this->assertStringContainsString('Schema Validation Errors: 2', $summary);
@@ -98,7 +98,7 @@ class VerifactuDocumentValidatorTest extends TestCase
public function test_formatted_errors_provide_structured_information()
{
$validator = new VerifactuDocumentValidator('<xml></xml>');
// Add some mock errors
$reflection = new \ReflectionClass($validator);
$errorsProperty = $reflection->getProperty('errors');
@@ -107,9 +107,9 @@ class VerifactuDocumentValidatorTest extends TestCase
'xsd' => ['Error 1', 'Error 2'],
'business' => ['Error 3']
]);
$formatted = $validator->getFormattedErrors();
$this->assertArrayHasKey('xsd', $formatted);
$this->assertArrayHasKey('business', $formatted);
$this->assertEquals(2, $formatted['xsd']['count']);

View File

@@ -59,7 +59,7 @@ class VerifactuFeatureTest extends TestCase
$this->markTestSkipped('We do not run these unattended as they attempt to hit the AEAT web service');
}
/**
* Helper to stub test data.
*
@@ -88,7 +88,7 @@ class VerifactuFeatureTest extends TestCase
$this->user = $u;
if(!$settings) {
if (!$settings) {
$settings = CompanySettings::defaults();
$settings->client_online_payment_notification = false;
$settings->client_manual_payment_notification = false;
@@ -174,10 +174,10 @@ class VerifactuFeatureTest extends TestCase
$item->notes = 'Test item';
$item->tax_name1 = 'IVA';
$item->tax_rate1 = 21;
$item->discount =0;
$item->discount = 0;
$line_items[] = $item;
$invoice = Invoice::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,
@@ -207,10 +207,10 @@ class VerifactuFeatureTest extends TestCase
->service()
->markSent()
->save();
return $invoice;
}
/**
* test_construction_and_validation
*
@@ -219,9 +219,9 @@ class VerifactuFeatureTest extends TestCase
*/
public function test_construction_and_validation()
{
// - current previous hash - 10C643EDC7DC727FAC6BAEBAAC7BEA67B5C1369A5A5ED74E5AD3149FC30A3C8C
//BE95547AA8B973A3D6A860B36833FBDE3C8AB853F4B8F05872574A5DA7314A23
// - current previous invoice number - TEST0033343443
// - current previous hash - 10C643EDC7DC727FAC6BAEBAAC7BEA67B5C1369A5A5ED74E5AD3149FC30A3C8C
//BE95547AA8B973A3D6A860B36833FBDE3C8AB853F4B8F05872574A5DA7314A23
// - current previous invoice number - TEST0033343443
$invoice = $this->buildData();
@@ -271,7 +271,7 @@ class VerifactuFeatureTest extends TestCase
$this->assertNotEmpty($verifactu->getEnvelope());
$envelope = $verifactu->getEnvelope();
$this->assertNotEmpty($envelope);
// In test mode, we don't actually send to the service
@@ -291,12 +291,12 @@ class VerifactuFeatureTest extends TestCase
$xx->forceDelete();
}
/**
* testBuildInvoiceCancellation
*
* test cancellation of an invoice and sending to AEAT
*
*
* @return void
*/
public function testBuildInvoiceCancellation()
@@ -363,11 +363,11 @@ class VerifactuFeatureTest extends TestCase
}
/**
* test_invoice_modification_validation
*
*
* Test that the modified invoice passes the validation rules
* @return void
*/
@@ -393,12 +393,12 @@ class VerifactuFeatureTest extends TestCase
$items = $invoice->line_items;
foreach($items as &$item) {
foreach ($items as &$item) {
$item->quantity = -1;
}
$invoice->line_items = $items;
$repo = new InvoiceRepository();
$invoice = $repo->save($invoice->toArray(), $invoice);
$invoice = $invoice->service()->markSent()->save();
@@ -412,13 +412,13 @@ class VerifactuFeatureTest extends TestCase
->getInvoice();
$soapXml = $document2->toSoapEnvelope();
$this->assertNotNull($document2->getHuella());
nlog("huella: " . $document2->getHuella());
nlog($soapXml);
$xslt = new VerifactuDocumentValidator($soapXml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
@@ -432,11 +432,11 @@ class VerifactuFeatureTest extends TestCase
$this->assertCount(0, $errors);
}
/**
* test_invoice_invoice_modification
* Creates a new invoice and sends to AEAT, follows with a matching credit note that is then sent to AEAT
*
*
* @return void
*/
public function test_invoice_invoice_modification_and_create_cancellation_of_rectification_invoice()
@@ -467,7 +467,7 @@ class VerifactuFeatureTest extends TestCase
nlog($document->toSoapEnvelope());
$response = $verifactu->send($document->toSoapEnvelope());
$this->assertNotNull($response);
$this->assertArrayHasKey('success', $response);
$this->assertTrue($response['success']);
@@ -480,14 +480,14 @@ class VerifactuFeatureTest extends TestCase
$invoice2->backup->document_type = 'R2';
$items = $invoice2->line_items;
foreach($items as &$item) {
foreach ($items as &$item) {
$item->quantity = -1;
}
$invoice2->line_items = $items;
$invoice2->save();
$data = $invoice2->toArray();
$data['client_id'] = $invoice->client_id;
unset($data['id']);
@@ -497,7 +497,7 @@ class VerifactuFeatureTest extends TestCase
$invoice2 = $invoice2->service()->markSent()->save();
$this->assertEquals(-121, $invoice2->amount);
$verifactu2 = new Verifactu($invoice2);
$document2 = $verifactu2->setTestMode()
->setPreviousHash($document->getHuella())
@@ -512,7 +512,7 @@ class VerifactuFeatureTest extends TestCase
$this->assertArrayHasKey('success', $response);
$this->assertTrue($response['success']);
//Lets try and cancel the credit note now - we should fail!!
//Lets try and cancel the credit note now - we should fail!!
$verifactu = new Verifactu($invoice2);
$document = (new RegistroAlta($invoice2))->run()->getInvoice();
$huella = $this->cancellationHash($document, $document2->getHuella());
@@ -544,8 +544,8 @@ class VerifactuFeatureTest extends TestCase
}
public function test_rectification_invoice()
{
public function test_rectification_invoice()
{
$soapXml = <<<XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sum="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd" xmlns:sum1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd">
<soapenv:Header/>
@@ -628,7 +628,7 @@ class VerifactuFeatureTest extends TestCase
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if(count($errors) > 0) {
if (count($errors) > 0) {
nlog('Errors:');
nlog($errors);
nlog('Errors:');
@@ -661,7 +661,7 @@ class VerifactuFeatureTest extends TestCase
nlog($rx);
}
}
@@ -672,16 +672,16 @@ class VerifactuFeatureTest extends TestCase
{
// Create a complete R1 invoice with all required elements matching the exact XML structure
$invoice = new VerifactuInvoice();
// Set required properties using setter methods to match the expected XML exactly
$invoice->setIdVersion('1.0');
$idFactura = new IDFactura();
$idFactura->setIdEmisorFactura('A39200019');
$idFactura->setNumSerieFactura('TEST0033343444');
$idFactura->setFechaExpedicionFactura('09-08-2025');
$invoice->setIdFactura($idFactura);
$invoice->setNombreRazonEmisor('CERTIFICADO FISICA PRUEBAS');
$invoice->setTipoFactura(VerifactuInvoice::TIPO_FACTURA_RECTIFICATIVA);
$invoice->setTipoRectificativa('S');
@@ -695,7 +695,7 @@ class VerifactuFeatureTest extends TestCase
// Set up rectification details exactly as in the expected XML
$invoice->setRectifiedInvoice('A39200019', 'TEST0033343443', '09-08-2025');
$importeRectificacion = [
'BaseRectificada' => 100.00,
'CuotaRectificada' => 21.00,
@@ -725,7 +725,7 @@ class VerifactuFeatureTest extends TestCase
$this->assertStringContainsString('xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"', $soapXml);
$this->assertStringContainsString('xmlns:sum="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd"', $soapXml);
$this->assertStringContainsString('xmlns:sum1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd"', $soapXml);
// Verify SOAP structure
$this->assertStringContainsString('<soapenv:Header/>', $soapXml);
$this->assertStringContainsString('<soapenv:Body>', $soapXml);
@@ -734,7 +734,7 @@ class VerifactuFeatureTest extends TestCase
$this->assertStringContainsString('<sum1:ObligadoEmision>', $soapXml);
$this->assertStringContainsString('<sum:RegistroFactura>', $soapXml);
$this->assertStringContainsString('<sum1:RegistroAlta>', $soapXml);
// Verify elements are in exact order as per the expected XML
$expectedOrder = [
'IDVersion',
@@ -834,7 +834,7 @@ class VerifactuFeatureTest extends TestCase
}
////////////////////////////////////////////////
////////////////////////////////////////////////
private function cancellationHash($document, $huella)
{
@@ -849,14 +849,14 @@ class VerifactuFeatureTest extends TestCase
"Huella={$huella}&" .
"FechaHoraHusoGenRegistro={$fechaHoraHusoGenRegistro}";
nlog("Cancellation Huella: " . $hashInput);
nlog("Cancellation Huella: " . $hashInput);
return strtoupper(hash('sha256', $hashInput));
}
//@todo - need to test that the user has granted power of attorney to the system
//@todo - need to test that the user has granted power of attorney to the system
//@todo - data must be written to the database to confirm this.
public function test_verifactu_authority()
{
@@ -868,10 +868,10 @@ class VerifactuFeatureTest extends TestCase
}
//@todo - need to confirm that building the xml and sending works.
//@todo - need to confirm that building the xml and sending works.
public function test_verifactu_invoice_model_can_build_xml()
{
// Generate current timestamp in the correct format
$currentTimestamp = now()->setTimezone('Europe/Madrid')->format('Y-m-d\TH:i:s');
@@ -911,16 +911,16 @@ class VerifactuFeatureTest extends TestCase
$invoice->setDesglose($desglose);
$destinatarios = [];
$destinatario = new PersonaFisicaJuridica();
$destinatarios = [];
$destinatario = new PersonaFisicaJuridica();
$destinatario
->setNif('A39200020')
->setNombreRazon('Empresa Ejemplo SL VV');
$destinatario
->setNif('A39200020')
->setNombreRazon('Empresa Ejemplo SL VV');
$destinatarios[] = $destinatario;
$destinatarios[] = $destinatario;
$invoice->setDestinatarios($destinatarios);
$invoice->setDestinatarios($destinatarios);
// Add information system
$sistema = new SistemaInformatico();
@@ -942,13 +942,13 @@ $invoice->setDestinatarios($destinatarios);
$this->assertNotNull($soapXml);
nlog($soapXml);
nlog($soapXml);
}
//@todo - need to confirm that building the xml and sending works.
public function test_generated_invoice_xml_can_send_to_web_service()
{
// Generate current timestamp in the correct format
$currentTimestamp = now()->setTimezone('Europe/Madrid')->format('Y-m-d\TH:i:s');
@@ -1073,7 +1073,7 @@ $invoice->setDestinatarios($destinatarios);
{
// Generate current timestamp in the correct format
// $currentTimestamp = date('Y-m-d\TH:i:sP');
$currentTimestamp = now()->setTimezone('Europe/Madrid')->format('Y-m-d\TH:i:sP');
$invoice_number = 'TEST0033343443';
$previous_invoice_number = 'TEST0033343442';
@@ -1081,7 +1081,7 @@ $invoice->setDestinatarios($destinatarios);
$previous_hash = '10C643EDC7DC727FAC6BAEBAAC7BEA67B5C1369A5A5ED74E5AD3149FC30A3C8C';
$nif = 'A39200019';
$soapXml = <<<XML
$soapXml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sum="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd"
@@ -1160,18 +1160,18 @@ $invoice->setDestinatarios($destinatarios);
// Calculate the correct hash using AEAT's specified format
$correctHash = $this->calculateVerifactuHash(
$nif, // IDEmisorFactura
$invoice_number, // NumSerieFactura
$invoice_number, // NumSerieFactura
$invoice_date, // FechaExpedicionFactura
'F1', // TipoFactura
'21.00', // CuotaTotal
'121.00', // ImporteTotal
$previous_hash, // Huella (empty for first calculation)
$currentTimestamp // FechaHoraHusoGenRegistro (current time)
);
);
// Replace the placeholder with the correct hash
$soapXml = str_replace('PLACEHOLDER_HUELLA', $correctHash, $soapXml);
nlog('Calculated hash for XML: ' . $correctHash);
// Sign the XML before sending
@@ -1181,7 +1181,7 @@ $invoice->setDestinatarios($destinatarios);
$soapXml = $signingService->sign();
nlog($soapXml);
// Try direct HTTP approach instead of SOAP client
$response = Http::withHeaders([
'Content-Type' => 'text/xml; charset=utf-8',
@@ -1202,12 +1202,12 @@ $invoice->setDestinatarios($destinatarios);
nlog('Response Status: ' . $response->status());
nlog('Response Headers: ' . json_encode($response->headers()));
nlog('Response Body: ' . $response->body());
if (!$response->successful()) {
\Log::error('Request failed with status: ' . $response->status());
\Log::error('Response body: ' . $response->body());
}
$this->assertTrue($response->successful());
@@ -1226,7 +1226,7 @@ $invoice->setDestinatarios($destinatarios);
*/
private function calculateVerifactuHash(
string $idEmisorFactura,
string $numSerieFactura,
string $numSerieFactura,
string $fechaExpedicionFactura,
string $tipoFactura,
string $cuotaTotal,
@@ -1243,11 +1243,11 @@ $invoice->setDestinatarios($destinatarios);
"ImporteTotal={$importeTotal}&" .
"Huella={$huella}&" .
"FechaHoraHusoGenRegistro={$fechaHoraHusoGenRegistro}";
nlog('Hash input string: ' . $hashInput);
// Calculate SHA256 hash and return in uppercase
return strtoupper(hash('sha256', $hashInput));
}
}
}

View File

@@ -26,7 +26,6 @@ use App\Services\EDocument\Standards\Verifactu\Models\IDOtro;
class VerifactuModelTest extends TestCase
{
public function test_and_create_new_invoice_for_non_spanish_client(): void
{
@@ -99,17 +98,17 @@ class VerifactuModelTest extends TestCase
// $invoice->setCupon($cupon);
$xml = $invoice->toXmlString();
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if(count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(0, $errors);
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if (count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(0, $errors);
@@ -192,17 +191,17 @@ class VerifactuModelTest extends TestCase
// $invoice->setCupon($cupon);
$xml = $invoice->toXmlString();
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if(count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(0, $errors);
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if (count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(0, $errors);
@@ -269,8 +268,8 @@ class VerifactuModelTest extends TestCase
$invoice->setEncadenamiento($encadenamiento);
$xml = $invoice->toXmlString();
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
@@ -363,7 +362,7 @@ class VerifactuModelTest extends TestCase
public function testInvalidXmlThrowsException(): void
{
$this->expectException(\DOMException::class);
$invalidXml = '<?xml version="1.0" encoding="UTF-8"?><unclosed>';
Invoice::fromXml($invalidXml);
}
@@ -371,7 +370,7 @@ class VerifactuModelTest extends TestCase
public function testMissingRequiredFieldsThrowsException(): void
{
$invoice = new Invoice();
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Missing required field: IDVersion');
@@ -450,7 +449,7 @@ class VerifactuModelTest extends TestCase
// Generate XML string
$xml = $invoice->toXmlString();
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
@@ -465,14 +464,14 @@ class VerifactuModelTest extends TestCase
// Test deserialization
$deserialized = Invoice::fromXml($xml);
$this->assertEquals(2, count($deserialized->getDestinatarios()));
// Verify first recipient (with NIF)
$this->assertEquals('Cliente 1 SL', $deserialized->getDestinatarios()[0]->getNombreRazon());
$this->assertEquals('B87654321', $deserialized->getDestinatarios()[0]->getNif());
// Verify second recipient (with IDOtro)
$this->assertEquals('Client 2 SARL', $deserialized->getDestinatarios()[1]->getNombreRazon());
}
public function testCreateAndSerializeInvoiceWithExemptOperation(): void
@@ -526,24 +525,24 @@ class VerifactuModelTest extends TestCase
// Generate XML string
$xml = $invoice->toXmlString();
// Debug output
// echo "\nGenerated XML:\n";
// echo $xml;
// echo "\n\n";
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if(count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(1, $errors);
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if (count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(1, $errors);
@@ -614,23 +613,23 @@ class VerifactuModelTest extends TestCase
// Generate XML string
$xml = $invoice->toXmlString();
// Debug output
// echo "\nGenerated XML:\n";
// echo $xml;
// echo "\n\n";
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if(count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(1, $errors);
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if (count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(1, $errors);
// Test deserialization
@@ -690,23 +689,23 @@ class VerifactuModelTest extends TestCase
// Generate XML string
$xml = $invoice->toXmlString();
// Debug output
// echo "\nGenerated XML:\n";
// echo $xml;
// echo "\n\n";
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if(count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(1, $errors);
$xslt = new VerifactuDocumentValidator($xml);
$xslt->validate();
$errors = $xslt->getVerifactuErrors();
if (count($errors) > 0) {
nlog($xml);
nlog($errors);
}
$this->assertCount(1, $errors);
// Test deserialization
@@ -719,7 +718,7 @@ class VerifactuModelTest extends TestCase
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid TipoFactura value');
$invoice = new Invoice();
$invoice
->setIdVersion('1.0')
@@ -734,7 +733,7 @@ class VerifactuModelTest extends TestCase
public function testInvalidTipoRectificativaThrowsException(): void
{
$this->expectException(\InvalidArgumentException::class);
$invoice = new Invoice();
$invoice
->setIdVersion('1.0')
@@ -770,7 +769,7 @@ class VerifactuModelTest extends TestCase
public function testInvalidNIFFormatThrowsException(): void
{
$this->expectException(\InvalidArgumentException::class);
$invoice = new Invoice();
$invoice
->setIdVersion('1.0')
@@ -811,7 +810,7 @@ class VerifactuModelTest extends TestCase
public function testInvalidAmountFormatThrowsException(): void
{
$this->expectException(\InvalidArgumentException::class);
$invoice = new Invoice();
$invoice
->setIdVersion('1.0')
@@ -845,7 +844,7 @@ class VerifactuModelTest extends TestCase
public function testInvalidSchemaThrowsException(): void
{
$this->expectException(\DOMException::class);
$invoice = new Invoice();
$invoice->setIdVersion('1.0')
->setIdFactura((new \App\Services\EDocument\Standards\Verifactu\Models\IDFactura())
@@ -900,7 +899,7 @@ class VerifactuModelTest extends TestCase
$invalidElement = $doc->createElementNS('https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd', 'sum1:InvalidElement');
$invalidElement->textContent = 'test';
$doc->documentElement->appendChild($invalidElement);
// Try to validate the invalid XML using our validateXml method
$reflectionClass = new \ReflectionClass(Invoice::class);
$validateXmlMethod = $reflectionClass->getMethod('validateXml');
@@ -941,7 +940,7 @@ class VerifactuModelTest extends TestCase
if (!$doc->loadXML($xml, LIBXML_NOBLANKS)) {
throw new \DOMException('Failed to load XML in assertValidatesAgainstXsd');
}
libxml_use_internal_errors(true);
$result = $doc->schemaValidate($xsdPath);
if (!$result) {
@@ -949,7 +948,7 @@ class VerifactuModelTest extends TestCase
}
libxml_clear_errors();
}
$this->assertTrue(
$result,
'XML does not validate against XSD schema'
@@ -963,4 +962,4 @@ class VerifactuModelTest extends TestCase
{
return __DIR__ . '/../schema/SuministroInformacion.xsd';
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -23,7 +24,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class EntityPaidToDateTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -23,7 +24,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\ExpenseController
*/
class ExpenseApiTest extends TestCase
@@ -78,7 +79,7 @@ class ExpenseApiTest extends TestCase
$response->assertStatus(200);
$expenses->cursor()->each(function ($e){
$expenses->cursor()->each(function ($e) {
$this->assertEquals('GST', $e->tax_name1);
$this->assertEquals(10, $e->tax_rate1);
});

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -19,7 +20,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\ExpenseCategoryController
*/
class ExpenseCategoryApiTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -25,7 +26,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\TestCase;
/**
*
*
*/
class ArDetailReportTest extends TestCase
{
@@ -117,7 +118,7 @@ class ArDetailReportTest extends TestCase
'notifications' => \App\DataMapper\CompanySettings::notificationDefaults(),
'settings' => null,
]);
$company_token = new \App\Models\CompanyToken();
$company_token->user_id = $this->user->id;
$company_token->company_id = $this->company->id;

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\TestCase;
/**
*
*
*/
class ArSummaryReportTest extends TestCase
{
@@ -108,7 +109,7 @@ class ArSummaryReportTest extends TestCase
'notifications' => \App\DataMapper\CompanySettings::notificationDefaults(),
'settings' => null,
]);
$company_token = new \App\Models\CompanyToken();
$company_token->user_id = $this->user->id;
$company_token->company_id = $this->company->id;
@@ -125,7 +126,7 @@ class ArSummaryReportTest extends TestCase
$truth->setUser($this->user);
$truth->setCompany($this->company);
$this->payload = [
'start_date' => '2000-01-01',
'end_date' => '2030-01-11',

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\TestCase;
/**
*
*
*/
class ClientBalanceReportTest extends TestCase
{
@@ -108,7 +109,7 @@ class ClientBalanceReportTest extends TestCase
'notifications' => \App\DataMapper\CompanySettings::notificationDefaults(),
'settings' => null,
]);
$company_token = new \App\Models\CompanyToken();
$company_token->user_id = $this->user->id;
$company_token->company_id = $this->company->id;
@@ -125,7 +126,7 @@ class ClientBalanceReportTest extends TestCase
$truth->setUser($this->user);
$truth->setCompany($this->company);
$this->payload = [
'start_date' => '2000-01-01',
'end_date' => '2030-01-11',

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -17,7 +18,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class ClientCsvTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\TestCase;
/**
*
*
*/
class ClientSalesReportTest extends TestCase
{
@@ -108,7 +109,7 @@ class ClientSalesReportTest extends TestCase
'notifications' => \App\DataMapper\CompanySettings::notificationDefaults(),
'settings' => null,
]);
$company_token = new \App\Models\CompanyToken();
$company_token->user_id = $this->user->id;
$company_token->company_id = $this->company->id;

View File

@@ -143,7 +143,7 @@ class EInvoiceReportTest extends TestCase
'user_id' => $this->user->id,
];
$guid = new \stdClass;
$guid = new \stdClass();
$guid->guid = '1234567890';
$i = Invoice::factory()->create([
@@ -180,7 +180,7 @@ class EInvoiceReportTest extends TestCase
public function testExpenseEInvoiceComponent()
{
$this->buildData();
$this->payload = [
@@ -198,19 +198,19 @@ class EInvoiceReportTest extends TestCase
'should_be_invoiced' => true,
]);
$a = new Activity();
$a->expense_id = $e->id;
$a->company_id = $this->company->id;
$a->user_id = $this->user->id;
$a->activity_type_id = 148;
$a->save();
$pl = new EInvoiceReport($this->company, $this->payload);
$response = $pl->run();
$a = new Activity();
$a->expense_id = $e->id;
$a->company_id = $this->company->id;
$a->user_id = $this->user->id;
$a->activity_type_id = 148;
$a->save();
$this->assertIsString($response);
$pl = new EInvoiceReport($this->company, $this->payload);
$response = $pl->run();
$this->account->delete();
$this->assertIsString($response);
$this->account->delete();
}
private function buildLineItems()
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -18,7 +19,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class ExportCompanyTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -26,7 +27,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\TestCase;
/**
*
*
* App\Services\Report\ProductSalesExport
*/
class ProductSalesReportTest extends TestCase
@@ -112,7 +113,7 @@ class ProductSalesReportTest extends TestCase
'notifications' => \App\DataMapper\CompanySettings::notificationDefaults(),
'settings' => null,
]);
$company_token = new \App\Models\CompanyToken();
$company_token->user_id = $this->user->id;
$company_token->company_id = $this->company->id;
@@ -129,7 +130,7 @@ class ProductSalesReportTest extends TestCase
$truth->setUser($this->user);
$truth->setCompany($this->company);
$this->payload = [
'start_date' => '2000-01-01',
'end_date' => '2030-01-11',

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -28,7 +29,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\TestCase;
/**
*
*
* App\Services\Report\ProfitLoss
*/
class ProfitAndLossReportTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -17,7 +18,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class ReportApiTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -35,7 +36,7 @@ use League\Csv\Reader;
use Tests\TestCase;
/**
*
*
*/
class ReportCsvGenerationTest extends TestCase
{
@@ -192,9 +193,10 @@ class ReportCsvGenerationTest extends TestCase
*/
private function buildData()
{
if($this->account)
if ($this->account) {
$this->account->forceDelete();
}
/** @var \App\Models\Account $account */
$this->account = Account::factory()->create([
'hosted_client_count' => 1000,
@@ -322,7 +324,7 @@ class ReportCsvGenerationTest extends TestCase
$this->assertEquals('client.name', $array[2]); //@phpstan-ignore-line
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -345,7 +347,7 @@ $this->account->forceDelete();
$products = explode(",", "clown,joker,batman,bob the builder");
foreach($products as $product) {
foreach ($products as $product) {
$query->where(function ($q) use ($product) {
$q->orWhereJsonContains('line_items', ['product_key' => $product]);
});
@@ -369,7 +371,7 @@ $this->account->forceDelete();
);
$query->where(function ($q) use ($products) {
foreach($products as $product) {
foreach ($products as $product) {
$q->orWhereJsonContains('line_items', ['product_key' => $product]);
}
});
@@ -399,7 +401,7 @@ $this->account->forceDelete();
$query = Invoice::query();
$query->where(function ($q) use ($products) {
foreach($products as $product) {
foreach ($products as $product) {
$q->orWhereJsonContains('line_items', ['product_key' => $product]);
}
});
@@ -415,7 +417,7 @@ $this->account->forceDelete();
$this->assertEquals(1, $query->count());
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -476,7 +478,7 @@ $this->account->forceDelete();
$this->assertEquals(1, $q->count());
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -556,9 +558,9 @@ $this->account->forceDelete();
$this->assertEquals('address1', $this->traverseJson($data, '0.0.value'));
$this->assertEquals('vendor.address1', $this->traverseJson($data, '0.0.identifier'));
$this->assertEquals('address1', $this->traverseJson($data, '0.0.display_value'));
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -630,7 +632,7 @@ $this->account->forceDelete();
$this->assertEquals('Vendor 1', $this->traverseJson($data, '0.0.display_value'));
$this->assertEquals('number', $this->traverseJson($data, '0.2.id'));
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -670,9 +672,9 @@ $this->account->forceDelete();
]);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$log = '[[1689547165,1689550765,"sumtin",true]]';
\App\Models\Task::factory()->create([
@@ -785,7 +787,7 @@ $this->account->forceDelete();
$csv = $response->body();
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -841,7 +843,7 @@ $this->account->forceDelete();
$this->assertEquals('Custom 3', $this->getFirstValueByColumn($csv, 'Task Custom Value 3'));
$this->assertEquals('Custom 4', $this->getFirstValueByColumn($csv, 'Task Custom Value 4'));
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -908,7 +910,7 @@ $this->account->forceDelete();
$this->assertEquals('custom_value1', $this->traverseJson($data, '0.0.identifier'));
$this->assertEquals('Custom 1', $this->traverseJson($data, '0.0.display_value'));
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -950,9 +952,9 @@ $this->account->forceDelete();
$invoice->client->paid_to_date = 0;
$invoice->push();
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$invoice->service()->markPaid()->save();
@@ -1057,7 +1059,7 @@ $invoice = $repo->save([], $invoice);
$csv = $response->body();
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -1103,7 +1105,7 @@ $this->account->forceDelete();
$this->assertEquals('2020-01-01', $this->getFirstValueByColumn($csv, 'Payment Date'));
$this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Payment Transaction Reference'));
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -1145,7 +1147,7 @@ $this->account->forceDelete();
$this->assertEquals('bob', $res[1]);
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -1286,7 +1288,7 @@ $this->account->forceDelete();
$response = $this->poll($hash);
$csv = $response->body();
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -1322,9 +1324,9 @@ $this->account->forceDelete();
]
]);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$data = [
'date_range' => 'all',
@@ -1370,7 +1372,7 @@ $this->account->forceDelete();
'X-API-TOKEN' => $this->token,
])->post('/api/v1/reports/invoices', $data)->assertStatus(200);
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -1426,7 +1428,7 @@ $this->account->forceDelete();
'X-API-TOKEN' => $this->token,
])->post('/api/v1/reports/recurring_invoices', $data)->assertStatus(200);
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -1475,7 +1477,7 @@ $this->account->forceDelete();
$this->assertEquals('Daily', $this->getFirstValueByColumn($csv, 'Recurring Invoice How Often'));
$this->assertEquals('Active', $this->getFirstValueByColumn($csv, 'Recurring Invoice Status'));
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -1516,8 +1518,8 @@ $this->account->forceDelete();
]
]);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$data = [
'date_range' => 'all',
@@ -1588,7 +1590,7 @@ $invoice = $repo->save([], $invoice);
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/reports/invoice_items', $data)->assertStatus(200);
$this->account->forceDelete();
$this->account->forceDelete();
}
@@ -1734,7 +1736,7 @@ $this->account->forceDelete();
$this->assertEquals('Public', $this->getFirstValueByColumn($csv, 'Purchase Order Public Notes'));
$this->assertEquals('Private', $this->getFirstValueByColumn($csv, 'Purchase Order Private Notes'));
$this->assertEquals('Terms', $this->getFirstValueByColumn($csv, 'Purchase Order Terms'));
$this->account->forceDelete();
}
@@ -1920,10 +1922,10 @@ $this->account->forceDelete();
]
]);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$repo = new InvoiceRepository();
$invoice = $repo->save([], $invoice);
$invoice->service()->markPaid()->save();
$data = [

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -33,7 +34,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class ReportPreviewTest extends TestCase
{
@@ -447,7 +448,7 @@ class ReportPreviewTest extends TestCase
'date_range' => 'all',
'report_keys' => ['client.name','client.balance','contact.email'],
'include_deleted' => false,
'user_id' => $this->user->id,
'user_id' => $this->user->id,
];
$p = (new PreviewReport($this->company, $data, ContactExport::class, '123'))->handle();

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -27,7 +28,7 @@ use App\Listeners\Invoice\InvoiceTransactionEventEntry;
use App\Listeners\Invoice\InvoiceTransactionEventEntryCash;
/**
*
*
*/
class TaxSummaryReportTest extends TestCase
{
@@ -111,7 +112,7 @@ class TaxSummaryReportTest extends TestCase
'notifications' => \App\DataMapper\CompanySettings::notificationDefaults(),
'settings' => null,
]);
$company_token = new \App\Models\CompanyToken();
$company_token->user_id = $this->user->id;
$company_token->company_id = $this->company->id;
@@ -219,7 +220,7 @@ class TaxSummaryReportTest extends TestCase
$i2 = $i2->calc()->getInvoice();
$i2->service()->markPaid();
for($x=0; $x<50; $x++){
for ($x = 0; $x < 50; $x++) {
$date = now();
@@ -243,7 +244,7 @@ class TaxSummaryReportTest extends TestCase
'uses_inclusive_taxes' => false,
'line_items' => $this->buildLineItems(),
]);
$i3 = $i3->calc()->getInvoice();
$i3 = $i3->service()->markSent()->save();
@@ -287,7 +288,7 @@ class TaxSummaryReportTest extends TestCase
$i2->service()->applyPaymentAmount(10, 'yadda')->save();
$this->travelTo(now()->addDay());
$i2->service()->applyPaymentAmount(1, 'yadda - 1')->save();
$this->travelTo(now()->addDay());
@@ -304,7 +305,7 @@ class TaxSummaryReportTest extends TestCase
config(['queue.default' => 'sync']);
$this->assertNotNull($payment);
$data = [
'id' => $payment->id,
'amount' => $payment->amount,
@@ -338,7 +339,7 @@ class TaxSummaryReportTest extends TestCase
config(['queue.default' => 'redis']);
$this->account->delete();
}
@@ -452,7 +453,7 @@ class TaxSummaryReportTest extends TestCase
$i = $i->calc()->getInvoice();
$i->service()->markSent()->save();
(new InvoiceTransactionEventEntry())->run($i);
$i2 = Invoice::factory()->create([
@@ -481,13 +482,13 @@ class TaxSummaryReportTest extends TestCase
(new InvoiceTransactionEventEntryCash())->run($i2, now()->subDays(30)->format('Y-m-d'), now()->addDays(30)->format('Y-m-d'));
// $tr = new \App\Services\Report\XLS\TaxReport($this->company, '2025-01-01', '2025-12-31');
// $response = $tr->run()->getXlsFile();
// $tr = new \App\Services\Report\XLS\TaxReport($this->company, '2025-01-01', '2025-12-31');
// $response = $tr->run()->getXlsFile();
// $this->assertNotEmpty($response);
// $this->assertNotEmpty($response);
$this->assertNotNull(TransactionEvent::where('invoice_id', $i->id)->first());
$this->assertNotNull(TransactionEvent::where('invoice_id', $i2->id)->first());
$this->assertNotNull(TransactionEvent::where('invoice_id', $i->id)->first());
$this->assertNotNull(TransactionEvent::where('invoice_id', $i2->id)->first());
$this->account->delete();

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -26,7 +27,7 @@ use Illuminate\Support\Facades\Schema;
use Tests\TestCase;
/**
*
*
*/
class UserSalesReportTest extends TestCase
{
@@ -111,7 +112,7 @@ class UserSalesReportTest extends TestCase
'notifications' => \App\DataMapper\CompanySettings::notificationDefaults(),
'settings' => null,
]);
$company_token = new \App\Models\CompanyToken();
$company_token->user_id = $this->user->id;
$company_token->company_id = $this->company->id;
@@ -128,7 +129,7 @@ class UserSalesReportTest extends TestCase
$truth->setUser($this->user);
$truth->setCompany($this->company);
$this->payload = [
'start_date' => '2000-01-01',
'end_date' => '2030-01-11',

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -17,7 +18,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\FilterController
*/
class FilterApiTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class GoCardlessInstantBankPaymentTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*

View File

@@ -99,7 +99,7 @@ class ImportQuickbooksControllerTest extends TestCase
$count = count($data);
$this->mock->shouldReceive('Query')->andReturnUsing(
function ($val, $s = 1, $max = 1000) use ($count, $data) {
if(stristr($val, 'count')) {
if (stristr($val, 'count')) {
return $count;
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Import\Transformer\BaseTransformer
*/
class BaseTransformerTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -25,7 +26,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Import\Providers\Csv
*/
class CsvImportTest extends TestCase
@@ -120,7 +121,7 @@ class CsvImportTest extends TestCase
Cache::put($hash.'-recurring_invoice', base64_encode($csv), 360);
// $this->user->setContext($this->company, $this->token);
$truth = app()->make(TruthSource::class);
$truth->setCompanyUser($this->cu);
$truth->setUser($this->user);
@@ -358,7 +359,7 @@ class CsvImportTest extends TestCase
Cache::put($hash.'-invoice', base64_encode($csv), 360);
// $this->user->setContext($this->company, $this->token);
// $truth = app()->make(TruthSource::class);
// $truth->setCompanyUser($this->cu);
// $truth->setUser($this->user);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -22,7 +23,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Import\Providers\Csv
*/
class TaskImportTest extends TestCase
@@ -95,7 +96,7 @@ class TaskImportTest extends TestCase
$time_log = json_decode($task->time_log);
foreach($time_log as $log) {
foreach ($time_log as $log) {
$this->assertTrue($log[3]);
}
@@ -105,7 +106,7 @@ class TaskImportTest extends TestCase
$time_log = json_decode($task->time_log);
foreach($time_log as $log) {
foreach ($time_log as $log) {
$this->assertTrue($log[3]);
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Import\Providers\Freshbooks
*/
class FreshbooksTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -53,7 +54,7 @@ use Illuminate\Support\Facades\Artisan;
use Tests\TestCase;
/**
*
*
*/
class ImportCompanyTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Import\Providers\Invoice2Go
*/
class Invoice2GoTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Import\Providers\Invoicely
*/
class InvoicelyTest extends TestCase

View File

@@ -36,16 +36,16 @@ class QuickbooksExportTest extends TestCase
protected function setUp(): void
{
parent::setUp();
parent::setUp();
if(config('ninja.testvars.travis') || !config('services.quickbooks.client_id')){
if (config('ninja.testvars.travis') || !config('services.quickbooks.client_id')) {
$this->markTestSkipped('No Quickbooks Client ID found');
}
$company = Company::find(1);
if(!$company){
if (!$company) {
$this->markTestSkipped('No company found');
}
@@ -63,8 +63,7 @@ class QuickbooksExportTest extends TestCase
// 'sales' => 'SalesReceipt',
];
foreach($entities as $key => $entity)
{
foreach ($entities as $key => $entity) {
$records = $this->qb->sdk()->fetchRecords($entity);
$this->assertNotNull($records);
@@ -90,4 +89,4 @@ class QuickbooksExportTest extends TestCase
}
}
}

View File

@@ -38,8 +38,8 @@ class QuickbooksMappingTest extends TestCase
protected function setUp(): void
{
parent::setUp();
parent::setUp();
if (config('ninja.testvars.travis') !== false) {
$this->markTestSkipped('Skip test for GH Actions');
@@ -52,7 +52,7 @@ class QuickbooksMappingTest extends TestCase
public function testBackupImport()
{
$qb = new QuickbooksService($this->company);
$pre_count = Client::where('company_id', $this->company->id)->count();
@@ -60,8 +60,8 @@ class QuickbooksMappingTest extends TestCase
$post_count = Client::where('company_id', $this->company->id)->count();
$this->assertGreaterThan($pre_count, $post_count);
$pre_count = Product::where('company_id', $this->company->id)->count();
$pre_count = Product::where('company_id', $this->company->id)->count();
$qb->product->syncToNinja($this->qb_data['products']);
$post_count = Product::where('company_id', $this->company->id)->count();
@@ -74,7 +74,7 @@ class QuickbooksMappingTest extends TestCase
Invoice::where('company_id', $this->company->id)->cursor()->each(function ($invoice) {
$invoice->forceDelete();
});
$pre_count = Invoice::where('company_id', $this->company->id)->count();
$this->assertGreaterThan(0, count($this->qb_data['invoices']));
@@ -87,12 +87,12 @@ class QuickbooksMappingTest extends TestCase
$pre_count = Payment::where('company_id', $this->company->id)->count();
$this->assertGreaterThan(0, count($this->qb_data['payments']));
$qb->payment->importToNinja($this->qb_data['payments']);
$post_count = Payment::where('company_id', $this->company->id)->count();
$this->assertGreaterThan($pre_count, $post_count);
//loop and check every single invoice amount/balance
$qb_invoices = collect($this->qb_data['invoices']);
@@ -102,7 +102,7 @@ class QuickbooksMappingTest extends TestCase
// nlog($qb_invoice);
// nlog($invoice->toArray());
if(!$qb_invoice) {
if (!$qb_invoice) {
nlog("Borked trying to find invoice {$invoice->sync->qb_id} in qb_invoices");
}
@@ -116,8 +116,8 @@ class QuickbooksMappingTest extends TestCase
// nlog($total_balance);
// nlog($invoice->balance);
$delta_amount = abs(round($total_amount - $invoice->amount,2));
$delta_balance = abs(round($total_balance - $invoice->balance,2));
$delta_amount = abs(round($total_amount - $invoice->amount, 2));
$delta_balance = abs(round($total_balance - $invoice->balance, 2));
$this->assertLessThanOrEqual(0.01, $delta_amount);
$this->assertLessThanOrEqual(0.01, $delta_balance);
@@ -144,12 +144,12 @@ class QuickbooksMappingTest extends TestCase
{
$this->assertTrue(isset($this->qb_data['clients']));
}
public function testClientTransformation()
{
$ct = new ClientTransformer($this->company);
$client_array = $ct->transform($this->qb_data['clients'][0]);
$this->assertNotNull($client_array);

View File

@@ -39,8 +39,8 @@ class QuickbooksTest extends TestCase
protected function setUp(): void
{
parent::setUp();
parent::setUp();
$this->markTestSkipped('Skip test for GH Actions');
// if (config('ninja.testvars.travis') !== false) {
@@ -216,16 +216,16 @@ class QuickbooksTest extends TestCase
$this->qb = new QuickbooksService($this->company);
$customer = $this->createQbCustomer();
//create ninja invoice
$qb_invoice = $this->createQbInvoice($customer);
$this->assertNotNull($qb_invoice);
$this->assertNotNull($qb_invoice);
// sleep(5);
// sleep(5);
// $updatedInvoice = $this->qb->sdk->FindById('invoice', $qb_invoice->Id->value);
// $updatedInvoice = $this->qb->sdk->FindById('invoice', $qb_invoice->Id->value);
@@ -236,7 +236,7 @@ $this->assertNotNull($qb_invoice);
{
$this->company = Company::whereNotNull('quickbooks')->first();
$this->qb = new QuickbooksService($this->company);
$resultingCustomerObj = $this->createQbCustomer();
// Check for errors
@@ -250,7 +250,7 @@ $this->assertNotNull($qb_invoice);
$this->assertNotNull($qb_id);
$c = Client::find($resultingCustomerObj[1]);
$this->assertEquals($qb_id, $c->sync->qb_id);
}
@@ -319,7 +319,7 @@ $this->assertNotNull($qb_invoice);
// $this->assertEquals(30, $i->balance);
$line_items = [];
// $taxDetail = [
// "TotalTax" => 0,
// "TaxLine" => []
@@ -327,8 +327,7 @@ $this->assertNotNull($qb_invoice);
$line_num = 1;
foreach($i->line_items as $line_item)
{
foreach ($i->line_items as $line_item) {
$product = Product::where('company_id', $this->company->id)
->where('product_key', $line_item->product_key)
->first();
@@ -340,7 +339,7 @@ $this->assertNotNull($qb_invoice);
'DetailType' => 'SalesItemLineDetail',
'SalesItemLineDetail' => [
'ItemRef' => [
'value' => $product->sync->qb_id,
'value' => $product->sync->qb_id,
],
'Qty' => $line_item->quantity,
'UnitPrice' => $line_item->cost,
@@ -371,7 +370,7 @@ $this->assertNotNull($qb_invoice);
// $taxDetail['TaxLine'][] = $tax_line_detail;
// $taxDetail['TotalTax'] += $line_item->tax_amount;
// }
// if ($line_item->tax_rate2 > 0) {
// $tax_line_detail = [
// "Amount" => $line_item->tax_amount,
@@ -442,14 +441,14 @@ $this->assertNotNull($qb_invoice);
// ]
// "Note" => $this->invoice->public_notes,
];
nlog($invoiceData);
$invoice = \QuickBooksOnline\API\Facades\Invoice::create($invoiceData);
$invoice = \QuickBooksOnline\API\Facades\Invoice::create($invoiceData);
nlog($invoice);
$qb_invoice = $this->qb->sdk->Add($invoice);
$sync = new InvoiceSync();

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -26,7 +27,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Import\Providers\Wave
*/
class WaveTest extends TestCase

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -25,7 +26,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Import\Providers\Zoho
*/
class ZohoTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -21,7 +22,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class InventoryManagementTest extends TestCase
{
@@ -45,7 +46,7 @@ class InventoryManagementTest extends TestCase
public function testInventoryMovements()
{
config(['queue.default' => 'sync']);
$product = Product::factory()->create([

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -26,7 +27,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
/**
*
*
* App\Models\InvoiceInvitation
*/
class InvitationTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -20,7 +21,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class InvoiceAmountPaymentTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -25,7 +26,7 @@ use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
*
*
* App\Jobs\Invoice\EmailInvoice
*/
class InvoiceEmailTest extends TestCase
@@ -54,14 +55,14 @@ class InvoiceEmailTest extends TestCase
{
$this->user->setCompany($this->company);
$this->actingAs($this->user);
$request = new SendEmailRequest();
collect($request->templates)->filter(function ($template){
collect($request->templates)->filter(function ($template) {
return stripos($template, 'quote') === false;
})->each(function ($template) use($request){
})->each(function ($template) use ($request) {
$data = [
"body" => "hey what's up",
"entity" => 'App\Models\Invoice',
@@ -72,9 +73,9 @@ class InvoiceEmailTest extends TestCase
$request->initialize($data);
$validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->passes());
});
@@ -88,7 +89,7 @@ class InvoiceEmailTest extends TestCase
}
public function testTemplateValidationWhenArray()
public function testTemplateValidationWhenArray()
{
$data = [
"body" => "hey what's up",

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -19,7 +20,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class InvoiceLinkTasksTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -85,11 +86,10 @@ class InvoiceTaxReportTest extends TestCase
$this->assertNotNull($i);
//test tax data object to see if we are using automated taxes.
if(isset($i->tax_data->geoState)){
if (isset($i->tax_data->geoState)) {
$nexus = $i->tax_data->geoState;
$country_nexus = 'USA';
}
else {
} else {
$nexus = strlen($i->client->state ?? '') > 0 ? $i->client->state : $i->company->settings->state;
$country_nexus = strlen($i->client->state ?? '') > 0 ? $i->client->country->iso_3166_2 : $i->company->country()->iso_3166_2;
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -28,7 +29,7 @@ use Illuminate\Support\Facades\Session;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
*
*
* App\Http\Controllers\InvoiceController
*/
class InvoiceTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -20,7 +21,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\PreviewController
*/
class LiveDesignTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -37,7 +38,7 @@ use Illuminate\Support\Str;
use Tests\TestCase;
/**
*
*
*/
class LoadTest extends TestCase
{

View File

@@ -64,7 +64,7 @@ class LocationApiTest extends TestCase
'city' => 'Location City',
'state' => 'Location State',
'postal_code' => 'Location Postal Code',
'country_id' => '4',
'country_id' => '4',
'is_shipping_location' => false,
]);
@@ -74,7 +74,7 @@ class LocationApiTest extends TestCase
'client_id' => $client->id,
'location_id' => $location->id,
]);
$invoice->service()->createInvitations()->markSent()->save();
$invitation = $invoice->invitations()->first();
@@ -89,7 +89,7 @@ class LocationApiTest extends TestCase
$this->assertEquals('Location State', $data['$client.state']);
$this->assertEquals('Location Postal Code', $data['$client.postal_code']);
$this->assertEquals('Afghanistan', $data['$client.country']);
$this->assertEquals('Shipping Address 1', $data['$client.shipping_address1']);
$this->assertEquals('Shipping Address 2', $data['$client.shipping_address2']);
$this->assertEquals('Shipping City', $data['$client.shipping_city']);
@@ -131,7 +131,7 @@ class LocationApiTest extends TestCase
'city' => 'Location City',
'state' => 'Location State',
'postal_code' => 'Location Postal Code',
'country_id' => '4',
'country_id' => '4',
'is_shipping_location' => true,
]);
@@ -141,7 +141,7 @@ class LocationApiTest extends TestCase
'client_id' => $client->id,
'location_id' => $location->id,
]);
$invoice->service()->createInvitations()->markSent()->save();
$invitation = $invoice->invitations()->first();
@@ -156,7 +156,7 @@ class LocationApiTest extends TestCase
$this->assertEquals('TS', $data['$client.state']);
$this->assertEquals('12345', $data['$client.postal_code']);
$this->assertEquals('United States', $data['$client.country']);
$this->assertEquals('Location Address 1', $data['$client.shipping_address1']);
$this->assertEquals('Location Address 2', $data['$client.shipping_address2']);
$this->assertEquals('Location City', $data['$client.shipping_city']);
@@ -199,7 +199,7 @@ class LocationApiTest extends TestCase
'city' => 'Location City',
'state' => 'Location State',
'postal_code' => 'Location Postal Code',
'country_id' => '4',
'country_id' => '4',
'is_shipping_location' => true,
]);
@@ -209,7 +209,7 @@ class LocationApiTest extends TestCase
'client_id' => $client->id,
'location_id' => $location->id,
]);
$invoice->service()->createInvitations()->markSent()->save();
$invitation = $invoice->invitations()->first();
@@ -224,7 +224,7 @@ class LocationApiTest extends TestCase
$this->assertEquals('Location State', $data['$client.shipping_state']);
$this->assertEquals('Location Postal Code', $data['$client.shipping_postal_code']);
$this->assertEquals('Afghanistan', $data['$client.shipping_country']);
}
public function testResolvingBusinessLocationData()
@@ -259,7 +259,7 @@ class LocationApiTest extends TestCase
'city' => 'Location City',
'state' => 'Location State',
'postal_code' => 'Location Postal Code',
'country_id' => '4',
'country_id' => '4',
]);
$invoice = Invoice::factory()->create([
@@ -268,7 +268,7 @@ class LocationApiTest extends TestCase
'client_id' => $client->id,
'location_id' => $location->id,
]);
$invoice->service()->createInvitations()->markSent()->save();
$invitation = $invoice->invitations()->first();
@@ -283,7 +283,7 @@ class LocationApiTest extends TestCase
$this->assertEquals('Location State', $data['$client.state']);
$this->assertEquals('Location Postal Code', $data['$client.postal_code']);
$this->assertEquals('Afghanistan', $data['$client.country']);
}
public function testLocationPost()
@@ -304,15 +304,15 @@ class LocationApiTest extends TestCase
$response->assertStatus(422);
$data = [
'name' => 'Test Location',
'address1' => '123 Test St',
'address2' => 'Suite 100',
'city' => 'Test City',
'state' => 'TS',
'postal_code' => '12345',
'country_id' => '840', // USA
'client_id' => $this->client->id,
$data = [
'name' => 'Test Location',
'address1' => '123 Test St',
'address2' => 'Suite 100',
'city' => 'Test City',
'state' => 'TS',
'postal_code' => '12345',
'country_id' => '840', // USA
'client_id' => $this->client->id,
];
$response = $this->withHeaders([

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -22,7 +23,7 @@ use Illuminate\Validation\ValidationException;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\Auth\LoginController
*/
class LoginTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
*
*
* App\Http\Controllers\ActivityController
*/
class MaxAmountTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -21,7 +22,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\MigrationController
*/
class MigrationTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -27,7 +28,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
/**
*
*
*/
class MultiPaymentDeleteTest extends TestCase
{
@@ -291,7 +292,7 @@ class MultiPaymentDeleteTest extends TestCase
],
'date' => '2019/12/12',
];
sleep(1);
sleep(1);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@@ -351,7 +352,7 @@ sleep(1);
])->post('/api/v1/invoices/bulk?action=delete', $data);
$this->assertFalse($invoice->verifactuEnabled());
$response->assertStatus(200);
$this->assertEquals(0, $invoice->fresh()->balance);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -24,7 +25,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class PlanTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -25,7 +26,7 @@ use App\Utils\Traits\Notifications\UserNotifies;
use Illuminate\Routing\Middleware\ThrottleRequests;
/**
*
*
* App\Utils\Traits\Notifications\UserNotifies
*/
class NotificationTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -22,7 +23,7 @@ use App\Factory\InvoiceItemFactory;
use App\Helpers\Subscription\SubscriptionCalculator;
/**
*
*
*/
class PaymentLinkTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -22,7 +23,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\PaymentTermController
*/
class PaymentTermsApiTest extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -33,7 +34,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\PaymentController
*/
class PaymentTest extends TestCase
@@ -65,11 +66,11 @@ class PaymentTest extends TestCase
public function testDeletedCreditPayment()
{
$client = Client::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'balance' => 0,
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'balance' => 0,
'paid_to_date' => 0,
'credit_balance' => 0,
'payment_balance' => 0,
@@ -151,17 +152,17 @@ class PaymentTest extends TestCase
$arr = $response->json();
$response->assertStatus(422);
}
public function testRefundCreditPayment()
{
$client = Client::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'balance' => 0,
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'balance' => 0,
'paid_to_date' => 0,
'credit_balance' => 0,
'payment_balance' => 0,
@@ -240,7 +241,7 @@ class PaymentTest extends TestCase
$this->assertEquals(0, $payment->refunded);
$this->assertEquals(0, $payment->applied);
$client = $client->refresh();
$client = $client->refresh();
$this->assertEquals(0, $client->balance);
$this->assertEquals(10, $client->paid_to_date);
@@ -249,7 +250,7 @@ class PaymentTest extends TestCase
$credit = $credit->refresh();
$this->assertEquals(0, $credit->balance);
$refund_payload = [
'id' => $payment->hashed_id,
'amount' => 10,
@@ -262,12 +263,12 @@ class PaymentTest extends TestCase
],
],
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/payments/refund', $refund_payload);
$response->assertStatus(200);
@@ -276,7 +277,7 @@ class PaymentTest extends TestCase
$credit = $credit->refresh();
$this->assertEquals(10, $credit->balance);
$client = $client->refresh();
$this->assertEquals(10, $client->balance);
$this->assertEquals(0, $client->paid_to_date);
@@ -284,7 +285,7 @@ class PaymentTest extends TestCase
$payment = $payment->refresh();
$this->assertEquals(0, $payment->refunded);
$this->assertEquals(0, $payment->applied);
}
public function testDeleteInvoiceDeletePaymentRaceCondition()
@@ -345,7 +346,7 @@ class PaymentTest extends TestCase
$this->assertEquals(true, $invoice->is_deleted);
$dead_payment = $invoice->payments->first();
$this->assertEquals(true, $dead_payment->is_deleted);
$response = $this->withHeaders([
@@ -359,7 +360,7 @@ class PaymentTest extends TestCase
public function testNullExchangeRateHandling()
{
$data = [
'amount' => 0,
'applied' => 0,
@@ -400,7 +401,7 @@ class PaymentTest extends TestCase
'vendor_id' => null,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -415,16 +416,16 @@ class PaymentTest extends TestCase
public function testNegativePaymentPaidToDate()
{
$c = Client::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,
]);
$this->assertEquals(0, $c->balance);
$this->assertEquals(0, $c->paid_to_date);
$this->assertEquals(0, $c->credit_balance);
$this->assertEquals(0, $c->payment_balance);
$this->assertEquals(0, $c->balance);
$this->assertEquals(0, $c->paid_to_date);
$this->assertEquals(0, $c->credit_balance);
$this->assertEquals(0, $c->payment_balance);
$data = [
'amount' => -500,
@@ -442,7 +443,7 @@ class PaymentTest extends TestCase
])->postJson('/api/v1/payments/', $data);
$response->assertStatus(200);
$p = $response->json()['data'];
$payment = Payment::find($this->decodePrimaryKey($p['id']));
@@ -471,7 +472,7 @@ class PaymentTest extends TestCase
}
public function testNullPaymentAmounts()
public function testNullPaymentAmounts()
{
$data = [

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -27,7 +28,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
* App\Http\Controllers\PaymentController
*/
class PaymentV2Test extends TestCase

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -28,7 +29,7 @@ use Tests\MockUnitData;
use Tests\TestCase;
/**
*
*
*/
class AutoUnappliedPaymentTest extends TestCase
{
@@ -96,7 +97,7 @@ class AutoUnappliedPaymentTest extends TestCase
try {
$invoice->service()->autoBill()->save();
} catch(\Exception $e) {
} catch (\Exception $e) {
}
@@ -156,7 +157,7 @@ class AutoUnappliedPaymentTest extends TestCase
try {
$invoice->service()->autoBill()->save();
} catch(\Exception $e) {
} catch (\Exception $e) {
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -27,7 +28,7 @@ use Tests\MockUnitData;
use Tests\TestCase;
/**
*
*
*/
class CreditPaymentTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -21,7 +22,7 @@ use Tests\MockUnitData;
use Tests\TestCase;
/**
*
*
*/
class DeletePaymentTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -21,7 +22,7 @@ use Tests\MockAccountData;
use Tests\TestCase;
/**
*
*
*/
class StorePaymentValidationTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -23,7 +24,7 @@ use Tests\MockUnitData;
use Tests\TestCase;
/**
*
*
*/
class UnappliedPaymentDeleteTest extends TestCase
{
@@ -189,7 +190,7 @@ class UnappliedPaymentDeleteTest extends TestCase
$payment_hashed_id = $arr['data']['id'];
$payment = Payment::find($this->decodePrimaryKey($payment_hashed_id));
$payment->invoices()->each(function ($i){
$payment->invoices()->each(function ($i) {
$this->assertEquals(20, $i->pivot->amount);
$this->assertEquals(0, $i->pivot->refunded);
@@ -207,7 +208,7 @@ class UnappliedPaymentDeleteTest extends TestCase
$this->assertEquals(20, $invoice->fresh()->balance);
$this->assertEquals(0, $invoice->fresh()->paid_to_date);
$this->assertEquals(0, $client->fresh()->paid_to_date);
$this->assertEquals(20, $client->fresh()->balance);
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@@ -20,7 +21,7 @@ use Tests\MockUnitData;
use Tests\TestCase;
/**
*
*
*/
class UnappliedPaymentRefundTest extends TestCase
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*

Some files were not shown because too many files have changed in this diff Show More