예제 #1
0
 public function testAppendChild()
 {
     $node = new Node();
     $node->appendChild($a = new A());
     $b = new B($node);
     $node->prependChild($c = new C());
     $node->appendChild($d = new D());
     $this->assertEquals(1, $a->getIndex());
     $this->assertEquals(2, $b->getIndex());
     $this->assertEquals(0, $c->getIndex());
     $this->assertEquals(3, $d->getIndex());
     $this->assertInstanceOf(A::class, $node->getChildAt(1));
     $this->assertInstanceOf(B::class, $node->getChildAt(2));
     $this->assertInstanceOf(C::class, $node->getChildAt(0));
     $this->assertInstanceOf(D::class, $node->getChildAt(3));
 }