@@ -50,7 +50,7 @@ |
||
50 | 50 | $configArray = $this->getConfigArray($configFile, true); |
51 | 51 | |
52 | 52 | if (is_string($configArray)) { |
53 | - throw new \RuntimeException('Unable to load config file. Please check ' . $configFile); |
|
53 | + throw new \RuntimeException('Unable to load config file. Please check '.$configFile); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->config = new Configuration(new Uri('http://www.example.com'), $dispatcher, $configArray); |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Symfony\Component\Console\Output\OutputInterface; |
6 | 6 | use whm\Smoke\Config\Configuration; |
7 | -use whm\Smoke\Extensions\SmokeResponseRetriever\Retriever\Retriever; |
|
8 | 7 | use whm\Smoke\Rules\CheckResult; |
9 | 8 | |
10 | 9 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->resultFile = $resultFile; |
29 | 29 | |
30 | 30 | if ($templateDir === null) { |
31 | - $this->templateDir = __DIR__ . '/templates'; |
|
31 | + $this->templateDir = __DIR__.'/templates'; |
|
32 | 32 | } else { |
33 | 33 | $this->templateDir = $templateDir; |
34 | 34 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | if (!file_put_contents($this->resultFile, $html)) { |
69 | - $this->output->writeln("<error>HTML Reporter extension: Could not write result file to " . $this->resultFile ."</error>"); |
|
69 | + $this->output->writeln("<error>HTML Reporter extension: Could not write result file to ".$this->resultFile."</error>"); |
|
70 | 70 | } else { |
71 | - $this->output->writeln("<info>HTML Reporter extension:</info> Result file written to " . $this->resultFile); |
|
71 | + $this->output->writeln("<info>HTML Reporter extension:</info> Result file written to ".$this->resultFile); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | const STATUS_SUCCESS = 'success'; |
53 | 53 | const STATUS_FAILURE = 'failure'; |
54 | 54 | |
55 | - public function init($apiKey, Configuration $_configuration, OutputInterface $_output, $server = 'https://webhook.koalamon.com', $system = '', $identifier = '', $tool = '', $url ='') |
|
55 | + public function init($apiKey, Configuration $_configuration, OutputInterface $_output, $server = 'https://webhook.koalamon.com', $system = '', $identifier = '', $tool = '', $url = '') |
|
56 | 56 | { |
57 | 57 | $httpClient = new \GuzzleHttp\Client(); |
58 | 58 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public function processResults($results) |
83 | 83 | { |
84 | 84 | foreach ($results as $result) { |
85 | - if($result->getStatus() == CheckResult::STATUS_SUCCESS) { |
|
85 | + if ($result->getStatus() == CheckResult::STATUS_SUCCESS) { |
|
86 | 86 | $this->success++; |
87 | 87 | } else { |
88 | 88 | $this->failed++; |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | public function finish() |
94 | 94 | { |
95 | 95 | $message = 'Checks: '; |
96 | - $message .= $this->success . ' succeeded, '; |
|
97 | - $message .= $this->failed . ' failed. '; |
|
96 | + $message .= $this->success.' succeeded, '; |
|
97 | + $message .= $this->failed.' failed. '; |
|
98 | 98 | |
99 | 99 | if ($this->failed > 0) { |
100 | 100 | $status = Event::STATUS_FAILURE; |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | $this->reporter->sendEvent($event); |
130 | 130 | } catch (KoalamonException $e) { |
131 | 131 | $this->output->writeln("\n <error> Error sending result to leankoala. </error>"); |
132 | - $this->output->writeln(' Url: ' . $e->getUrl()); |
|
133 | - $this->output->writeln(' Payload: ' . $e->getPayload()); |
|
132 | + $this->output->writeln(' Url: '.$e->getUrl()); |
|
133 | + $this->output->writeln(' Payload: '.$e->getPayload()); |
|
134 | 134 | $this->output->writeln(""); |
135 | 135 | } catch (\Exception $e) { |
136 | 136 | $this->output->writeln($e->getMessage()); |
@@ -97,7 +97,7 @@ |
||
97 | 97 | } catch (ValidationFailedException $e) { |
98 | 98 | $result = new CheckResult(CheckResult::STATUS_FAILURE, $e->getMessage()); |
99 | 99 | } catch (\Exception $e) { |
100 | - $result = new CheckResult(CheckResult::STATUS_FAILURE, 'An error occured: ' . $e->getMessage()); |
|
100 | + $result = new CheckResult(CheckResult::STATUS_FAILURE, 'An error occured: '.$e->getMessage()); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $this->eventDispatcher->simpleNotify('Scanner.CheckResponse.Rule', array('checkResult' => $result, 'ruleName' => $name)); |
@@ -36,12 +36,12 @@ |
||
36 | 36 | if ($cookieCount > $this->maxCookies) { |
37 | 37 | $result = new CheckResult( |
38 | 38 | CheckResult::STATUS_FAILURE, |
39 | - $cookieCount . ' cookies were stored (limit was ' . $this->maxCookies . ').', |
|
39 | + $cookieCount.' cookies were stored (limit was '.$this->maxCookies.').', |
|
40 | 40 | $cookieCount); |
41 | 41 | } else { |
42 | 42 | $result = new CheckResult( |
43 | 43 | CheckResult::STATUS_SUCCESS, |
44 | - $cookieCount . ' cookies were stored (limit was ' . $this->maxCookies . ').', |
|
44 | + $cookieCount.' cookies were stored (limit was '.$this->maxCookies.').', |
|
45 | 45 | $cookieCount); |
46 | 46 | } |
47 | 47 |
@@ -18,7 +18,6 @@ |
||
18 | 18 | private $maxCookies; |
19 | 19 | |
20 | 20 | /** |
21 | - * @param int $maxDuration The maximum duration a http call is allowed to take (time to first byte) |
|
22 | 21 | */ |
23 | 22 | public function init($maxElements = 20) |
24 | 23 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function doValidation(ResponseInterface $response) |
25 | 25 | { |
26 | - $content = (string)$response->getBody(); |
|
26 | + $content = (string) $response->getBody(); |
|
27 | 27 | |
28 | 28 | $domDocument = new \DOMDocument(); |
29 | 29 | @$domDocument->loadHTML($content); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | try { |
41 | 41 | $selectorAsXPath = $converter->toXPath($selector['pattern']); |
42 | 42 | } catch (\Exception $e) { |
43 | - throw new ValidationFailedException('Invalid css selector (' . $selector['pattern'] . ').'); |
|
43 | + throw new ValidationFailedException('Invalid css selector ('.$selector['pattern'].').'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $count = $domXPath->query($selectorAsXPath)->length; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | if ($error === true) { |
55 | 55 | $allNotFoundSelectors = implode('", "', $snotFoundSelectors); |
56 | 56 | |
57 | - throw new ValidationFailedException('CSS Selector "' . $allNotFoundSelectors . '" not found in DOM.'); |
|
57 | + throw new ValidationFailedException('CSS Selector "'.$allNotFoundSelectors.'" not found in DOM.'); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | && strpos($response->getContentType(), 'pdf') === false |
27 | 27 | && strpos($response->getContentType(), 'postscript') === false |
28 | 28 | && strpos($response->getContentType(), 'zip') === false |
29 | - && strlen((string)$response->getBody()) >= $this->minFileSize |
|
29 | + && strlen((string) $response->getBody()) >= $this->minFileSize |
|
30 | 30 | ) { |
31 | 31 | if (!$response->hasHeader('Content-Encoding') || $response->getHeader('Content-Encoding')[0] !== 'gzip') { |
32 | 32 | throw new ValidationFailedException('gzip compression not active'); |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | if ($response instanceof RequestAwareResponse) { |
38 | 38 | $request = $response->getRequest(); |
39 | 39 | if ($request instanceof DeviceAwareRequest) { |
40 | - return ' (Device: ' . $request->getDevice()->getName() . ')'; |
|
40 | + return ' (Device: '.$request->getDevice()->getName().')'; |
|
41 | 41 | } else if ($request instanceof ViewportAwareRequest) { |
42 | 42 | $viewport = $request->getViewport(); |
43 | - return ' (Viewport: width: ' . $viewport->getWidth() . ', height: ' . $viewport->getHeight() . ')'; |
|
43 | + return ' (Viewport: width: '.$viewport->getWidth().', height: '.$viewport->getHeight().')'; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | |
50 | 50 | protected function renderFailure(CheckResult $result) |
51 | 51 | { |
52 | - $this->output->writeln(' <error> ' . (string)$result->getResponse()->getUri() . $this->getRequestString($result->getResponse()) . ' </error> coming from ' . (string)$this->retriever->getComingFrom($result->getResponse()->getUri())); |
|
53 | - $this->output->writeln(' - ' . $result->getMessage() . ' [rule: ' . $result->getRuleName() . ']'); |
|
52 | + $this->output->writeln(' <error> '.(string) $result->getResponse()->getUri().$this->getRequestString($result->getResponse()).' </error> coming from '.(string) $this->retriever->getComingFrom($result->getResponse()->getUri())); |
|
53 | + $this->output->writeln(' - '.$result->getMessage().' [rule: '.$result->getRuleName().']'); |
|
54 | 54 | $this->output->writeln(''); |
55 | 55 | } |
56 | 56 | |
57 | 57 | protected function renderSuccess(CheckResult $result) |
58 | 58 | { |
59 | - $this->output->writeln(' <info> ' . (string)$result->getResponse()->getUri() . $this->getRequestString($result->getResponse()) . ' </info> all tests passed'); |
|
59 | + $this->output->writeln(' <info> '.(string) $result->getResponse()->getUri().$this->getRequestString($result->getResponse()).' </info> all tests passed'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | protected function renderSkipped(CheckResult $result) |
63 | 63 | { |
64 | - $this->output->writeln(' <comment> ' . (string)$result->getResponse()->getUri() . $this->getRequestString($result->getResponse()) . ' </comment>test skipped'); |
|
65 | - $this->output->writeln(' - ' . $result->getMessage() . ' [rule: ' . $result->getRuleName() . ']'); |
|
64 | + $this->output->writeln(' <comment> '.(string) $result->getResponse()->getUri().$this->getRequestString($result->getResponse()).' </comment>test skipped'); |
|
65 | + $this->output->writeln(' - '.$result->getMessage().' [rule: '.$result->getRuleName().']'); |
|
66 | 66 | } |
67 | 67 | } |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | |
32 | 32 | // @todo this could be part of an abstract class |
33 | 33 | if ($this->useDom) { |
34 | - $content = (string)$response->getBody(); |
|
34 | + $content = (string) $response->getBody(); |
|
35 | 35 | } else { |
36 | 36 | if ($response instanceof DomAwareResponse) { |
37 | 37 | $content = $response->getHtmlBody(); |
38 | 38 | } else { |
39 | - $content = (string)$response->getBody(); |
|
39 | + $content = (string) $response->getBody(); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | $count = $domXPath->query($xpath['pattern'])->length; |
49 | 49 | |
50 | 50 | if ($xpath['relation'] === 'equals') { |
51 | - $result = $count === (int)$xpath['value']; |
|
52 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were exact ' . $xpath['value'] . ' occurencies.'; |
|
51 | + $result = $count === (int) $xpath['value']; |
|
52 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were exact '.$xpath['value'].' occurencies.'; |
|
53 | 53 | } elseif ($xpath['relation'] === 'less than') { |
54 | - $result = $count < (int)$xpath['value']; |
|
55 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were less than ' . $xpath['value'] . '.'; |
|
54 | + $result = $count < (int) $xpath['value']; |
|
55 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were less than '.$xpath['value'].'.'; |
|
56 | 56 | } elseif ($xpath['relation'] === 'greater than') { |
57 | - $result = $count > (int)$xpath['value']; |
|
58 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were more than ' . $xpath['value'] . '.'; |
|
57 | + $result = $count > (int) $xpath['value']; |
|
58 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were more than '.$xpath['value'].'.'; |
|
59 | 59 | } else { |
60 | - throw new \RuntimeException('Relation not defined. Given "' . $xpath['relation'] . '" expected [equals, greater than, less than]'); |
|
60 | + throw new \RuntimeException('Relation not defined. Given "'.$xpath['relation'].'" expected [equals, greater than, less than]'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $this->assert($result, $message); |