@@ -11,29 +11,29 @@ |
||
11 | 11 | */ |
12 | 12 | class HasClassCheck implements EnvironmentCheck |
13 | 13 | { |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $className; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $className; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @param string $className The name of the class to look for. |
|
21 | - */ |
|
22 | - public function __construct($className) |
|
23 | - { |
|
24 | - $this->className = $className; |
|
25 | - } |
|
19 | + /** |
|
20 | + * @param string $className The name of the class to look for. |
|
21 | + */ |
|
22 | + public function __construct($className) |
|
23 | + { |
|
24 | + $this->className = $className; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * {@inheritDoc} |
|
29 | - * |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - public function check() |
|
33 | - { |
|
34 | - if (class_exists($this->className)) { |
|
35 | - return [EnvironmentCheck::OK, 'Class ' . $this->className.' exists']; |
|
36 | - } |
|
37 | - return [EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist']; |
|
38 | - } |
|
27 | + /** |
|
28 | + * {@inheritDoc} |
|
29 | + * |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + public function check() |
|
33 | + { |
|
34 | + if (class_exists($this->className)) { |
|
35 | + return [EnvironmentCheck::OK, 'Class ' . $this->className.' exists']; |
|
36 | + } |
|
37 | + return [EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist']; |
|
38 | + } |
|
39 | 39 | } |
@@ -11,77 +11,77 @@ |
||
11 | 11 | */ |
12 | 12 | class FileWriteableCheck implements EnvironmentCheck |
13 | 13 | { |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $path; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $path; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @param string $path The full path. If a relative path, it will relative to the BASE_PATH. |
|
21 | - */ |
|
22 | - public function __construct($path) |
|
23 | - { |
|
24 | - $this->path = $path; |
|
25 | - } |
|
19 | + /** |
|
20 | + * @param string $path The full path. If a relative path, it will relative to the BASE_PATH. |
|
21 | + */ |
|
22 | + public function __construct($path) |
|
23 | + { |
|
24 | + $this->path = $path; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * {@inheritDoc} |
|
29 | - * |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - public function check() |
|
33 | - { |
|
34 | - if ($this->path[0] == '/') { |
|
35 | - $filename = $this->path; |
|
36 | - } else { |
|
37 | - $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
38 | - } |
|
27 | + /** |
|
28 | + * {@inheritDoc} |
|
29 | + * |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + public function check() |
|
33 | + { |
|
34 | + if ($this->path[0] == '/') { |
|
35 | + $filename = $this->path; |
|
36 | + } else { |
|
37 | + $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
38 | + } |
|
39 | 39 | |
40 | - if (file_exists($filename)) { |
|
41 | - $isWriteable = is_writeable($filename); |
|
42 | - } else { |
|
43 | - $isWriteable = is_writeable(dirname($filename)); |
|
44 | - } |
|
40 | + if (file_exists($filename)) { |
|
41 | + $isWriteable = is_writeable($filename); |
|
42 | + } else { |
|
43 | + $isWriteable = is_writeable(dirname($filename)); |
|
44 | + } |
|
45 | 45 | |
46 | - if (!$isWriteable) { |
|
47 | - if (function_exists('posix_getgroups')) { |
|
48 | - $userID = posix_geteuid(); |
|
49 | - $user = posix_getpwuid($userID); |
|
46 | + if (!$isWriteable) { |
|
47 | + if (function_exists('posix_getgroups')) { |
|
48 | + $userID = posix_geteuid(); |
|
49 | + $user = posix_getpwuid($userID); |
|
50 | 50 | |
51 | - $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename)); |
|
52 | - $currentOwner = posix_getpwuid($currentOwnerID); |
|
51 | + $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename)); |
|
52 | + $currentOwner = posix_getpwuid($currentOwnerID); |
|
53 | 53 | |
54 | - $message = "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is " |
|
55 | - . "currently owned by '$currentOwner[name]'. "; |
|
54 | + $message = "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is " |
|
55 | + . "currently owned by '$currentOwner[name]'. "; |
|
56 | 56 | |
57 | - if ($user['name'] == $currentOwner['name']) { |
|
58 | - $message .= 'We recommend that you make the file writeable.'; |
|
59 | - } else { |
|
60 | - $groups = posix_getgroups(); |
|
61 | - $groupList = []; |
|
62 | - foreach ($groups as $group) { |
|
63 | - $groupInfo = posix_getgrgid($group); |
|
64 | - if (in_array($currentOwner['name'], $groupInfo['members'])) { |
|
65 | - $groupList[] = $groupInfo['name']; |
|
66 | - } |
|
67 | - } |
|
68 | - if ($groupList) { |
|
69 | - $message .= " We recommend that you make the file group-writeable and change the group to " |
|
70 | - . "one of these groups:\n - " . implode("\n - ", $groupList) |
|
71 | - . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
|
72 | - } else { |
|
73 | - $message .= " There is no user-group that contains both the web-server user and the owner " |
|
74 | - . "of this file. Change the ownership of the file, create a new group, or temporarily " |
|
75 | - . "make the file writeable by everyone during the install process."; |
|
76 | - } |
|
77 | - } |
|
78 | - } else { |
|
79 | - $message = "The webserver user needs to be able to write to this file:\n$filename"; |
|
80 | - } |
|
57 | + if ($user['name'] == $currentOwner['name']) { |
|
58 | + $message .= 'We recommend that you make the file writeable.'; |
|
59 | + } else { |
|
60 | + $groups = posix_getgroups(); |
|
61 | + $groupList = []; |
|
62 | + foreach ($groups as $group) { |
|
63 | + $groupInfo = posix_getgrgid($group); |
|
64 | + if (in_array($currentOwner['name'], $groupInfo['members'])) { |
|
65 | + $groupList[] = $groupInfo['name']; |
|
66 | + } |
|
67 | + } |
|
68 | + if ($groupList) { |
|
69 | + $message .= " We recommend that you make the file group-writeable and change the group to " |
|
70 | + . "one of these groups:\n - " . implode("\n - ", $groupList) |
|
71 | + . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
|
72 | + } else { |
|
73 | + $message .= " There is no user-group that contains both the web-server user and the owner " |
|
74 | + . "of this file. Change the ownership of the file, create a new group, or temporarily " |
|
75 | + . "make the file writeable by everyone during the install process."; |
|
76 | + } |
|
77 | + } |
|
78 | + } else { |
|
79 | + $message = "The webserver user needs to be able to write to this file:\n$filename"; |
|
80 | + } |
|
81 | 81 | |
82 | - return [EnvironmentCheck::ERROR, $message]; |
|
83 | - } |
|
82 | + return [EnvironmentCheck::ERROR, $message]; |
|
83 | + } |
|
84 | 84 | |
85 | - return [EnvironmentCheck::OK, '']; |
|
86 | - } |
|
85 | + return [EnvironmentCheck::OK, '']; |
|
86 | + } |
|
87 | 87 | } |
@@ -16,27 +16,27 @@ |
||
16 | 16 | */ |
17 | 17 | class DevHealthControllerTest extends SapphireTest |
18 | 18 | { |
19 | - /** |
|
20 | - * {@inheritDoc} |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $usesDatabase = true; |
|
19 | + /** |
|
20 | + * {@inheritDoc} |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $usesDatabase = true; |
|
24 | 24 | |
25 | - public function testIndexCreatesChecker() |
|
26 | - { |
|
27 | - $controller = new DevHealthController(); |
|
25 | + public function testIndexCreatesChecker() |
|
26 | + { |
|
27 | + $controller = new DevHealthController(); |
|
28 | 28 | |
29 | - $request = new HTTPRequest('GET', 'example.com'); |
|
29 | + $request = new HTTPRequest('GET', 'example.com'); |
|
30 | 30 | |
31 | - // we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty |
|
32 | - // permission type strings, which is what health check uses. |
|
31 | + // we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty |
|
32 | + // permission type strings, which is what health check uses. |
|
33 | 33 | |
34 | - putenv('ENVCHECK_BASICAUTH_USERNAME="foo"'); |
|
35 | - putenv('ENVCHECK_BASICAUTH_PASSWORD="bar"'); |
|
34 | + putenv('ENVCHECK_BASICAUTH_USERNAME="foo"'); |
|
35 | + putenv('ENVCHECK_BASICAUTH_PASSWORD="bar"'); |
|
36 | 36 | |
37 | - $_SERVER['PHP_AUTH_USER'] = 'foo'; |
|
38 | - $_SERVER['PHP_AUTH_PW'] = 'bar'; |
|
37 | + $_SERVER['PHP_AUTH_USER'] = 'foo'; |
|
38 | + $_SERVER['PHP_AUTH_PW'] = 'bar'; |
|
39 | 39 | |
40 | - $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
|
41 | - } |
|
40 | + $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
|
41 | + } |
|
42 | 42 | } |
@@ -16,18 +16,18 @@ |
||
16 | 16 | */ |
17 | 17 | class DevCheckControllerTest extends SapphireTest |
18 | 18 | { |
19 | - /** |
|
20 | - * {@inheritDoc} |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $usesDatabase = true; |
|
19 | + /** |
|
20 | + * {@inheritDoc} |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $usesDatabase = true; |
|
24 | 24 | |
25 | - public function testIndexCreatesChecker() |
|
26 | - { |
|
27 | - $controller = new DevCheckController(); |
|
25 | + public function testIndexCreatesChecker() |
|
26 | + { |
|
27 | + $controller = new DevCheckController(); |
|
28 | 28 | |
29 | - $request = new HTTPRequest('GET', 'example.com'); |
|
29 | + $request = new HTTPRequest('GET', 'example.com'); |
|
30 | 30 | |
31 | - $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
|
32 | - } |
|
31 | + $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
|
32 | + } |
|
33 | 33 | } |
@@ -15,15 +15,15 @@ |
||
15 | 15 | */ |
16 | 16 | class URLCheckTest extends SapphireTest |
17 | 17 | { |
18 | - public function testCheckReportsMissingPages() |
|
19 | - { |
|
20 | - $check = new URLCheck('foo', 'bar'); |
|
18 | + public function testCheckReportsMissingPages() |
|
19 | + { |
|
20 | + $check = new URLCheck('foo', 'bar'); |
|
21 | 21 | |
22 | - $expected = [ |
|
23 | - EnvironmentCheck::ERROR, |
|
24 | - 'Error retrieving "foo" (Code: 404)' |
|
25 | - ]; |
|
22 | + $expected = [ |
|
23 | + EnvironmentCheck::ERROR, |
|
24 | + 'Error retrieving "foo" (Code: 404)' |
|
25 | + ]; |
|
26 | 26 | |
27 | - $this->assertEquals($expected, $check->check()); |
|
28 | - } |
|
27 | + $this->assertEquals($expected, $check->check()); |
|
28 | + } |
|
29 | 29 | } |
@@ -15,24 +15,24 @@ |
||
15 | 15 | */ |
16 | 16 | class FileWritableCheckTest extends SapphireTest |
17 | 17 | { |
18 | - public function testCheckReportsWritablePaths() |
|
19 | - { |
|
20 | - $check = new FileWriteableCheck(TEMP_FOLDER); |
|
18 | + public function testCheckReportsWritablePaths() |
|
19 | + { |
|
20 | + $check = new FileWriteableCheck(TEMP_FOLDER); |
|
21 | 21 | |
22 | - $expected = [ |
|
23 | - EnvironmentCheck::OK, |
|
24 | - '' |
|
25 | - ]; |
|
22 | + $expected = [ |
|
23 | + EnvironmentCheck::OK, |
|
24 | + '' |
|
25 | + ]; |
|
26 | 26 | |
27 | - $this->assertEquals($expected, $check->check()); |
|
28 | - } |
|
27 | + $this->assertEquals($expected, $check->check()); |
|
28 | + } |
|
29 | 29 | |
30 | - public function testCheckReportsNonWritablePaths() |
|
31 | - { |
|
32 | - $check = new FileWriteableCheck('/var'); |
|
30 | + public function testCheckReportsNonWritablePaths() |
|
31 | + { |
|
32 | + $check = new FileWriteableCheck('/var'); |
|
33 | 33 | |
34 | - $result = $check->check(); |
|
34 | + $result = $check->check(); |
|
35 | 35 | |
36 | - $this->assertEquals(EnvironmentCheck::ERROR, $result[0]); |
|
37 | - } |
|
36 | + $this->assertEquals(EnvironmentCheck::ERROR, $result[0]); |
|
37 | + } |
|
38 | 38 | } |
@@ -15,17 +15,17 @@ |
||
15 | 15 | */ |
16 | 16 | class ExternalURLCheckTest extends SapphireTest |
17 | 17 | { |
18 | - public function testCheckReportsMissingPages() |
|
19 | - { |
|
20 | - $this->markTestSkipped('ExternalURLCheck seems faulty on some systems'); |
|
18 | + public function testCheckReportsMissingPages() |
|
19 | + { |
|
20 | + $this->markTestSkipped('ExternalURLCheck seems faulty on some systems'); |
|
21 | 21 | |
22 | - $check = new ExternalURLCheck('http://missing-site/'); |
|
22 | + $check = new ExternalURLCheck('http://missing-site/'); |
|
23 | 23 | |
24 | - $expected = [ |
|
25 | - EnvironmentCheck::ERROR, |
|
26 | - 'Success retrieving "http://missing-site/" (Code: 404)' |
|
27 | - ]; |
|
24 | + $expected = [ |
|
25 | + EnvironmentCheck::ERROR, |
|
26 | + 'Success retrieving "http://missing-site/" (Code: 404)' |
|
27 | + ]; |
|
28 | 28 | |
29 | - $this->assertEquals($expected, $check->check()); |
|
30 | - } |
|
29 | + $this->assertEquals($expected, $check->check()); |
|
30 | + } |
|
31 | 31 | } |
@@ -15,27 +15,27 @@ |
||
15 | 15 | */ |
16 | 16 | class HasClassCheckTest extends SapphireTest |
17 | 17 | { |
18 | - public function testCheckReportsMissingClasses() |
|
19 | - { |
|
20 | - $check = new HasClassCheck('foo'); |
|
18 | + public function testCheckReportsMissingClasses() |
|
19 | + { |
|
20 | + $check = new HasClassCheck('foo'); |
|
21 | 21 | |
22 | - $expected = [ |
|
23 | - EnvironmentCheck::ERROR, |
|
24 | - 'Class foo doesn\'t exist' |
|
25 | - ]; |
|
22 | + $expected = [ |
|
23 | + EnvironmentCheck::ERROR, |
|
24 | + 'Class foo doesn\'t exist' |
|
25 | + ]; |
|
26 | 26 | |
27 | - $this->assertEquals($expected, $check->check()); |
|
28 | - } |
|
27 | + $this->assertEquals($expected, $check->check()); |
|
28 | + } |
|
29 | 29 | |
30 | - public function testCheckReportsFoundClasses() |
|
31 | - { |
|
32 | - $check = new HasClassCheck('stdClass'); |
|
30 | + public function testCheckReportsFoundClasses() |
|
31 | + { |
|
32 | + $check = new HasClassCheck('stdClass'); |
|
33 | 33 | |
34 | - $expected = [ |
|
35 | - EnvironmentCheck::OK, |
|
36 | - 'Class stdClass exists', |
|
37 | - ]; |
|
34 | + $expected = [ |
|
35 | + EnvironmentCheck::OK, |
|
36 | + 'Class stdClass exists', |
|
37 | + ]; |
|
38 | 38 | |
39 | - $this->assertEquals($expected, $check->check()); |
|
40 | - } |
|
39 | + $this->assertEquals($expected, $check->check()); |
|
40 | + } |
|
41 | 41 | } |
@@ -16,25 +16,25 @@ |
||
16 | 16 | */ |
17 | 17 | class DatabaseCheckTest extends SapphireTest |
18 | 18 | { |
19 | - /** |
|
20 | - * {@inheritDoc} |
|
21 | - * @var bool |
|
22 | - */ |
|
23 | - protected $usesDatabase = true; |
|
19 | + /** |
|
20 | + * {@inheritDoc} |
|
21 | + * @var bool |
|
22 | + */ |
|
23 | + protected $usesDatabase = true; |
|
24 | 24 | |
25 | - public function testCheckReportsValidConnection() |
|
26 | - { |
|
27 | - $member = new Member; |
|
28 | - $member->FirstName = 'Bob'; |
|
29 | - $member->write(); |
|
25 | + public function testCheckReportsValidConnection() |
|
26 | + { |
|
27 | + $member = new Member; |
|
28 | + $member->FirstName = 'Bob'; |
|
29 | + $member->write(); |
|
30 | 30 | |
31 | - $check = new DatabaseCheck(); |
|
31 | + $check = new DatabaseCheck(); |
|
32 | 32 | |
33 | - $expected = [ |
|
34 | - EnvironmentCheck::OK, |
|
35 | - '' |
|
36 | - ]; |
|
33 | + $expected = [ |
|
34 | + EnvironmentCheck::OK, |
|
35 | + '' |
|
36 | + ]; |
|
37 | 37 | |
38 | - $this->assertEquals($expected, $check->check()); |
|
39 | - } |
|
38 | + $this->assertEquals($expected, $check->check()); |
|
39 | + } |
|
40 | 40 | } |