Completed
Push — master ( ce859b...64aab5 )
by Kenji
02:48
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.
application/tests/_ci_phpunit_test/TestSuiteProvider.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -52,71 +52,71 @@
 block discarded – undo
52 52
  */
53 53
 final class TestSuiteProvider
54 54
 {
55
-    /**
56
-     * phpunit configuration file
57
-     *
58
-     * @var string
59
-     */
60
-    private static $file;
55
+	/**
56
+	 * phpunit configuration file
57
+	 *
58
+	 * @var string
59
+	 */
60
+	private static $file;
61 61
 
62
-    /**
63
-     * constructor
64
-     */
65
-    private function __construct() {}
62
+	/**
63
+	 * constructor
64
+	 */
65
+	private function __construct() {}
66 66
 
67
-    /**
68
-     * set the phpunit configuration file
69
-     *
70
-     * @param string $file the path or filename of the phunit configuration file
71
-     */
72
-    public static function setConfigurationFile($file)
73
-    {
74
-        static::$file = $file;
75
-    }
67
+	/**
68
+	 * set the phpunit configuration file
69
+	 *
70
+	 * @param string $file the path or filename of the phunit configuration file
71
+	 */
72
+	public static function setConfigurationFile($file)
73
+	{
74
+		static::$file = $file;
75
+	}
76 76
 
77
-    /**
78
-     * get the phpunit test suite instance
79
-     *
80
-     * @return PHPUnit_Framework_TestSuite returns the phpunit test suite instance
81
-     * @throws FileNotFoundException       if the file is not found
82
-     */
83
-    public static function suite()
84
-    {
85
-        $file = static::checkConfigurationFile(
86
-            static::getConfigurationFile()
87
-        );
77
+	/**
78
+	 * get the phpunit test suite instance
79
+	 *
80
+	 * @return PHPUnit_Framework_TestSuite returns the phpunit test suite instance
81
+	 * @throws FileNotFoundException       if the file is not found
82
+	 */
83
+	public static function suite()
84
+	{
85
+		$file = static::checkConfigurationFile(
86
+			static::getConfigurationFile()
87
+		);
88 88
 
89
-        return PHPUnit_Util_Configuration::getInstance($file)
90
-            ->getTestSuiteConfiguration();
91
-    }
89
+		return PHPUnit_Util_Configuration::getInstance($file)
90
+			->getTestSuiteConfiguration();
91
+	}
92 92
 
93
-    /**
94
-     * get the phpunit configuration file
95
-     *
96
-     * @return string
97
-     */
98
-    private static function getConfigurationFile()
99
-    {
100
-        static::$file = isset(static::$file)
101
-            ? static::$file
102
-            : TESTPATH.'phpunit.xml';
93
+	/**
94
+	 * get the phpunit configuration file
95
+	 *
96
+	 * @return string
97
+	 */
98
+	private static function getConfigurationFile()
99
+	{
100
+		static::$file = isset(static::$file)
101
+			? static::$file
102
+			: TESTPATH.'phpunit.xml';
103 103
 
104
-        return static::$file;
105
-    }
104
+		return static::$file;
105
+	}
106 106
 
107
-    /**
108
-     * check the given file
109
-     *
110
-     * @param  string                $file file to check
111
-     * @return string                returns the file if it is valid
112
-     * @throws FileNotFoundException if the file is not found
113
-     */
114
-    private static function checkConfigurationFile($file)
115
-    {
116
-        if (!file_exists($file)) {
117
-            throw new \RuntimeException("The requested phpunit configuration was not found at $file");
118
-        }
107
+	/**
108
+	 * check the given file
109
+	 *
110
+	 * @param  string                $file file to check
111
+	 * @return string                returns the file if it is valid
112
+	 * @throws FileNotFoundException if the file is not found
113
+	 */
114
+	private static function checkConfigurationFile($file)
115
+	{
116
+		if (!file_exists($file)) {
117
+			throw new \RuntimeException("The requested phpunit configuration was not found at $file");
118
+		}
119 119
 
120
-        return $file;
121
-    }
120
+		return $file;
121
+	}
122 122
 }
Please login to merge, or discard this patch.
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(__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(__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(__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(__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.