From bbc2ac2f9d658ff10a1135689037381dff44e2d0 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 21 Apr 2020 19:51:42 -0700 Subject: [PATCH] Updated tests with new location.id!=location.parent_id rule --- tests/unit/LocationTest.php | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/tests/unit/LocationTest.php b/tests/unit/LocationTest.php index 7c748b7b6a..09cf2ff589 100644 --- a/tests/unit/LocationTest.php +++ b/tests/unit/LocationTest.php @@ -12,14 +12,30 @@ class LocationTest extends BaseTest */ protected $tester; - // public function testAssetAdd() - // { - // $location = factory(Location::class)->make(); - // $values = [ - // 'name' => $location->name, - // ]; + public function testPassesIfNotSelfParent() { + + $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()); + + + } - // Location::create($values); - // $this->tester->seeRecord('locations', $values); - // } }