mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
38 lines
842 B
PHP
38 lines
842 B
PHP
<?php
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\Location;
|
|
use Tests\TestCase;
|
|
|
|
|
|
class LocationTest extends TestCase
|
|
{
|
|
/**
|
|
* @var \UnitTester
|
|
*/
|
|
protected $tester;
|
|
|
|
public function testPassesIfNotSelfParent()
|
|
{
|
|
$a = Location::factory()->make([
|
|
'name' => 'Test Location',
|
|
'id' => 1,
|
|
'parent_id' => Location::factory()->create(['id' => 10])->id,
|
|
]);
|
|
|
|
$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(trans('validation.non_circular', ['attribute' => 'parent id']), $a->getErrors());
|
|
}
|
|
}
|