snipe-it/tests/Unit/ComponentTest.php

45 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace Tests\Unit;
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;
2024-08-06 13:25:22 -07:00
final class ComponentTest extends TestCase
{
2024-08-06 13:25:22 -07:00
public function testAComponentBelongsToACompany(): void
{
2021-06-10 13:17:44 -07:00
$component = Component::factory()
->create(
[
'company_id' => Company::factory()->create()->id
]
);
$this->assertInstanceOf(Company::class, $component->company);
}
2024-08-06 13:25:22 -07:00
public function testAComponentHasALocation(): void
{
2021-06-10 13:17:44 -07:00
$component = Component::factory()
->create(['location_id' => Location::factory()->create()->id]);
$this->assertInstanceOf(Location::class, $component->location);
}
2024-08-06 13:25:22 -07:00
public function testAComponentBelongsToACategory(): void
{
$component = Component::factory()->ramCrucial4()
->create(
[
'category_id' =>
Category::factory()->create(
[
'category_type' => 'component'
]
)->id]);
$this->assertInstanceOf(Category::class, $component->category);
$this->assertEquals('component', $component->category->category_type);
}
}