snipe-it/tests/Unit/ComponentTest.php

48 lines
1.4 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;
use Tests\Support\InteractsWithSettings;
2023-03-07 16:57:55 -08:00
use Tests\TestCase;
2023-03-07 16:57:55 -08:00
class ComponentTest extends TestCase
{
use InteractsWithSettings;
public function testAComponentBelongsToACompany()
{
2021-06-10 13:17:44 -07:00
$component = Component::factory()
->create(
[
'company_id' => Company::factory()->create()->id
]
);
$this->assertInstanceOf(Company::class, $component->company);
}
public function testAComponentHasALocation()
{
2021-06-10 13:17:44 -07:00
$component = Component::factory()
->create(['location_id' => Location::factory()->create()->id]);
$this->assertInstanceOf(Location::class, $component->location);
}
public function testAComponentBelongsToACategory()
{
$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);
}
}