Completed
Pull Request — master (#313)
by Kenji
02:12
created
application/tests/_ci_phpunit_test/patcher/Cache.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -251,10 +251,10 @@
 block discarded – undo
251 251
 	}
252 252
 
253 253
 	/**
254
-	* Recursive Unlink
255
-	*
256
-	* @param string $dir
257
-	*/
254
+	 * Recursive Unlink
255
+	 *
256
+	 * @param string $dir
257
+	 */
258 258
 	protected static function recursiveUnlink($dir)
259 259
 	{
260 260
 		if (! is_dir($dir))
Please login to merge, or discard this patch.
application/tests/_ci_phpunit_test/patcher/MonkeyPatch.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,12 +37,12 @@
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	/**
40
-     * Patch on constant
41
-     * 
42
-     * @param type $constant
43
-     * @param type $value
44
-     * @param type $class_method
45
-     */
40
+	 * Patch on constant
41
+	 * 
42
+	 * @param type $constant
43
+	 * @param type $value
44
+	 * @param type $class_method
45
+	 */
46 46
 	public static function patchConstant($constant, $value, $class_method = null)
47 47
 	{
48 48
 		ConstProxy::patch($constant, $value, $class_method);
Please login to merge, or discard this patch.
lib/Installer.php 1 patch
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -10,191 +10,191 @@
 block discarded – undo
10 10
 
11 11
 class Installer
12 12
 {
13
-    private $silent = false;
14
-    private $app_dir = 'application';
15
-    private $pub_dir = 'public';
16
-    private $test_dir = 'tests';
17
-
18
-    public function __construct($argv)
19
-    {
20
-        $this->parse_args($argv);
21
-    }
22
-
23
-    private function parse_args($argv)
24
-    {
25
-        $argc = count($argv);
26
-
27
-        if ($argc === 1) {
28
-            return;
29
-        }
30
-
31
-        for ($i = 1; $i <= $argc; $i++) {
32
-            if (! isset($argv[$i])) {
33
-                break;
34
-            }
35
-
36
-            switch ($argv[$i]) {
37
-                // php install.php -s
38
-                case '-s':
39
-                    $this->silent = true;
40
-                    break;
41
-
42
-                // php install.php -a application
43
-                case '-a':
44
-                    if (is_dir($argv[$i+1])) {
45
-                        $this->app_dir = $argv[$i+1];
46
-                    } else {
47
-                        throw new Exception('No such directory: '.$argv[$i+1]);
48
-                    }
49
-                    $i++;
50
-                    break;
51
-
52
-                // php install.php -p public
53
-                case '-p':
54
-                    if (is_dir($argv[$i+1])) {
55
-                        $this->pub_dir = $argv[$i+1];
56
-                    } else {
57
-                        throw new Exception('No such directory: '.$argv[$i+1]);
58
-                    }
59
-                    $i++;
60
-                    break;
61
-
62
-                default:
63
-                    throw new Exception('Unknown argument: '.$argv[$i]);
64
-            }
65
-        }
66
-    }
67
-
68
-    public function install()
69
-    {
70
-        $this->recursiveCopy(
71
-            dirname(dirname(__FILE__)).'/application/tests',
72
-            $this->app_dir.'/'.$this->test_dir
73
-        );
74
-        $this->fixPath();
75
-    }
76
-
77
-    /**
78
-     * Fix paths in Bootstrap.php
79
-     */
80
-    private function fixPath()
81
-    {
82
-        $file = $this->app_dir.'/'.$this->test_dir.'/Bootstrap.php';
83
-        $contents = file_get_contents($file);
84
-
85
-        if (! file_exists('system')) {
86
-            if (file_exists('vendor/codeigniter/framework/system')) {
87
-                $contents = str_replace(
88
-                    '$system_path = \'../../system\';',
89
-                    '$system_path = \'../../vendor/codeigniter/framework/system\';',
90
-                    $contents
91
-                );
92
-            } else {
93
-                throw new Exception('Can\'t find "system" folder.');
94
-            }
95
-        }
96
-
97
-        if (! file_exists('index.php')) {
98
-            if (file_exists($this->pub_dir.'/index.php')) {
99
-                // CodeIgniter 3.0.6 and after
100
-                $contents = str_replace(
101
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);",
102
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').DIRECTORY_SEPARATOR);",
103
-                    $contents
104
-                );
105
-                // CodeIgniter 3.0.5 and before
106
-                $contents = str_replace(
107
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');",
108
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').'/');",
109
-                    $contents
110
-                );
111
-            } elseif (file_exists($this->app_dir.'/public/index.php')) {
112
-                // CodeIgniter 3.0.6 and after
113
-                $contents = str_replace(
114
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);",
115
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);",
116
-                    $contents
117
-                );
118
-                // CodeIgniter 3.0.5 and before
119
-                $contents = str_replace(
120
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');",
121
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');",
122
-                    $contents
123
-                );
124
-                if ($this->app_dir !== 'application') {
125
-                    $contents = str_replace(
126
-                        "\$application_folder = '../../application';",
127
-                        "\$application_folder = '../../{$this->app_dir}';",
128
-                        $contents
129
-                    );
130
-                }
131
-            } else {
132
-                throw new Exception('Can\'t find "index.php".');
133
-            }
134
-        }
135
-
136
-        file_put_contents($file, $contents);
137
-    }
138
-
139
-    public function update()
140
-    {
141
-        $target_dir = $this->app_dir.'/'.$this->test_dir.'/_ci_phpunit_test';
142
-        $this->recursiveUnlink($target_dir);
143
-        $this->recursiveCopy(
144
-            dirname(dirname(__FILE__)).'/application/tests/_ci_phpunit_test',
145
-            $target_dir
146
-        );
147
-    }
148
-
149
-    /**
150
-     * Recursive Copy
151
-     *
152
-     * @param string $src
153
-     * @param string $dst
154
-     */
155
-    private function recursiveCopy($src, $dst)
156
-    {
157
-        @mkdir($dst, 0755);
158
-
159
-        $iterator = new \RecursiveIteratorIterator(
160
-            new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS),
161
-            \RecursiveIteratorIterator::SELF_FIRST
162
-        );
163
-
164
-        foreach ($iterator as $file) {
165
-            if ($file->isDir()) {
166
-                @mkdir($dst.'/'.$iterator->getSubPathName());
167
-            } else {
168
-                $success = copy($file, $dst.'/'.$iterator->getSubPathName());
169
-                if ($success) {
170
-                    if (! $this->silent) {
171
-                        echo 'copied: '.$dst.'/'.$iterator->getSubPathName().PHP_EOL;
172
-                    }
173
-                }
174
-            }
175
-        }
176
-    }
177
-
178
-    /**
179
-     * Recursive Unlink
180
-     *
181
-     * @param string $dir
182
-     */
183
-    private function recursiveUnlink($dir)
184
-    {
185
-        $iterator = new \RecursiveIteratorIterator(
186
-            new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
187
-            \RecursiveIteratorIterator::CHILD_FIRST
188
-        );
189
-
190
-        foreach ($iterator as $file) {
191
-            if ($file->isDir()) {
192
-                rmdir($file);
193
-            } else {
194
-                unlink($file);
195
-            }
196
-        }
197
-
198
-        rmdir($dir);
199
-    }
13
+	private $silent = false;
14
+	private $app_dir = 'application';
15
+	private $pub_dir = 'public';
16
+	private $test_dir = 'tests';
17
+
18
+	public function __construct($argv)
19
+	{
20
+		$this->parse_args($argv);
21
+	}
22
+
23
+	private function parse_args($argv)
24
+	{
25
+		$argc = count($argv);
26
+
27
+		if ($argc === 1) {
28
+			return;
29
+		}
30
+
31
+		for ($i = 1; $i <= $argc; $i++) {
32
+			if (! isset($argv[$i])) {
33
+				break;
34
+			}
35
+
36
+			switch ($argv[$i]) {
37
+				// php install.php -s
38
+				case '-s':
39
+					$this->silent = true;
40
+					break;
41
+
42
+				// php install.php -a application
43
+				case '-a':
44
+					if (is_dir($argv[$i+1])) {
45
+						$this->app_dir = $argv[$i+1];
46
+					} else {
47
+						throw new Exception('No such directory: '.$argv[$i+1]);
48
+					}
49
+					$i++;
50
+					break;
51
+
52
+				// php install.php -p public
53
+				case '-p':
54
+					if (is_dir($argv[$i+1])) {
55
+						$this->pub_dir = $argv[$i+1];
56
+					} else {
57
+						throw new Exception('No such directory: '.$argv[$i+1]);
58
+					}
59
+					$i++;
60
+					break;
61
+
62
+				default:
63
+					throw new Exception('Unknown argument: '.$argv[$i]);
64
+			}
65
+		}
66
+	}
67
+
68
+	public function install()
69
+	{
70
+		$this->recursiveCopy(
71
+			dirname(dirname(__FILE__)).'/application/tests',
72
+			$this->app_dir.'/'.$this->test_dir
73
+		);
74
+		$this->fixPath();
75
+	}
76
+
77
+	/**
78
+	 * Fix paths in Bootstrap.php
79
+	 */
80
+	private function fixPath()
81
+	{
82
+		$file = $this->app_dir.'/'.$this->test_dir.'/Bootstrap.php';
83
+		$contents = file_get_contents($file);
84
+
85
+		if (! file_exists('system')) {
86
+			if (file_exists('vendor/codeigniter/framework/system')) {
87
+				$contents = str_replace(
88
+					'$system_path = \'../../system\';',
89
+					'$system_path = \'../../vendor/codeigniter/framework/system\';',
90
+					$contents
91
+				);
92
+			} else {
93
+				throw new Exception('Can\'t find "system" folder.');
94
+			}
95
+		}
96
+
97
+		if (! file_exists('index.php')) {
98
+			if (file_exists($this->pub_dir.'/index.php')) {
99
+				// CodeIgniter 3.0.6 and after
100
+				$contents = str_replace(
101
+					"define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);",
102
+					"define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').DIRECTORY_SEPARATOR);",
103
+					$contents
104
+				);
105
+				// CodeIgniter 3.0.5 and before
106
+				$contents = str_replace(
107
+					"define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');",
108
+					"define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').'/');",
109
+					$contents
110
+				);
111
+			} elseif (file_exists($this->app_dir.'/public/index.php')) {
112
+				// CodeIgniter 3.0.6 and after
113
+				$contents = str_replace(
114
+					"define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);",
115
+					"define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);",
116
+					$contents
117
+				);
118
+				// CodeIgniter 3.0.5 and before
119
+				$contents = str_replace(
120
+					"define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');",
121
+					"define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');",
122
+					$contents
123
+				);
124
+				if ($this->app_dir !== 'application') {
125
+					$contents = str_replace(
126
+						"\$application_folder = '../../application';",
127
+						"\$application_folder = '../../{$this->app_dir}';",
128
+						$contents
129
+					);
130
+				}
131
+			} else {
132
+				throw new Exception('Can\'t find "index.php".');
133
+			}
134
+		}
135
+
136
+		file_put_contents($file, $contents);
137
+	}
138
+
139
+	public function update()
140
+	{
141
+		$target_dir = $this->app_dir.'/'.$this->test_dir.'/_ci_phpunit_test';
142
+		$this->recursiveUnlink($target_dir);
143
+		$this->recursiveCopy(
144
+			dirname(dirname(__FILE__)).'/application/tests/_ci_phpunit_test',
145
+			$target_dir
146
+		);
147
+	}
148
+
149
+	/**
150
+	 * Recursive Copy
151
+	 *
152
+	 * @param string $src
153
+	 * @param string $dst
154
+	 */
155
+	private function recursiveCopy($src, $dst)
156
+	{
157
+		@mkdir($dst, 0755);
158
+
159
+		$iterator = new \RecursiveIteratorIterator(
160
+			new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS),
161
+			\RecursiveIteratorIterator::SELF_FIRST
162
+		);
163
+
164
+		foreach ($iterator as $file) {
165
+			if ($file->isDir()) {
166
+				@mkdir($dst.'/'.$iterator->getSubPathName());
167
+			} else {
168
+				$success = copy($file, $dst.'/'.$iterator->getSubPathName());
169
+				if ($success) {
170
+					if (! $this->silent) {
171
+						echo 'copied: '.$dst.'/'.$iterator->getSubPathName().PHP_EOL;
172
+					}
173
+				}
174
+			}
175
+		}
176
+	}
177
+
178
+	/**
179
+	 * Recursive Unlink
180
+	 *
181
+	 * @param string $dir
182
+	 */
183
+	private function recursiveUnlink($dir)
184
+	{
185
+		$iterator = new \RecursiveIteratorIterator(
186
+			new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
187
+			\RecursiveIteratorIterator::CHILD_FIRST
188
+		);
189
+
190
+		foreach ($iterator as $file) {
191
+			if ($file->isDir()) {
192
+				rmdir($file);
193
+			} else {
194
+				unlink($file);
195
+			}
196
+		}
197
+
198
+		rmdir($dir);
199
+	}
200 200
 }
Please login to merge, or discard this patch.
application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@
 block discarded – undo
10 10
 
11 11
 class CIPHPUnitTestRequest
12 12
 {
13
-    /**
14
-     * @var TestCase
15
-     */
13
+	/**
14
+	 * @var TestCase
15
+	 */
16 16
 	protected $testCase;
17 17
 
18 18
 	/**
Please login to merge, or discard this patch.
application/tests/_ci_phpunit_test/TestSuiteProvider.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 // Support PHPUnit 6.0
46 46
 if (! class_exists('PHPUnit_Util_Configuration')) {
47
-    class_alias('PHPUnit\Util\Configuration', 'PHPUnit_Util_Configuration');
47
+	class_alias('PHPUnit\Util\Configuration', 'PHPUnit_Util_Configuration');
48 48
 }
49 49
 
50 50
 /**
@@ -57,71 +57,71 @@  discard block
 block discarded – undo
57 57
  */
58 58
 final class TestSuiteProvider
59 59
 {
60
-    /**
61
-     * phpunit configuration file
62
-     *
63
-     * @var string
64
-     */
65
-    private static $file;
60
+	/**
61
+	 * phpunit configuration file
62
+	 *
63
+	 * @var string
64
+	 */
65
+	private static $file;
66 66
 
67
-    /**
68
-     * constructor
69
-     */
70
-    private function __construct() {}
67
+	/**
68
+	 * constructor
69
+	 */
70
+	private function __construct() {}
71 71
 
72
-    /**
73
-     * set the phpunit configuration file
74
-     *
75
-     * @param string $file the path or filename of the phunit configuration file
76
-     */
77
-    public static function setConfigurationFile($file)
78
-    {
79
-        static::$file = $file;
80
-    }
72
+	/**
73
+	 * set the phpunit configuration file
74
+	 *
75
+	 * @param string $file the path or filename of the phunit configuration file
76
+	 */
77
+	public static function setConfigurationFile($file)
78
+	{
79
+		static::$file = $file;
80
+	}
81 81
 
82
-    /**
83
-     * get the phpunit test suite instance
84
-     *
85
-     * @return PHPUnit_Framework_TestSuite returns the phpunit test suite instance
86
-     * @throws FileNotFoundException       if the file is not found
87
-     */
88
-    public static function suite()
89
-    {
90
-        $file = static::checkConfigurationFile(
91
-            static::getConfigurationFile()
92
-        );
82
+	/**
83
+	 * get the phpunit test suite instance
84
+	 *
85
+	 * @return PHPUnit_Framework_TestSuite returns the phpunit test suite instance
86
+	 * @throws FileNotFoundException       if the file is not found
87
+	 */
88
+	public static function suite()
89
+	{
90
+		$file = static::checkConfigurationFile(
91
+			static::getConfigurationFile()
92
+		);
93 93
 
94
-        return PHPUnit_Util_Configuration::getInstance($file)
95
-            ->getTestSuiteConfiguration();
96
-    }
94
+		return PHPUnit_Util_Configuration::getInstance($file)
95
+			->getTestSuiteConfiguration();
96
+	}
97 97
 
98
-    /**
99
-     * get the phpunit configuration file
100
-     *
101
-     * @return string
102
-     */
103
-    private static function getConfigurationFile()
104
-    {
105
-        static::$file = isset(static::$file)
106
-            ? static::$file
107
-            : TESTPATH.'phpunit.xml';
98
+	/**
99
+	 * get the phpunit configuration file
100
+	 *
101
+	 * @return string
102
+	 */
103
+	private static function getConfigurationFile()
104
+	{
105
+		static::$file = isset(static::$file)
106
+			? static::$file
107
+			: TESTPATH.'phpunit.xml';
108 108
 
109
-        return static::$file;
110
-    }
109
+		return static::$file;
110
+	}
111 111
 
112
-    /**
113
-     * check the given file
114
-     *
115
-     * @param  string                $file file to check
116
-     * @return string                returns the file if it is valid
117
-     * @throws FileNotFoundException if the file is not found
118
-     */
119
-    private static function checkConfigurationFile($file)
120
-    {
121
-        if (!file_exists($file)) {
122
-            throw new \RuntimeException("The requested phpunit configuration was not found at $file");
123
-        }
112
+	/**
113
+	 * check the given file
114
+	 *
115
+	 * @param  string                $file file to check
116
+	 * @return string                returns the file if it is valid
117
+	 * @throws FileNotFoundException if the file is not found
118
+	 */
119
+	private static function checkConfigurationFile($file)
120
+	{
121
+		if (!file_exists($file)) {
122
+			throw new \RuntimeException("The requested phpunit configuration was not found at $file");
123
+		}
124 124
 
125
-        return $file;
126
-    }
125
+		return $file;
126
+	}
127 127
 }
Please login to merge, or discard this patch.