|
@@ -22,7 +22,7 @@ discard block |
|
|
block discarded – undo |
|
22
|
22
|
public function doValidation(Response $response) |
|
23
|
23
|
{ |
|
24
|
24
|
$domDocument = new \DOMDocument(); |
|
25
|
|
- @$domDocument->loadHTML((string)$response->getBody()); |
|
|
25
|
+ @$domDocument->loadHTML((string) $response->getBody()); |
|
26
|
26
|
|
|
27
|
27
|
$domXPath = new \DOMXPath($domDocument); |
|
28
|
28
|
|
|
@@ -30,16 +30,16 @@ discard block |
|
|
block discarded – undo |
|
30
|
30
|
$count = $domXPath->query($xpath['pattern'])->length; |
|
31
|
31
|
|
|
32
|
32
|
if ($xpath['relation'] === 'equals') { |
|
33
|
|
- $result = $count == (int)$xpath['value']; |
|
34
|
|
- $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were exact ' . $xpath['value'] . ' occurencies.'; |
|
|
33
|
+ $result = $count == (int) $xpath['value']; |
|
|
34
|
+ $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were exact '.$xpath['value'].' occurencies.'; |
|
35
|
35
|
} elseif ($xpath['relation'] === 'less than') { |
|
36
|
|
- $result = $count < (int)$xpath['value']; |
|
37
|
|
- $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were less than ' . $xpath['value'] . '.'; |
|
|
36
|
+ $result = $count < (int) $xpath['value']; |
|
|
37
|
+ $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were less than '.$xpath['value'].'.'; |
|
38
|
38
|
} elseif ($xpath['relation'] === 'greater than') { |
|
39
|
|
- $result = $count > (int)$xpath['value']; |
|
40
|
|
- $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were more than ' . $xpath['value'] . '.'; |
|
|
39
|
+ $result = $count > (int) $xpath['value']; |
|
|
40
|
+ $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were more than '.$xpath['value'].'.'; |
|
41
|
41
|
} else { |
|
42
|
|
- throw new \RuntimeException('Relation not defined. Given "' . $xpath['relation'] . '" expected [equals, greater than, less than]'); |
|
|
42
|
+ throw new \RuntimeException('Relation not defined. Given "'.$xpath['relation'].'" expected [equals, greater than, less than]'); |
|
43
|
43
|
} |
|
44
|
44
|
|
|
45
|
45
|
$this->assert($result, $message); |