Remove helper methods by inlining where needed
This commit is contained in:
@@ -57,8 +57,6 @@ class AccessoryTest extends BaseTest
|
||||
|
||||
public function testAnAccessoryHasAManufacturer()
|
||||
{
|
||||
$this->createValidManufacturer('apple');
|
||||
$this->createValidCategory('accessory-keyboard-category');
|
||||
$accessory = Accessory::factory()->appleBtKeyboard()->create(
|
||||
[
|
||||
'category_id' => Category::factory()->create(),
|
||||
|
||||
@@ -14,89 +14,4 @@ use Artisan;
|
||||
abstract class BaseTest extends TestCase
|
||||
{
|
||||
use LazilyRefreshDatabase;
|
||||
|
||||
protected function signIn($user = null)
|
||||
{
|
||||
if (! $user) {
|
||||
$user = User::factory()->superuser()->create([
|
||||
'location_id' => $this->createValidLocation()->id,
|
||||
]);
|
||||
}
|
||||
Auth::login($user);
|
||||
return $user;
|
||||
}
|
||||
|
||||
protected function createValidAssetModel()
|
||||
{
|
||||
return \App\Models\AssetModel::factory()->create([
|
||||
'category_id' => $this->createValidCategory(),
|
||||
'manufacturer_id' => $this->createValidManufacturer(),
|
||||
'depreciation_id' => $this->createValidDepreciation(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function createValidCategory()
|
||||
{
|
||||
return \App\Models\Category::factory()->make();
|
||||
}
|
||||
|
||||
protected function createValidCompany()
|
||||
{
|
||||
return \App\Models\Company::factory()->create();
|
||||
}
|
||||
|
||||
protected function createValidDepartment($state = 'engineering', $overrides = [])
|
||||
{
|
||||
return \App\Models\Department::factory()->create(array_merge([
|
||||
'location_id' => $this->createValidLocation()->id,
|
||||
], $overrides));
|
||||
}
|
||||
|
||||
protected function createValidDepreciation()
|
||||
{
|
||||
return \App\Models\Depreciation::factory()->create();
|
||||
}
|
||||
|
||||
protected function createValidLocation($overrides = [])
|
||||
{
|
||||
return \App\Models\Location::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createValidManufacturer()
|
||||
{
|
||||
return \App\Models\Manufacturer::factory()->create();
|
||||
}
|
||||
|
||||
protected function createValidSupplier($overrides = [])
|
||||
{
|
||||
return \App\Models\Supplier::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createValidStatuslabel($state = 'rtd', $overrides = [])
|
||||
{
|
||||
return \App\Models\Statuslabel::factory()->state()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createValidUser($overrides = [])
|
||||
{
|
||||
return \App\Models\User::factory()->create(
|
||||
array_merge([
|
||||
'location_id'=>$this->createValidLocation()->id,
|
||||
], $overrides)
|
||||
);
|
||||
}
|
||||
|
||||
protected function createValidAsset($overrides = [])
|
||||
{
|
||||
$locId = $this->createValidLocation()->id;
|
||||
$this->createValidAssetModel();
|
||||
|
||||
return \App\Models\Asset::factory()->laptopMbp()->create(
|
||||
array_merge([
|
||||
'rtd_location_id' => $locId,
|
||||
'location_id' => $locId,
|
||||
'supplier_id' => $this->createValidSupplier()->id,
|
||||
], $overrides)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ class DepreciationTest extends BaseTest
|
||||
|
||||
public function testADepreciationHasModels()
|
||||
{
|
||||
$this->createValidAssetModel();
|
||||
$depreciation = Depreciation::factory()->create();
|
||||
|
||||
AssetModel::factory()
|
||||
|
||||
@@ -14,12 +14,10 @@ class LocationTest extends BaseTest
|
||||
|
||||
public function testPassesIfNotSelfParent()
|
||||
{
|
||||
$this->createValidLocation(['id' => 10]);
|
||||
|
||||
$a = Location::factory()->make([
|
||||
'name' => 'Test Location',
|
||||
'id' => 1,
|
||||
'parent_id' => 10,
|
||||
'parent_id' => Location::factory()->create(['id' => 10])->id,
|
||||
]);
|
||||
|
||||
$this->assertTrue($a->isValid());
|
||||
|
||||
Reference in New Issue
Block a user