2017-07-11 20:37:02 -07:00
|
|
|
<?php
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2017-08-31 11:14:21 -07:00
|
|
|
use App\Models\User;
|
2017-07-11 20:37:02 -07:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
|
|
|
|
|
|
class BaseTest extends \Codeception\TestCase\Test
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2017-07-11 20:37:02 -07:00
|
|
|
protected function _before()
|
|
|
|
{
|
|
|
|
Artisan::call('migrate');
|
2021-06-10 13:17:44 -07:00
|
|
|
\App\Models\Setting::factory()->create();
|
2017-07-11 20:37:02 -07:00
|
|
|
}
|
2017-08-31 11:14:21 -07:00
|
|
|
|
|
|
|
protected function signIn($user = null)
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
if (! $user) {
|
2021-06-10 13:17:44 -07:00
|
|
|
$user = User::factory()->superuser()->create([
|
2021-06-10 13:15:52 -07:00
|
|
|
'location_id' => $this->createValidLocation()->id,
|
2020-04-27 18:02:14 -07:00
|
|
|
]);
|
2017-08-31 11:14:21 -07:00
|
|
|
}
|
|
|
|
Auth::login($user);
|
|
|
|
|
|
|
|
return $user;
|
|
|
|
}
|
2018-07-23 06:48:21 -07:00
|
|
|
|
|
|
|
protected function createValidAssetModel($state = 'mbp-13-model', $overrides = [])
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\AssetModel::factory()->state()->create(array_merge([
|
2018-07-23 06:48:21 -07:00
|
|
|
'category_id' => $this->createValidCategory(),
|
|
|
|
'manufacturer_id' => $this->createValidManufacturer(),
|
|
|
|
'depreciation_id' => $this->createValidDepreciation(),
|
2021-06-10 13:15:52 -07:00
|
|
|
], $overrides));
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function createValidCategory($state = 'asset-laptop-category', $overrides = [])
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Category::factory()->state()->create($overrides);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function createValidCompany($overrides = [])
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Company::factory()->create($overrides);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function createValidDepartment($state = 'engineering', $overrides = [])
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Department::factory()->state()->create(array_merge([
|
2021-06-10 13:15:52 -07:00
|
|
|
'location_id' => $this->createValidLocation()->id,
|
2018-07-23 06:48:21 -07:00
|
|
|
], $overrides));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function createValidDepreciation($state = 'computer', $overrides = [])
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Depreciation::factory()->state()->create($overrides);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function createValidLocation($overrides = [])
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Location::factory()->create($overrides);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function createValidManufacturer($state = 'apple', $overrides = [])
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Manufacturer::factory()->state()->create($overrides);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function createValidSupplier($overrides = [])
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Supplier::factory()->create($overrides);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
protected function createValidStatuslabel($state = 'rtd', $overrides = [])
|
2018-07-23 06:48:21 -07:00
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Statuslabel::factory()->state()->create($overrides);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
protected function createValidUser($overrides = [])
|
2018-07-23 06:48:21 -07:00
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\User::factory()->create(
|
2021-06-10 13:15:52 -07:00
|
|
|
array_merge([
|
|
|
|
'location_id'=>$this->createValidLocation()->id,
|
2020-04-27 18:02:14 -07:00
|
|
|
], $overrides)
|
|
|
|
);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
|
|
|
|
2020-04-28 08:37:13 -07:00
|
|
|
protected function createValidAsset($overrides = [])
|
2018-07-23 06:48:21 -07:00
|
|
|
{
|
2020-04-27 18:02:14 -07:00
|
|
|
$locId = $this->createValidLocation()->id;
|
2018-07-23 06:48:21 -07:00
|
|
|
$this->createValidAssetModel();
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
return \App\Models\Asset::factory()->laptopMbp()->create(
|
2020-04-27 18:02:14 -07:00
|
|
|
array_merge([
|
|
|
|
'rtd_location_id' => $locId,
|
|
|
|
'location_id' => $locId,
|
2021-06-10 13:15:52 -07:00
|
|
|
'supplier_id' => $this->createValidSupplier()->id,
|
2020-04-27 18:02:14 -07:00
|
|
|
], $overrides)
|
|
|
|
);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
2017-07-11 20:37:02 -07:00
|
|
|
}
|