mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 14:54:34 -04:00
Improve how tests function under parallel testing
This commit is contained in:
parent
0d767f7d98
commit
d708d054f2
@ -40,6 +40,9 @@ class InvitationTest extends TestCase
|
|||||||
protected function setUp() :void
|
protected function setUp() :void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->faker = \Faker\Factory::create();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvoiceCreationAfterInvoiceMarkedSent()
|
public function testInvoiceCreationAfterInvoiceMarkedSent()
|
||||||
@ -52,10 +55,13 @@ class InvitationTest extends TestCase
|
|||||||
$account->default_company_id = $company->id;
|
$account->default_company_id = $company->id;
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
$user = User::where('email', 'user@example.com')->first();
|
$fake_email = $this->faker->email();
|
||||||
|
|
||||||
|
$user = User::where('email', $fake_email)->first();
|
||||||
|
|
||||||
if (! $user) {
|
if (! $user) {
|
||||||
$user = User::factory()->create([
|
$user = User::factory()->create([
|
||||||
|
'email' => $fake_email,
|
||||||
'account_id' => $account->id,
|
'account_id' => $account->id,
|
||||||
'confirmation_code' => $this->createDbHash(config('database.default')),
|
'confirmation_code' => $this->createDbHash(config('database.default')),
|
||||||
]);
|
]);
|
||||||
|
@ -54,29 +54,8 @@ class CompanyLedgerTest extends TestCase
|
|||||||
|
|
||||||
$this->artisan('db:seed --force');
|
$this->artisan('db:seed --force');
|
||||||
|
|
||||||
/* Warm up the cache !*/
|
$this->faker = \Faker\Factory::create();
|
||||||
$cached_tables = config('ninja.cached_tables');
|
$fake_email = $this->faker->email();
|
||||||
|
|
||||||
foreach ($cached_tables as $name => $class) {
|
|
||||||
|
|
||||||
// check that the table exists in case the migration is pending
|
|
||||||
if (! Schema::hasTable((new $class())->getTable())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($name == 'payment_terms') {
|
|
||||||
$orderBy = 'num_days';
|
|
||||||
} elseif ($name == 'fonts') {
|
|
||||||
$orderBy = 'sort_order';
|
|
||||||
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
|
|
||||||
$orderBy = 'name';
|
|
||||||
} else {
|
|
||||||
$orderBy = 'id';
|
|
||||||
}
|
|
||||||
$tableData = $class::orderBy($orderBy)->get();
|
|
||||||
if ($tableData->count()) {
|
|
||||||
Cache::forever($name, $tableData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->account = Account::factory()->create();
|
$this->account = Account::factory()->create();
|
||||||
$this->company = Company::factory()->create([
|
$this->company = Company::factory()->create([
|
||||||
@ -93,7 +72,7 @@ class CompanyLedgerTest extends TestCase
|
|||||||
$settings->state = 'State';
|
$settings->state = 'State';
|
||||||
$settings->postal_code = 'Postal Code';
|
$settings->postal_code = 'Postal Code';
|
||||||
$settings->phone = '555-343-2323';
|
$settings->phone = '555-343-2323';
|
||||||
$settings->email = 'user@example.com';
|
$settings->email = $fake_email;
|
||||||
$settings->country_id = '840';
|
$settings->country_id = '840';
|
||||||
$settings->vat_number = 'vat number';
|
$settings->vat_number = 'vat number';
|
||||||
$settings->id_number = 'id number';
|
$settings->id_number = 'id number';
|
||||||
@ -106,10 +85,12 @@ class CompanyLedgerTest extends TestCase
|
|||||||
$this->account->default_company_id = $this->company->id;
|
$this->account->default_company_id = $this->company->id;
|
||||||
$this->account->save();
|
$this->account->save();
|
||||||
|
|
||||||
$user = User::whereEmail('user@example.com')->first();
|
|
||||||
|
$user = User::whereEmail($fake_email)->first();
|
||||||
|
|
||||||
if (! $user) {
|
if (! $user) {
|
||||||
$user = User::factory()->create([
|
$user = User::factory()->create([
|
||||||
|
'email' => $fake_email,
|
||||||
'account_id' => $this->account->id,
|
'account_id' => $this->account->id,
|
||||||
'password' => Hash::make('ALongAndBriliantPassword'),
|
'password' => Hash::make('ALongAndBriliantPassword'),
|
||||||
'confirmation_code' => $this->createDbHash(config('database.default')),
|
'confirmation_code' => $this->createDbHash(config('database.default')),
|
||||||
|
@ -213,6 +213,9 @@ trait MockAccountData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->faker = \Faker\Factory::create();
|
||||||
|
$fake_email = $this->faker->email();
|
||||||
|
|
||||||
$this->account = Account::factory()->create([
|
$this->account = Account::factory()->create([
|
||||||
'hosted_client_count' => 1000,
|
'hosted_client_count' => 1000,
|
||||||
'hosted_company_count' => 1000,
|
'hosted_company_count' => 1000,
|
||||||
@ -233,7 +236,6 @@ trait MockAccountData
|
|||||||
$settings = CompanySettings::defaults();
|
$settings = CompanySettings::defaults();
|
||||||
|
|
||||||
$settings->company_logo = 'https://pdf.invoicing.co/favicon-v2.png';
|
$settings->company_logo = 'https://pdf.invoicing.co/favicon-v2.png';
|
||||||
// $settings->company_logo = asset('images/new_logo.png');
|
|
||||||
$settings->website = 'www.invoiceninja.com';
|
$settings->website = 'www.invoiceninja.com';
|
||||||
$settings->address1 = 'Address 1';
|
$settings->address1 = 'Address 1';
|
||||||
$settings->address2 = 'Address 2';
|
$settings->address2 = 'Address 2';
|
||||||
@ -241,7 +243,7 @@ trait MockAccountData
|
|||||||
$settings->state = 'State';
|
$settings->state = 'State';
|
||||||
$settings->postal_code = 'Postal Code';
|
$settings->postal_code = 'Postal Code';
|
||||||
$settings->phone = '555-343-2323';
|
$settings->phone = '555-343-2323';
|
||||||
$settings->email = 'user@example.com';
|
$settings->email = $fake_email;
|
||||||
$settings->country_id = '840';
|
$settings->country_id = '840';
|
||||||
$settings->vat_number = 'vat number';
|
$settings->vat_number = 'vat number';
|
||||||
$settings->id_number = 'id number';
|
$settings->id_number = 'id number';
|
||||||
@ -256,13 +258,13 @@ trait MockAccountData
|
|||||||
$this->account->default_company_id = $this->company->id;
|
$this->account->default_company_id = $this->company->id;
|
||||||
$this->account->save();
|
$this->account->save();
|
||||||
|
|
||||||
$user = User::whereEmail('user@example.com')->first();
|
$user = User::whereEmail($fake_email)->first();
|
||||||
|
|
||||||
if (! $user) {
|
if (! $user) {
|
||||||
$user = User::factory()->create([
|
$user = User::factory()->create([
|
||||||
'account_id' => $this->account->id,
|
'account_id' => $this->account->id,
|
||||||
'confirmation_code' => $this->createDbHash(config('database.default')),
|
'confirmation_code' => $this->createDbHash(config('database.default')),
|
||||||
'email' => 'user@example.com',
|
'email' => $fake_email,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,13 +62,15 @@ class GeneratesConvertedQuoteCounterTest extends TestCase
|
|||||||
$this->account->num_users = 3;
|
$this->account->num_users = 3;
|
||||||
$this->account->save();
|
$this->account->save();
|
||||||
|
|
||||||
$user = User::whereEmail('user@example.com')->first();
|
$fake_email = $this->faker->email();
|
||||||
|
|
||||||
|
$user = User::whereEmail($fake_email)->first();
|
||||||
|
|
||||||
if (! $user) {
|
if (! $user) {
|
||||||
$user = User::factory()->create([
|
$user = User::factory()->create([
|
||||||
'account_id' => $this->account->id,
|
'account_id' => $this->account->id,
|
||||||
'confirmation_code' => $this->createDbHash(config('database.default')),
|
'confirmation_code' => $this->createDbHash(config('database.default')),
|
||||||
'email' => 'user@example.com',
|
'email' => $fake_email,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user