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;
|
2021-12-02 16:33:16 -08:00
|
|
|
use App\Models\Manufacturer;
|
|
|
|
use App\Models\Location;
|
2017-06-12 17:39:03 -07:00
|
|
|
use App\Models\Category;
|
2021-12-02 16:33:16 -08:00
|
|
|
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
|
|
|
{
|
2018-07-23 06:48:21 -07:00
|
|
|
public function testAnAccessoryBelongsToACompany()
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
$accessory = Accessory::factory()
|
2021-12-02 16:33:16 -08:00
|
|
|
->create(
|
|
|
|
[
|
|
|
|
'company_id' =>
|
|
|
|
Company::factory()->create()->id]);
|
|
|
|
$this->assertInstanceOf(Company::class, $accessory->company);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
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()
|
2021-12-02 16:33:16 -08:00
|
|
|
->create(
|
|
|
|
[
|
|
|
|
'location_id' => Location::factory()->create()->id
|
|
|
|
]);
|
|
|
|
$this->assertInstanceOf(Location::class, $accessory->location);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
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()
|
2021-12-02 16:33:16 -08:00
|
|
|
->create(
|
|
|
|
[
|
|
|
|
'category_id' =>
|
|
|
|
Category::factory()->create(
|
|
|
|
[
|
|
|
|
'category_type' => 'accessory'
|
|
|
|
]
|
|
|
|
)->id]);
|
|
|
|
$this->assertInstanceOf(Category::class, $accessory->category);
|
2018-07-23 06:48:21 -07:00
|
|
|
$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()
|
|
|
|
{
|
2021-12-02 16:33:16 -08:00
|
|
|
$accessory = Accessory::factory()->appleBtKeyboard()->create(
|
|
|
|
[
|
|
|
|
'category_id' => Category::factory()->create(),
|
2023-02-07 16:40:27 -08:00
|
|
|
'manufacturer_id' => Manufacturer::factory()->apple()->create()
|
2021-12-02 16:33:16 -08:00
|
|
|
]);
|
|
|
|
$this->assertInstanceOf(Manufacturer::class, $accessory->manufacturer);
|
2018-07-23 06:48:21 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|