mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Fixed accessory test
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
35ba28bff9
commit
b0d2fc787a
|
@ -2,7 +2,10 @@
|
|||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Location;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
|
@ -20,22 +23,35 @@ class AccessoryTest extends BaseTest
|
|||
public function testAnAccessoryBelongsToACompany()
|
||||
{
|
||||
$accessory = Accessory::factory()
|
||||
->create(['company_id' => \App\Models\Company::factory()->create()->id]);
|
||||
$this->assertInstanceOf(App\Models\Company::class, $accessory->company);
|
||||
->create(
|
||||
[
|
||||
'company_id' =>
|
||||
Company::factory()->create()->id]);
|
||||
$this->assertInstanceOf(Company::class, $accessory->company);
|
||||
}
|
||||
|
||||
public function testAnAccessoryHasALocation()
|
||||
{
|
||||
$accessory = Accessory::factory()
|
||||
->create(['location_id' => \App\Models\Location::factory()->create()->id]);
|
||||
$this->assertInstanceOf(App\Models\Location::class, $accessory->location);
|
||||
->create(
|
||||
[
|
||||
'location_id' => Location::factory()->create()->id
|
||||
]);
|
||||
$this->assertInstanceOf(Location::class, $accessory->location);
|
||||
}
|
||||
|
||||
public function testAnAccessoryBelongsToACategory()
|
||||
{
|
||||
$accessory = Accessory::factory()->appleBtKeyboard()
|
||||
->create(['category_id' => Category::factory()->accessoryKeyboardCategory()->create(['category_type' => 'accessory'])->id]);
|
||||
$this->assertInstanceOf(App\Models\Category::class, $accessory->category);
|
||||
->create(
|
||||
[
|
||||
'category_id' =>
|
||||
Category::factory()->create(
|
||||
[
|
||||
'category_type' => 'accessory'
|
||||
]
|
||||
)->id]);
|
||||
$this->assertInstanceOf(Category::class, $accessory->category);
|
||||
$this->assertEquals('accessory', $accessory->category->category_type);
|
||||
}
|
||||
|
||||
|
@ -43,7 +59,11 @@ class AccessoryTest extends BaseTest
|
|||
{
|
||||
$this->createValidManufacturer('apple');
|
||||
$this->createValidCategory('accessory-keyboard-category');
|
||||
$accessory = Accessory::factory()->appleBtKeyboard()->create(['category_id' => 1]);
|
||||
$this->assertInstanceOf(App\Models\Manufacturer::class, $accessory->manufacturer);
|
||||
$accessory = Accessory::factory()->appleBtKeyboard()->create(
|
||||
[
|
||||
'category_id' => Category::factory()->create(),
|
||||
'category_id' => Manufacturer::factory()->apple()->create()
|
||||
]);
|
||||
$this->assertInstanceOf(Manufacturer::class, $accessory->manufacturer);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue