Completed
Push — master ( c9c952...88a49a )
by Kenji
02:42 queued 11s
created
application/tests/_ci_phpunit_test/CIPHPUnitTest.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 		if (! defined('TESTPATH')) {
24 24
 			define('TESTPATH', APPPATH.'tests'.DIRECTORY_SEPARATOR);
25 25
 		}
26
-        // Current Bootstrap.php should define this, but in case it doesn't:
26
+		// Current Bootstrap.php should define this, but in case it doesn't:
27 27
 		if (! defined('CI_PHPUNIT_TESTPATH')) {
28 28
 			define('CI_PHPUNIT_TESTPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
29 29
 		}
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function init(array $autoload_dirs = null)
29 29
 	{
30
-		if (! defined('TESTPATH')) {
30
+		if ( ! defined('TESTPATH')) {
31 31
 			define('TESTPATH', APPPATH.'tests'.DIRECTORY_SEPARATOR);
32 32
 		}
33 33
         // Current Bootstrap.php should define this, but in case it doesn't:
34
-		if (! defined('CI_PHPUNIT_TESTPATH')) {
34
+		if ( ! defined('CI_PHPUNIT_TESTPATH')) {
35 35
 			define('CI_PHPUNIT_TESTPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
36 36
 		}
37 37
 
@@ -48,38 +48,38 @@  discard block
 block discarded – undo
48 48
 		$cwd_backup = getcwd();
49 49
 
50 50
 		// Load autoloader for ci-phpunit-test
51
-		require __DIR__ . '/autoloader.php';
51
+		require __DIR__.'/autoloader.php';
52 52
 
53
-		require TESTPATH . 'TestCase.php';
53
+		require TESTPATH.'TestCase.php';
54 54
 
55
-		$db_test_case_file = TESTPATH . 'DbTestCase.php';
55
+		$db_test_case_file = TESTPATH.'DbTestCase.php';
56 56
 		if (is_readable($db_test_case_file))
57 57
 		{
58 58
 			require $db_test_case_file;
59 59
 		}
60 60
 
61
-		$unit_test_case_file = TESTPATH . 'UnitTestCase.php';
61
+		$unit_test_case_file = TESTPATH.'UnitTestCase.php';
62 62
 		if (is_readable($unit_test_case_file))
63 63
 		{
64 64
 			require $unit_test_case_file;
65 65
 		}
66 66
 
67 67
 		// Replace a few Common functions
68
-		require __DIR__ . '/replacing/core/Common.php';
69
-		require BASEPATH . 'core/Common.php';
68
+		require __DIR__.'/replacing/core/Common.php';
69
+		require BASEPATH.'core/Common.php';
70 70
 
71 71
 		// Workaround for missing CodeIgniter's error handler
72 72
 		// See https://github.com/kenjis/ci-phpunit-test/issues/37
73 73
 		set_error_handler('_error_handler');
74 74
 
75 75
 		// Load new functions of CIPHPUnitTest
76
-		require __DIR__ . '/functions.php';
76
+		require __DIR__.'/functions.php';
77 77
 		// Load ci-phpunit-test CI_Loader
78
-		require __DIR__ . '/replacing/core/Loader.php';
78
+		require __DIR__.'/replacing/core/Loader.php';
79 79
 		// Load ci-phpunit-test CI_Input
80
-		require __DIR__ . '/replacing/core/Input.php';
80
+		require __DIR__.'/replacing/core/Input.php';
81 81
 		// Load ci-phpunit-test CI_Output
82
-		require __DIR__ . '/replacing/core/Output.php';
82
+		require __DIR__.'/replacing/core/Output.php';
83 83
 
84 84
 		// Change current directory
85 85
 		chdir(FCPATH);
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 		 *
95 95
 		 * And away we go...
96 96
 		 */
97
-		require __DIR__ . '/replacing/core/CodeIgniter.php';
97
+		require __DIR__.'/replacing/core/CodeIgniter.php';
98 98
 
99 99
 		// Create CodeIgniter instance
100
-		if (! self::wiredesignzHmvcInstalled())
100
+		if ( ! self::wiredesignzHmvcInstalled())
101 101
 		{
102 102
 			new CI_Controller();
103 103
 		}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public static function createCodeIgniterInstance($use_my_controller = false)
123 123
 	{
124
-		if (! self::wiredesignzHmvcInstalled())
124
+		if ( ! self::wiredesignzHmvcInstalled())
125 125
 		{
126 126
 			if ($use_my_controller && self::hasMyController())
127 127
 			{
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 		}
147 147
 
148 148
 		$my_controller_file =
149
-			APPPATH . 'core/' . config_item('subclass_prefix') . 'Controller.php';
149
+			APPPATH.'core/'.config_item('subclass_prefix').'Controller.php';
150 150
 
151 151
 		if (file_exists($my_controller_file))
152 152
 		{
153
-			$controller_class = config_item('subclass_prefix') . 'Controller';
153
+			$controller_class = config_item('subclass_prefix').'Controller';
154 154
 			if ( ! class_exists($controller_class))
155 155
 			{
156 156
 				require $my_controller_file;
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	protected static function replaceLoader()
183 183
 	{
184 184
 		$my_loader_file =
185
-			APPPATH . 'core/' . config_item('subclass_prefix') . 'Loader.php';
185
+			APPPATH.'core/'.config_item('subclass_prefix').'Loader.php';
186 186
 
187 187
 		if (file_exists($my_loader_file))
188 188
 		{
189
-			self::$loader_class = config_item('subclass_prefix') . 'Loader';
189
+			self::$loader_class = config_item('subclass_prefix').'Loader';
190 190
 			if ( ! class_exists(self::$loader_class))
191 191
 			{
192 192
 				require $my_loader_file;
@@ -205,19 +205,19 @@  discard block
 block discarded – undo
205 205
 
206 206
 	protected static function loadHelper($helper)
207 207
 	{
208
-		$my_helper_file = APPPATH . 'helpers/' . config_item('subclass_prefix') . $helper . '.php';
208
+		$my_helper_file = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php';
209 209
 		if (file_exists($my_helper_file))
210 210
 		{
211 211
 			require $my_helper_file;
212 212
 		}
213
-		require __DIR__ . '/replacing/helpers/' . $helper . '.php';
213
+		require __DIR__.'/replacing/helpers/'.$helper.'.php';
214 214
 	}
215 215
 
216 216
 	public static function setPatcherCacheDir($dir = null)
217 217
 	{
218 218
 		if ($dir === null)
219 219
 		{
220
-			$dir = CI_PHPUNIT_TESTPATH . 'tmp/cache';
220
+			$dir = CI_PHPUNIT_TESTPATH.'tmp/cache';
221 221
 		}
222 222
 
223 223
 		MonkeyPatchManager::setCacheDir(
Please login to merge, or discard this patch.
lib/Installer.php 1 patch
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -10,200 +10,200 @@
 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
-    private $from_composer = false;
18
-
19
-    public function __construct($argv)
20
-    {
21
-        $this->parse_args($argv);
22
-    }
23
-
24
-    private function parse_args($argv)
25
-    {
26
-        $argc = count($argv);
27
-
28
-        if ($argc === 1) {
29
-            return;
30
-        }
31
-
32
-        for ($i = 1; $i <= $argc; $i++) {
33
-            if (! isset($argv[$i])) {
34
-                break;
35
-            }
36
-
37
-            switch ($argv[$i]) {
38
-                // php install.php -s
39
-                case '-s':
40
-                    $this->silent = true;
41
-                    break;
42
-
43
-                // php install.php -a application
44
-                case '-a':
45
-                    if (is_dir($argv[$i+1])) {
46
-                        $this->app_dir = $argv[$i+1];
47
-                    } else {
48
-                        throw new Exception('No such directory: '.$argv[$i+1]);
49
-                    }
50
-                    $i++;
51
-                    break;
52
-
53
-                // php install.php -p public
54
-                case '-p':
55
-                    if (is_dir($argv[$i+1])) {
56
-                        $this->pub_dir = $argv[$i+1];
57
-                    } else {
58
-                        throw new Exception('No such directory: '.$argv[$i+1]);
59
-                    }
60
-                    $i++;
61
-                    break;
62
-
63
-                case '--from-composer':
64
-                    $this->from_composer = true;
65
-                    $i++;
66
-                    break;
67
-
68
-                default:
69
-                    throw new Exception('Unknown argument: '.$argv[$i]);
70
-            }
71
-        }
72
-    }
73
-
74
-    public function install()
75
-    {
76
-        $this->recursiveCopy(
77
-            dirname(dirname(__FILE__)).'/application/tests',
78
-            $this->app_dir.'/'.$this->test_dir
79
-        );
80
-        $this->fixPath();
81
-        if ($this->from_composer) {
82
-            $this->recursiveUnlink($this->app_dir.'/'.$this->test_dir.'/_ci_phpunit_test');
83
-        }
84
-    }
85
-
86
-    /**
87
-     * Fix paths in Bootstrap.php
88
-     */
89
-    private function fixPath()
90
-    {
91
-        $file = $this->app_dir.'/'.$this->test_dir.'/Bootstrap.php';
92
-        $contents = file_get_contents($file);
93
-
94
-        if (! file_exists('system')) {
95
-            if (file_exists('vendor/codeigniter/framework/system')) {
96
-                $contents = str_replace(
97
-                    '$system_path = \'../../system\';',
98
-                    '$system_path = \'../../vendor/codeigniter/framework/system\';',
99
-                    $contents
100
-                );
101
-            } else {
102
-                throw new Exception('Can\'t find "system" folder.');
103
-            }
104
-        }
105
-
106
-        if (! file_exists('index.php')) {
107
-            if (file_exists($this->pub_dir.'/index.php')) {
108
-                // CodeIgniter 3.0.6 and after
109
-                $contents = str_replace(
110
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);",
111
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').DIRECTORY_SEPARATOR);",
112
-                    $contents
113
-                );
114
-                // CodeIgniter 3.0.5 and before
115
-                $contents = str_replace(
116
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');",
117
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').'/');",
118
-                    $contents
119
-                );
120
-            } elseif (file_exists($this->app_dir.'/public/index.php')) {
121
-                // CodeIgniter 3.0.6 and after
122
-                $contents = str_replace(
123
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);",
124
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);",
125
-                    $contents
126
-                );
127
-                // CodeIgniter 3.0.5 and before
128
-                $contents = str_replace(
129
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');",
130
-                    "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');",
131
-                    $contents
132
-                );
133
-                if ($this->app_dir !== 'application') {
134
-                    $contents = str_replace(
135
-                        "\$application_folder = '../../application';",
136
-                        "\$application_folder = '../../{$this->app_dir}';",
137
-                        $contents
138
-                    );
139
-                }
140
-            } else {
141
-                throw new Exception('Can\'t find "index.php".');
142
-            }
143
-        }
144
-
145
-        file_put_contents($file, $contents);
146
-    }
147
-
148
-    public function update()
149
-    {
150
-        $target_dir = $this->app_dir.'/'.$this->test_dir.'/_ci_phpunit_test';
151
-        $this->recursiveUnlink($target_dir);
152
-        $this->recursiveCopy(
153
-            dirname(dirname(__FILE__)).'/application/tests/_ci_phpunit_test',
154
-            $target_dir
155
-        );
156
-    }
157
-
158
-    /**
159
-     * Recursive Copy
160
-     *
161
-     * @param string $src
162
-     * @param string $dst
163
-     */
164
-    private function recursiveCopy($src, $dst)
165
-    {
166
-        @mkdir($dst, 0755);
167
-
168
-        $iterator = new \RecursiveIteratorIterator(
169
-            new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS),
170
-            \RecursiveIteratorIterator::SELF_FIRST
171
-        );
172
-
173
-        foreach ($iterator as $file) {
174
-            if ($file->isDir()) {
175
-                @mkdir($dst.'/'.$iterator->getSubPathName());
176
-            } else {
177
-                $success = copy($file, $dst.'/'.$iterator->getSubPathName());
178
-                if ($success) {
179
-                    if (! $this->silent) {
180
-                        echo 'copied: '.$dst.'/'.$iterator->getSubPathName().PHP_EOL;
181
-                    }
182
-                }
183
-            }
184
-        }
185
-    }
186
-
187
-    /**
188
-     * Recursive Unlink
189
-     *
190
-     * @param string $dir
191
-     */
192
-    private function recursiveUnlink($dir)
193
-    {
194
-        $iterator = new \RecursiveIteratorIterator(
195
-            new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
196
-            \RecursiveIteratorIterator::CHILD_FIRST
197
-        );
198
-
199
-        foreach ($iterator as $file) {
200
-            if ($file->isDir()) {
201
-                rmdir($file);
202
-            } else {
203
-                unlink($file);
204
-            }
205
-        }
206
-
207
-        rmdir($dir);
208
-    }
13
+	private $silent = false;
14
+	private $app_dir = 'application';
15
+	private $pub_dir = 'public';
16
+	private $test_dir = 'tests';
17
+	private $from_composer = false;
18
+
19
+	public function __construct($argv)
20
+	{
21
+		$this->parse_args($argv);
22
+	}
23
+
24
+	private function parse_args($argv)
25
+	{
26
+		$argc = count($argv);
27
+
28
+		if ($argc === 1) {
29
+			return;
30
+		}
31
+
32
+		for ($i = 1; $i <= $argc; $i++) {
33
+			if (! isset($argv[$i])) {
34
+				break;
35
+			}
36
+
37
+			switch ($argv[$i]) {
38
+				// php install.php -s
39
+				case '-s':
40
+					$this->silent = true;
41
+					break;
42
+
43
+				// php install.php -a application
44
+				case '-a':
45
+					if (is_dir($argv[$i+1])) {
46
+						$this->app_dir = $argv[$i+1];
47
+					} else {
48
+						throw new Exception('No such directory: '.$argv[$i+1]);
49
+					}
50
+					$i++;
51
+					break;
52
+
53
+				// php install.php -p public
54
+				case '-p':
55
+					if (is_dir($argv[$i+1])) {
56
+						$this->pub_dir = $argv[$i+1];
57
+					} else {
58
+						throw new Exception('No such directory: '.$argv[$i+1]);
59
+					}
60
+					$i++;
61
+					break;
62
+
63
+				case '--from-composer':
64
+					$this->from_composer = true;
65
+					$i++;
66
+					break;
67
+
68
+				default:
69
+					throw new Exception('Unknown argument: '.$argv[$i]);
70
+			}
71
+		}
72
+	}
73
+
74
+	public function install()
75
+	{
76
+		$this->recursiveCopy(
77
+			dirname(dirname(__FILE__)).'/application/tests',
78
+			$this->app_dir.'/'.$this->test_dir
79
+		);
80
+		$this->fixPath();
81
+		if ($this->from_composer) {
82
+			$this->recursiveUnlink($this->app_dir.'/'.$this->test_dir.'/_ci_phpunit_test');
83
+		}
84
+	}
85
+
86
+	/**
87
+	 * Fix paths in Bootstrap.php
88
+	 */
89
+	private function fixPath()
90
+	{
91
+		$file = $this->app_dir.'/'.$this->test_dir.'/Bootstrap.php';
92
+		$contents = file_get_contents($file);
93
+
94
+		if (! file_exists('system')) {
95
+			if (file_exists('vendor/codeigniter/framework/system')) {
96
+				$contents = str_replace(
97
+					'$system_path = \'../../system\';',
98
+					'$system_path = \'../../vendor/codeigniter/framework/system\';',
99
+					$contents
100
+				);
101
+			} else {
102
+				throw new Exception('Can\'t find "system" folder.');
103
+			}
104
+		}
105
+
106
+		if (! file_exists('index.php')) {
107
+			if (file_exists($this->pub_dir.'/index.php')) {
108
+				// CodeIgniter 3.0.6 and after
109
+				$contents = str_replace(
110
+					"define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);",
111
+					"define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').DIRECTORY_SEPARATOR);",
112
+					$contents
113
+				);
114
+				// CodeIgniter 3.0.5 and before
115
+				$contents = str_replace(
116
+					"define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');",
117
+					"define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').'/');",
118
+					$contents
119
+				);
120
+			} elseif (file_exists($this->app_dir.'/public/index.php')) {
121
+				// CodeIgniter 3.0.6 and after
122
+				$contents = str_replace(
123
+					"define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);",
124
+					"define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);",
125
+					$contents
126
+				);
127
+				// CodeIgniter 3.0.5 and before
128
+				$contents = str_replace(
129
+					"define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');",
130
+					"define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');",
131
+					$contents
132
+				);
133
+				if ($this->app_dir !== 'application') {
134
+					$contents = str_replace(
135
+						"\$application_folder = '../../application';",
136
+						"\$application_folder = '../../{$this->app_dir}';",
137
+						$contents
138
+					);
139
+				}
140
+			} else {
141
+				throw new Exception('Can\'t find "index.php".');
142
+			}
143
+		}
144
+
145
+		file_put_contents($file, $contents);
146
+	}
147
+
148
+	public function update()
149
+	{
150
+		$target_dir = $this->app_dir.'/'.$this->test_dir.'/_ci_phpunit_test';
151
+		$this->recursiveUnlink($target_dir);
152
+		$this->recursiveCopy(
153
+			dirname(dirname(__FILE__)).'/application/tests/_ci_phpunit_test',
154
+			$target_dir
155
+		);
156
+	}
157
+
158
+	/**
159
+	 * Recursive Copy
160
+	 *
161
+	 * @param string $src
162
+	 * @param string $dst
163
+	 */
164
+	private function recursiveCopy($src, $dst)
165
+	{
166
+		@mkdir($dst, 0755);
167
+
168
+		$iterator = new \RecursiveIteratorIterator(
169
+			new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS),
170
+			\RecursiveIteratorIterator::SELF_FIRST
171
+		);
172
+
173
+		foreach ($iterator as $file) {
174
+			if ($file->isDir()) {
175
+				@mkdir($dst.'/'.$iterator->getSubPathName());
176
+			} else {
177
+				$success = copy($file, $dst.'/'.$iterator->getSubPathName());
178
+				if ($success) {
179
+					if (! $this->silent) {
180
+						echo 'copied: '.$dst.'/'.$iterator->getSubPathName().PHP_EOL;
181
+					}
182
+				}
183
+			}
184
+		}
185
+	}
186
+
187
+	/**
188
+	 * Recursive Unlink
189
+	 *
190
+	 * @param string $dir
191
+	 */
192
+	private function recursiveUnlink($dir)
193
+	{
194
+		$iterator = new \RecursiveIteratorIterator(
195
+			new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
196
+			\RecursiveIteratorIterator::CHILD_FIRST
197
+		);
198
+
199
+		foreach ($iterator as $file) {
200
+			if ($file->isDir()) {
201
+				rmdir($file);
202
+			} else {
203
+				unlink($file);
204
+			}
205
+		}
206
+
207
+		rmdir($dir);
208
+	}
209 209
 }
Please login to merge, or discard this patch.
application/tests/Bootstrap.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  * NOTE: If you change these, also change the error_reporting() code below
55 55
  */
56 56
 // This `if` statemant is needed for @runInSeparateProcess
57
-if (! defined('ENVIRONMENT'))
57
+if ( ! defined('ENVIRONMENT'))
58 58
 {
59 59
 	define('ENVIRONMENT', 'testing');
60 60
 }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
233 233
 
234 234
 	// Path to the test directory containing all the test files.
235
-	define('TESTPATH', __dir__.DIRECTORY_SEPARATOR);  // Should be the folder this `Bootstrap.php` file is in.
235
+	define('TESTPATH', __dir__.DIRECTORY_SEPARATOR); // Should be the folder this `Bootstrap.php` file is in.
236 236
 
237 237
 	// Path to the system directory
238 238
 	define('BASEPATH', $system_path);
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
315 315
 
316 316
 	// Path to the ci-phpunit-test directory
317
-	if (is_file(TESTPATH . '_ci_phpunit_test' . DIRECTORY_SEPARATOR . 'CIPHPUnitTest.php'))
317
+	if (is_file(TESTPATH.'_ci_phpunit_test'.DIRECTORY_SEPARATOR.'CIPHPUnitTest.php'))
318 318
 	{
319
-		define('CI_PHPUNIT_TESTPATH', TESTPATH . '_ci_phpunit_test' . DIRECTORY_SEPARATOR);
319
+		define('CI_PHPUNIT_TESTPATH', TESTPATH.'_ci_phpunit_test'.DIRECTORY_SEPARATOR);
320 320
 	}
321 321
 	else
322 322
 	{
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 define('TESTPATH', APPPATH.'tests'.DIRECTORY_SEPARATOR);
383 383
 */
384 384
 
385
-require CI_PHPUNIT_TESTPATH . '/CIPHPUnitTest.php';
385
+require CI_PHPUNIT_TESTPATH.'/CIPHPUnitTest.php';
386 386
 
387 387
 CIPHPUnitTest::init();
388 388
 // Or you can set directories for autoloading
Please login to merge, or discard this patch.