mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -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;
|
namespace Tests\Unit;
|
||||||
|
|
||||||
use App\Models\Accessory;
|
use App\Models\Accessory;
|
||||||
|
use App\Models\Manufacturer;
|
||||||
|
use App\Models\Location;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
|
use App\Models\Company;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||||
|
@ -20,22 +23,35 @@ class AccessoryTest extends BaseTest
|
||||||
public function testAnAccessoryBelongsToACompany()
|
public function testAnAccessoryBelongsToACompany()
|
||||||
{
|
{
|
||||||
$accessory = Accessory::factory()
|
$accessory = Accessory::factory()
|
||||||
->create(['company_id' => \App\Models\Company::factory()->create()->id]);
|
->create(
|
||||||
$this->assertInstanceOf(App\Models\Company::class, $accessory->company);
|
[
|
||||||
|
'company_id' =>
|
||||||
|
Company::factory()->create()->id]);
|
||||||
|
$this->assertInstanceOf(Company::class, $accessory->company);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAnAccessoryHasALocation()
|
public function testAnAccessoryHasALocation()
|
||||||
{
|
{
|
||||||
$accessory = Accessory::factory()
|
$accessory = Accessory::factory()
|
||||||
->create(['location_id' => \App\Models\Location::factory()->create()->id]);
|
->create(
|
||||||
$this->assertInstanceOf(App\Models\Location::class, $accessory->location);
|
[
|
||||||
|
'location_id' => Location::factory()->create()->id
|
||||||
|
]);
|
||||||
|
$this->assertInstanceOf(Location::class, $accessory->location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAnAccessoryBelongsToACategory()
|
public function testAnAccessoryBelongsToACategory()
|
||||||
{
|
{
|
||||||
$accessory = Accessory::factory()->appleBtKeyboard()
|
$accessory = Accessory::factory()->appleBtKeyboard()
|
||||||
->create(['category_id' => Category::factory()->accessoryKeyboardCategory()->create(['category_type' => 'accessory'])->id]);
|
->create(
|
||||||
$this->assertInstanceOf(App\Models\Category::class, $accessory->category);
|
[
|
||||||
|
'category_id' =>
|
||||||
|
Category::factory()->create(
|
||||||
|
[
|
||||||
|
'category_type' => 'accessory'
|
||||||
|
]
|
||||||
|
)->id]);
|
||||||
|
$this->assertInstanceOf(Category::class, $accessory->category);
|
||||||
$this->assertEquals('accessory', $accessory->category->category_type);
|
$this->assertEquals('accessory', $accessory->category->category_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +59,11 @@ class AccessoryTest extends BaseTest
|
||||||
{
|
{
|
||||||
$this->createValidManufacturer('apple');
|
$this->createValidManufacturer('apple');
|
||||||
$this->createValidCategory('accessory-keyboard-category');
|
$this->createValidCategory('accessory-keyboard-category');
|
||||||
$accessory = Accessory::factory()->appleBtKeyboard()->create(['category_id' => 1]);
|
$accessory = Accessory::factory()->appleBtKeyboard()->create(
|
||||||
$this->assertInstanceOf(App\Models\Manufacturer::class, $accessory->manufacturer);
|
[
|
||||||
|
'category_id' => Category::factory()->create(),
|
||||||
|
'category_id' => Manufacturer::factory()->apple()->create()
|
||||||
|
]);
|
||||||
|
$this->assertInstanceOf(Manufacturer::class, $accessory->manufacturer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue