Completed
Pull Request — master (#34)
by Stig
04:28 queued 02:13
created
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/SMTPConnectCheck.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -7,67 +7,67 @@
 block discarded – undo
7 7
  */
8 8
 class SMTPConnectCheck implements EnvironmentCheck
9 9
 {
10
-    /**
11
-     * @var string
12
-     */
13
-    protected $host;
10
+	/**
11
+	 * @var string
12
+	 */
13
+	protected $host;
14 14
 
15
-    /**
16
-     * @var int
17
-     */
18
-    protected $port;
15
+	/**
16
+	 * @var int
17
+	 */
18
+	protected $port;
19 19
 
20
-    /**
21
-     * Timeout (in seconds).
22
-     *
23
-     * @var int
24
-     */
25
-    protected $timeout;
20
+	/**
21
+	 * Timeout (in seconds).
22
+	 *
23
+	 * @var int
24
+	 */
25
+	protected $timeout;
26 26
 
27
-    /**
28
-     * @param null|string $host
29
-     * @param null|int $port
30
-     * @param int $timeout
31
-     */
32
-    public function __construct($host = null, $port = null, $timeout = 15)
33
-    {
34
-        $this->host = ($host) ? $host : ini_get('SMTP');
35
-        if (!$this->host) {
36
-            $this->host = 'localhost';
37
-        }
27
+	/**
28
+	 * @param null|string $host
29
+	 * @param null|int $port
30
+	 * @param int $timeout
31
+	 */
32
+	public function __construct($host = null, $port = null, $timeout = 15)
33
+	{
34
+		$this->host = ($host) ? $host : ini_get('SMTP');
35
+		if (!$this->host) {
36
+			$this->host = 'localhost';
37
+		}
38 38
         
39
-        $this->port = ($port) ? $port : ini_get('smtp_port');
40
-        if (!$this->port) {
41
-            $this->port = 25;
42
-        }
39
+		$this->port = ($port) ? $port : ini_get('smtp_port');
40
+		if (!$this->port) {
41
+			$this->port = 25;
42
+		}
43 43
 
44
-        $this->timeout = $timeout;
45
-    }
44
+		$this->timeout = $timeout;
45
+	}
46 46
 
47
-    /**
48
-     * @inheritdoc
49
-     *
50
-     * @return array
51
-     */
52
-    public function check()
53
-    {
54
-        $f = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
55
-        if (!$f) {
56
-            return array(
57
-                EnvironmentCheck::ERROR,
58
-                sprintf("Couldn't connect to SMTP on %s:%s (Error: %s %s)", $this->host, $this->port, $errno, $errstr)
59
-            );
60
-        }
47
+	/**
48
+	 * @inheritdoc
49
+	 *
50
+	 * @return array
51
+	 */
52
+	public function check()
53
+	{
54
+		$f = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
55
+		if (!$f) {
56
+			return array(
57
+				EnvironmentCheck::ERROR,
58
+				sprintf("Couldn't connect to SMTP on %s:%s (Error: %s %s)", $this->host, $this->port, $errno, $errstr)
59
+			);
60
+		}
61 61
 
62
-        fwrite($f, "HELO its_me\r\n");
63
-        $response = fread($f, 26);
64
-        if (substr($response, 0, 3) != '220') {
65
-            return array(
66
-                EnvironmentCheck::ERROR,
67
-                sprintf("Invalid mail server response: %s", $response)
68
-            );
69
-        }
62
+		fwrite($f, "HELO its_me\r\n");
63
+		$response = fread($f, 26);
64
+		if (substr($response, 0, 3) != '220') {
65
+			return array(
66
+				EnvironmentCheck::ERROR,
67
+				sprintf("Invalid mail server response: %s", $response)
68
+			);
69
+		}
70 70
 
71
-        return array(EnvironmentCheck::OK, '');
72
-    }
71
+		return array(EnvironmentCheck::OK, '');
72
+	}
73 73
 }
Please login to merge, or discard this patch.
code/checks/SolrIndexCheck.php 1 patch
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.
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/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.
tests/checks/FileWritableCheckTest.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,24 +5,24 @@
 block discarded – undo
5 5
  */
6 6
 class FileWritableCheckTest extends SapphireTest
7 7
 {
8
-    public function testCheckReportsWritablePaths()
9
-    {
10
-        $check = new FileWriteableCheck(TEMP_FOLDER);
8
+	public function testCheckReportsWritablePaths()
9
+	{
10
+		$check = new FileWriteableCheck(TEMP_FOLDER);
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
 
20
-    public function testCheckReportsNonWritablePaths()
21
-    {
22
-        $check = new FileWriteableCheck('/var');
20
+	public function testCheckReportsNonWritablePaths()
21
+	{
22
+		$check = new FileWriteableCheck('/var');
23 23
 
24
-        $result = $check->check();
24
+		$result = $check->check();
25 25
 
26
-        $this->assertEquals(EnvironmentCheck::ERROR, $result[0]);
27
-    }
26
+		$this->assertEquals(EnvironmentCheck::ERROR, $result[0]);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
tests/checks/HasClassCheckTest.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -5,27 +5,27 @@
 block discarded – undo
5 5
  */
6 6
 class HasClassCheckTest extends SapphireTest
7 7
 {
8
-    public function testCheckReportsMissingClasses()
9
-    {
10
-        $check = new HasClassCheck('foo');
8
+	public function testCheckReportsMissingClasses()
9
+	{
10
+		$check = new HasClassCheck('foo');
11 11
 
12
-        $expected = array(
13
-            EnvironmentCheck::ERROR,
14
-            'Class foo doesn\'t exist',
15
-        );
12
+		$expected = array(
13
+			EnvironmentCheck::ERROR,
14
+			'Class foo doesn\'t exist',
15
+		);
16 16
 
17
-        $this->assertEquals($expected, $check->check());
18
-    }
17
+		$this->assertEquals($expected, $check->check());
18
+	}
19 19
 
20
-    public function testCheckReportsFoundClasses()
21
-    {
22
-        $check = new HasClassCheck('stdClass');
20
+	public function testCheckReportsFoundClasses()
21
+	{
22
+		$check = new HasClassCheck('stdClass');
23 23
 
24
-        $expected = array(
25
-                EnvironmentCheck::OK,
26
-                'Class stdClass exists',
27
-        );
24
+		$expected = array(
25
+				EnvironmentCheck::OK,
26
+				'Class stdClass exists',
27
+		);
28 28
 
29
-        $this->assertEquals($expected, $check->check());
30
-    }
29
+		$this->assertEquals($expected, $check->check());
30
+	}
31 31
 }
Please login to merge, or discard this patch.
tests/checks/HasFunctionCheckTest.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -5,27 +5,27 @@
 block discarded – undo
5 5
  */
6 6
 class HasFunctionCheckTest extends SapphireTest
7 7
 {
8
-    public function testCheckReportsMissingFunctions()
9
-    {
10
-        $check = new HasFunctionCheck('foo');
8
+	public function testCheckReportsMissingFunctions()
9
+	{
10
+		$check = new HasFunctionCheck('foo');
11 11
 
12
-        $expected = array(
13
-            EnvironmentCheck::ERROR,
14
-            'foo() doesn\'t exist',
15
-        );
12
+		$expected = array(
13
+			EnvironmentCheck::ERROR,
14
+			'foo() doesn\'t exist',
15
+		);
16 16
 
17
-        $this->assertEquals($expected, $check->check());
18
-    }
17
+		$this->assertEquals($expected, $check->check());
18
+	}
19 19
 
20
-    public function testCheckReportsFoundFunctions()
21
-    {
22
-        $check = new HasFunctionCheck('class_exists');
20
+	public function testCheckReportsFoundFunctions()
21
+	{
22
+		$check = new HasFunctionCheck('class_exists');
23 23
 
24
-        $expected = array(
25
-            EnvironmentCheck::OK,
26
-            'class_exists() exists',
27
-        );
24
+		$expected = array(
25
+			EnvironmentCheck::OK,
26
+			'class_exists() exists',
27
+		);
28 28
 
29
-        $this->assertEquals($expected, $check->check());
30
-    }
29
+		$this->assertEquals($expected, $check->check());
30
+	}
31 31
 }
Please login to merge, or discard this patch.