fix validator for taking ancestors into account

This commit is contained in:
2021-12-07 18:05:05 +01:00
parent b1b9acc686
commit e6c60e66fc
3 changed files with 46 additions and 6 deletions

View File

@@ -61,4 +61,20 @@ final class SocialIssueTest extends TestCase
$this->assertFalse($child->isDescendantOf($grandChild));
}
public function testGetAncestors()
{
$parent = new SocialIssue();
$child = (new SocialIssue())->setParent($parent);
$grandChild = (new SocialIssue())->setParent($child);
$grandGrandChild = (new SocialIssue())->setParent($grandChild);
$unrelated = new SocialIssue();
$this->assertContains($parent, $grandGrandChild->getAncestors(true));
$this->assertContains($child, $grandGrandChild->getAncestors(true));
$this->assertContains($grandChild, $grandGrandChild->getAncestors(true));
$this->assertContains($grandGrandChild, $grandGrandChild->getAncestors(true));
$this->assertNotContains($grandGrandChild, $grandGrandChild->getAncestors(false));
$this->assertCount(0, $unrelated->getAncestors(false));
}
}