This commit is contained in:
2022-10-18 14:37:33 +02:00
parent 8928664f87
commit 9eb451e359
15 changed files with 79 additions and 76 deletions

View File

@@ -55,29 +55,6 @@ final class SocialIssueTest extends TestCase
$this->assertCount(0, $unrelated->getAncestors(false));
}
public function testIsDescendantOf()
{
$parent = new SocialIssue();
$child = (new SocialIssue())->setParent($parent);
$grandChild = (new SocialIssue())->setParent($child);
$grandGrandChild = (new SocialIssue())->setParent($grandChild);
$unrelated = new SocialIssue();
$this->assertTrue($grandGrandChild->isDescendantOf($parent));
$this->assertTrue($grandGrandChild->isDescendantOf($grandChild));
$this->assertTrue($grandGrandChild->isDescendantOf($child));
$this->assertFalse($grandGrandChild->isDescendantOf($unrelated));
$this->assertTrue($grandChild->isDescendantOf($parent));
$this->assertTrue($grandChild->isDescendantOf($child));
$this->assertFalse($grandChild->isDescendantOf($unrelated));
$this->assertFalse($grandChild->isDescendantOf($grandChild));
$this->assertFalse($unrelated->isDescendantOf($parent));
$this->assertFalse($child->isDescendantOf($grandChild));
}
public function testGetDescendantsWithThisForIssues()
{
$parentA = new SocialIssue();
@@ -106,4 +83,27 @@ final class SocialIssueTest extends TestCase
$this->assertNotContains($unrelatedA, $actual);
$this->assertNotContains($unrelatedB, $actual);
}
public function testIsDescendantOf()
{
$parent = new SocialIssue();
$child = (new SocialIssue())->setParent($parent);
$grandChild = (new SocialIssue())->setParent($child);
$grandGrandChild = (new SocialIssue())->setParent($grandChild);
$unrelated = new SocialIssue();
$this->assertTrue($grandGrandChild->isDescendantOf($parent));
$this->assertTrue($grandGrandChild->isDescendantOf($grandChild));
$this->assertTrue($grandGrandChild->isDescendantOf($child));
$this->assertFalse($grandGrandChild->isDescendantOf($unrelated));
$this->assertTrue($grandChild->isDescendantOf($parent));
$this->assertTrue($grandChild->isDescendantOf($child));
$this->assertFalse($grandChild->isDescendantOf($unrelated));
$this->assertFalse($grandChild->isDescendantOf($grandChild));
$this->assertFalse($unrelated->isDescendantOf($parent));
$this->assertFalse($child->isDescendantOf($grandChild));
}
}