@@ -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', $pub = 'public') |
|
| 23 | - { |
|
| 24 | - $this->recursiveCopy( |
|
| 25 | - dirname(__FILE__) . '/application/tests', |
|
| 26 | - $app . '/' . static::TEST_FOLDER |
|
| 27 | - ); |
|
| 28 | - $this->fixPath($app, $pub); |
|
| 29 | - } |
|
| 22 | + public function install($app = 'application', $pub = 'public') |
|
| 23 | + { |
|
| 24 | + $this->recursiveCopy( |
|
| 25 | + dirname(__FILE__) . '/application/tests', |
|
| 26 | + $app . '/' . static::TEST_FOLDER |
|
| 27 | + ); |
|
| 28 | + $this->fixPath($app, $pub); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Fix paths in Bootstrap.php |
|
| 33 | - */ |
|
| 34 | - private function fixPath($app = 'application', $pub = 'public') |
|
| 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', $pub = 'public') |
|
| 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($pub . '/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__).'/../../'. $pub).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__).'/../../' . $pub).'/');", |
|
| 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($pub . '/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__).'/../../'. $pub).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__).'/../../' . $pub).'/');", |
|
| 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 | } |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | public function install($app = 'application', $pub = 'public') |
| 23 | 23 | { |
| 24 | 24 | $this->recursiveCopy( |
| 25 | - dirname(__FILE__) . '/application/tests', |
|
| 26 | - $app . '/' . static::TEST_FOLDER |
|
| 25 | + dirname(__FILE__).'/application/tests', |
|
| 26 | + $app.'/'.static::TEST_FOLDER |
|
| 27 | 27 | ); |
| 28 | 28 | $this->fixPath($app, $pub); |
| 29 | 29 | } |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | private function fixPath($app = 'application', $pub = 'public') |
| 35 | 35 | { |
| 36 | - $file = $app . '/' . static::TEST_FOLDER . '/Bootstrap.php'; |
|
| 36 | + $file = $app.'/'.static::TEST_FOLDER.'/Bootstrap.php'; |
|
| 37 | 37 | $contents = file_get_contents($file); |
| 38 | 38 | |
| 39 | - if (! file_exists('system')) { |
|
| 39 | + if ( ! file_exists('system')) { |
|
| 40 | 40 | if (file_exists('vendor/codeigniter/framework/system')) { |
| 41 | 41 | $contents = str_replace( |
| 42 | 42 | '$system_path = \'../../system\';', |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if (! file_exists('index.php')) { |
|
| 52 | - if (file_exists($pub . '/index.php')) { |
|
| 51 | + if ( ! file_exists('index.php')) { |
|
| 52 | + if (file_exists($pub.'/index.php')) { |
|
| 53 | 53 | // CodeIgniter 3.0.6 and after |
| 54 | 54 | $contents = str_replace( |
| 55 | 55 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | "define('FCPATH', realpath(dirname(__FILE__).'/../../' . $pub).'/');", |
| 63 | 63 | $contents |
| 64 | 64 | ); |
| 65 | - } elseif (file_exists($app . '/public/index.php')) { |
|
| 65 | + } elseif (file_exists($app.'/public/index.php')) { |
|
| 66 | 66 | // CodeIgniter 3.0.6 and after |
| 67 | 67 | $contents = str_replace( |
| 68 | 68 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function update($app = 'application') |
| 94 | 94 | { |
| 95 | - $target_dir = $app . '/' . static::TEST_FOLDER . '/_ci_phpunit_test'; |
|
| 95 | + $target_dir = $app.'/'.static::TEST_FOLDER.'/_ci_phpunit_test'; |
|
| 96 | 96 | $this->recursiveUnlink($target_dir); |
| 97 | 97 | $this->recursiveCopy( |
| 98 | - dirname(__FILE__) . '/application/tests/_ci_phpunit_test', |
|
| 98 | + dirname(__FILE__).'/application/tests/_ci_phpunit_test', |
|
| 99 | 99 | $target_dir |
| 100 | 100 | ); |
| 101 | 101 | } |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | foreach ($iterator as $file) { |
| 119 | 119 | if ($file->isDir()) { |
| 120 | - @mkdir($dst . '/' . $iterator->getSubPathName()); |
|
| 120 | + @mkdir($dst.'/'.$iterator->getSubPathName()); |
|
| 121 | 121 | } else { |
| 122 | - $success = copy($file, $dst . '/' . $iterator->getSubPathName()); |
|
| 122 | + $success = copy($file, $dst.'/'.$iterator->getSubPathName()); |
|
| 123 | 123 | if ($success) { |
| 124 | - if (! $this->silent) { |
|
| 125 | - echo 'copied: ' . $dst . '/' . $iterator->getSubPathName() . PHP_EOL; |
|
| 124 | + if ( ! $this->silent) { |
|
| 125 | + echo 'copied: '.$dst.'/'.$iterator->getSubPathName().PHP_EOL; |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -15,41 +15,41 @@ |
||
| 15 | 15 | $pub_dir = 'public'; |
| 16 | 16 | |
| 17 | 17 | if ($argc > 1) { |
| 18 | - for ($i = 1; $i <= $argc; $i++) { |
|
| 19 | - if (! isset($argv[$i])) { |
|
| 20 | - break; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - switch ($argv[$i]) { |
|
| 24 | - // php install.php -s |
|
| 25 | - case '-s': |
|
| 26 | - $silent = true; |
|
| 27 | - break; |
|
| 28 | - |
|
| 29 | - // php install.php -a application |
|
| 30 | - case '-a': |
|
| 31 | - if (is_dir($argv[$i+1])) { |
|
| 32 | - $app_dir = $argv[$i+1]; |
|
| 33 | - } else { |
|
| 34 | - throw new Exception('No such directory: ' . $argv[$i+1]); |
|
| 35 | - } |
|
| 36 | - $i++; |
|
| 37 | - break; |
|
| 38 | - |
|
| 39 | - // php install.php -p public |
|
| 40 | - case '-p': |
|
| 41 | - if (is_dir($argv[$i+1])) { |
|
| 42 | - $pub_dir = $argv[$i+1]; |
|
| 43 | - } else { |
|
| 44 | - throw new Exception('No such directory: ' . $argv[$i+1]); |
|
| 45 | - } |
|
| 46 | - $i++; |
|
| 47 | - break; |
|
| 48 | - |
|
| 49 | - default: |
|
| 50 | - throw new Exception('Unknown argument: ' . $argv[$i]); |
|
| 51 | - } |
|
| 52 | - } |
|
| 18 | + for ($i = 1; $i <= $argc; $i++) { |
|
| 19 | + if (! isset($argv[$i])) { |
|
| 20 | + break; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + switch ($argv[$i]) { |
|
| 24 | + // php install.php -s |
|
| 25 | + case '-s': |
|
| 26 | + $silent = true; |
|
| 27 | + break; |
|
| 28 | + |
|
| 29 | + // php install.php -a application |
|
| 30 | + case '-a': |
|
| 31 | + if (is_dir($argv[$i+1])) { |
|
| 32 | + $app_dir = $argv[$i+1]; |
|
| 33 | + } else { |
|
| 34 | + throw new Exception('No such directory: ' . $argv[$i+1]); |
|
| 35 | + } |
|
| 36 | + $i++; |
|
| 37 | + break; |
|
| 38 | + |
|
| 39 | + // php install.php -p public |
|
| 40 | + case '-p': |
|
| 41 | + if (is_dir($argv[$i+1])) { |
|
| 42 | + $pub_dir = $argv[$i+1]; |
|
| 43 | + } else { |
|
| 44 | + throw new Exception('No such directory: ' . $argv[$i+1]); |
|
| 45 | + } |
|
| 46 | + $i++; |
|
| 47 | + break; |
|
| 48 | + |
|
| 49 | + default: |
|
| 50 | + throw new Exception('Unknown argument: ' . $argv[$i]); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $installer = new Installer($silent); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @link https://github.com/kenjis/ci-phpunit-test |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -require __DIR__ . '/Installer.php'; |
|
| 11 | +require __DIR__.'/Installer.php'; |
|
| 12 | 12 | |
| 13 | 13 | $silent = false; |
| 14 | 14 | $app_dir = 'application'; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | if ($argc > 1) { |
| 18 | 18 | for ($i = 1; $i <= $argc; $i++) { |
| 19 | - if (! isset($argv[$i])) { |
|
| 19 | + if ( ! isset($argv[$i])) { |
|
| 20 | 20 | break; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -28,26 +28,26 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | // php install.php -a application |
| 30 | 30 | case '-a': |
| 31 | - if (is_dir($argv[$i+1])) { |
|
| 32 | - $app_dir = $argv[$i+1]; |
|
| 31 | + if (is_dir($argv[$i + 1])) { |
|
| 32 | + $app_dir = $argv[$i + 1]; |
|
| 33 | 33 | } else { |
| 34 | - throw new Exception('No such directory: ' . $argv[$i+1]); |
|
| 34 | + throw new Exception('No such directory: '.$argv[$i + 1]); |
|
| 35 | 35 | } |
| 36 | 36 | $i++; |
| 37 | 37 | break; |
| 38 | 38 | |
| 39 | 39 | // php install.php -p public |
| 40 | 40 | case '-p': |
| 41 | - if (is_dir($argv[$i+1])) { |
|
| 42 | - $pub_dir = $argv[$i+1]; |
|
| 41 | + if (is_dir($argv[$i + 1])) { |
|
| 42 | + $pub_dir = $argv[$i + 1]; |
|
| 43 | 43 | } else { |
| 44 | - throw new Exception('No such directory: ' . $argv[$i+1]); |
|
| 44 | + throw new Exception('No such directory: '.$argv[$i + 1]); |
|
| 45 | 45 | } |
| 46 | 46 | $i++; |
| 47 | 47 | break; |
| 48 | 48 | |
| 49 | 49 | default: |
| 50 | - throw new Exception('Unknown argument: ' . $argv[$i]); |
|
| 50 | + throw new Exception('Unknown argument: '.$argv[$i]); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |