Completed
Pull Request — master (#34)
by Stig
02:35
created
code/checks/HasClassCheck.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
code/checks/HasFunctionCheck.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
code/checks/SolrIndexCheck.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
         if (!empty($brokenCores)) {
48 48
             return array(
49 49
                 EnvironmentCheck::ERROR,
50
-                'The following indexes are unavailable: ' . implode($brokenCores, ', ')
50
+                'The following indexes are unavailable: '.implode($brokenCores, ', ')
51 51
             );
52 52
         }
53 53
 
Please login to merge, or discard this patch.
code/checks/URLCheck.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -7,52 +7,52 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
tests/DevCheckControllerTest.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
tests/DevHealthControllerTest.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,21 +5,21 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
tests/EnvironmentCheckerTest.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,100 +1,100 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
tests/checks/DatabaseCheckTest.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5,15 +5,15 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
tests/checks/ExternalURLCheckTest.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@
 block discarded – undo
5 5
  */
6 6
 class ExternalURLCheckTest extends SapphireTest
7 7
 {
8
-    public function testCheckReportsMissingPages()
9
-    {
10
-        $this->markTestSkipped('ExternalURLCheck seems faulty on some systems');
8
+	public function testCheckReportsMissingPages()
9
+	{
10
+		$this->markTestSkipped('ExternalURLCheck seems faulty on some systems');
11 11
 
12
-        $check = new ExternalURLCheck('http://missing-site/');
12
+		$check = new ExternalURLCheck('http://missing-site/');
13 13
 
14
-        $expected = array(
15
-            EnvironmentCheck::ERROR,
16
-            'Success retrieving "http://missing-site/" (Code: 404)',
17
-        );
14
+		$expected = array(
15
+			EnvironmentCheck::ERROR,
16
+			'Success retrieving "http://missing-site/" (Code: 404)',
17
+		);
18 18
 
19
-        $this->assertEquals($expected, $check->check());
20
-    }
19
+		$this->assertEquals($expected, $check->check());
20
+	}
21 21
 }
Please login to merge, or discard this patch.