mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-11 08:04:09 -08:00
bc355e1f26
Signed-off-by: snipe <snipe@snipe.net>
42 lines
995 B
PHP
42 lines
995 B
PHP
<?php
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\Location;
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
use Tests\Unit\BaseTest;
|
|
|
|
class LocationTest extends BaseTest
|
|
{
|
|
/**
|
|
* @var \UnitTester
|
|
*/
|
|
protected $tester;
|
|
|
|
public function testPassesIfNotSelfParent()
|
|
{
|
|
$this->createValidLocation(['id' => 10]);
|
|
|
|
$a = Location::factory()->make([
|
|
'name' => 'Test Location',
|
|
'id' => 1,
|
|
'parent_id' => 10,
|
|
]);
|
|
|
|
$this->assertTrue($a->isValid());
|
|
}
|
|
|
|
public function testFailsIfSelfParent()
|
|
{
|
|
$a = Location::factory()->make([
|
|
'name' => 'Test Location',
|
|
'id' => 1,
|
|
'parent_id' => 1,
|
|
]);
|
|
|
|
$this->assertFalse($a->isValid());
|
|
$this->assertStringContainsString('The parent id and id must be different', $a->getErrors());
|
|
}
|
|
}
|