99namespace SteveGrunwell \PHPUnit_Markup_Assertions ;
1010
1111use DOMDocument ;
12- use Laminas \Dom \Query ;
12+ use Laminas \Dom \Document ;
13+ use Laminas \Dom \Document \Query ;
1314use PHPUnit \Framework \RiskyTestError ;
1415
1516trait MarkupAssertionsTrait
1617{
17-
1818 /**
1919 * Assert that the given string contains an element matching the given selector.
2020 *
@@ -23,6 +23,8 @@ trait MarkupAssertionsTrait
2323 * @param string $selector A query selector for the element to find.
2424 * @param string $output The output that should contain the $selector.
2525 * @param string $message A message to display if the assertion fails.
26+ *
27+ * @return void
2628 */
2729 public function assertContainsSelector ($ selector , $ output = '' , $ message = '' )
2830 {
@@ -56,6 +58,8 @@ public function assertNotContainsSelector($selector, $output = '', $message = ''
5658 * @param string $selector A query selector for the element to find.
5759 * @param string $output The markup to run the assertion against.
5860 * @param string $message A message to display if the assertion fails.
61+ *
62+ * @return void
5963 */
6064 public function assertSelectorCount ($ count , $ selector , $ output = '' , $ message = '' )
6165 {
@@ -73,6 +77,8 @@ public function assertSelectorCount($count, $selector, $output = '', $message =
7377 * @param string $output The output that should contain an element with the
7478 * provided $attributes.
7579 * @param string $message A message to display if the assertion fails.
80+ *
81+ * @return void
7682 */
7783 public function assertHasElementWithAttributes ($ attributes = [], $ output = '' , $ message = '' )
7884 {
@@ -92,6 +98,8 @@ public function assertHasElementWithAttributes($attributes = [], $output = '', $
9298 * @param string $output The output that should not contain an element with the
9399 * provided $attributes.
94100 * @param string $message A message to display if the assertion fails.
101+ *
102+ * @return void
95103 */
96104 public function assertNotHasElementWithAttributes ($ attributes = [], $ output = '' , $ message = '' )
97105 {
@@ -111,6 +119,8 @@ public function assertNotHasElementWithAttributes($attributes = [], $output = ''
111119 * @param string $selector A query selector for the element to find.
112120 * @param string $output The output that should contain the $selector.
113121 * @param string $message A message to display if the assertion fails.
122+ *
123+ * @return void
114124 */
115125 public function assertElementContains ($ contents , $ selector = '' , $ output = '' , $ message = '' )
116126 {
@@ -134,6 +144,8 @@ public function assertElementContains($contents, $selector = '', $output = '', $
134144 * @param string $selector A query selector for the element to find.
135145 * @param string $output The output that should not contain the $selector.
136146 * @param string $message A message to display if the assertion fails.
147+ *
148+ * @return void
137149 */
138150 public function assertElementNotContains ($ contents , $ selector = '' , $ output = '' , $ message = '' )
139151 {
@@ -157,6 +169,8 @@ public function assertElementNotContains($contents, $selector = '', $output = ''
157169 * @param string $selector A query selector for the element to find.
158170 * @param string $output The output that should contain the $selector.
159171 * @param string $message A message to display if the assertion fails.
172+ *
173+ * @return void
160174 */
161175 public function assertElementRegExp ($ regexp , $ selector = '' , $ output = '' , $ message = '' )
162176 {
@@ -180,6 +194,8 @@ public function assertElementRegExp($regexp, $selector = '', $output = '', $mess
180194 * @param string $selector A query selector for the element to find.
181195 * @param string $output The output that should not contain the $selector.
182196 * @param string $message A message to display if the assertion fails.
197+ *
198+ * @return void
183199 */
184200 public function assertElementNotRegExp ($ regexp , $ selector = '' , $ output = '' , $ message = '' )
185201 {
@@ -202,13 +218,11 @@ public function assertElementNotRegExp($regexp, $selector = '', $output = '', $m
202218 * @param string $markup The HTML for the DOMDocument.
203219 * @param string $query The DOM selector query.
204220 *
205- * @return NodeList
221+ * @return \Laminas\Dom\Document\ NodeList
206222 */
207223 protected function executeDomQuery ($ markup , $ query )
208224 {
209- $ dom = new Query ($ markup );
210-
211- return $ dom ->execute ($ query );
225+ return Query::execute ($ query , new Document ($ markup ), Query::TYPE_CSS );
212226 }
213227
214228 /**
@@ -257,7 +271,7 @@ protected function getInnerHtmlOfMatchedElements($markup, $query)
257271
258272 // Loop through results and collect their innerHTML values.
259273 foreach ($ results as $ result ) {
260- $ document = new DOMDocument ;
274+ $ document = new DOMDocument () ;
261275 $ document ->appendChild ($ document ->importNode ($ result ->firstChild , true ));
262276
263277 $ contents [] = trim ($ document ->saveHTML ());
0 commit comments