| @@ -42,6 +42,11 @@ | ||
| 42 | 42 | return json_decode($systems->getBody()); | 
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | + /** | |
| 46 | + * @param string $url | |
| 47 | + * | |
| 48 | + * @return string | |
| 49 | + */ | |
| 45 | 50 | private function prepareUrl($url) | 
| 46 | 51 |      { | 
| 47 | 52 |          $preparedUrl = str_replace("#project#", $this->project, $url); | 
| @@ -13,6 +13,9 @@ | ||
| 13 | 13 | return $this->getStatusCode(); | 
| 14 | 14 | } | 
| 15 | 15 | |
| 16 | + /** | |
| 17 | + * @return string | |
| 18 | + */ | |
| 16 | 19 | public function getContentType() | 
| 17 | 20 |      { | 
| 18 | 21 |          $exploded = explode(';', $this->hasHeader('Content-Type') ? $this->getHeader('Content-Type')[0] : null); | 
| @@ -159,6 +159,10 @@ | ||
| 159 | 159 | } | 
| 160 | 160 | } | 
| 161 | 161 | |
| 162 | + /** | |
| 163 | + * @param string $identifier | |
| 164 | + * @param string $message | |
| 165 | + */ | |
| 162 | 166 | public function send($identifier, $system, $message, $status, $url = '', $value = 0) | 
| 163 | 167 |      { | 
| 164 | 168 | $event = new Event($identifier, $system, $status, $this->tool, $message, $value); | 
| @@ -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 | } | 
| @@ -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 |      { | 
| @@ -29,12 +29,12 @@ discard block | ||
| 29 | 29 | |
| 30 | 30 |          foreach ($this->regExs as $regEx) { | 
| 31 | 31 |              if ($regEx['isRegEx']) { | 
| 32 | -                if (preg_match('^' . $regEx['pattern'] . '^', (string) $response->getBody()) === 0) { | |
| 33 | - $errors[] = 'Regular expression: ' . $regEx['pattern']; | |
| 32 | +                if (preg_match('^'.$regEx['pattern'].'^', (string) $response->getBody()) === 0) { | |
| 33 | + $errors[] = 'Regular expression: '.$regEx['pattern']; | |
| 34 | 34 | } | 
| 35 | 35 |              } else { | 
| 36 | -                if (preg_match('^' . preg_quote($regEx['pattern']) . '^', (string) $response->getBody()) === 0) { | |
| 37 | - $errors[] = 'Text: ' . $regEx['pattern']; | |
| 36 | +                if (preg_match('^'.preg_quote($regEx['pattern']).'^', (string) $response->getBody()) === 0) { | |
| 37 | + $errors[] = 'Text: '.$regEx['pattern']; | |
| 38 | 38 | } | 
| 39 | 39 | } | 
| 40 | 40 | } | 
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | $errorString = 'The following text elements where not found: <ul>'; | 
| 44 | 44 | |
| 45 | 45 |              foreach ($errors as $error) { | 
| 46 | - $errorString .= '<li>' . $error . '</li>'; | |
| 46 | + $errorString .= '<li>'.$error.'</li>'; | |
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 | $errorString .= '</ul>'; | 
| @@ -11,10 +11,10 @@ | ||
| 11 | 11 |          preg_match_all('^\${(.*)}^', $fileContent, $matches); | 
| 12 | 12 |          foreach ($matches[1] as $varName) { | 
| 13 | 13 |              if (!getenv($varName)) { | 
| 14 | -                throw new \RuntimeException('The mandatory env variable (' . $varName . ') from the config file was not set.'); | |
| 14 | +                throw new \RuntimeException('The mandatory env variable ('.$varName.') from the config file was not set.'); | |
| 15 | 15 | } | 
| 16 | 16 | |
| 17 | -            $fileContent = str_replace('${' . $varName . '}', getenv($varName), $fileContent); | |
| 17 | +            $fileContent = str_replace('${'.$varName.'}', getenv($varName), $fileContent); | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | 20 | return Yaml::parse($fileContent); | 
| @@ -30,18 +30,18 @@ | ||
| 30 | 30 | return; | 
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | - $filename = $this->tmpDir . DIRECTORY_SEPARATOR . md5($response->getBody()) . '.js'; | |
| 33 | + $filename = $this->tmpDir.DIRECTORY_SEPARATOR.md5($response->getBody()).'.js'; | |
| 34 | 34 | file_put_contents($filename, $response->getBody()); | 
| 35 | - $conf = __DIR__ . DIRECTORY_SEPARATOR . 'jsHint.conf'; | |
| 35 | + $conf = __DIR__.DIRECTORY_SEPARATOR.'jsHint.conf'; | |
| 36 | 36 | |
| 37 | - $command = $this->jsHintExecutable . ' --config ' . $conf . ' --verbose ' . $filename . ' | grep -E E[0-9]+.$'; | |
| 37 | + $command = $this->jsHintExecutable.' --config '.$conf.' --verbose '.$filename.' | grep -E E[0-9]+.$'; | |
| 38 | 38 | $validationResult = shell_exec($command); | 
| 39 | 39 | |
| 40 | 40 | unlink($filename); | 
| 41 | 41 | |
| 42 | 42 |          if (!is_null($validationResult)) { | 
| 43 | - $errorMsg = str_replace($filename . ':', '', $validationResult); | |
| 44 | -            throw new ValidationFailedException('JavaScript error found: ' . $errorMsg); | |
| 43 | + $errorMsg = str_replace($filename.':', '', $validationResult); | |
| 44 | +            throw new ValidationFailedException('JavaScript error found: '.$errorMsg); | |
| 45 | 45 | } | 
| 46 | 46 | } | 
| 47 | 47 | } | 
| @@ -21,7 +21,7 @@ | ||
| 21 | 21 | public function validate(Response $response) | 
| 22 | 22 |      { | 
| 23 | 23 |          if ($response->getStatus() > $this->maxStatusCode) { | 
| 24 | -            throw new ValidationFailedException('Status code ' . $response->getStatus() . ' found.'); | |
| 24 | +            throw new ValidationFailedException('Status code '.$response->getStatus().' found.'); | |
| 25 | 25 | } | 
| 26 | 26 | } | 
| 27 | 27 | } | 
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | public function validate(Response $response) | 
| 26 | 26 |      { | 
| 27 | 27 |          if ($response->getStatus() !== $this->expectedStatus) { | 
| 28 | -            throw new ValidationFailedException('Status code ' . $response->getStatus() . ' found, ' . $this->expectedStatus . ' expected.'); | |
| 28 | +            throw new ValidationFailedException('Status code '.$response->getStatus().' found, '.$this->expectedStatus.' expected.'); | |
| 29 | 29 | } | 
| 30 | 30 | } | 
| 31 | 31 | } | 
| @@ -26,6 +26,6 @@ | ||
| 26 | 26 | protected function doValidation(Response $response) | 
| 27 | 27 |      { | 
| 28 | 28 | $size = strlen($response->getBody()) / 1000; | 
| 29 | -        $this->assert($size <= $this->maxSize, 'The size of this html file is too big (' . $size . ' KB)'); | |
| 29 | +        $this->assert($size <= $this->maxSize, 'The size of this html file is too big ('.$size.' KB)'); | |
| 30 | 30 | } | 
| 31 | 31 | } |