snipe-it/tests/Unit/LocationTest.php

38 lines
847 B
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
namespace Tests\Unit;
2016-03-25 01:18:05 -07:00
use App\Models\Location;
use Tests\Unit\BaseTest;
2016-03-25 01:18:05 -07:00
class LocationTest extends BaseTest
2016-03-25 01:18:05 -07:00
{
/**
* @var \UnitTester
*/
2016-03-25 01:18:05 -07:00
protected $tester;
public function testPassesIfNotSelfParent()
{
2021-06-10 13:17:44 -07:00
$a = Location::factory()->make([
'name' => 'Test Location',
'id' => 1,
'parent_id' => Location::factory()->create(['id' => 10])->id,
]);
$this->assertTrue($a->isValid());
}
public function testFailsIfSelfParent()
{
2021-06-10 13:17:44 -07:00
$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());
}
2016-03-25 01:18:05 -07:00
}