@@ -52,71 +52,71 @@ |
||
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 | - : APPPATH.'tests/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 | + : APPPATH.'tests/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 | } |
@@ -251,10 +251,10 @@ |
||
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)) |
@@ -37,12 +37,12 @@ |
||
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); |
@@ -15,17 +15,17 @@ |
||
15 | 15 | |
16 | 16 | // php install.php -s |
17 | 17 | if (isset($argv[1]) && $argv[1] === '-s') { |
18 | - $silent = true; |
|
18 | + $silent = true; |
|
19 | 19 | |
20 | - // php install.php -s app |
|
21 | - if (isset($argv[2]) && is_dir($argv[2])) { |
|
22 | - $app_dir = $argv[2]; |
|
23 | - } |
|
20 | + // php install.php -s app |
|
21 | + if (isset($argv[2]) && is_dir($argv[2])) { |
|
22 | + $app_dir = $argv[2]; |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // php install.php app |
27 | 27 | if (isset($argv[1]) && is_dir($argv[1])) { |
28 | - $app_dir = $argv[1]; |
|
28 | + $app_dir = $argv[1]; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | $installer = new Installer($silent); |
@@ -15,17 +15,17 @@ |
||
15 | 15 | |
16 | 16 | // php update.php -s |
17 | 17 | if (isset($argv[1]) && $argv[1] === '-s') { |
18 | - $silent = true; |
|
18 | + $silent = true; |
|
19 | 19 | |
20 | - // php update.php -s app |
|
21 | - if (isset($argv[2]) && is_dir($argv[2])) { |
|
22 | - $app_dir = $argv[2]; |
|
23 | - } |
|
20 | + // php update.php -s app |
|
21 | + if (isset($argv[2]) && is_dir($argv[2])) { |
|
22 | + $app_dir = $argv[2]; |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // php update.php app |
27 | 27 | if (isset($argv[1]) && is_dir($argv[1])) { |
28 | - $app_dir = $argv[1]; |
|
28 | + $app_dir = $argv[1]; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | $installer = new Installer($silent); |
@@ -10,145 +10,145 @@ |
||
10 | 10 | |
11 | 11 | class Installer |
12 | 12 | { |
13 | - const TEST_FOLDER = 'tests'; |
|
13 | + const TEST_FOLDER = 'tests'; |
|
14 | 14 | |
15 | - private $silent = false; |
|
15 | + private $silent = false; |
|
16 | 16 | |
17 | - public function __construct($silent = false) |
|
18 | - { |
|
19 | - $this->silent = $silent; |
|
20 | - } |
|
17 | + public function __construct($silent = false) |
|
18 | + { |
|
19 | + $this->silent = $silent; |
|
20 | + } |
|
21 | 21 | |
22 | - public function install($app = 'application') |
|
23 | - { |
|
24 | - $this->recursiveCopy( |
|
25 | - dirname(__FILE__) . '/application/tests', |
|
26 | - $app . '/' . static::TEST_FOLDER |
|
27 | - ); |
|
28 | - $this->fixPath($app); |
|
29 | - } |
|
22 | + public function install($app = 'application') |
|
23 | + { |
|
24 | + $this->recursiveCopy( |
|
25 | + dirname(__FILE__) . '/application/tests', |
|
26 | + $app . '/' . static::TEST_FOLDER |
|
27 | + ); |
|
28 | + $this->fixPath($app); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Fix paths in Bootstrap.php |
|
33 | - */ |
|
34 | - private function fixPath($app = 'application') |
|
35 | - { |
|
36 | - $file = $app . '/' . static::TEST_FOLDER . '/Bootstrap.php'; |
|
37 | - $contents = file_get_contents($file); |
|
31 | + /** |
|
32 | + * Fix paths in Bootstrap.php |
|
33 | + */ |
|
34 | + private function fixPath($app = 'application') |
|
35 | + { |
|
36 | + $file = $app . '/' . static::TEST_FOLDER . '/Bootstrap.php'; |
|
37 | + $contents = file_get_contents($file); |
|
38 | 38 | |
39 | - if (! file_exists('system')) { |
|
40 | - if (file_exists('vendor/codeigniter/framework/system')) { |
|
41 | - $contents = str_replace( |
|
42 | - '$system_path = \'../../system\';', |
|
43 | - '$system_path = \'../../vendor/codeigniter/framework/system\';', |
|
44 | - $contents |
|
45 | - ); |
|
46 | - } else { |
|
47 | - throw new Exception('Can\'t find "system" folder.'); |
|
48 | - } |
|
49 | - } |
|
39 | + if (! file_exists('system')) { |
|
40 | + if (file_exists('vendor/codeigniter/framework/system')) { |
|
41 | + $contents = str_replace( |
|
42 | + '$system_path = \'../../system\';', |
|
43 | + '$system_path = \'../../vendor/codeigniter/framework/system\';', |
|
44 | + $contents |
|
45 | + ); |
|
46 | + } else { |
|
47 | + throw new Exception('Can\'t find "system" folder.'); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - if (! file_exists('index.php')) { |
|
52 | - if (file_exists('public/index.php')) { |
|
53 | - // CodeIgniter 3.0.6 and after |
|
54 | - $contents = str_replace( |
|
55 | - "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
|
56 | - "define('FCPATH', realpath(dirname(__FILE__).'/../../public').DIRECTORY_SEPARATOR);", |
|
57 | - $contents |
|
58 | - ); |
|
59 | - // CodeIgniter 3.0.5 and before |
|
60 | - $contents = str_replace( |
|
61 | - "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
|
62 | - "define('FCPATH', realpath(dirname(__FILE__).'/../../public').'/');", |
|
63 | - $contents |
|
64 | - ); |
|
65 | - } elseif (file_exists($app . '/public/index.php')) { |
|
66 | - // CodeIgniter 3.0.6 and after |
|
67 | - $contents = str_replace( |
|
68 | - "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
|
69 | - "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);", |
|
70 | - $contents |
|
71 | - ); |
|
72 | - // CodeIgniter 3.0.5 and before |
|
73 | - $contents = str_replace( |
|
74 | - "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
|
75 | - "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');", |
|
76 | - $contents |
|
77 | - ); |
|
78 | - if ($app != 'application') { |
|
79 | - $contents = str_replace( |
|
80 | - "\$application_folder = '../../application';", |
|
81 | - "\$application_folder = '../../{$app}';", |
|
82 | - $contents |
|
83 | - ); |
|
84 | - } |
|
85 | - } else { |
|
86 | - throw new Exception('Can\'t find "index.php".'); |
|
87 | - } |
|
88 | - } |
|
51 | + if (! file_exists('index.php')) { |
|
52 | + if (file_exists('public/index.php')) { |
|
53 | + // CodeIgniter 3.0.6 and after |
|
54 | + $contents = str_replace( |
|
55 | + "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
|
56 | + "define('FCPATH', realpath(dirname(__FILE__).'/../../public').DIRECTORY_SEPARATOR);", |
|
57 | + $contents |
|
58 | + ); |
|
59 | + // CodeIgniter 3.0.5 and before |
|
60 | + $contents = str_replace( |
|
61 | + "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
|
62 | + "define('FCPATH', realpath(dirname(__FILE__).'/../../public').'/');", |
|
63 | + $contents |
|
64 | + ); |
|
65 | + } elseif (file_exists($app . '/public/index.php')) { |
|
66 | + // CodeIgniter 3.0.6 and after |
|
67 | + $contents = str_replace( |
|
68 | + "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
|
69 | + "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);", |
|
70 | + $contents |
|
71 | + ); |
|
72 | + // CodeIgniter 3.0.5 and before |
|
73 | + $contents = str_replace( |
|
74 | + "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
|
75 | + "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');", |
|
76 | + $contents |
|
77 | + ); |
|
78 | + if ($app != 'application') { |
|
79 | + $contents = str_replace( |
|
80 | + "\$application_folder = '../../application';", |
|
81 | + "\$application_folder = '../../{$app}';", |
|
82 | + $contents |
|
83 | + ); |
|
84 | + } |
|
85 | + } else { |
|
86 | + throw new Exception('Can\'t find "index.php".'); |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - file_put_contents($file, $contents); |
|
91 | - } |
|
90 | + file_put_contents($file, $contents); |
|
91 | + } |
|
92 | 92 | |
93 | - public function update($app = 'application') |
|
94 | - { |
|
95 | - $target_dir = $app . '/' . static::TEST_FOLDER . '/_ci_phpunit_test'; |
|
96 | - $this->recursiveUnlink($target_dir); |
|
97 | - $this->recursiveCopy( |
|
98 | - dirname(__FILE__) . '/application/tests/_ci_phpunit_test', |
|
99 | - $target_dir |
|
100 | - ); |
|
101 | - } |
|
93 | + public function update($app = 'application') |
|
94 | + { |
|
95 | + $target_dir = $app . '/' . static::TEST_FOLDER . '/_ci_phpunit_test'; |
|
96 | + $this->recursiveUnlink($target_dir); |
|
97 | + $this->recursiveCopy( |
|
98 | + dirname(__FILE__) . '/application/tests/_ci_phpunit_test', |
|
99 | + $target_dir |
|
100 | + ); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Recursive Copy |
|
105 | - * |
|
106 | - * @param string $src |
|
107 | - * @param string $dst |
|
108 | - */ |
|
109 | - private function recursiveCopy($src, $dst) |
|
110 | - { |
|
111 | - @mkdir($dst, 0755); |
|
103 | + /** |
|
104 | + * Recursive Copy |
|
105 | + * |
|
106 | + * @param string $src |
|
107 | + * @param string $dst |
|
108 | + */ |
|
109 | + private function recursiveCopy($src, $dst) |
|
110 | + { |
|
111 | + @mkdir($dst, 0755); |
|
112 | 112 | |
113 | - $iterator = new \RecursiveIteratorIterator( |
|
114 | - new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), |
|
115 | - \RecursiveIteratorIterator::SELF_FIRST |
|
116 | - ); |
|
113 | + $iterator = new \RecursiveIteratorIterator( |
|
114 | + new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), |
|
115 | + \RecursiveIteratorIterator::SELF_FIRST |
|
116 | + ); |
|
117 | 117 | |
118 | - foreach ($iterator as $file) { |
|
119 | - if ($file->isDir()) { |
|
120 | - @mkdir($dst . '/' . $iterator->getSubPathName()); |
|
121 | - } else { |
|
122 | - $success = copy($file, $dst . '/' . $iterator->getSubPathName()); |
|
123 | - if ($success) { |
|
124 | - if (! $this->silent) { |
|
125 | - echo 'copied: ' . $dst . '/' . $iterator->getSubPathName() . PHP_EOL; |
|
126 | - } |
|
127 | - } |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
118 | + foreach ($iterator as $file) { |
|
119 | + if ($file->isDir()) { |
|
120 | + @mkdir($dst . '/' . $iterator->getSubPathName()); |
|
121 | + } else { |
|
122 | + $success = copy($file, $dst . '/' . $iterator->getSubPathName()); |
|
123 | + if ($success) { |
|
124 | + if (! $this->silent) { |
|
125 | + echo 'copied: ' . $dst . '/' . $iterator->getSubPathName() . PHP_EOL; |
|
126 | + } |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Recursive Unlink |
|
134 | - * |
|
135 | - * @param string $dir |
|
136 | - */ |
|
137 | - private function recursiveUnlink($dir) |
|
138 | - { |
|
139 | - $iterator = new \RecursiveIteratorIterator( |
|
140 | - new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), |
|
141 | - \RecursiveIteratorIterator::CHILD_FIRST |
|
142 | - ); |
|
132 | + /** |
|
133 | + * Recursive Unlink |
|
134 | + * |
|
135 | + * @param string $dir |
|
136 | + */ |
|
137 | + private function recursiveUnlink($dir) |
|
138 | + { |
|
139 | + $iterator = new \RecursiveIteratorIterator( |
|
140 | + new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), |
|
141 | + \RecursiveIteratorIterator::CHILD_FIRST |
|
142 | + ); |
|
143 | 143 | |
144 | - foreach ($iterator as $file) { |
|
145 | - if ($file->isDir()) { |
|
146 | - rmdir($file); |
|
147 | - } else { |
|
148 | - unlink($file); |
|
149 | - } |
|
150 | - } |
|
144 | + foreach ($iterator as $file) { |
|
145 | + if ($file->isDir()) { |
|
146 | + rmdir($file); |
|
147 | + } else { |
|
148 | + unlink($file); |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - rmdir($dir); |
|
153 | - } |
|
152 | + rmdir($dir); |
|
153 | + } |
|
154 | 154 | } |