2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
use App\Models\Location;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2021-06-10 13:15:52 -07:00
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2017-07-11 20:37:02 -07:00
|
|
|
class LocationTest extends BaseTest
|
2016-03-25 01:18:05 -07:00
|
|
|
{
|
|
|
|
/**
|
2021-06-10 13:15:52 -07:00
|
|
|
* @var \UnitTester
|
|
|
|
*/
|
2016-03-25 01:18:05 -07:00
|
|
|
protected $tester;
|
2017-06-12 17:39:03 -07:00
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
public function testPassesIfNotSelfParent()
|
|
|
|
{
|
2020-04-28 08:31:30 -07:00
|
|
|
$this->createValidLocation(['id' => 10]);
|
2020-04-21 19:51:42 -07:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
$a = Location::factory()->make([
|
2020-04-21 19:51:42 -07:00
|
|
|
'name' => 'Test Location',
|
|
|
|
'id' => 1,
|
|
|
|
'parent_id' => 10,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertTrue($a->isValid());
|
|
|
|
}
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
public function testFailsIfSelfParent()
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
$a = Location::factory()->make([
|
2020-04-21 19:51:42 -07:00
|
|
|
'name' => 'Test Location',
|
|
|
|
'id' => 1,
|
|
|
|
'parent_id' => 1,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertFalse($a->isValid());
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertStringContainsString('The parent id and id must be different', $a->getErrors());
|
2020-04-21 19:51:42 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|