Completed
Push — master ( 128ddb...c5783a )
by
unknown
14s queued 10s
created
src/Checks/CacheHeadersCheck.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         $goodTypes = [ValidationResult::TYPE_GOOD, ValidationResult::TYPE_INFO];
124 124
         $good = array_filter(
125 125
             $this->result->getMessages(),
126
-            function ($val, $key) use ($goodTypes) {
126
+            function($val, $key) use ($goodTypes) {
127 127
                 if (in_array($val['messageType'], $goodTypes)) {
128 128
                     return true;
129 129
                 }
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
             ARRAY_FILTER_USE_BOTH
133 133
         );
134 134
         if (!empty($good)) {
135
-            $ret .= "GOOD: " . implode('; ', array_column($good, 'message')) . " ";
135
+            $ret .= "GOOD: ".implode('; ', array_column($good, 'message'))." ";
136 136
         }
137 137
 
138 138
         // Filter bad messages
139 139
         $badTypes = [ValidationResult::TYPE_ERROR, ValidationResult::TYPE_WARNING];
140 140
         $bad = array_filter(
141 141
             $this->result->getMessages(),
142
-            function ($val, $key) use ($badTypes) {
142
+            function($val, $key) use ($badTypes) {
143 143
                 if (in_array($val['messageType'], $badTypes)) {
144 144
                     return true;
145 145
                 }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             ARRAY_FILTER_USE_BOTH
149 149
         );
150 150
         if (!empty($bad)) {
151
-            $ret .= "BAD: " . implode('; ', array_column($bad, 'message'));
151
+            $ret .= "BAD: ".implode('; ', array_column($bad, 'message'));
152 152
         }
153 153
         return $ret;
154 154
     }
Please login to merge, or discard this patch.
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -20,188 +20,188 @@
 block discarded – undo
20 20
  */
21 21
 class CacheHeadersCheck implements EnvironmentCheck
22 22
 {
23
-    use Fetcher;
24
-
25
-    /**
26
-     * Settings that must be included in the Cache-Control header
27
-     *
28
-     * @var array
29
-     */
30
-    protected $mustInclude = [];
31
-
32
-    /**
33
-     * Settings that must be excluded in the Cache-Control header
34
-     *
35
-     * @var array
36
-     */
37
-    protected $mustExclude = [];
38
-
39
-    /**
40
-     * Result to keep track of status and messages for all checks, reuses
41
-     * ValidationResult for convenience.
42
-     *
43
-     * @var ValidationResult
44
-     */
45
-    protected $result;
46
-
47
-    /**
48
-     * Set up with URL, arrays of header settings to check.
49
-     *
50
-     * @param string $url
51
-     * @param array $mustInclude Settings that must be included in Cache-Control
52
-     * @param array $mustExclude Settings that must be excluded in Cache-Control
53
-     */
54
-    public function __construct($url = '', $mustInclude = [], $mustExclude = [])
55
-    {
56
-        $this->setURL($url);
57
-        $this->mustInclude = $mustInclude;
58
-        $this->mustExclude = $mustExclude;
59
-    }
60
-
61
-    /**
62
-     * Check that correct caching headers are present.
63
-     *
64
-     * @return void
65
-     */
66
-    public function check()
67
-    {
68
-        // Using a validation result to capture messages
69
-        $this->result = new ValidationResult();
70
-
71
-        $response = $this->client->get($this->getURL());
72
-        $fullURL = $this->getURL();
73
-        if ($response === null) {
74
-            return [
75
-                EnvironmentCheck::ERROR,
76
-                "Cache headers check request failed for $fullURL",
77
-            ];
78
-        }
79
-
80
-        //Check that Etag exists
81
-        $this->checkEtag($response);
82
-
83
-        // Check Cache-Control settings
84
-        $this->checkCacheControl($response);
85
-
86
-        if ($this->result->isValid()) {
87
-            return [
88
-                EnvironmentCheck::OK,
89
-                $this->getMessage(),
90
-            ];
91
-        } else {
92
-            // @todo Ability to return a warning
93
-            return [
94
-                EnvironmentCheck::ERROR,
95
-                $this->getMessage(),
96
-            ];
97
-        }
98
-    }
99
-
100
-    /**
101
-     * Collate messages from ValidationResult so that it is clear which parts
102
-     * of the check passed and which failed.
103
-     *
104
-     * @return string
105
-     */
106
-    private function getMessage()
107
-    {
108
-        $ret = '';
109
-        // Filter good messages
110
-        $goodTypes = [ValidationResult::TYPE_GOOD, ValidationResult::TYPE_INFO];
111
-        $good = array_filter(
112
-            $this->result->getMessages(),
113
-            function ($val, $key) use ($goodTypes) {
114
-                if (in_array($val['messageType'], $goodTypes)) {
115
-                    return true;
116
-                }
117
-                return false;
118
-            },
119
-            ARRAY_FILTER_USE_BOTH
120
-        );
121
-        if (!empty($good)) {
122
-            $ret .= "GOOD: " . implode('; ', array_column($good, 'message')) . " ";
123
-        }
124
-
125
-        // Filter bad messages
126
-        $badTypes = [ValidationResult::TYPE_ERROR, ValidationResult::TYPE_WARNING];
127
-        $bad = array_filter(
128
-            $this->result->getMessages(),
129
-            function ($val, $key) use ($badTypes) {
130
-                if (in_array($val['messageType'], $badTypes)) {
131
-                    return true;
132
-                }
133
-                return false;
134
-            },
135
-            ARRAY_FILTER_USE_BOTH
136
-        );
137
-        if (!empty($bad)) {
138
-            $ret .= "BAD: " . implode('; ', array_column($bad, 'message'));
139
-        }
140
-        return $ret;
141
-    }
142
-
143
-    /**
144
-     * Check that ETag header exists
145
-     *
146
-     * @param ResponseInterface $response
147
-     * @return void
148
-     */
149
-    private function checkEtag(ResponseInterface $response)
150
-    {
151
-        $eTag = $response->getHeaderLine('ETag');
152
-        $fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);
153
-
154
-        if ($eTag) {
155
-            $this->result->addMessage(
156
-                "$fullURL includes an Etag header in response",
157
-                ValidationResult::TYPE_GOOD
158
-            );
159
-            return;
160
-        }
161
-        $this->result->addError(
162
-            "$fullURL is missing an Etag header",
163
-            ValidationResult::TYPE_WARNING
164
-        );
165
-    }
166
-
167
-    /**
168
-     * Check that the correct header settings are either included or excluded.
169
-     *
170
-     * @param ResponseInterface $response
171
-     * @return void
172
-     */
173
-    private function checkCacheControl(ResponseInterface $response)
174
-    {
175
-        $cacheControl = $response->getHeaderLine('Cache-Control');
176
-        $vals = array_map('trim', explode(',', $cacheControl));
177
-        $fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);
178
-
179
-        // All entries from must contain should be present
180
-        if ($this->mustInclude == array_intersect($this->mustInclude, $vals)) {
181
-            $matched = implode(",", $this->mustInclude);
182
-            $this->result->addMessage(
183
-                "$fullURL includes all settings: {$matched}",
184
-                ValidationResult::TYPE_GOOD
185
-            );
186
-        } else {
187
-            $missing = implode(",", array_diff($this->mustInclude, $vals));
188
-            $this->result->addError(
189
-                "$fullURL is excluding some settings: {$missing}"
190
-            );
191
-        }
192
-
193
-        // All entries from must exclude should not be present
194
-        if (empty(array_intersect($this->mustExclude, $vals))) {
195
-            $missing = implode(",", $this->mustExclude);
196
-            $this->result->addMessage(
197
-                "$fullURL excludes all settings: {$missing}",
198
-                ValidationResult::TYPE_GOOD
199
-            );
200
-        } else {
201
-            $matched = implode(",", array_intersect($this->mustExclude, $vals));
202
-            $this->result->addError(
203
-                "$fullURL is including some settings: {$matched}"
204
-            );
205
-        }
206
-    }
23
+	use Fetcher;
24
+
25
+	/**
26
+	 * Settings that must be included in the Cache-Control header
27
+	 *
28
+	 * @var array
29
+	 */
30
+	protected $mustInclude = [];
31
+
32
+	/**
33
+	 * Settings that must be excluded in the Cache-Control header
34
+	 *
35
+	 * @var array
36
+	 */
37
+	protected $mustExclude = [];
38
+
39
+	/**
40
+	 * Result to keep track of status and messages for all checks, reuses
41
+	 * ValidationResult for convenience.
42
+	 *
43
+	 * @var ValidationResult
44
+	 */
45
+	protected $result;
46
+
47
+	/**
48
+	 * Set up with URL, arrays of header settings to check.
49
+	 *
50
+	 * @param string $url
51
+	 * @param array $mustInclude Settings that must be included in Cache-Control
52
+	 * @param array $mustExclude Settings that must be excluded in Cache-Control
53
+	 */
54
+	public function __construct($url = '', $mustInclude = [], $mustExclude = [])
55
+	{
56
+		$this->setURL($url);
57
+		$this->mustInclude = $mustInclude;
58
+		$this->mustExclude = $mustExclude;
59
+	}
60
+
61
+	/**
62
+	 * Check that correct caching headers are present.
63
+	 *
64
+	 * @return void
65
+	 */
66
+	public function check()
67
+	{
68
+		// Using a validation result to capture messages
69
+		$this->result = new ValidationResult();
70
+
71
+		$response = $this->client->get($this->getURL());
72
+		$fullURL = $this->getURL();
73
+		if ($response === null) {
74
+			return [
75
+				EnvironmentCheck::ERROR,
76
+				"Cache headers check request failed for $fullURL",
77
+			];
78
+		}
79
+
80
+		//Check that Etag exists
81
+		$this->checkEtag($response);
82
+
83
+		// Check Cache-Control settings
84
+		$this->checkCacheControl($response);
85
+
86
+		if ($this->result->isValid()) {
87
+			return [
88
+				EnvironmentCheck::OK,
89
+				$this->getMessage(),
90
+			];
91
+		} else {
92
+			// @todo Ability to return a warning
93
+			return [
94
+				EnvironmentCheck::ERROR,
95
+				$this->getMessage(),
96
+			];
97
+		}
98
+	}
99
+
100
+	/**
101
+	 * Collate messages from ValidationResult so that it is clear which parts
102
+	 * of the check passed and which failed.
103
+	 *
104
+	 * @return string
105
+	 */
106
+	private function getMessage()
107
+	{
108
+		$ret = '';
109
+		// Filter good messages
110
+		$goodTypes = [ValidationResult::TYPE_GOOD, ValidationResult::TYPE_INFO];
111
+		$good = array_filter(
112
+			$this->result->getMessages(),
113
+			function ($val, $key) use ($goodTypes) {
114
+				if (in_array($val['messageType'], $goodTypes)) {
115
+					return true;
116
+				}
117
+				return false;
118
+			},
119
+			ARRAY_FILTER_USE_BOTH
120
+		);
121
+		if (!empty($good)) {
122
+			$ret .= "GOOD: " . implode('; ', array_column($good, 'message')) . " ";
123
+		}
124
+
125
+		// Filter bad messages
126
+		$badTypes = [ValidationResult::TYPE_ERROR, ValidationResult::TYPE_WARNING];
127
+		$bad = array_filter(
128
+			$this->result->getMessages(),
129
+			function ($val, $key) use ($badTypes) {
130
+				if (in_array($val['messageType'], $badTypes)) {
131
+					return true;
132
+				}
133
+				return false;
134
+			},
135
+			ARRAY_FILTER_USE_BOTH
136
+		);
137
+		if (!empty($bad)) {
138
+			$ret .= "BAD: " . implode('; ', array_column($bad, 'message'));
139
+		}
140
+		return $ret;
141
+	}
142
+
143
+	/**
144
+	 * Check that ETag header exists
145
+	 *
146
+	 * @param ResponseInterface $response
147
+	 * @return void
148
+	 */
149
+	private function checkEtag(ResponseInterface $response)
150
+	{
151
+		$eTag = $response->getHeaderLine('ETag');
152
+		$fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);
153
+
154
+		if ($eTag) {
155
+			$this->result->addMessage(
156
+				"$fullURL includes an Etag header in response",
157
+				ValidationResult::TYPE_GOOD
158
+			);
159
+			return;
160
+		}
161
+		$this->result->addError(
162
+			"$fullURL is missing an Etag header",
163
+			ValidationResult::TYPE_WARNING
164
+		);
165
+	}
166
+
167
+	/**
168
+	 * Check that the correct header settings are either included or excluded.
169
+	 *
170
+	 * @param ResponseInterface $response
171
+	 * @return void
172
+	 */
173
+	private function checkCacheControl(ResponseInterface $response)
174
+	{
175
+		$cacheControl = $response->getHeaderLine('Cache-Control');
176
+		$vals = array_map('trim', explode(',', $cacheControl));
177
+		$fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);
178
+
179
+		// All entries from must contain should be present
180
+		if ($this->mustInclude == array_intersect($this->mustInclude, $vals)) {
181
+			$matched = implode(",", $this->mustInclude);
182
+			$this->result->addMessage(
183
+				"$fullURL includes all settings: {$matched}",
184
+				ValidationResult::TYPE_GOOD
185
+			);
186
+		} else {
187
+			$missing = implode(",", array_diff($this->mustInclude, $vals));
188
+			$this->result->addError(
189
+				"$fullURL is excluding some settings: {$missing}"
190
+			);
191
+		}
192
+
193
+		// All entries from must exclude should not be present
194
+		if (empty(array_intersect($this->mustExclude, $vals))) {
195
+			$missing = implode(",", $this->mustExclude);
196
+			$this->result->addMessage(
197
+				"$fullURL excludes all settings: {$missing}",
198
+				ValidationResult::TYPE_GOOD
199
+			);
200
+		} else {
201
+			$matched = implode(",", array_intersect($this->mustExclude, $vals));
202
+			$this->result->addError(
203
+				"$fullURL is including some settings: {$matched}"
204
+			);
205
+		}
206
+	}
207 207
 }
Please login to merge, or discard this patch.
src/Checks/SessionCheck.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
         if ($cookie) {
57 57
             return [
58 58
                 EnvironmentCheck::ERROR,
59
-                "Sessions are being set for {$fullURL} : Set-Cookie => " . $cookie,
59
+                "Sessions are being set for {$fullURL} : Set-Cookie => ".$cookie,
60 60
             ];
61 61
         }
62 62
         return [
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -14,58 +14,58 @@
 block discarded – undo
14 14
  */
15 15
 class SessionCheck implements EnvironmentCheck
16 16
 {
17
-    use Fetcher;
17
+	use Fetcher;
18 18
 
19
-    /**
20
-     * Set up check with URL
21
-     *
22
-     * @param string $url The route, excluding the domain
23
-     * @inheritdoc
24
-     */
25
-    public function __construct($url = '')
26
-    {
27
-        $this->setURL($url);
28
-    }
19
+	/**
20
+	 * Set up check with URL
21
+	 *
22
+	 * @param string $url The route, excluding the domain
23
+	 * @inheritdoc
24
+	 */
25
+	public function __construct($url = '')
26
+	{
27
+		$this->setURL($url);
28
+	}
29 29
 
30
-    /**
31
-     * Check that the response for URL does not create a session
32
-     *
33
-     * @return array
34
-     */
35
-    public function check()
36
-    {
37
-        $response = $this->client->get($this->getURL());
38
-        $cookie = $this->getCookie($response);
39
-        $fullURL = $this->getURL();
30
+	/**
31
+	 * Check that the response for URL does not create a session
32
+	 *
33
+	 * @return array
34
+	 */
35
+	public function check()
36
+	{
37
+		$response = $this->client->get($this->getURL());
38
+		$cookie = $this->getCookie($response);
39
+		$fullURL = $this->getURL();
40 40
 
41
-        if ($cookie) {
42
-            return [
43
-                EnvironmentCheck::ERROR,
44
-                "Sessions are being set for {$fullURL} : Set-Cookie => " . $cookie,
45
-            ];
46
-        }
47
-        return [
48
-            EnvironmentCheck::OK,
49
-            "Sessions are not being created for {$fullURL} 
Please login to merge, or discard this patch.
tests/Checks/CacheHeadersCheckTest.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -15,87 +15,87 @@
 block discarded – undo
15 15
  */
16 16
 class CacheHeadersCheckTest extends SapphireTest
17 17
 {
18
-    /**
19
-     * Test that directives that must be included, are.
20
-     *
21
-     * @return void
22
-     */
23
-    public function testMustInclude()
24
-    {
25
-        // Create a mock and queue responses
26
-        $mock = new MockHandler([
27
-            new Response(200, ['Cache-Control' => 'must-revalidate', 'ETag' => '123']),
28
-            new Response(200, ['Cache-Control' =>'no-cache', 'ETag' => '123']),
29
-            new Response(200, ['ETag' => '123']),
30
-            new Response(200, ['Cache-Control' => 'must-revalidate, private', 'ETag' => '123']),
31
-        ]);
18
+	/**
19
+	 * Test that directives that must be included, are.
20
+	 *
21
+	 * @return void
22
+	 */
23
+	public function testMustInclude()
24
+	{
25
+		// Create a mock and queue responses
26
+		$mock = new MockHandler([
27
+			new Response(200, ['Cache-Control' => 'must-revalidate', 'ETag' => '123']),
28
+			new Response(200, ['Cache-Control' =>'no-cache', 'ETag' => '123']),
29
+			new Response(200, ['ETag' => '123']),
30
+			new Response(200, ['Cache-Control' => 'must-revalidate, private', 'ETag' => '123']),
31
+		]);
32 32
 
33
-        $handler = HandlerStack::create($mock);
34
-        $client = new Client(['handler' => $handler]);
33
+		$handler = HandlerStack::create($mock);
34
+		$client = new Client(['handler' => $handler]);
35 35
 
36
-        $cacheHeadersCheck = new CacheHeadersCheck('/', ['must-revalidate']);
37
-        $cacheHeadersCheck->client = $client;
36
+		$cacheHeadersCheck = new CacheHeadersCheck('/', ['must-revalidate']);
37
+		$cacheHeadersCheck->client = $client;
38 38
 
39
-        // Run checks for each response above
40
-        $this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
41
-        $this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
42
-        $this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
43
-        $this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
44
-    }
39
+		// Run checks for each response above
40
+		$this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
41
+		$this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
42
+		$this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
43
+		$this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
44
+	}
45 45
 
46
-    /**
47
-     * Test that directives that must be excluded, are.
48
-     *
49
-     * @return void
50
-     */
51
-    public function testMustExclude()
52
-    {
53
-        // Create a mock and queue responses
54
-        $mock = new MockHandler([
55
-            new Response(200, ['Cache-Control' => 'must-revalidate', 'ETag' => '123']),
56
-            new Response(200, ['Cache-Control' =>'no-cache', 'ETag' => '123']),
57
-            new Response(200, ['ETag' => '123']),
58
-            new Response(200, ['Cache-Control' =>'private, no-store', ' ETag' => '123']),
59
-        ]);
46
+	/**
47
+	 * Test that directives that must be excluded, are.
48
+	 *
49
+	 * @return void
50
+	 */
51
+	public function testMustExclude()
52
+	{
53
+		// Create a mock and queue responses
54
+		$mock = new MockHandler([
55
+			new Response(200, ['Cache-Control' => 'must-revalidate', 'ETag' => '123']),
56
+			new Response(200, ['Cache-Control' =>'no-cache', 'ETag' => '123']),
57
+			new Response(200, ['ETag' => '123']),
58
+			new Response(200, ['Cache-Control' =>'private, no-store', ' ETag' => '123']),
59
+		]);
60 60
 
61
-        $handler = HandlerStack::create($mock);
62
-        $client = new Client(['handler' => $handler]);
61
+		$handler = HandlerStack::create($mock);
62
+		$client = new Client(['handler' => $handler]);
63 63
 
64
-        $cacheHeadersCheck = new CacheHeadersCheck('/', [], ["no-store", "no-cache", "private"]);
65
-        $cacheHeadersCheck->client = $client;
64
+		$cacheHeadersCheck = new CacheHeadersCheck('/', [], ["no-store", "no-cache", "private"]);
65
+		$cacheHeadersCheck->client = $client;
66 66
 
67
-        // Run checks for each response above
68
-        $this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
69
-        $this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
70
-        $this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
71
-        $this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
72
-    }
67
+		// Run checks for each response above
68
+		$this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
69
+		$this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
70
+		$this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
71
+		$this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
72
+	}
73 73
 
74
-    /**
75
-     * Test that Etag header must exist in response.
76
-     *
77
-     * @return void
78
-     */
79
-    public function testEtag()
80
-    {
81
-        // Create a mock and queue responses
82
-        $mock = new MockHandler([
83
-            new Response(200, ['Cache-Control' => 'must-revalidate', 'ETag' => '123']),
84
-            new Response(200, ['Cache-Control' =>'no-cache']),
85
-            new Response(200, ['ETag' => '123']),
86
-            new Response(200, []),
87
-        ]);
74
+	/**
75
+	 * Test that Etag header must exist in response.
76
+	 *
77
+	 * @return void
78
+	 */
79
+	public function testEtag()
80
+	{
81
+		// Create a mock and queue responses
82
+		$mock = new MockHandler([
83
+			new Response(200, ['Cache-Control' => 'must-revalidate', 'ETag' => '123']),
84
+			new Response(200, ['Cache-Control' =>'no-cache']),
85
+			new Response(200, ['ETag' => '123']),
86
+			new Response(200, []),
87
+		]);
88 88
 
89
-        $handler = HandlerStack::create($mock);
90
-        $client = new Client(['handler' => $handler]);
89
+		$handler = HandlerStack::create($mock);
90
+		$client = new Client(['handler' => $handler]);
91 91
 
92
-        $cacheHeadersCheck = new CacheHeadersCheck('/');
93
-        $cacheHeadersCheck->client = $client;
92
+		$cacheHeadersCheck = new CacheHeadersCheck('/');
93
+		$cacheHeadersCheck->client = $client;
94 94
 
95
-        // Run checks for each response above
96
-        $this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
97
-        $this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
98
-        $this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
99
-        $this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
100
-    }
95
+		// Run checks for each response above
96
+		$this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
97
+		$this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
98
+		$this->assertContains(EnvironmentCheck::OK, $cacheHeadersCheck->check());
99
+		$this->assertContains(EnvironmentCheck::ERROR, $cacheHeadersCheck->check());
100
+	}
101 101
 }
Please login to merge, or discard this patch.
tests/Checks/SessionCheckTest.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,62 +15,62 @@
 block discarded – undo
15 15
  */
16 16
 class SessionCheckTest extends SapphireTest
17 17
 {
18
-    /**
19
-     * @var SilverStripe\EnvironmentCheck\Checks\SessionCheck
20
-     */
21
-    public $sessionCheck = null;
18
+	/**
19
+	 * @var SilverStripe\EnvironmentCheck\Checks\SessionCheck
20
+	 */
21
+	public $sessionCheck = null;
22 22
 
23
-    /**
24
-     * Create a session check for use by tests.
25
-     *
26
-     * @return void
27
-     */
28
-    protected function setUp()
29
-    {
30
-        parent::setUp();
31
-        $this->sessionCheck = new SessionCheck('/');
32
-    }
23
+	/**
24
+	 * Create a session check for use by tests.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	protected function setUp()
29
+	{
30
+		parent::setUp();
31
+		$this->sessionCheck = new SessionCheck('/');
32
+	}
33 33
 
34
-    /**
35
-     * Env check reports error when session cookies are being set.
36
-     *
37
-     * @return void
38
-     */
39
-    public function testSessionSet()
40
-    {
41
-        // Create a mock and queue two responses.
42
-        $mock = new MockHandler([
43
-            new Response(200, ['Set-Cookie' => 'PHPSESSID:foo']),
44
-            new Response(200, ['Set-Cookie' => 'SECSESSID:bar'])
45
-        ]);
34
+	/**
35
+	 * Env check reports error when session cookies are being set.
36
+	 *
37
+	 * @return void
38
+	 */
39
+	public function testSessionSet()
40
+	{
41
+		// Create a mock and queue two responses.
42
+		$mock = new MockHandler([
43
+			new Response(200, ['Set-Cookie' => 'PHPSESSID:foo']),
44
+			new Response(200, ['Set-Cookie' => 'SECSESSID:bar'])
45
+		]);
46 46
 
47
-        $handler = HandlerStack::create($mock);
48
-        $client = new Client(['handler' => $handler]);
49
-        $this->sessionCheck->client = $client;
47
+		$handler = HandlerStack::create($mock);
48
+		$client = new Client(['handler' => $handler]);
49
+		$this->sessionCheck->client = $client;
50 50
 
51
-        // Check for PHPSESSID
52
-        $this->assertContains(EnvironmentCheck::ERROR, $this->sessionCheck->check());
51
+		// Check for PHPSESSID
52
+		$this->assertContains(EnvironmentCheck::ERROR, $this->sessionCheck->check());
53 53
 
54
-        // Check for SECSESSID
55
-        $this->assertContains(EnvironmentCheck::ERROR, $this->sessionCheck->check());
56
-    }
54
+		// Check for SECSESSID
55
+		$this->assertContains(EnvironmentCheck::ERROR, $this->sessionCheck->check());
56
+	}
57 57
 
58
-    /**
59
-     * Env check responds OK when no session cookies are set in response.
60
-     *
61
-     * @return void
62
-     */
63
-    public function testSessionNotSet()
64
-    {
65
-        // Create a mock and queue two responses.
66
-        $mock = new MockHandler([
67
-            new Response(200)
68
-        ]);
58
+	/**
59
+	 * Env check responds OK when no session cookies are set in response.
60
+	 *
61
+	 * @return void
62
+	 */
63
+	public function testSessionNotSet()
64
+	{
65
+		// Create a mock and queue two responses.
66
+		$mock = new MockHandler([
67
+			new Response(200)
68
+		]);
69 69
 
70
-        $handler = HandlerStack::create($mock);
71
-        $client = new Client(['handler' => $handler]);
72
-        $this->sessionCheck->client = $client;
70
+		$handler = HandlerStack::create($mock);
71
+		$client = new Client(['handler' => $handler]);
72
+		$this->sessionCheck->client = $client;
73 73
 
74
-        $this->assertContains(EnvironmentCheck::OK, $this->sessionCheck->check());
75
-    }
74
+		$this->assertContains(EnvironmentCheck::OK, $this->sessionCheck->check());
75
+	}
76 76
 }
Please login to merge, or discard this patch.
src/Services/ClientFactory.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -14,36 +14,36 @@
 block discarded – undo
14 14
  */
15 15
 class ClientFactory implements Factory
16 16
 {
17
-    use Configurable;
17
+	use Configurable;
18 18
 
19
-    /**
20
-     * Default config for Guzzle client.
21
-     *
22
-     * @var array
23
-     */
24
-    private static $default_config = [];
19
+	/**
20
+	 * Default config for Guzzle client.
21
+	 *
22
+	 * @var array
23
+	 */
24
+	private static $default_config = [];
25 25
 
26
-    /**
27
-     * Wrapper to create a Guzzle client.
28
-     *
29
-     * {@inheritdoc}
30
-     */
31
-    public function create($service, array $params = [])
32
-    {
33
-        return new GuzzleClient($this->getConfig($params));
34
-    }
26
+	/**
27
+	 * Wrapper to create a Guzzle client.
28
+	 *
29
+	 * {@inheritdoc}
30
+	 */
31
+	public function create($service, array $params = [])
32
+	{
33
+		return new GuzzleClient($this->getConfig($params));
34
+	}
35 35
 
36
-    /**
37
-     * Merge config provided from yaml with default config
38
-     *
39
-     * @param array $overrides
40
-     * @return array
41
-     */
42
-    public function getConfig(array $overrides)
43
-    {
44
-        return array_merge(
45
-            $this->config()->get('default_config'),
46
-            $overrides
47
-        );
48
-    }
36
+	/**
37
+	 * Merge config provided from yaml with default config
38
+	 *
39
+	 * @param array $overrides
40
+	 * @return array
41
+	 */
42
+	public function getConfig(array $overrides)
43
+	{
44
+		return array_merge(
45
+			$this->config()->get('default_config'),
46
+			$overrides
47
+		);
48
+	}
49 49
 }
Please login to merge, or discard this patch.
src/Traits/Fetcher.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,41 +11,41 @@
 block discarded – undo
11 11
  */
12 12
 trait Fetcher
13 13
 {
14
-    /**
15
-     * Client for making requests, set vi Injector.
16
-     *
17
-     * @see SilverStripe\EnvironmentCheck\Services
18
-     *
19
-     * @var GuzzleHttp\Client
20
-     */
21
-    public $client = null;
14
+	/**
15
+	 * Client for making requests, set vi Injector.
16
+	 *
17
+	 * @see SilverStripe\EnvironmentCheck\Services
18
+	 *
19
+	 * @var GuzzleHttp\Client
20
+	 */
21
+	public $client = null;
22 22
 
23
-    /**
24
-     * Absolute URL for requests.
25
-     *
26
-     * @var string
27
-     */
28
-    protected $url;
23
+	/**
24
+	 * Absolute URL for requests.
25
+	 *
26
+	 * @var string
27
+	 */
28
+	protected $url;
29 29
 
30
-    /**
31
-     * Set URL for requests.
32
-     *
33
-     * @param string $url Relative URL
34
-     * @return self
35
-     */
36
-    public function setURL($url)
37
-    {
38
-        $this->url = Director::absoluteURL($url);
39
-        return $this;
40
-    }
30
+	/**
31
+	 * Set URL for requests.
32
+	 *
33
+	 * @param string $url Relative URL
34
+	 * @return self
35
+	 */
36
+	public function setURL($url)
37
+	{
38
+		$this->url = Director::absoluteURL($url);
39
+		return $this;
40
+	}
41 41
 
42
-    /**
43
-     * Getter for URL
44
-     *
45
-     * @return string
46
-     */
47
-    public function getURL()
48
-    {
49
-        return $this->url;
50
-    }
42
+	/**
43
+	 * Getter for URL
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function getURL()
48
+	{
49
+		return $this->url;
50
+	}
51 51
 }
Please login to merge, or discard this patch.