snipe-it/tests/unit/LocationTest.php

41 lines
995 B
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
2016-03-25 01:18:05 -07:00
use App\Models\Location;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Hash;
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()
{
2020-04-28 08:31:30 -07:00
$this->createValidLocation(['id' => 10]);
$a = factory(Location::class)->make([
'name' => 'Test Location',
'id' => 1,
'parent_id' => 10,
]);
$this->assertTrue($a->isValid());
}
public function testFailsIfSelfParent()
{
$a = factory(Location::class)->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());
}
2016-03-25 01:18:05 -07:00
}