Completed
Push — master ( 6bb926...1e6b5f )
by Nils
02:11
created
src/Rules/Seo/RobotsDisallowAllRule.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,6 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Extensions/SmokeReporter/Reporter/XUnitReporter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
src/Rules/Http/Header/SuccessStatusRule.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     public function validate(ResponseInterface $response)
23 23
     {
24 24
         if ($response->getStatusCode() > $this->maxStatusCode) {
25
-            throw new ValidationFailedException('Status code ' . $response->getStatusCode() . ' found.');
25
+            throw new ValidationFailedException('Status code '.$response->getStatusCode().' found.');
26 26
         }
27 27
     }
28 28
 }
Please login to merge, or discard this patch.
src/Rules/Http/Header/HttpStatusRule.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
     public function validate(ResponseInterface $response)
27 27
     {
28 28
         if ($response->getStatusCode() !== $this->expectedStatus) {
29
-            throw new ValidationFailedException('Status code ' . $response->getStatusCode() . ' found, ' . $this->expectedStatus . ' expected.');
29
+            throw new ValidationFailedException('Status code '.$response->getStatusCode().' found, '.$this->expectedStatus.' expected.');
30 30
         }
31 31
     }
32 32
 }
Please login to merge, or discard this patch.
src/Rules/Html/CountRule.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 
27 27
     protected function doValidation(ResponseInterface $response)
28 28
     {
29
-        $document = new Document((string)$response->getBody());
29
+        $document = new Document((string) $response->getBody());
30 30
         $files = $this->getFilesToCount($document, $response);
31 31
 
32 32
         $this->assert(count($files) <= $this->maxCount, sprintf($this->errorMessage, count($files)));
Please login to merge, or discard this patch.
src/Rules/Xml/Sitemap/ValidRule.php 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -27,6 +27,9 @@  discard block
 block discarded – undo
27 27
         $this->strictMode = $strictMode;
28 28
     }
29 29
 
30
+    /**
31
+     * @param boolean $isIndex
32
+     */
30 33
     private function getSchema($isIndex)
31 34
     {
32 35
         if ($isIndex) {
@@ -40,6 +43,10 @@  discard block
 block discarded – undo
40 43
         }
41 44
     }
42 45
 
46
+    /**
47
+     * @param string $body
48
+     * @param string $filename
49
+     */
43 50
     private function validateBody($body, $filename, $isIndex = true)
44 51
     {
45 52
         $dom = new \DOMDocument();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
     private function getSchema($isIndex)
31 31
     {
32 32
         if ($isIndex) {
33
-            return __DIR__ . '/' . self::INDEX;
33
+            return __DIR__.'/'.self::INDEX;
34 34
         }
35 35
 
36 36
         if ($this->strictMode) {
37
-            return __DIR__ . '/' . self::SCHEMA;
37
+            return __DIR__.'/'.self::SCHEMA;
38 38
         } else {
39
-            return __DIR__ . '/' . self::NON_STRICT_SCHEMA;
39
+            return __DIR__.'/'.self::NON_STRICT_SCHEMA;
40 40
         }
41 41
     }
42 42
 
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
         if (!$valid) {
51 51
             $lastError = libxml_get_last_error();
52 52
             throw new ValidationFailedException(
53
-                'The given sitemap file (' . $filename . ') did not validate against the sitemap schema (last error: ' . str_replace("\n", '', $lastError->message) . ').');
53
+                'The given sitemap file ('.$filename.') did not validate against the sitemap schema (last error: '.str_replace("\n", '', $lastError->message).').');
54 54
         }
55 55
     }
56 56
 
57 57
     protected function doValidation(ResponseInterface $response)
58 58
     {
59
-        $body = (string)$response->getBody();
59
+        $body = (string) $response->getBody();
60 60
 
61 61
         // sitemapindex or urlset
62 62
         if (preg_match('/<sitemapindex/', $body)) {
63
-            $this->validateBody($body, (string)$response->getUri());
63
+            $this->validateBody($body, (string) $response->getUri());
64 64
         } elseif (preg_match('/<urlset/', $body)) {
65
-            $this->validateBody($body, (string)$response->getUri(), false);
65
+            $this->validateBody($body, (string) $response->getUri(), false);
66 66
         }
67 67
     }
68 68
 }
Please login to merge, or discard this patch.
src/Rules/Xml/DuplicateIdRule.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
             return;
19 19
         }
20 20
 
21
-        $crawler = new Crawler((string)$response->getBody());
21
+        $crawler = new Crawler((string) $response->getBody());
22 22
 
23 23
         $idList = $crawler->filterXPath('//*[@id!=""]');
24 24
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         if (count($duplicatedIds) > 0) {
38 38
             unset($duplicatedIds['']);
39
-            throw new ValidationFailedException('Duplicate ids found (' . implode(', ', array_keys($duplicatedIds)) . ')');
39
+            throw new ValidationFailedException('Duplicate ids found ('.implode(', ', array_keys($duplicatedIds)).')');
40 40
         }
41 41
     }
42 42
 }
Please login to merge, or discard this patch.
src/Rules/Json/ValidRule.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@
 block discarded – undo
26 26
 
27 27
     public function doValidation(ResponseInterface $response)
28 28
     {
29
-        $result = json_decode((string)$response->getBody());
29
+        $result = json_decode((string) $response->getBody());
30 30
         if ($result === null) {
31
-            throw new ValidationFailedException("The given JSON data can not be validated (last error: '" . $this->json_errors[json_last_error()] . "').");
31
+            throw new ValidationFailedException("The given JSON data can not be validated (last error: '".$this->json_errors[json_last_error()]."').");
32 32
         }
33 33
     }
34 34
 }
Please login to merge, or discard this patch.
src/Rules/Html/ForeignDomainImageRule.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     protected function doValidation(ResponseInterface $response)
28 28
     {
29
-        $document = new Document((string)$response->getBody());
29
+        $document = new Document((string) $response->getBody());
30 30
         $images = $document->getImages($response->getUri());
31 31
 
32 32
         $foreignImages = array();
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
         foreach ($images as $image) {
38 38
             /* @var $image Uri */
39 39
             if ($currentUri->getHost($this->depth) !== $image->getHost($this->depth)) {
40
-                $foreignImages[] = (string)$image;
40
+                $foreignImages[] = (string) $image;
41 41
             }
42 42
         }
43 43
 
44
-        $this->assert(count($foreignImages) === 0, 'Images from a foreign domain where found (' . implode(', ', $foreignImages) . ')');
44
+        $this->assert(count($foreignImages) === 0, 'Images from a foreign domain where found ('.implode(', ', $foreignImages).')');
45 45
     }
46 46
 }
Please login to merge, or discard this patch.