Exemplo n.º 1
0
 public function testGetAncestor()
 {
     $a = new Leaf(['kind' => 'a']);
     $div = new Node();
     $body = new Node(['kind' => 'body']);
     $body->appendChild($div)->appendChild($a);
     $ancestor = $a->getAncestor(2);
     $this->assertEquals($body, $ancestor);
 }
Exemplo n.º 2
0
 public function testOffsetSet()
 {
     $n = new Node();
     self::$n->offsetSet(1, $n);
     $this->assertEquals($n, self::$n[1]);
     $n1 = new Node();
     self::$n->offsetSet(100, $n1);
     $this->assertEquals($n1, self::$n->last());
     $n2 = new Node();
     self::$n->offsetSet(0, $n2);
     $this->assertEquals($n2, self::$n->first());
     foreach (self::$n as $key => $child) {
         $keys[] = $key;
         $nodes[] = $child;
     }
     $this->assertEquals([$n2, $n, self::$n2, $n1], $nodes);
     $this->assertEquals([0, 1, 2, 3], $keys);
 }
Exemplo n.º 3
0
 public function testHasChildNodes()
 {
     $this->assertTrue(self::$n->hasChildNodes());
     $n = new Node();
     $this->assertFalse($n->hasChildNodes());
 }