Shlomi Fish avatar Shlomi Fish committed 7bcc1a7

Extract _count_children_by_name .

Comments (0)

Files changed (1)

     return _generic_count($doc, 'getChildrenByLocalName', [@_]);
 }
 
+sub _count_children_by_name
+{
+    local $Test::Builder::Level = $Test::Builder::Level + 1;
+    my $doc = shift;
+
+    return _generic_count($doc, 'getChildrenByTagName', [@_]);
+}
+
 {
     print "# 1. Document Attributes\n";
 
             is( scalar( @as ), 2, ' TODO : Add test name');
 
             my $A = $doc2->getDocumentElement;
-            @as   = $A->getChildrenByTagName( "A" );
             # TEST
-            is( scalar( @as ), 1, ' TODO : Add test name');
-            @as   = $A->getChildrenByTagName( "C:A" );
+            _count_children_by_name($A, 'A', 1, q{1 A});
             # TEST
-            is( scalar( @as ), 1, ' TODO : Add test name');
-            @as   = $A->getChildrenByTagName( "C:B" );
+            _count_children_by_name($A, 'C:A', 1, q{C:A});
             # TEST
-            is( scalar( @as ), 0, ' TODO : Add test name');
-            @as   = $A->getChildrenByTagName( "*" );
+            _count_children_by_name($A, 'C:B', 0, q{No C:B children});
             # TEST
-            is( scalar( @as ), 2, ' TODO : Add test name');
+            _count_children_by_name($A, "*", 2, q{2 Childern in $A in total});
+
             @as   = $A->getChildrenByTagNameNS( "*", "A" );
             # TEST
             is( scalar( @as ), 2, ' TODO : Add test name');
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.