2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
2021-11-30 20:09:29 -08:00
|
|
|
namespace Tests\Unit;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
use App\Models\Accessory;
|
2017-06-12 17:39:03 -07:00
|
|
|
use App\Models\Category;
|
2016-03-25 01:18:05 -07:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2021-06-10 13:15:52 -07:00
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
2021-11-30 20:09:29 -08:00
|
|
|
use Tests\Unit\BaseTest;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2017-07-11 20:37:02 -07:00
|
|
|
class AccessoryTest extends BaseTest
|
2016-03-25 01:18:05 -07:00
|
|
|
{
|
2017-06-12 17:39:03 -07:00
|
|
|
/**
|
2021-06-10 13:15:52 -07:00
|
|
|
* @var \UnitTester
|
|
|
|
*/
|
2017-06-12 17:39:03 -07:00
|
|
|
protected $tester;
|
|
|
|
|
2021-12-02 16:14:23 -08:00
|
|
|
|
2017-06-12 17:39:03 -07:00
|
|
|
|
2018-07-23 06:48:21 -07:00
|
|
|
public function testAnAccessoryBelongsToACompany()
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
$accessory = Accessory::factory()
|
|
|
|
->create(['company_id' => \App\Models\Company::factory()->create()->id]);
|
2018-07-23 06:48:21 -07:00
|
|
|
$this->assertInstanceOf(App\Models\Company::class, $accessory->company);
|
|
|
|
}
|
2017-06-12 17:39:03 -07:00
|
|
|
|
2018-07-23 06:48:21 -07:00
|
|
|
public function testAnAccessoryHasALocation()
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
$accessory = Accessory::factory()
|
|
|
|
->create(['location_id' => \App\Models\Location::factory()->create()->id]);
|
2018-07-23 06:48:21 -07:00
|
|
|
$this->assertInstanceOf(App\Models\Location::class, $accessory->location);
|
|
|
|
}
|
2017-06-12 17:39:03 -07:00
|
|
|
|
2018-07-23 06:48:21 -07:00
|
|
|
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]);
|
2018-07-23 06:48:21 -07:00
|
|
|
$this->assertInstanceOf(App\Models\Category::class, $accessory->category);
|
|
|
|
$this->assertEquals('accessory', $accessory->category->category_type);
|
|
|
|
}
|
2017-06-12 17:39:03 -07:00
|
|
|
|
2018-07-23 06:48:21 -07:00
|
|
|
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]);
|
2018-07-23 06:48:21 -07:00
|
|
|
$this->assertInstanceOf(App\Models\Manufacturer::class, $accessory->manufacturer);
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|