snipe-it/tests/Unit/AccessoryTest.php

58 lines
1.7 KiB
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
namespace Tests\Unit;
2016-03-25 01:18:05 -07:00
use App\Models\Accessory;
use App\Models\Manufacturer;
use App\Models\Location;
use App\Models\Category;
use App\Models\Company;
2023-03-07 16:57:55 -08:00
use Tests\TestCase;
2016-03-25 01:18:05 -07:00
2023-03-07 16:57:55 -08:00
class AccessoryTest extends TestCase
2016-03-25 01:18:05 -07:00
{
public function testAnAccessoryBelongsToACompany()
{
2021-06-10 13:17:44 -07:00
$accessory = Accessory::factory()
->create(
[
'company_id' =>
Company::factory()->create()->id]);
$this->assertInstanceOf(Company::class, $accessory->company);
}
public function testAnAccessoryHasALocation()
{
2021-06-10 13:17:44 -07:00
$accessory = Accessory::factory()
->create(
[
'location_id' => Location::factory()->create()->id
]);
$this->assertInstanceOf(Location::class, $accessory->location);
}
public function testAnAccessoryBelongsToACategory()
{
2021-06-10 13:17:44 -07:00
$accessory = Accessory::factory()->appleBtKeyboard()
->create(
[
'category_id' =>
Category::factory()->create(
[
'category_type' => 'accessory'
]
)->id]);
$this->assertInstanceOf(Category::class, $accessory->category);
$this->assertEquals('accessory', $accessory->category->category_type);
}
public function testAnAccessoryHasAManufacturer()
{
$accessory = Accessory::factory()->appleBtKeyboard()->create(
[
'category_id' => Category::factory()->create(),
2023-02-07 16:40:27 -08:00
'manufacturer_id' => Manufacturer::factory()->apple()->create()
]);
$this->assertInstanceOf(Manufacturer::class, $accessory->manufacturer);
}
2016-03-25 01:18:05 -07:00
}