Create a contact for portal tests

This commit is contained in:
Burak Çakırel 2020-01-07 15:41:47 +03:00
parent 3e81ea08ca
commit b83207d104

View File

@ -5,6 +5,7 @@ namespace Database\Seeds;
use App\Abstracts\Model; use App\Abstracts\Model;
use App\Jobs\Auth\CreateUser; use App\Jobs\Auth\CreateUser;
use App\Jobs\Common\CreateCompany; use App\Jobs\Common\CreateCompany;
use App\Jobs\Common\CreateContact;
use App\Traits\Jobs; use App\Traits\Jobs;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -27,12 +28,14 @@ class TestCompany extends Seeder
$this->createUser(); $this->createUser();
$this->createContact();
Model::reguard(); Model::reguard();
} }
private function createCompany() private function createCompany()
{ {
$this->dispatch(new CreateCompany([ $user = $this->dispatch(new CreateCompany([
'name' => 'My Company', 'name' => 'My Company',
'domain' => 'company.com', 'domain' => 'company.com',
'address' => 'New Street 1254', 'address' => 'New Street 1254',
@ -46,6 +49,8 @@ class TestCompany extends Seeder
], ],
])); ]));
session(['company_id' => $user->companies()->pluck('id')->first()]);
$this->command->info('Test company created.'); $this->command->info('Test company created.');
} }
@ -63,4 +68,21 @@ class TestCompany extends Seeder
$this->command->info('Test user created.'); $this->command->info('Test user created.');
} }
private function createContact()
{
$this->dispatch(new CreateContact([
'type' => 'customer',
'name' => 'Test Contact',
'email' => 'contact@company.com',
'currency_code' => setting('default.currency', 'USD'),
'password' => '123456',
'password_confirmation' => '123456',
'company_id' => session('company_id'),
'enabled' => '1',
'create_user' => 1,
]));
$this->command->info('Test contact created.');
}
} }