|
1 | 1 | #!/usr/bin/env php |
2 | 2 | <?php |
3 | 3 |
|
4 | | -function includeIfExists($file) |
5 | | -{ |
| 4 | +foreach (array(__DIR__ . '/../autoload.php', __DIR__ . '/../vendor/autoload.php') as $file) { |
6 | 5 | if (file_exists($file)) { |
7 | | - return include $file; |
| 6 | + define('PHPUNIT_COMPOSER_INSTALL', $file); |
| 7 | + break; |
8 | 8 | } |
9 | 9 | } |
10 | | -// Including composer autoload |
11 | | -if ( |
12 | | - (!$loader = includeIfExists( __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php')) |
13 | | - && (!$loader = includeIfExists( __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php')) |
14 | | - ) |
15 | | -{ |
16 | | - die( |
17 | | - 'You must set up the project dependencies, run the following commands:'.PHP_EOL. |
18 | | - 'curl -s http://getcomposer.org/installer | php'.PHP_EOL. |
19 | | - 'php composer.phar install'.PHP_EOL |
20 | | - ); |
21 | | -} |
22 | | -// Including phpunit autoload |
23 | | -if ( |
24 | | - (!file_exists( __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . 'PHPUnit' . DIRECTORY_SEPARATOR . 'Autoload.php')) |
25 | | - && (!file_exists( __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . 'PHPUnit' . DIRECTORY_SEPARATOR . 'Autoload.php')) |
26 | | - ) |
27 | | -{ |
28 | | - die( |
29 | | - 'You must set up the project dependencies, run the following commands:'.PHP_EOL. |
30 | | - 'curl -s http://getcomposer.org/installer | php'.PHP_EOL. |
31 | | - 'php composer.phar install'.PHP_EOL |
32 | | - ); |
| 10 | + |
| 11 | +if (!defined('PHPUNIT_COMPOSER_INSTALL')) { |
| 12 | + echo 'You need to set up the project dependencies using the following commands:' . PHP_EOL . |
| 13 | + 'wget http://getcomposer.org/composer.phar' . PHP_EOL . |
| 14 | + 'php composer.phar install' . PHP_EOL; |
| 15 | + die(1); |
33 | 16 | } |
34 | 17 |
|
| 18 | +require PHPUNIT_COMPOSER_INSTALL; |
35 | 19 |
|
36 | 20 | \PHPUnitRandomizer\Command::main(); |
0 commit comments