snipe-it/tests/unit/LocationTest.php
snipe 17bd6d71e7 Fixed location unit test
Signed-off-by: snipe <snipe@snipe.net>
2021-12-01 22:45:39 -08:00

41 lines
926 B
PHP

<?php
namespace Tests\Unit;
use App\Models\Location;
use Tests\Unit\BaseTest;
use Illuminate\Database\Eloquent\Factories\Factory;
use Tests\TestCase;
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(trans('validation.non_circular', ['attribute' => 'parent id']), $a->getErrors());
}
}