@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | 6 | use whm\Html\Document; |
7 | -use whm\Smoke\Http\Response; |
|
8 | 7 | |
9 | 8 | /** |
10 | 9 | * This rules counts the js files that are included in a document. If the number is higher |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace whm\Smoke\Rules\Image; |
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | -use whm\Smoke\Http\Response; |
|
7 | 6 | use whm\Smoke\Rules\StandardRule; |
8 | 7 | |
9 | 8 | /** |
@@ -30,8 +30,8 @@ |
||
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | - $imageHash = md5((string)$response->getBody()); |
|
33 | + $imageHash = md5((string) $response->getBody()); |
|
34 | 34 | |
35 | - $this->assert(!array_key_exists($imageHash, $this->favicons), 'Seems like you use the standard favicon of your framework (' . $this->favicons[$imageHash] . ').'); |
|
35 | + $this->assert(!array_key_exists($imageHash, $this->favicons), 'Seems like you use the standard favicon of your framework ('.$this->favicons[$imageHash].').'); |
|
36 | 36 | } |
37 | 37 | } |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use JsonSchema\Validator; |
6 | 6 | use Psr\Http\Message\ResponseInterface; |
7 | -use whm\Smoke\Http\Response; |
|
8 | 7 | use whm\Smoke\Rules\StandardRule; |
9 | 8 | use whm\Smoke\Rules\ValidationFailedException; |
10 | 9 |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | protected function doValidation(ResponseInterface $response) |
35 | 35 | { |
36 | - $data = json_decode((string)$response->getBody()); |
|
36 | + $data = json_decode((string) $response->getBody()); |
|
37 | 37 | if ($data === null) { |
38 | - throw new ValidationFailedException("The given JSON data can not be validated (last error: '" . $this->json_errors[json_last_error()] . "')."); |
|
38 | + throw new ValidationFailedException("The given JSON data can not be validated (last error: '".$this->json_errors[json_last_error()]."')."); |
|
39 | 39 | } else { |
40 | 40 | $errorStatus = false; |
41 | 41 | $messageParts = array(); |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | $errorStatus = true; |
52 | 52 | $errorMessage = ''; |
53 | 53 | foreach ($validator->getErrors() as $error) { |
54 | - $errorMessage = $errorMessage . sprintf("[%s] %s\n", $error['property'], $error['message']); |
|
54 | + $errorMessage = $errorMessage.sprintf("[%s] %s\n", $error['property'], $error['message']); |
|
55 | 55 | } |
56 | - $messageParts[] = $jsonSchemaFile['jsonfilename'] . ' - ' . $jsonSchemaFile['jsonfileurl'] . '(last error: ' . $errorMessage . ').'; |
|
56 | + $messageParts[] = $jsonSchemaFile['jsonfilename'].' - '.$jsonSchemaFile['jsonfileurl'].'(last error: '.$errorMessage.').'; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | 60 | if ($errorStatus === true) { |
61 | - $message = 'JSON file (' . (string) $response->getUri() . ') does not validate against the following JSON Schema files: ' . implode(', ', $messageParts); |
|
61 | + $message = 'JSON file ('.(string) $response->getUri().') does not validate against the following JSON Schema files: '.implode(', ', $messageParts); |
|
62 | 62 | throw new ValidationFailedException($message); |
63 | 63 | } |
64 | 64 | } |
@@ -4,8 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | 6 | use Symfony\Component\DomCrawler\Crawler; |
7 | -use whm\Smoke\Http\Response; |
|
8 | -use whm\Smoke\Rules\Rule; |
|
9 | 7 | use whm\Smoke\Rules\StandardRule; |
10 | 8 | |
11 | 9 | /** |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | |
20 | 20 | protected function doValidation(ResponseInterface $response) |
21 | 21 | { |
22 | - $crawler = new Crawler((string)$response->getBody()); |
|
22 | + $crawler = new Crawler((string) $response->getBody()); |
|
23 | 23 | $actionNodes = $crawler->filterXPath('//form[//input[@type="password"]]'); |
24 | 24 | |
25 | - $url = (string)$response->getUri(); |
|
25 | + $url = (string) $response->getUri(); |
|
26 | 26 | |
27 | 27 | foreach ($actionNodes as $node) { |
28 | 28 | $action = $node->getAttribute('action'); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | while ($parent = $parent->parentNode) { |
38 | 38 | if (property_exists($parent, 'tagName')) { |
39 | - $fullPath = $parent->tagName . '/' . $fullPath; |
|
39 | + $fullPath = $parent->tagName.'/'.$fullPath; |
|
40 | 40 | } else { |
41 | 41 | break; |
42 | 42 | } |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace whm\Smoke\Rules\Seo; |
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | -use whm\Smoke\Http\Response; |
|
7 | 6 | use whm\Smoke\Rules\Rule; |
8 | 7 | use whm\Smoke\Rules\ValidationFailedException; |
9 | 8 |
@@ -4,8 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Ivory\HttpAdapter\HttpAdapterInterface; |
6 | 6 | use Psr\Http\Message\ResponseInterface; |
7 | -use whm\Smoke\Http\ClientAware; |
|
8 | -use whm\Smoke\Http\Response; |
|
9 | 7 | use whm\Smoke\Rules\Rule; |
10 | 8 | use whm\Smoke\Rules\ValidationFailedException; |
11 | 9 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | |
22 | 22 | public function validate(ResponseInterface $response) |
23 | 23 | { |
24 | - $url = $response->getUri()->getScheme() . '://' . $response->getUri()->getHost(); |
|
24 | + $url = $response->getUri()->getScheme().'://'.$response->getUri()->getHost(); |
|
25 | 25 | |
26 | 26 | if (substr_count($url, '/') === 2) { |
27 | - $filename = $robotsUrl = $url . '/robots.txt'; |
|
27 | + $filename = $robotsUrl = $url.'/robots.txt'; |
|
28 | 28 | } elseif (substr_count($url, '/') === 3) { |
29 | - $filename = $robotsUrl = $url . 'robots.txt'; |
|
29 | + $filename = $robotsUrl = $url.'robots.txt'; |
|
30 | 30 | } else { |
31 | 31 | return; |
32 | 32 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | $normalizedContent = $this->normalizeContent($content); |
41 | 41 | |
42 | - if (strpos($normalizedContent, 'user-agent:* disallow:/' . PHP_EOL) !== false) { |
|
42 | + if (strpos($normalizedContent, 'user-agent:* disallow:/'.PHP_EOL) !== false) { |
|
43 | 43 | throw new ValidationFailedException('The robots.txt contains disallow all (Disallow: /)'); |
44 | 44 | } |
45 | 45 |
@@ -28,6 +28,10 @@ |
||
28 | 28 | |
29 | 29 | abstract protected function doValidation(ResponseInterface $response); |
30 | 30 | |
31 | + /** |
|
32 | + * @param boolean $valueToBeTrue |
|
33 | + * @param string $errorMessage |
|
34 | + */ |
|
31 | 35 | protected function assert($valueToBeTrue, $errorMessage) |
32 | 36 | { |
33 | 37 | if (!$valueToBeTrue) { |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | public function init($filters = array(), $filterFile = '', $exclusive = array()) |
42 | 42 | { |
43 | 43 | if (count($exclusive) > 0 && (count($filters) > 0 || $filterFile !== '')) { |
44 | - throw new \RuntimeException("It's not possible to define filter lists and an exclusive list at the same time [Extension: " . get_class($this) . '].'); |
|
44 | + throw new \RuntimeException("It's not possible to define filter lists and an exclusive list at the same time [Extension: ".get_class($this).'].'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if ($filterFile !== '') { |
48 | 48 | if (!file_exists($filterFile)) { |
49 | - throw new \RuntimeException('Filter file not found: ' . $filterFile); |
|
49 | + throw new \RuntimeException('Filter file not found: '.$filterFile); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $filterElements = EnvAwareYaml::parse(file_get_contents($filterFile)); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function isFiltered(Event $event, $ruleName, UriAwareResponse $response) |
87 | 87 | { |
88 | - $uri = (string)$this->retriever->getOriginUri($response->getUri()); |
|
88 | + $uri = (string) $this->retriever->getOriginUri($response->getUri()); |
|
89 | 89 | |
90 | 90 | if ($this->currentModus === self::MODUS_FILTER) { |
91 | 91 | $isFiltered = $this->isFilteredByFilter($ruleName, $uri); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | private function isFilteredByFilter($ruleName, $uri) |
105 | 105 | { |
106 | 106 | foreach ($this->filters as $filter) { |
107 | - if ($ruleName === $filter['rule'] && 0 < preg_match('$' . $filter['uri'] . '$', $uri)) { |
|
107 | + if ($ruleName === $filter['rule'] && 0 < preg_match('$'.$filter['uri'].'$', $uri)) { |
|
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $failures = 0; |
60 | 60 | |
61 | 61 | if ($this->retriever instanceof CrawlingRetriever) { |
62 | - $startPage = (string)$this->retriever->getStartPage(); |
|
62 | + $startPage = (string) $this->retriever->getStartPage(); |
|
63 | 63 | } else { |
64 | 64 | $startPage = ''; |
65 | 65 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | $testCase->addFailure(new Failure($ruleName, $message)); |
81 | 81 | |
82 | 82 | if ($this->retriever instanceof CrawlingRetriever) { |
83 | - $stackTrace = $result->getUrl() . ' coming from ' . (string)$this->retriever->getComingFrom($result->getUrl()) . PHP_EOL; |
|
84 | - $stackTrace .= ' - ' . $message . " [rule: $ruleName]"; |
|
83 | + $stackTrace = $result->getUrl().' coming from '.(string) $this->retriever->getComingFrom($result->getUrl()).PHP_EOL; |
|
84 | + $stackTrace .= ' - '.$message." [rule: $ruleName]"; |
|
85 | 85 | $testCase->setSystemOut($stackTrace); |
86 | 86 | } |
87 | 87 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | file_put_contents($this->filename, $xUnitReport->toXml()); |
94 | 94 | |
95 | - $this->output->writeln(' <info>Writing XUnit Output to file:</info> ' . $this->filename); |
|
95 | + $this->output->writeln(' <info>Writing XUnit Output to file:</info> '.$this->filename); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public function processResults($results) |