@@ -319,4 +319,52 @@ public function testDeleteNode()
319319 unset($ a );
320320 $ this ->assertEquals ('<div class="all"><p>Hey bro, <br /> :)</p></div> ' , (string ) $ dom );
321321 }
322+
323+ public function testCountChildren ()
324+ {
325+ $ dom = new Dom ;
326+ $ dom ->load ('<strong>hello</strong><code class="language-php">$foo = "bar";</code> ' );
327+ $ this ->assertEquals (2 , $ dom ->countChildren ());
328+ }
329+
330+ public function testGetChildrenArray ()
331+ {
332+ $ dom = new Dom ;
333+ $ dom ->load ('<strong>hello</strong><code class="language-php">$foo = "bar";</code> ' );
334+ $ this ->assertInternalType ('array ' , $ dom ->getChildren ());
335+ }
336+
337+ public function testHasChildren ()
338+ {
339+ $ dom = new Dom ;
340+ $ dom ->load ('<strong>hello</strong><code class="language-php">$foo = "bar";</code> ' );
341+ $ this ->assertTrue ($ dom ->hasChildren ());
342+ }
343+
344+ public function testFindByIdVar1 ()
345+ {
346+ $ dom = new Dom ;
347+ $ dom ->load ('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div> ' );
348+ /** @var Dom\AbstractNode $result */
349+ $ result = $ dom ->findById (4 );
350+ $ this ->assertEquals (4 , $ result ->id ());
351+ }
352+
353+ public function testFindByIdVar2 ()
354+ {
355+ $ dom = new Dom ;
356+ $ dom ->load ('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div> ' );
357+ /** @var Dom\AbstractNode $result */
358+ $ result = $ dom ->findById (5 );
359+ $ this ->assertEquals (5 , $ result ->id ());
360+ }
361+
362+ public function testFindByIdNotFountEleement ()
363+ {
364+ $ dom = new Dom ;
365+ $ dom ->load ('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div> ' );
366+ /** @var Dom\AbstractNode $result */
367+ $ result = $ dom ->findById (8 );
368+ $ this ->assertFalse ($ result );
369+ }
322370}
0 commit comments