Fixes for tests
This commit is contained in:
parent
08332ed087
commit
cba7e7b2bd
|
|
@ -495,7 +495,7 @@ class Client extends BaseModel implements HasLocalePreference
|
|||
return $item->id == $currency_id;
|
||||
});
|
||||
|
||||
});
|
||||
}) ?? \App\Models\Currency::find($this->getSetting('currency_id'));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -263,6 +263,7 @@ class StaticServiceProvider extends ServiceProvider
|
|||
|
||||
});
|
||||
|
||||
nlog("static service provider registered");
|
||||
}
|
||||
|
||||
public function boot()
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ use App\Models\Credit;
|
|||
use App\Models\Expense;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\User;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
|
@ -652,6 +653,9 @@ $this->account->forceDelete();
|
|||
]);
|
||||
|
||||
|
||||
$repo = new InvoiceRepository();
|
||||
$invoice = $repo->save([], $invoice);
|
||||
|
||||
$log = '[[1689547165,1689550765,"sumtin",true]]';
|
||||
|
||||
\App\Models\Task::factory()->create([
|
||||
|
|
@ -912,6 +916,11 @@ $this->account->forceDelete();
|
|||
$invoice->client->paid_to_date = 0;
|
||||
$invoice->push();
|
||||
|
||||
|
||||
$repo = new InvoiceRepository();
|
||||
$invoice = $repo->save([], $invoice);
|
||||
|
||||
|
||||
$invoice->service()->markPaid()->save();
|
||||
|
||||
$data = [
|
||||
|
|
@ -1262,6 +1271,10 @@ $this->account->forceDelete();
|
|||
'terms' => 'Terms',
|
||||
]);
|
||||
|
||||
$repo = new InvoiceRepository();
|
||||
$invoice = $repo->save([], $invoice);
|
||||
|
||||
|
||||
$data = [
|
||||
'date_range' => 'all',
|
||||
'report_keys' => ["client.name","invoice.number","invoice.amount","payment.date", "payment.amount","invoice.user"],
|
||||
|
|
@ -1452,6 +1465,9 @@ $this->account->forceDelete();
|
|||
]
|
||||
]);
|
||||
|
||||
$repo = new InvoiceRepository();
|
||||
$invoice = $repo->save([], $invoice);
|
||||
|
||||
$data = [
|
||||
'date_range' => 'all',
|
||||
'report_keys' => ["client.name","invoice.number","invoice.amount","payment.date", "payment.amount", "item.quantity", "item.cost", "item.line_total", "item.discount", "item.notes", "item.product_key", "item.custom_value1", "item.tax_name1", "item.tax_rate1",],
|
||||
|
|
@ -1844,6 +1860,10 @@ $this->account->forceDelete();
|
|||
'terms' => 'Terms',
|
||||
]);
|
||||
|
||||
$repo = new InvoiceRepository();
|
||||
$invoice = $repo->save([], $invoice);
|
||||
|
||||
|
||||
$invoice->service()->markPaid()->save();
|
||||
|
||||
$data = [
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
class ProjectApiTest extends TestCase
|
||||
{
|
||||
use MakesHash;
|
||||
use DatabaseTransactions;
|
||||
// use DatabaseTransactions;
|
||||
use MockAccountData;
|
||||
|
||||
protected $faker;
|
||||
|
|
|
|||
|
|
@ -11,59 +11,62 @@
|
|||
|
||||
namespace Tests;
|
||||
|
||||
use App\DataMapper\ClientRegistrationFields;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Factory\CompanyUserFactory;
|
||||
use App\Factory\CreditFactory;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Factory\InvoiceInvitationFactory;
|
||||
use App\Factory\InvoiceItemFactory;
|
||||
use App\Factory\InvoiceToRecurringInvoiceFactory;
|
||||
use App\Factory\PurchaseOrderFactory;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||
use App\Models\Account;
|
||||
use App\Models\BankIntegration;
|
||||
use App\Models\BankTransaction;
|
||||
use App\Models\BankTransactionRule;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use App\Models\Quote;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\CompanyToken;
|
||||
use App\Models\Country;
|
||||
use App\Models\Credit;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Models\Country;
|
||||
use App\Models\Expense;
|
||||
use App\Models\ExpenseCategory;
|
||||
use App\Models\GroupSetting;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Product;
|
||||
use App\Models\Project;
|
||||
use App\Models\PurchaseOrderInvitation;
|
||||
use App\Models\Quote;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\Currency;
|
||||
use App\Models\Scheduler;
|
||||
use App\Models\TaskStatus;
|
||||
use App\Utils\TruthSource;
|
||||
use App\Models\CompanyToken;
|
||||
use App\Models\GroupSetting;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\VendorContact;
|
||||
use App\Factory\CreditFactory;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\RecurringQuote;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Models\BankIntegration;
|
||||
use App\Models\BankTransaction;
|
||||
use App\Models\ExpenseCategory;
|
||||
use App\Models\QuoteInvitation;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\RecurringExpense;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Models\RecurringQuote;
|
||||
use App\Models\Scheduler;
|
||||
use App\Models\Task;
|
||||
use App\Models\TaskStatus;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\User;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\VendorContact;
|
||||
use App\Utils\Traits\GeneratesCounter;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\TruthSource;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Factory\CompanyUserFactory;
|
||||
use App\Factory\InvoiceItemFactory;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Models\BankTransactionRule;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Factory\PurchaseOrderFactory;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Utils\Traits\GeneratesCounter;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Models\PurchaseOrderInvitation;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Factory\InvoiceInvitationFactory;
|
||||
use App\DataMapper\ClientRegistrationFields;
|
||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||
use App\Repositories\RecurringInvoiceRepository;
|
||||
use App\Factory\InvoiceToRecurringInvoiceFactory;
|
||||
|
||||
/**
|
||||
* Class MockAccountData.
|
||||
|
|
@ -208,6 +211,18 @@ trait MockAccountData
|
|||
Artisan::call('db:seed', ['--force' => true]);
|
||||
}
|
||||
|
||||
|
||||
app()->singleton('currencies', function ($app) {
|
||||
|
||||
$resource = Currency::query()->orderBy('name')->get();
|
||||
|
||||
Cache::forever('currencies', $resource);
|
||||
|
||||
return $resource;
|
||||
|
||||
});
|
||||
|
||||
|
||||
$this->faker = \Faker\Factory::create();
|
||||
$fake_email = $this->faker->email();
|
||||
|
||||
|
|
@ -309,9 +324,13 @@ trait MockAccountData
|
|||
'company_id' => $this->company->id,
|
||||
]);
|
||||
|
||||
// $client_settings = ClientSettings::defaults();
|
||||
// $client_settings->currency_id = '1';
|
||||
|
||||
$this->client = Client::factory()->create([
|
||||
'user_id' => $user_id,
|
||||
'company_id' => $this->company->id,
|
||||
// 'settings' => $client_settings,
|
||||
]);
|
||||
|
||||
Storage::makeDirectory($this->company->company_key.'/'.$this->client->client_hash.'/invoices', 0755, true);
|
||||
|
|
@ -439,6 +458,9 @@ trait MockAccountData
|
|||
'uses_inclusive_taxes' => false,
|
||||
]);
|
||||
|
||||
$repo = new RecurringInvoiceRepository();
|
||||
$this->recurring_invoice = $repo->save([], $this->recurring_invoice);
|
||||
|
||||
$this->recurring_invoice_calc = new InvoiceSum($this->recurring_invoice);
|
||||
$this->recurring_invoice_calc->build();
|
||||
$this->recurring_invoice = $this->recurring_invoice_calc->getRecurringInvoice();
|
||||
|
|
@ -480,6 +502,9 @@ trait MockAccountData
|
|||
$this->invoice->fresh()->service()->markSent();
|
||||
// $this->invoice->service()->markSent();
|
||||
|
||||
$repo = new InvoiceRepository();
|
||||
$this->invoice = $repo->save([], $this->invoice);
|
||||
|
||||
$this->quote = Quote::factory()->create([
|
||||
'user_id' => $user_id,
|
||||
'client_id' => $this->client->id,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ abstract class TestCase extends BaseTestCase
|
|||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace Tests\Unit;
|
|||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -21,7 +22,7 @@ use Tests\TestCase;
|
|||
*/
|
||||
class AutoBillInvoiceTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
// use DatabaseTransactions;
|
||||
use MockAccountData;
|
||||
|
||||
protected function setUp(): void
|
||||
|
|
@ -29,10 +30,12 @@ class AutoBillInvoiceTest extends TestCase
|
|||
parent::setUp();
|
||||
|
||||
$this->makeTestData();
|
||||
|
||||
}
|
||||
|
||||
public function testAutoBillFunctionality()
|
||||
{
|
||||
$this->assertEquals('1', $this->client->settings->currency_id);
|
||||
$this->assertEquals($this->client->balance, 10);
|
||||
$this->assertEquals($this->client->paid_to_date, 0);
|
||||
$this->assertEquals($this->client->credit_balance, 10);
|
||||
|
|
|
|||
|
|
@ -14,13 +14,14 @@ namespace Tests\Unit\Chart;
|
|||
use Tests\TestCase;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Currency;
|
||||
use Tests\MockAccountData;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Models\Expense;
|
||||
use App\Services\Chart\ChartService;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
/**
|
||||
|
|
@ -30,7 +31,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
class ChartCurrencyTest extends TestCase
|
||||
{
|
||||
use MockAccountData;
|
||||
use DatabaseTransactions;
|
||||
// use DatabaseTransactions;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
@ -72,6 +73,8 @@ class ChartCurrencyTest extends TestCase
|
|||
'user_id' => $this->user->id,
|
||||
'company_id' => $company->id,
|
||||
'settings' => $settings,
|
||||
'balance' => 0,
|
||||
'paid_to_date' => 0,
|
||||
]);
|
||||
|
||||
Currency::query()->where('id', 1)->update(['exchange_rate' => 1]);
|
||||
|
|
@ -84,9 +87,10 @@ class ChartCurrencyTest extends TestCase
|
|||
'user_id' => $this->user->id,
|
||||
'company_id' => $company->id,
|
||||
'settings' => $settings,
|
||||
'balance' => 0,
|
||||
'paid_to_date' => 0,
|
||||
]);
|
||||
|
||||
|
||||
$i1 = Invoice::factory()->create([
|
||||
'client_id' => $usd->id,
|
||||
'user_id' => $this->user->id,
|
||||
|
|
@ -96,7 +100,18 @@ class ChartCurrencyTest extends TestCase
|
|||
'paid_to_date' => 0,
|
||||
'status_id' => 2,
|
||||
'date' => now(),
|
||||
'due_date' => now()
|
||||
'due_date' => now(),
|
||||
'line_items' => [
|
||||
[
|
||||
'product_key' => 'product_1',
|
||||
'quantity' => 1,
|
||||
'cost' => 100,
|
||||
]
|
||||
],
|
||||
'tax_rate1' => 0,
|
||||
'tax_rate2' => 0,
|
||||
'tax_rate3' => 0,
|
||||
'discount' => 0,
|
||||
]);
|
||||
|
||||
$i2 = Invoice::factory()->create([
|
||||
|
|
@ -108,19 +123,37 @@ class ChartCurrencyTest extends TestCase
|
|||
'paid_to_date' => 0,
|
||||
'status_id' => 2,
|
||||
'date' => now(),
|
||||
'due_date' => now()
|
||||
'due_date' => now(),
|
||||
'line_items' => [
|
||||
[
|
||||
'product_key' => 'product_1',
|
||||
'quantity' => 1,
|
||||
'cost' => 100,
|
||||
]
|
||||
],
|
||||
'tax_rate1' => 0,
|
||||
'tax_rate2' => 0,
|
||||
'tax_rate3' => 0,
|
||||
'discount' => 0,
|
||||
]);
|
||||
|
||||
$repo = new InvoiceRepository();
|
||||
$i1 = $repo->save([], $i1);
|
||||
$i2 = $repo->save([], $i2);
|
||||
|
||||
$i1->service()->markPaid()->save();
|
||||
$i2->service()->markPaid()->save();
|
||||
|
||||
|
||||
$this->assertEquals(100, $i1->amount);
|
||||
$this->assertEquals(100, $i2->amount);
|
||||
|
||||
$cs = new ChartService($company, $this->user, true);
|
||||
$results = $cs->totals('1970-01-01', '2050-01-01');
|
||||
|
||||
nlog($results);
|
||||
$this->assertCount(2, $results['currencies']);
|
||||
|
||||
// nlog($results);
|
||||
|
||||
$this->assertEquals('USD', $results['currencies'][1]);
|
||||
$this->assertEquals('GBP', $results['currencies'][2]);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use Tests\TestCase;
|
|||
class CompanyDocumentsTest extends TestCase
|
||||
{
|
||||
use MockAccountData;
|
||||
use DatabaseTransactions;
|
||||
// use DatabaseTransactions;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
class EInvoiceTest extends TestCase
|
||||
{
|
||||
use MockAccountData;
|
||||
use DatabaseTransactions;
|
||||
// use DatabaseTransactions;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
class EntityTest extends TestCase
|
||||
{
|
||||
use MockAccountData;
|
||||
use DatabaseTransactions;
|
||||
// use DatabaseTransactions;
|
||||
|
||||
public $invoice;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use Tests\TestCase;
|
|||
class FactoryCreationTest extends TestCase
|
||||
{
|
||||
use MakesHash;
|
||||
use DatabaseTransactions;
|
||||
// use DatabaseTransactions;
|
||||
use MockAccountData;
|
||||
|
||||
protected function setUp(): void
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
class GeneratesCounterTest extends TestCase
|
||||
{
|
||||
use GeneratesCounter;
|
||||
use DatabaseTransactions;
|
||||
// use DatabaseTransactions;
|
||||
use MakesHash;
|
||||
use MockAccountData;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1 @@
|
|||
<?php
|
||||
|
||||
// This is global bootstrap for autoloading
|
||||
use Codeception\Util\Fixtures;
|
||||
|
||||
Fixtures::add('url', 'http://localhost');
|
||||
Fixtures::add('username', 'user@example.com');
|
||||
Fixtures::add('password', 'password');
|
||||
|
||||
Fixtures::add('api_secret', 'password');
|
||||
Fixtures::add('stripe_secret_key', 'sk_test_g888H1K4efDxHKj7fSFTBGgU');
|
||||
Fixtures::add('stripe_publishable_key', '');
|
||||
|
|
|
|||
Loading…
Reference in New Issue