@@ -5,73 +5,73 @@ |
||
5 | 5 | */ |
6 | 6 | class FileWriteableCheck implements EnvironmentCheck |
7 | 7 | { |
8 | - /** |
|
9 | - * @var string |
|
10 | - */ |
|
11 | - protected $path; |
|
8 | + /** |
|
9 | + * @var string |
|
10 | + */ |
|
11 | + protected $path; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @param string $path The full path. If a relative path, it will relative to the BASE_PATH. |
|
15 | - */ |
|
16 | - public function __construct($path) |
|
17 | - { |
|
18 | - $this->path = $path; |
|
19 | - } |
|
13 | + /** |
|
14 | + * @param string $path The full path. If a relative path, it will relative to the BASE_PATH. |
|
15 | + */ |
|
16 | + public function __construct($path) |
|
17 | + { |
|
18 | + $this->path = $path; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @inheritdoc |
|
23 | - * |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function check() |
|
27 | - { |
|
28 | - if ($this->path[0] == '/') { |
|
29 | - $filename = $this->path; |
|
30 | - } else { |
|
31 | - $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
32 | - } |
|
21 | + /** |
|
22 | + * @inheritdoc |
|
23 | + * |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function check() |
|
27 | + { |
|
28 | + if ($this->path[0] == '/') { |
|
29 | + $filename = $this->path; |
|
30 | + } else { |
|
31 | + $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
32 | + } |
|
33 | 33 | |
34 | - if (file_exists($filename)) { |
|
35 | - $isWriteable = is_writeable($filename); |
|
36 | - } else { |
|
37 | - $isWriteable = is_writeable(dirname($filename)); |
|
38 | - } |
|
34 | + if (file_exists($filename)) { |
|
35 | + $isWriteable = is_writeable($filename); |
|
36 | + } else { |
|
37 | + $isWriteable = is_writeable(dirname($filename)); |
|
38 | + } |
|
39 | 39 | |
40 | - if (!$isWriteable) { |
|
41 | - if (function_exists('posix_getgroups')) { |
|
42 | - $userID = posix_geteuid(); |
|
43 | - $user = posix_getpwuid($userID); |
|
40 | + if (!$isWriteable) { |
|
41 | + if (function_exists('posix_getgroups')) { |
|
42 | + $userID = posix_geteuid(); |
|
43 | + $user = posix_getpwuid($userID); |
|
44 | 44 | |
45 | - $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename)); |
|
46 | - $currentOwner = posix_getpwuid($currentOwnerID); |
|
45 | + $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename)); |
|
46 | + $currentOwner = posix_getpwuid($currentOwnerID); |
|
47 | 47 | |
48 | - $message = "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is currently owned by '$currentOwner[name]'. "; |
|
48 | + $message = "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is currently owned by '$currentOwner[name]'. "; |
|
49 | 49 | |
50 | - if ($user['name'] == $currentOwner['name']) { |
|
51 | - $message .= "We recommend that you make the file writeable."; |
|
52 | - } else { |
|
53 | - $groups = posix_getgroups(); |
|
54 | - $groupList = array(); |
|
55 | - foreach ($groups as $group) { |
|
56 | - $groupInfo = posix_getgrgid($group); |
|
57 | - if (in_array($currentOwner['name'], $groupInfo['members'])) { |
|
58 | - $groupList[] = $groupInfo['name']; |
|
59 | - } |
|
60 | - } |
|
61 | - if ($groupList) { |
|
62 | - $message .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - ". implode("\n - ", $groupList) |
|
63 | - . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
|
64 | - } else { |
|
65 | - $message .= " There is no user-group that contains both the web-server user and the owner of this file. Change the ownership of the file, create a new group, or temporarily make the file writeable by everyone during the install process."; |
|
66 | - } |
|
67 | - } |
|
68 | - } else { |
|
69 | - $message = "The webserver user needs to be able to write to this file:\n$filename"; |
|
70 | - } |
|
50 | + if ($user['name'] == $currentOwner['name']) { |
|
51 | + $message .= "We recommend that you make the file writeable."; |
|
52 | + } else { |
|
53 | + $groups = posix_getgroups(); |
|
54 | + $groupList = array(); |
|
55 | + foreach ($groups as $group) { |
|
56 | + $groupInfo = posix_getgrgid($group); |
|
57 | + if (in_array($currentOwner['name'], $groupInfo['members'])) { |
|
58 | + $groupList[] = $groupInfo['name']; |
|
59 | + } |
|
60 | + } |
|
61 | + if ($groupList) { |
|
62 | + $message .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - ". implode("\n - ", $groupList) |
|
63 | + . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
|
64 | + } else { |
|
65 | + $message .= " There is no user-group that contains both the web-server user and the owner of this file. Change the ownership of the file, create a new group, or temporarily make the file writeable by everyone during the install process."; |
|
66 | + } |
|
67 | + } |
|
68 | + } else { |
|
69 | + $message = "The webserver user needs to be able to write to this file:\n$filename"; |
|
70 | + } |
|
71 | 71 | |
72 | - return array(EnvironmentCheck::ERROR, $message); |
|
73 | - } |
|
72 | + return array(EnvironmentCheck::ERROR, $message); |
|
73 | + } |
|
74 | 74 | |
75 | - return array(EnvironmentCheck::OK,''); |
|
76 | - } |
|
75 | + return array(EnvironmentCheck::OK,''); |
|
76 | + } |
|
77 | 77 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | if ($groupList) { |
62 | - $message .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - ". implode("\n - ", $groupList) |
|
62 | + $message .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - " . implode("\n - ", $groupList) |
|
63 | 63 | . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
64 | 64 | } else { |
65 | 65 | $message .= " There is no user-group that contains both the web-server user and the owner of this file. Change the ownership of the file, create a new group, or temporarily make the file writeable by everyone during the install process."; |
@@ -72,6 +72,6 @@ discard block |
||
72 | 72 | return array(EnvironmentCheck::ERROR, $message); |
73 | 73 | } |
74 | 74 | |
75 | - return array(EnvironmentCheck::OK,''); |
|
75 | + return array(EnvironmentCheck::OK, ''); |
|
76 | 76 | } |
77 | 77 | } |
@@ -5,30 +5,30 @@ |
||
5 | 5 | */ |
6 | 6 | class HasClassCheck implements EnvironmentCheck |
7 | 7 | { |
8 | - /** |
|
9 | - * @var string |
|
10 | - */ |
|
11 | - protected $className; |
|
8 | + /** |
|
9 | + * @var string |
|
10 | + */ |
|
11 | + protected $className; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @param string $className The name of the class to look for. |
|
15 | - */ |
|
16 | - public function __construct($className) |
|
17 | - { |
|
18 | - $this->className = $className; |
|
19 | - } |
|
13 | + /** |
|
14 | + * @param string $className The name of the class to look for. |
|
15 | + */ |
|
16 | + public function __construct($className) |
|
17 | + { |
|
18 | + $this->className = $className; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @inheritdoc |
|
23 | - * |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function check() |
|
27 | - { |
|
28 | - if (class_exists($this->className)) { |
|
29 | - return array(EnvironmentCheck::OK, 'Class ' . $this->className.' exists'); |
|
30 | - } else { |
|
31 | - return array(EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist'); |
|
32 | - } |
|
33 | - } |
|
21 | + /** |
|
22 | + * @inheritdoc |
|
23 | + * |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function check() |
|
27 | + { |
|
28 | + if (class_exists($this->className)) { |
|
29 | + return array(EnvironmentCheck::OK, 'Class ' . $this->className.' exists'); |
|
30 | + } else { |
|
31 | + return array(EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist'); |
|
32 | + } |
|
33 | + } |
|
34 | 34 | } |
@@ -26,9 +26,9 @@ |
||
26 | 26 | public function check() |
27 | 27 | { |
28 | 28 | if (class_exists($this->className)) { |
29 | - return array(EnvironmentCheck::OK, 'Class ' . $this->className.' exists'); |
|
29 | + return array(EnvironmentCheck::OK, 'Class ' . $this->className . ' exists'); |
|
30 | 30 | } else { |
31 | - return array(EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist'); |
|
31 | + return array(EnvironmentCheck::ERROR, 'Class ' . $this->className . ' doesn\'t exist'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | } |
@@ -5,30 +5,30 @@ |
||
5 | 5 | */ |
6 | 6 | class HasFunctionCheck implements EnvironmentCheck |
7 | 7 | { |
8 | - /** |
|
9 | - * @var string |
|
10 | - */ |
|
11 | - protected $functionName; |
|
8 | + /** |
|
9 | + * @var string |
|
10 | + */ |
|
11 | + protected $functionName; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @param string $functionName The name of the function to look for. |
|
15 | - */ |
|
16 | - public function __construct($functionName) |
|
17 | - { |
|
18 | - $this->functionName = $functionName; |
|
19 | - } |
|
13 | + /** |
|
14 | + * @param string $functionName The name of the function to look for. |
|
15 | + */ |
|
16 | + public function __construct($functionName) |
|
17 | + { |
|
18 | + $this->functionName = $functionName; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @inheritdoc |
|
23 | - * |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function check() |
|
27 | - { |
|
28 | - if (function_exists($this->functionName)) { |
|
29 | - return array(EnvironmentCheck::OK, $this->functionName.'() exists'); |
|
30 | - } else { |
|
31 | - return array(EnvironmentCheck::ERROR, $this->functionName.'() doesn\'t exist'); |
|
32 | - } |
|
33 | - } |
|
21 | + /** |
|
22 | + * @inheritdoc |
|
23 | + * |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function check() |
|
27 | + { |
|
28 | + if (function_exists($this->functionName)) { |
|
29 | + return array(EnvironmentCheck::OK, $this->functionName.'() exists'); |
|
30 | + } else { |
|
31 | + return array(EnvironmentCheck::ERROR, $this->functionName.'() doesn\'t exist'); |
|
32 | + } |
|
33 | + } |
|
34 | 34 | } |
@@ -26,9 +26,9 @@ |
||
26 | 26 | public function check() |
27 | 27 | { |
28 | 28 | if (function_exists($this->functionName)) { |
29 | - return array(EnvironmentCheck::OK, $this->functionName.'() exists'); |
|
29 | + return array(EnvironmentCheck::OK, $this->functionName . '() exists'); |
|
30 | 30 | } else { |
31 | - return array(EnvironmentCheck::ERROR, $this->functionName.'() doesn\'t exist'); |
|
31 | + return array(EnvironmentCheck::ERROR, $this->functionName . '() doesn\'t exist'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | } |
@@ -7,50 +7,50 @@ |
||
7 | 7 | */ |
8 | 8 | class SolrIndexCheck implements EnvironmentCheck |
9 | 9 | { |
10 | - /** |
|
11 | - * @var null|string |
|
12 | - */ |
|
13 | - protected $indexClass; |
|
10 | + /** |
|
11 | + * @var null|string |
|
12 | + */ |
|
13 | + protected $indexClass; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @param string $indexClass Limit the index checks to the specified class and all its subclasses. |
|
17 | - */ |
|
18 | - public function __construct($indexClass = null) |
|
19 | - { |
|
20 | - $this->indexClass = $indexClass; |
|
21 | - } |
|
15 | + /** |
|
16 | + * @param string $indexClass Limit the index checks to the specified class and all its subclasses. |
|
17 | + */ |
|
18 | + public function __construct($indexClass = null) |
|
19 | + { |
|
20 | + $this->indexClass = $indexClass; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @inheritdoc |
|
25 | - * |
|
26 | - * @return array |
|
27 | - */ |
|
28 | - public function check() |
|
29 | - { |
|
30 | - $brokenCores = array(); |
|
23 | + /** |
|
24 | + * @inheritdoc |
|
25 | + * |
|
26 | + * @return array |
|
27 | + */ |
|
28 | + public function check() |
|
29 | + { |
|
30 | + $brokenCores = array(); |
|
31 | 31 | |
32 | - if (!class_exists('Solr')) { |
|
33 | - return array( |
|
34 | - EnvironmentCheck::ERROR, |
|
35 | - 'Class `Solr` not found. Is the fulltextsearch module installed?' |
|
36 | - ); |
|
37 | - } |
|
32 | + if (!class_exists('Solr')) { |
|
33 | + return array( |
|
34 | + EnvironmentCheck::ERROR, |
|
35 | + 'Class `Solr` not found. Is the fulltextsearch module installed?' |
|
36 | + ); |
|
37 | + } |
|
38 | 38 | |
39 | - $service = Solr::service(); |
|
40 | - foreach (Solr::get_indexes($this->indexClass) as $index) { |
|
41 | - $core = $index->getIndexName(); |
|
42 | - if (!$service->coreIsActive($core)) { |
|
43 | - $brokenCores[] = $core; |
|
44 | - } |
|
45 | - } |
|
39 | + $service = Solr::service(); |
|
40 | + foreach (Solr::get_indexes($this->indexClass) as $index) { |
|
41 | + $core = $index->getIndexName(); |
|
42 | + if (!$service->coreIsActive($core)) { |
|
43 | + $brokenCores[] = $core; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - if (!empty($brokenCores)) { |
|
48 | - return array( |
|
49 | - EnvironmentCheck::ERROR, |
|
50 | - 'The following indexes are unavailable: ' . implode($brokenCores, ', ') |
|
51 | - ); |
|
52 | - } |
|
47 | + if (!empty($brokenCores)) { |
|
48 | + return array( |
|
49 | + EnvironmentCheck::ERROR, |
|
50 | + 'The following indexes are unavailable: ' . implode($brokenCores, ', ') |
|
51 | + ); |
|
52 | + } |
|
53 | 53 | |
54 | - return array(EnvironmentCheck::OK, 'Expected indexes are available.'); |
|
55 | - } |
|
54 | + return array(EnvironmentCheck::OK, 'Expected indexes are available.'); |
|
55 | + } |
|
56 | 56 | } |
@@ -7,52 +7,52 @@ |
||
7 | 7 | */ |
8 | 8 | class URLCheck implements EnvironmentCheck |
9 | 9 | { |
10 | - /** |
|
11 | - * @var string |
|
12 | - */ |
|
13 | - protected $url; |
|
10 | + /** |
|
11 | + * @var string |
|
12 | + */ |
|
13 | + protected $url; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $testString; |
|
15 | + /** |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $testString; |
|
19 | 19 | |
20 | - /* |
|
20 | + /* |
|
21 | 21 | * @param string $url The URL to check, relative to the site (homepage is ''). |
22 | 22 | * @param string $testString An optional piece of text to search for on the homepage. |
23 | 23 | */ |
24 | - public function __construct($url = '', $testString = '') |
|
25 | - { |
|
26 | - $this->url = $url; |
|
27 | - $this->testString = $testString; |
|
28 | - } |
|
24 | + public function __construct($url = '', $testString = '') |
|
25 | + { |
|
26 | + $this->url = $url; |
|
27 | + $this->testString = $testString; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @inheritdoc |
|
32 | - * |
|
33 | - * @return array |
|
34 | - * |
|
35 | - * @throws SS_HTTPResponse_Exception |
|
36 | - */ |
|
37 | - public function check() |
|
38 | - { |
|
39 | - $response = Director::test($this->url); |
|
30 | + /** |
|
31 | + * @inheritdoc |
|
32 | + * |
|
33 | + * @return array |
|
34 | + * |
|
35 | + * @throws SS_HTTPResponse_Exception |
|
36 | + */ |
|
37 | + public function check() |
|
38 | + { |
|
39 | + $response = Director::test($this->url); |
|
40 | 40 | |
41 | - if ($response->getStatusCode() != 200) { |
|
42 | - return array( |
|
43 | - EnvironmentCheck::ERROR, |
|
44 | - sprintf('Error retrieving "%s" (Code: %d)', $this->url, $response->getStatusCode()) |
|
45 | - ); |
|
46 | - } elseif ($this->testString && (strpos($response->getBody(), $this->testString) === false)) { |
|
47 | - return array( |
|
48 | - EnvironmentCheck::WARNING, |
|
49 | - sprintf('Success retrieving "%s", but string "%s" not found', $this->url, $this->testString) |
|
50 | - ); |
|
51 | - } else { |
|
52 | - return array( |
|
53 | - EnvironmentCheck::OK, |
|
54 | - sprintf('Success retrieving "%s"', $this->url) |
|
55 | - ); |
|
56 | - } |
|
57 | - } |
|
41 | + if ($response->getStatusCode() != 200) { |
|
42 | + return array( |
|
43 | + EnvironmentCheck::ERROR, |
|
44 | + sprintf('Error retrieving "%s" (Code: %d)', $this->url, $response->getStatusCode()) |
|
45 | + ); |
|
46 | + } elseif ($this->testString && (strpos($response->getBody(), $this->testString) === false)) { |
|
47 | + return array( |
|
48 | + EnvironmentCheck::WARNING, |
|
49 | + sprintf('Success retrieving "%s", but string "%s" not found', $this->url, $this->testString) |
|
50 | + ); |
|
51 | + } else { |
|
52 | + return array( |
|
53 | + EnvironmentCheck::OK, |
|
54 | + sprintf('Success retrieving "%s"', $this->url) |
|
55 | + ); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | } |
@@ -5,12 +5,12 @@ |
||
5 | 5 | */ |
6 | 6 | class DevCheckControllerTest extends SapphireTest |
7 | 7 | { |
8 | - public function testIndexCreatesChecker() |
|
9 | - { |
|
10 | - $controller = new DevCheckController(); |
|
8 | + public function testIndexCreatesChecker() |
|
9 | + { |
|
10 | + $controller = new DevCheckController(); |
|
11 | 11 | |
12 | - $request = new SS_HTTPRequest('GET', 'example.com'); |
|
12 | + $request = new SS_HTTPRequest('GET', 'example.com'); |
|
13 | 13 | |
14 | - $this->assertInstanceOf('EnvironmentChecker', $controller->index($request)); |
|
15 | - } |
|
14 | + $this->assertInstanceOf('EnvironmentChecker', $controller->index($request)); |
|
15 | + } |
|
16 | 16 | } |
@@ -5,21 +5,21 @@ |
||
5 | 5 | */ |
6 | 6 | class DevHealthControllerTest extends SapphireTest |
7 | 7 | { |
8 | - public function testIndexCreatesChecker() |
|
9 | - { |
|
10 | - $controller = new DevHealthController(); |
|
8 | + public function testIndexCreatesChecker() |
|
9 | + { |
|
10 | + $controller = new DevHealthController(); |
|
11 | 11 | |
12 | - $request = new SS_HTTPRequest('GET', 'example.com'); |
|
12 | + $request = new SS_HTTPRequest('GET', 'example.com'); |
|
13 | 13 | |
14 | - // we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty |
|
15 | - // permission type strings, which is what health check uses. |
|
14 | + // we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty |
|
15 | + // permission type strings, which is what health check uses. |
|
16 | 16 | |
17 | - define('ENVCHECK_BASICAUTH_USERNAME', 'foo'); |
|
18 | - define('ENVCHECK_BASICAUTH_PASSWORD', 'bar'); |
|
17 | + define('ENVCHECK_BASICAUTH_USERNAME', 'foo'); |
|
18 | + define('ENVCHECK_BASICAUTH_PASSWORD', 'bar'); |
|
19 | 19 | |
20 | - $_SERVER['PHP_AUTH_USER'] = 'foo'; |
|
21 | - $_SERVER['PHP_AUTH_PW'] = 'bar'; |
|
20 | + $_SERVER['PHP_AUTH_USER'] = 'foo'; |
|
21 | + $_SERVER['PHP_AUTH_PW'] = 'bar'; |
|
22 | 22 | |
23 | - $this->assertInstanceOf('EnvironmentChecker', $controller->index($request)); |
|
24 | - } |
|
23 | + $this->assertInstanceOf('EnvironmentChecker', $controller->index($request)); |
|
24 | + } |
|
25 | 25 | } |
@@ -1,100 +1,100 @@ |
||
1 | 1 | <?php |
2 | 2 | class EnvironmentCheckerTest extends SapphireTest |
3 | 3 | { |
4 | - public function setUpOnce() |
|
5 | - { |
|
6 | - parent::setUpOnce(); |
|
4 | + public function setUpOnce() |
|
5 | + { |
|
6 | + parent::setUpOnce(); |
|
7 | 7 | |
8 | - Phockito::include_hamcrest(); |
|
9 | - } |
|
8 | + Phockito::include_hamcrest(); |
|
9 | + } |
|
10 | 10 | |
11 | - public function setUp() |
|
12 | - { |
|
13 | - parent::setUp(); |
|
11 | + public function setUp() |
|
12 | + { |
|
13 | + parent::setUp(); |
|
14 | 14 | |
15 | - Config::nest(); |
|
16 | - } |
|
15 | + Config::nest(); |
|
16 | + } |
|
17 | 17 | |
18 | - public function tearDown() |
|
19 | - { |
|
20 | - Config::unnest(); |
|
18 | + public function tearDown() |
|
19 | + { |
|
20 | + Config::unnest(); |
|
21 | 21 | |
22 | - parent::tearDown(); |
|
23 | - } |
|
22 | + parent::tearDown(); |
|
23 | + } |
|
24 | 24 | |
25 | - public function testOnlyLogsWithErrors() |
|
26 | - { |
|
27 | - Config::inst()->update('EnvironmentChecker', 'log_results_warning', true); |
|
28 | - Config::inst()->update('EnvironmentChecker', 'log_results_error', true); |
|
29 | - EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckNoErrors()); |
|
30 | - $checker = Phockito::spy( |
|
31 | - 'EnvironmentChecker', |
|
32 | - 'test suite', |
|
33 | - 'test' |
|
34 | - ); |
|
25 | + public function testOnlyLogsWithErrors() |
|
26 | + { |
|
27 | + Config::inst()->update('EnvironmentChecker', 'log_results_warning', true); |
|
28 | + Config::inst()->update('EnvironmentChecker', 'log_results_error', true); |
|
29 | + EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckNoErrors()); |
|
30 | + $checker = Phockito::spy( |
|
31 | + 'EnvironmentChecker', |
|
32 | + 'test suite', |
|
33 | + 'test' |
|
34 | + ); |
|
35 | 35 | |
36 | - $response = $checker->index(); |
|
37 | - Phockito::verify($checker, 0)->log(anything(), anything()); |
|
38 | - EnvironmentCheckSuite::reset(); |
|
39 | - } |
|
36 | + $response = $checker->index(); |
|
37 | + Phockito::verify($checker, 0)->log(anything(), anything()); |
|
38 | + EnvironmentCheckSuite::reset(); |
|
39 | + } |
|
40 | 40 | |
41 | - public function testLogsWithWarnings() |
|
42 | - { |
|
43 | - Config::inst()->update('EnvironmentChecker', 'log_results_warning', true); |
|
44 | - Config::inst()->update('EnvironmentChecker', 'log_results_error', false); |
|
45 | - EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckWarnings()); |
|
46 | - EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckErrors()); |
|
47 | - $checker = Phockito::spy( |
|
48 | - 'EnvironmentChecker', |
|
49 | - 'test suite', |
|
50 | - 'test' |
|
51 | - ); |
|
41 | + public function testLogsWithWarnings() |
|
42 | + { |
|
43 | + Config::inst()->update('EnvironmentChecker', 'log_results_warning', true); |
|
44 | + Config::inst()->update('EnvironmentChecker', 'log_results_error', false); |
|
45 | + EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckWarnings()); |
|
46 | + EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckErrors()); |
|
47 | + $checker = Phockito::spy( |
|
48 | + 'EnvironmentChecker', |
|
49 | + 'test suite', |
|
50 | + 'test' |
|
51 | + ); |
|
52 | 52 | |
53 | - $response = $checker->index(); |
|
54 | - Phockito::verify($checker, 1)->log(containsString('warning'), anything()); |
|
55 | - Phockito::verify($checker, 0)->log(containsString('error'), anything()); |
|
56 | - EnvironmentCheckSuite::reset(); |
|
57 | - } |
|
53 | + $response = $checker->index(); |
|
54 | + Phockito::verify($checker, 1)->log(containsString('warning'), anything()); |
|
55 | + Phockito::verify($checker, 0)->log(containsString('error'), anything()); |
|
56 | + EnvironmentCheckSuite::reset(); |
|
57 | + } |
|
58 | 58 | |
59 | - public function testLogsWithErrors() |
|
60 | - { |
|
61 | - Config::inst()->update('EnvironmentChecker', 'log_results_error', false); |
|
62 | - Config::inst()->update('EnvironmentChecker', 'log_results_error', true); |
|
63 | - EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckWarnings()); |
|
64 | - EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckErrors()); |
|
65 | - $checker = Phockito::spy( |
|
66 | - 'EnvironmentChecker', |
|
67 | - 'test suite', |
|
68 | - 'test' |
|
69 | - ); |
|
59 | + public function testLogsWithErrors() |
|
60 | + { |
|
61 | + Config::inst()->update('EnvironmentChecker', 'log_results_error', false); |
|
62 | + Config::inst()->update('EnvironmentChecker', 'log_results_error', true); |
|
63 | + EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckWarnings()); |
|
64 | + EnvironmentCheckSuite::register('test suite', new EnvironmentCheckerTest_CheckErrors()); |
|
65 | + $checker = Phockito::spy( |
|
66 | + 'EnvironmentChecker', |
|
67 | + 'test suite', |
|
68 | + 'test' |
|
69 | + ); |
|
70 | 70 | |
71 | - $response = $checker->index(); |
|
72 | - Phockito::verify($checker, 0)->log(containsString('warning'), anything()); |
|
73 | - Phockito::verify($checker, 1)->log(containsString('error'), anything()); |
|
74 | - EnvironmentCheckSuite::reset(); |
|
75 | - } |
|
71 | + $response = $checker->index(); |
|
72 | + Phockito::verify($checker, 0)->log(containsString('warning'), anything()); |
|
73 | + Phockito::verify($checker, 1)->log(containsString('error'), anything()); |
|
74 | + EnvironmentCheckSuite::reset(); |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | class EnvironmentCheckerTest_CheckNoErrors implements EnvironmentCheck, TestOnly |
79 | 79 | { |
80 | - public function check() |
|
81 | - { |
|
82 | - return array(EnvironmentCheck::OK, ''); |
|
83 | - } |
|
80 | + public function check() |
|
81 | + { |
|
82 | + return array(EnvironmentCheck::OK, ''); |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | class EnvironmentCheckerTest_CheckWarnings implements EnvironmentCheck, TestOnly |
87 | 87 | { |
88 | - public function check() |
|
89 | - { |
|
90 | - return array(EnvironmentCheck::WARNING, "test warning"); |
|
91 | - } |
|
88 | + public function check() |
|
89 | + { |
|
90 | + return array(EnvironmentCheck::WARNING, "test warning"); |
|
91 | + } |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | class EnvironmentCheckerTest_CheckErrors implements EnvironmentCheck, TestOnly |
95 | 95 | { |
96 | - public function check() |
|
97 | - { |
|
98 | - return array(EnvironmentCheck::ERROR, "test error"); |
|
99 | - } |
|
96 | + public function check() |
|
97 | + { |
|
98 | + return array(EnvironmentCheck::ERROR, "test error"); |
|
99 | + } |
|
100 | 100 | } |
@@ -5,15 +5,15 @@ |
||
5 | 5 | */ |
6 | 6 | class DatabaseCheckTest extends SapphireTest |
7 | 7 | { |
8 | - public function testCheckReportsValidConnection() |
|
9 | - { |
|
10 | - $check = new DatabaseCheck(); |
|
8 | + public function testCheckReportsValidConnection() |
|
9 | + { |
|
10 | + $check = new DatabaseCheck(); |
|
11 | 11 | |
12 | - $expected = array( |
|
13 | - EnvironmentCheck::OK, |
|
14 | - '', |
|
15 | - ); |
|
12 | + $expected = array( |
|
13 | + EnvironmentCheck::OK, |
|
14 | + '', |
|
15 | + ); |
|
16 | 16 | |
17 | - $this->assertEquals($expected, $check->check()); |
|
18 | - } |
|
17 | + $this->assertEquals($expected, $check->check()); |
|
18 | + } |
|
19 | 19 | } |