Skip to content

Commit

Permalink
install all modules during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Mar 27, 2020
1 parent 0a79c20 commit ca7e0eb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
36 changes: 31 additions & 5 deletions database/seeds/TestCompany.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Jobs\Common\CreateCompany;
use App\Jobs\Common\CreateContact;
use App\Traits\Jobs;
use Artisan;
use Illuminate\Database\Seeder;

class TestCompany extends Seeder
Expand All @@ -28,7 +29,9 @@ public function run()

$this->createUser();

$this->createContact();
$this->createCustomer();

$this->installModules();

Model::reguard();
}
Expand Down Expand Up @@ -69,12 +72,12 @@ public function createUser()
$this->command->info('Test user created.');
}

private function createContact()
private function createCustomer()
{
$this->dispatch(new CreateContact([
'type' => 'customer',
'name' => 'Test Contact',
'email' => 'contact@company.com',
'name' => 'Test Customer',
'email' => 'customer@company.com',
'currency_code' => setting('default.currency', 'USD'),
'password' => '123456',
'password_confirmation' => '123456',
Expand All @@ -83,6 +86,29 @@ private function createContact()
'create_user' => 1,
]));

$this->command->info('Test contact created.');
$this->command->info('Test customer created.');
}

private function installModules()
{
$core_modules = ['offline-payments', 'paypal-standard'];

$modules = module()->all();

foreach ($modules as $module) {
$alias = $module->getAlias();

if (in_array($alias, $core_modules)) {
continue;
}

Artisan::call('module:install', [
'alias' => $alias,
'company' => session('company_id'),
'locale' => session('locale', app()->getLocale()),
]);
}

$this->command->info('Modules installed.');
}
}
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ protected function setUp(): void
parent::setUp();

Artisan::call('db:seed', ['--class' => '\Database\Seeds\TestCompany', '--force' => true]);
Artisan::call('company:seed', ['company' => 1]);
}
}

0 comments on commit ca7e0eb

Please sign in to comment.