snipe-it/tests/Unit/AccessoryTest.php

50 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\Category;
2016-03-25 01:18:05 -07:00
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\Unit\BaseTest;
2016-03-25 01:18:05 -07:00
class AccessoryTest extends BaseTest
2016-03-25 01:18:05 -07:00
{
/**
* @var \UnitTester
*/
protected $tester;
public function testAnAccessoryBelongsToACompany()
{
2021-06-10 13:17:44 -07:00
$accessory = Accessory::factory()
->create(['company_id' => \App\Models\Company::factory()->create()->id]);
$this->assertInstanceOf(App\Models\Company::class, $accessory->company);
}
public function testAnAccessoryHasALocation()
{
2021-06-10 13:17:44 -07:00
$accessory = Accessory::factory()
->create(['location_id' => \App\Models\Location::factory()->create()->id]);
$this->assertInstanceOf(App\Models\Location::class, $accessory->location);
}
public function testAnAccessoryBelongsToACategory()
{
2021-06-10 13:17:44 -07:00
$accessory = Accessory::factory()->appleBtKeyboard()
->create(['category_id' => Category::factory()->accessoryKeyboardCategory()->create(['category_type' => 'accessory'])->id]);
$this->assertInstanceOf(App\Models\Category::class, $accessory->category);
$this->assertEquals('accessory', $accessory->category->category_type);
}
public function testAnAccessoryHasAManufacturer()
{
$this->createValidManufacturer('apple');
$this->createValidCategory('accessory-keyboard-category');
2021-06-10 13:17:44 -07:00
$accessory = Accessory::factory()->appleBtKeyboard()->create(['category_id' => 1]);
$this->assertInstanceOf(App\Models\Manufacturer::class, $accessory->manufacturer);
}
2016-03-25 01:18:05 -07:00
}