2020-04-30 06:50:12 -07:00
|
|
|
<?php
|
2021-11-30 20:09:29 -08:00
|
|
|
namespace Tests\Unit;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2020-04-30 06:50:12 -07:00
|
|
|
use App\Models\Category;
|
|
|
|
use App\Models\Company;
|
|
|
|
use App\Models\Component;
|
|
|
|
use App\Models\Location;
|
2023-03-07 16:57:55 -08:00
|
|
|
use Tests\TestCase;
|
2020-04-30 06:50:12 -07:00
|
|
|
|
2024-08-06 13:25:22 -07:00
|
|
|
final class ComponentTest extends TestCase
|
2020-04-30 06:50:12 -07:00
|
|
|
{
|
2024-08-06 13:25:22 -07:00
|
|
|
public function testAComponentBelongsToACompany(): void
|
2020-04-30 06:50:12 -07:00
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
$component = Component::factory()
|
2021-12-02 19:43:15 -08:00
|
|
|
->create(
|
|
|
|
[
|
|
|
|
'company_id' => Company::factory()->create()->id
|
|
|
|
]
|
|
|
|
);
|
2020-04-30 06:50:12 -07:00
|
|
|
$this->assertInstanceOf(Company::class, $component->company);
|
|
|
|
}
|
|
|
|
|
2024-08-06 13:25:22 -07:00
|
|
|
public function testAComponentHasALocation(): void
|
2020-04-30 06:50:12 -07:00
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
$component = Component::factory()
|
|
|
|
->create(['location_id' => Location::factory()->create()->id]);
|
2020-04-30 06:50:12 -07:00
|
|
|
$this->assertInstanceOf(Location::class, $component->location);
|
|
|
|
}
|
|
|
|
|
2024-08-06 13:25:22 -07:00
|
|
|
public function testAComponentBelongsToACategory(): void
|
2020-04-30 06:50:12 -07:00
|
|
|
{
|
2021-12-02 19:43:15 -08:00
|
|
|
$component = Component::factory()->ramCrucial4()
|
|
|
|
->create(
|
|
|
|
[
|
|
|
|
'category_id' =>
|
|
|
|
Category::factory()->create(
|
|
|
|
[
|
|
|
|
'category_type' => 'component'
|
|
|
|
]
|
|
|
|
)->id]);
|
2020-04-30 06:50:12 -07:00
|
|
|
$this->assertInstanceOf(Category::class, $component->category);
|
|
|
|
$this->assertEquals('component', $component->category->category_type);
|
|
|
|
}
|
|
|
|
}
|