@@ -15,7 +15,6 @@ |
||
15 | 15 | protected $contentTypes = array('text/html'); |
16 | 16 | |
17 | 17 | /** |
18 | - * @param int $string The string that the document must contain |
|
19 | 18 | */ |
20 | 19 | public function init(array $regExs) |
21 | 20 | { |
@@ -25,8 +25,8 @@ |
||
25 | 25 | protected function doValidation(ResponseInterface $response) |
26 | 26 | { |
27 | 27 | foreach ($this->regExs as $regEx) { |
28 | - $this->assert(preg_match('^' . $regEx . '^', (string)$response->getBody()) === 0, |
|
29 | - 'The given regular expression (' . $regEx . ') was found in this document.'); |
|
28 | + $this->assert(preg_match('^'.$regEx.'^', (string) $response->getBody()) === 0, |
|
29 | + 'The given regular expression ('.$regEx.') was found in this document.'); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $sslOptions = stream_context_create(array('ssl' => array('capture_peer_cert' => true))); |
30 | 30 | |
31 | 31 | $request = stream_socket_client( |
32 | - 'ssl://' . $host . ':443', |
|
32 | + 'ssl://'.$host.':443', |
|
33 | 33 | $errno, |
34 | 34 | $errstr, |
35 | 35 | 30, |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace whm\Smoke\Rules\Http; |
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | -use whm\Smoke\Http\Response; |
|
7 | 6 | use whm\Smoke\Rules\Rule; |
8 | 7 | |
9 | 8 | abstract class HttpsRule implements Rule |
@@ -21,8 +21,8 @@ |
||
21 | 21 | if (!$success) { |
22 | 22 | $lastError = libxml_get_last_error(); |
23 | 23 | |
24 | - throw new ValidationFailedException('The xml file ' . $response->getUri() . ' is not well formed (last error: ' . |
|
25 | - str_replace("\n", '', $lastError->message) . ').'); |
|
24 | + throw new ValidationFailedException('The xml file '.$response->getUri().' is not well formed (last error: '. |
|
25 | + str_replace("\n", '', $lastError->message).').'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | private function getSchema($isIndex) |
30 | 30 | { |
31 | 31 | if ($isIndex) { |
32 | - return __DIR__ . '/' . self::INDEX; |
|
32 | + return __DIR__.'/'.self::INDEX; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | if ($this->strictMode) { |
36 | - return __DIR__ . '/' . self::SCHEMA; |
|
36 | + return __DIR__.'/'.self::SCHEMA; |
|
37 | 37 | } else { |
38 | - return __DIR__ . '/' . self::NON_STRICT_SCHEMA; |
|
38 | + return __DIR__.'/'.self::NON_STRICT_SCHEMA; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if (!$valid) { |
50 | 50 | $lastError = libxml_get_last_error(); |
51 | 51 | throw new ValidationFailedException( |
52 | - 'The given sitemap file (' . $filename . ') did not validate against the sitemap schema (last error: ' . str_replace("\n", '', $lastError->message) . ').'); |
|
52 | + 'The given sitemap file ('.$filename.') did not validate against the sitemap schema (last error: '.str_replace("\n", '', $lastError->message).').'); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 |
@@ -26,6 +26,9 @@ discard block |
||
26 | 26 | $this->strictMode = $strictMode; |
27 | 27 | } |
28 | 28 | |
29 | + /** |
|
30 | + * @param boolean $isIndex |
|
31 | + */ |
|
29 | 32 | private function getSchema($isIndex) |
30 | 33 | { |
31 | 34 | if ($isIndex) { |
@@ -39,6 +42,10 @@ discard block |
||
39 | 42 | } |
40 | 43 | } |
41 | 44 | |
45 | + /** |
|
46 | + * @param \Psr\Http\Message\StreamInterface $body |
|
47 | + * @param string $filename |
|
48 | + */ |
|
42 | 49 | private function validateBody($body, $filename, $isIndex = true) |
43 | 50 | { |
44 | 51 | $dom = new \DOMDocument(); |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace whm\Smoke\Rules\Xml\Sitemap; |
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | -use whm\Smoke\Http\Response; |
|
7 | 6 | use whm\Smoke\Rules\StandardRule; |
8 | 7 | use whm\Smoke\Rules\ValidationFailedException; |
9 | 8 |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | public function finish() |
97 | 97 | { |
98 | - $this->output->writeln('Sending results to ' . $this->server . " ... \n"); |
|
98 | + $this->output->writeln('Sending results to '.$this->server." ... \n"); |
|
99 | 99 | |
100 | 100 | if ($this->groupBy === 'prefix') { |
101 | 101 | $this->sendGroupedByPrefix(); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | foreach ($this->getRuleKeys() as $rule) { |
128 | 128 | foreach ($systems as $system) { |
129 | - $identifier = $this->tool . '_' . $this->getPrefix($rule) . '_' . $system; |
|
129 | + $identifier = $this->tool.'_'.$this->getPrefix($rule).'_'.$system; |
|
130 | 130 | $failureMessages[$identifier]['message'] = ''; |
131 | 131 | $failureMessages[$identifier]['system'] = $system; |
132 | 132 | $failureMessages[$identifier]['tool'] = $this->getPrefix($rule); |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | $system = $this->retriever->getSystem(($result->getUrl())); |
144 | 144 | } |
145 | 145 | |
146 | - $identifer = $this->tool . '_' . $this->getPrefix($ruleLKey) . '_' . $system; |
|
146 | + $identifer = $this->tool.'_'.$this->getPrefix($ruleLKey).'_'.$system; |
|
147 | 147 | |
148 | 148 | if ($failureMessages[$identifer]['message'] === '') { |
149 | - $failureMessages[$identifer]['message'] = 'The ' . $this->getPrefix($ruleLKey) . ' test for #system_name# failed.<ul>'; |
|
149 | + $failureMessages[$identifer]['message'] = 'The '.$this->getPrefix($ruleLKey).' test for #system_name# failed.<ul>'; |
|
150 | 150 | } |
151 | 151 | ++$counter[$identifer]; |
152 | - $message = '<li>' . $message . '<br>url: ' . $result->getUrl(); |
|
152 | + $message = '<li>'.$message.'<br>url: '.$result->getUrl(); |
|
153 | 153 | if ($this->addComingFrom) { |
154 | - $message .= ', coming from: ' . $this->retriever->getComingFrom($result->getUrl()); |
|
154 | + $message .= ', coming from: '.$this->retriever->getComingFrom($result->getUrl()); |
|
155 | 155 | } |
156 | 156 | $message .= '</li>'; |
157 | 157 | $failureMessages[$identifer]['message'] .= $message; |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | |
162 | 162 | foreach ($failureMessages as $key => $failureMessage) { |
163 | 163 | if ($failureMessage['message'] !== '') { |
164 | - $this->send($this->identifier . '_' . $key, $failureMessage['system'], $failureMessage['message'] . '</ul>', self::STATUS_FAILURE, '', $counter[$key], $failureMessage['tool']); |
|
164 | + $this->send($this->identifier.'_'.$key, $failureMessage['system'], $failureMessage['message'].'</ul>', self::STATUS_FAILURE, '', $counter[$key], $failureMessage['tool']); |
|
165 | 165 | } else { |
166 | - $this->send($this->identifier . '_' . $key, $failureMessage['system'], '', self::STATUS_SUCCESS, '', 0, $failureMessage['tool']); |
|
166 | + $this->send($this->identifier.'_'.$key, $failureMessage['system'], '', self::STATUS_SUCCESS, '', 0, $failureMessage['tool']); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $failedTests = array(); |
176 | 176 | if ($result->isFailure()) { |
177 | 177 | foreach ($result->getMessages() as $ruleLKey => $message) { |
178 | - $identifier = 'smoke_' . $ruleLKey . '_' . $result->getUrl(); |
|
178 | + $identifier = 'smoke_'.$ruleLKey.'_'.$result->getUrl(); |
|
179 | 179 | |
180 | 180 | if ($this->system === '') { |
181 | 181 | $system = str_replace('http://', '', $result->getUrl()); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | foreach ($rules as $rule) { |
190 | 190 | if (!in_array($rule, $failedTests, true)) { |
191 | - $identifier = 'smoke_' . $rule . '_' . $result->getUrl(); |
|
191 | + $identifier = 'smoke_'.$rule.'_'.$result->getUrl(); |
|
192 | 192 | |
193 | 193 | if ($this->systemUseRetriever) { |
194 | 194 | $system = $this->retriever->getSystem($result->getUrl()); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | } else { |
198 | 198 | $system = $this->system; |
199 | 199 | } |
200 | - $this->send($identifier, $system, 'smoke_' . $rule . '_' . $result->getUrl(), self::STATUS_SUCCESS, (string) $result->getUrl()); |
|
200 | + $this->send($identifier, $system, 'smoke_'.$rule.'_'.$result->getUrl(), self::STATUS_SUCCESS, (string) $result->getUrl()); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -221,17 +221,17 @@ discard block |
||
221 | 221 | $system = $this->retriever->getSystem(new Uri($result->getUrl())); |
222 | 222 | } |
223 | 223 | if ($failureMessages[$ruleLKey] === '') { |
224 | - $failureMessages[$ruleLKey]['message'] = ' The smoke test for #system_name# failed (Rule: ' . $ruleLKey . ').<ul>'; |
|
224 | + $failureMessages[$ruleLKey]['message'] = ' The smoke test for #system_name# failed (Rule: '.$ruleLKey.').<ul>'; |
|
225 | 225 | } |
226 | 226 | ++$counter[$ruleLKey]; |
227 | 227 | |
228 | 228 | $comingFrom = ''; |
229 | 229 | |
230 | 230 | if ($this->addComingFrom && $this->retriever->getComingFrom($result->getUrl())) { |
231 | - $comingFrom = ', coming from: ' . $this->retriever->getComingFrom($result->getUrl()); |
|
231 | + $comingFrom = ', coming from: '.$this->retriever->getComingFrom($result->getUrl()); |
|
232 | 232 | } |
233 | 233 | |
234 | - $failureMessages[$ruleLKey]['message'] .= '<li>' . $message . ' (url: ' . $result->getUrl() . $comingFrom . ')</li > '; |
|
234 | + $failureMessages[$ruleLKey]['message'] .= '<li>'.$message.' (url: '.$result->getUrl().$comingFrom.')</li > '; |
|
235 | 235 | $failureMessages[$ruleLKey]['system'] = $system; |
236 | 236 | } |
237 | 237 | } |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | |
240 | 240 | foreach ($failureMessages as $key => $failureMessage) { |
241 | 241 | if ($failureMessage !== '') { |
242 | - $this->send($this->identifier . '_' . $key, $this->system, $failureMessage['message'] . ' </ul > ', self::STATUS_FAILURE, '', $counter[$key]); |
|
242 | + $this->send($this->identifier.'_'.$key, $this->system, $failureMessage['message'].' </ul > ', self::STATUS_FAILURE, '', $counter[$key]); |
|
243 | 243 | } else { |
244 | - $this->send($this->identifier . '_' . $key, $this->system, '', self::STATUS_SUCCESS, '', 0); |
|
244 | + $this->send($this->identifier.'_'.$key, $this->system, '', self::STATUS_SUCCESS, '', 0); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
@@ -246,6 +246,10 @@ |
||
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | + /** |
|
250 | + * @param string $identifier |
|
251 | + * @param string $message |
|
252 | + */ |
|
249 | 253 | private function send($identifier, $system, $message, $status, $url = '', $value = 0, $tool = null) |
250 | 254 | { |
251 | 255 | if (is_null($tool)) { |
@@ -39,12 +39,12 @@ |
||
39 | 39 | $error = true; |
40 | 40 | $lastError = libxml_get_last_error(); |
41 | 41 | |
42 | - $messageParts[] = $xsdFile['xsdfilename'] . ' - ' . $xsdFile['xsdfileurl'] . '(last error: ' . str_replace("\n", '', $lastError->message) . ').'; |
|
42 | + $messageParts[] = $xsdFile['xsdfilename'].' - '.$xsdFile['xsdfileurl'].'(last error: '.str_replace("\n", '', $lastError->message).').'; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | if ($error === true) { |
47 | - $message = 'XML file (' . $filename . ') does not validate against the following XSD files: ' . implode(', ', $messageParts); |
|
47 | + $message = 'XML file ('.$filename.') does not validate against the following XSD files: '.implode(', ', $messageParts); |
|
48 | 48 | throw new ValidationFailedException($message); |
49 | 49 | } |
50 | 50 | } |
@@ -49,6 +49,9 @@ |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | + /** |
|
53 | + * @param string $content |
|
54 | + */ |
|
52 | 55 | private function normalizeContent($content) |
53 | 56 | { |
54 | 57 | $normalizedContent = strtolower($content); |
@@ -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 |
@@ -72,6 +72,9 @@ |
||
72 | 72 | $this->output->writeln(''); |
73 | 73 | } |
74 | 74 | |
75 | + /** |
|
76 | + * @param integer $ruleKey |
|
77 | + */ |
|
75 | 78 | private function getFailedUrls($ruleKey) |
76 | 79 | { |
77 | 80 | $failedUrls = array(); |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | /** @var CheckResult $result */ |
82 | 82 | if ($result->getStatus() === CheckResult::STATUS_FAILURE) { |
83 | 83 | if ($ruleKey === $key) { |
84 | - $failedUrls[] = (string) $result->getResponse()->getUri() . ' - ' . $result->getMessage(); |
|
84 | + $failedUrls[] = (string) $result->getResponse()->getUri().' - '.$result->getMessage(); |
|
85 | 85 | ++$count; |
86 | 86 | } |
87 | 87 | if ($count > $this->maxResults) { |
88 | - $failedUrls[] = '... only the first ' . $this->maxResults . ' elements are shown.'; |
|
88 | + $failedUrls[] = '... only the first '.$this->maxResults.' elements are shown.'; |
|
89 | 89 | break; |
90 | 90 | } |
91 | 91 | } |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | $failedUrls = $this->getFailedUrls($ruleKey); |
105 | 105 | |
106 | 106 | if (count($failedUrls) > 0) { |
107 | - $this->output->writeln(' <error> ' . get_class($rule) . ' </error>'); |
|
107 | + $this->output->writeln(' <error> '.get_class($rule).' </error>'); |
|
108 | 108 | } else { |
109 | - $this->output->writeln(' <info> ' . get_class($rule) . ' </info>'); |
|
109 | + $this->output->writeln(' <info> '.get_class($rule).' </info>'); |
|
110 | 110 | } |
111 | 111 | |
112 | - $this->output->writeln(' ' . str_replace("\n", "\n ", $info['documentation']) . "\n"); |
|
112 | + $this->output->writeln(' '.str_replace("\n", "\n ", $info['documentation'])."\n"); |
|
113 | 113 | |
114 | 114 | foreach ($failedUrls as $failedUrl) { |
115 | - $this->output->writeln(' - ' . $failedUrl); |
|
115 | + $this->output->writeln(' - '.$failedUrl); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $this->output->writeln(''); |
@@ -30,13 +30,13 @@ |
||
30 | 30 | |
31 | 31 | protected function renderFailure(CheckResult $result) |
32 | 32 | { |
33 | - $this->output->writeln(' <error> ' . (string) $result->getResponse()->getUri() . ' </error> coming from ' . (string) $this->retriever->getComingFrom($result->getResponse()->getUri())); |
|
34 | - $this->output->writeln(' - ' . $result->getMessage() . ' [rule: ' . $result->getRuleName() . ']'); |
|
33 | + $this->output->writeln(' <error> '.(string) $result->getResponse()->getUri().' </error> coming from '.(string) $this->retriever->getComingFrom($result->getResponse()->getUri())); |
|
34 | + $this->output->writeln(' - '.$result->getMessage().' [rule: '.$result->getRuleName().']'); |
|
35 | 35 | $this->output->writeln(''); |
36 | 36 | } |
37 | 37 | |
38 | 38 | protected function renderSuccess(CheckResult $result) |
39 | 39 | { |
40 | - $this->output->writeln(' <info> ' . (string) $result->getResponse()->getUri() . ' </info> all tests passed'); |
|
40 | + $this->output->writeln(' <info> '.(string) $result->getResponse()->getUri().' </info> all tests passed'); |
|
41 | 41 | } |
42 | 42 | } |