File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -174,13 +174,13 @@ class Helper {
174174		<description>light Belgian waffles covered with strawberrys and whipped cream</description> 
175175		<calories>900</calories> 
176176	</food> 
177- 	<food> 
177+ 	<food special-date="2020-08-30" > 
178178		<name>Berry-Berry Belgian Waffles</name> 
179179		<price>$8.95</price> 
180180		<description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description> 
181181		<calories>900</calories> 
182182	</food> 
183- 	<food> 
183+ 	<food offer="10%" > 
184184		<name>French Toast</name> 
185185		<price>$4.50</price> 
186186		<description>thick slices made from our homemade sourdough bread</description> 
Original file line number Diff line number Diff line change @@ -20,6 +20,31 @@ public function testConstruction() {
2020		// test construction from a XMLDocument object, just to be sure 
2121		$ fromXMLDocumentnew  XMLDocument ($ fromRawXML
2222		$ this assertInstanceOf (XMLDocument::class, $ fromXMLDocument
23+ 	}
24+ 
25+ 	public  function  testQuerySelector () {
26+ 		$ documentnew  XMLDocument (Helper::XML );
27+ 		$ firstFoodName$ documentquerySelector ("food name " );
28+ 		self ::assertEquals ("Belgian Waffles " , $ firstFoodNamenodeValue );
29+ 	}
30+ 
31+ 	public  function  testQuerySelectorAttribute () {
32+ 		$ documentnew  XMLDocument (Helper::XML );
33+ 		$ offerFood$ documentquerySelector ("food[offer] " );
34+ 		self ::assertEquals ("10% " , $ offerFoodgetAttribute ("offer " ));
35+ 	}
36+ 
37+ 	public  function  testQuerySelectorAll () {
38+ 		$ documentnew  XMLDocument (Helper::XML );
39+ 		$ totalCalories0 ;
40+ 
41+ 		foreach ($ documentquerySelectorAll ("breakfast-menu>food calories " ) as  $ caloriesElement
42+ 			$ totalCaloriesint )$ caloriesElementnodeValue ;
43+ 		}
2344
45+ 		self ::assertEquals (
46+ 			650  + 900  + 900  + 600  + 950 ,
47+ 			$ totalCalories
48+ 		);
2449	}
2550}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments