Skip to content

Commit

Permalink
made usage of Composer autoloader for subtree-split unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Nov 9, 2012
1 parent c290776 commit b27b749
Show file tree
Hide file tree
Showing 112 changed files with 209 additions and 747 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Bridge/Doctrine/.gitignore
@@ -0,0 +1,4 @@
vendor/
composer.lock
phpunit.xml

20 changes: 3 additions & 17 deletions src/Symfony/Bridge/Doctrine/README.md
Expand Up @@ -9,20 +9,6 @@ Resources

You can run the unit tests with the following command:

phpunit -c src/Symfony/Bridge/Doctrine/

If you also want to run the unit tests that depend on other Symfony
Components, declare the following environment variables before running
PHPUnit:

export DOCTRINE_COMMON=../path/to/doctrine-common
export DOCTRINE_DBAL=../path/to/doctrine-dbal
export DOCTRINE_ORM=../path/to/doctrine
export DOCTRINE_FIXTURES=../path/to/doctrine-fixtures
export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation
export SYMFONY_DEPENDENCY_INJECTION=../path/to/DependencyInjection
export SYMFONY_FORM=../path/to/Form
export SYMFONY_SECURITY=../path/to/Security
export SYMFONY_VALIDATOR=../path/to/Validator
export SYMFONY_HTTP_KERNEL=../path/to/HttpKernel
export SYMFONY_EVENT_DISPATCHER=../path/to/EventDispatcher
$ cd path/to/Symfony/Bridge/Doctrine/
$ composer.phar install --dev
$ phpunit
60 changes: 2 additions & 58 deletions src/Symfony/Bridge/Doctrine/Tests/bootstrap.php
Expand Up @@ -9,62 +9,6 @@
* file that was distributed with this source code.
*/

spl_autoload_register($loader = function ($class) {
foreach (array(
'SYMFONY_HTTP_FOUNDATION' => 'HttpFoundation',
'SYMFONY_DEPENDENCY_INJECTION' => 'DependencyInjection',
'SYMFONY_FORM' => 'Form',
'SYMFONY_SECURITY' => 'Security',
'SYMFONY_VALIDATOR' => 'Validator',
'SYMFONY_HTTP_KERNEL' => 'HttpKernel',
'SYMFONY_EVENT_DISPATCHER' => 'EventDispatcher',
) as $env => $name) {
if (isset($_SERVER[$env]) && 0 === strpos(ltrim($class, '/'), 'Symfony\Component\\'.$name)) {
if (file_exists($file = $_SERVER[$env].'/'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\\'.$name)).'.php')) {
require_once $file;
}
}
}
$loader = require __DIR__.'/../vendor/autoload.php';

if (isset($_SERVER['SYMFONY_HTTP_FOUNDATION']) && 'SessionHandlerInterface' === ltrim($class, '/')) {
require_once $_SERVER['SYMFONY_HTTP_FOUNDATION'].'/Resources/stubs/SessionHandlerInterface.php';
}

if (isset($_SERVER['DOCTRINE_FIXTURES']) && 0 === strpos(ltrim($class, '/'), 'Doctrine\Common\DataFixtures')) {
if (file_exists($file = $_SERVER['DOCTRINE_FIXTURES'].'/lib/'.str_replace('\\', '/', $class).'.php')) {
require_once $file;
}
}

if (isset($_SERVER['DOCTRINE_COMMON']) && 0 === strpos(ltrim($class, '/'), 'Doctrine\Common')) {
if (file_exists($file = $_SERVER['DOCTRINE_COMMON'].'/lib/'.str_replace('\\', '/', $class).'.php')) {
require_once $file;
}
}

if (isset($_SERVER['DOCTRINE_DBAL']) && 0 === strpos(ltrim($class, '/'), 'Doctrine\DBAL')) {
if (file_exists($file = $_SERVER['DOCTRINE_DBAL'].'/lib/'.str_replace('\\', '/', $class).'.php')) {
require_once $file;
}
}

if (isset($_SERVER['DOCTRINE_ORM']) && 0 === strpos(ltrim($class, '/'), 'Doctrine\ORM')) {
if (file_exists($file = $_SERVER['DOCTRINE_ORM'].'/lib/'.str_replace('\\', '/', $class).'.php')) {
require_once $file;
}
}

if (0 === strpos(ltrim($class, '/'), 'Symfony\Bridge\Doctrine')) {
if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Bridge\Doctrine')).'.php')) {
require_once $file;
}
}
});

if (isset($_SERVER['DOCTRINE_COMMON'])) {
Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function($class) use ($loader) {
$loader($class);

return class_exists($class, false);
});
}
Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
10 changes: 10 additions & 0 deletions src/Symfony/Bridge/Doctrine/composer.json
Expand Up @@ -19,6 +19,16 @@
"php": ">=5.3.3",
"doctrine/common": ">=2.2,<2.4-dev"
},
"require-dev": {
"symfony/dependency-injection": "2.2.*",
"symfony/form": "2.2.*",
"symfony/http-kernel": "2.2.*",
"symfony/security": "2.2.*",
"symfony/validator": "2.2.*",
"doctrine/data-fixtures": "1.0.*",
"doctrine/dbal": ">=2.2,<2.4-dev",
"doctrine/orm": ">=2.2.3,<2.4-dev"
},
"suggest": {
"symfony/form": "2.2.*",
"symfony/validator": "2.2.*",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/phpunit.xml.dist
Expand Up @@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
bootstrap="Tests/bootstrap.php"
>
<testsuites>
<testsuite name="Symfony Doctrine Bridge Test Suite">
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Bridge/Monolog/.gitignore
@@ -0,0 +1,4 @@
vendor/
composer.lock
phpunit.xml

11 changes: 3 additions & 8 deletions src/Symfony/Bridge/Monolog/README.md
Expand Up @@ -8,11 +8,6 @@ Resources

You can run the unit tests with the following command:

phpunit -c src/Symfony/Bridge/Monolog/

If you also want to run the unit tests that depend on other Symfony
Components, declare the following environment variables before running
PHPUnit:

export MONOLOG=../path/to/Monolog
export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation
$ cd path/to/Symfony/Bridge/Monolog/
$ composer.phar install --dev
$ phpunit
34 changes: 0 additions & 34 deletions src/Symfony/Bridge/Monolog/Tests/bootstrap.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/phpunit.xml.dist
Expand Up @@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Symfony Monolog Bridge Test Suite">
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Bridge/Propel1/.gitignore
@@ -0,0 +1,4 @@
vendor/
composer.lock
phpunit.xml

15 changes: 3 additions & 12 deletions src/Symfony/Bridge/Propel1/README.md
Expand Up @@ -8,15 +8,6 @@ Resources

You can run the unit tests with the following command:

phpunit -c src/Symfony/Bridge/Propel/

If you also want to run the unit tests that depend on other Symfony
Components, declare the following environment variables before running
PHPUnit:

export PROPEL1=../path/to/Propel
export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation
export SYMFONY_HTTP_KERNEL=../path/to/HttpKernel
export SYMFONY_FORM=../path/to/Form
export SYMFONY_EVENT_DISPATCHER=../path/to/EventDispatcher
export SYMFONY_OPTIONS_RESOLVER=../path/to/OptionsResolver
$ cd path/to/Symfony/Bridge/Propel1/
$ composer.phar install --dev
$ phpunit
36 changes: 0 additions & 36 deletions src/Symfony/Bridge/Propel1/Tests/bootstrap.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Propel1/phpunit.xml.dist
Expand Up @@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="Tests/bootstrap.php"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Symfony Propel1 Bridge Test Suite">
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bridge/Twig/.gitignore
@@ -1,2 +1,4 @@
vendor/
composer.lock
phpunit.xml

6 changes: 3 additions & 3 deletions src/Symfony/Bridge/Twig/README.md
Expand Up @@ -10,6 +10,6 @@ Resources
If you want to run the unit tests, install dev dependencies before
running PHPUnit:

php composer.phar install --dev

phpunit
$ cd path/to/Symfony/Bridge/Twig/
$ composer.phar install --dev
$ phpunit
14 changes: 0 additions & 14 deletions src/Symfony/Bridge/Twig/Tests/bootstrap.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/phpunit.xml.dist
Expand Up @@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="Tests/bootstrap.php"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Symfony Twig Bridge Test Suite">
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/BrowserKit/.gitignore
@@ -1,2 +1,4 @@
vendor/
composer.lock
phpunit.xml

9 changes: 3 additions & 6 deletions src/Symfony/Component/BrowserKit/README.md
Expand Up @@ -18,9 +18,6 @@ provided by the HttpKernel component.

You can run the unit tests with the following command:

phpunit

If you also want to run the unit tests that depend on other Symfony
Components, install dev dependencies before running PHPUnit:

php composer.phar install --dev
$ cd path/to/Symfony/Component/BrowserKit/
$ composer.phar install --dev
$ phpunit
22 changes: 0 additions & 22 deletions src/Symfony/Component/BrowserKit/Tests/bootstrap.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/phpunit.xml.dist
Expand Up @@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="Tests/bootstrap.php"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Symfony BrowserKit Component Test Suite">
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/ClassLoader/.gitignore
@@ -1,2 +1,4 @@
vendor/
composer.lock
phpunit.xml

9 changes: 3 additions & 6 deletions src/Symfony/Component/ClassLoader/README.md
Expand Up @@ -64,9 +64,6 @@ Resources

You can run the unit tests with the following command:

phpunit

If you also want to run the unit tests that depend on other Symfony
Components, install dev dependencies before running PHPUnit:

php composer.phar install --dev
$ cd path/to/Symfony/Component/ClassLoader/
$ composer.phar install --dev
$ phpunit
22 changes: 0 additions & 22 deletions src/Symfony/Component/ClassLoader/Tests/bootstrap.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/phpunit.xml.dist
Expand Up @@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="Tests/bootstrap.php"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Symfony ClassLoader Component Test Suite">
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Config/.gitignore
@@ -0,0 +1,4 @@
vendor/
composer.lock
phpunit.xml

0 comments on commit b27b749

Please sign in to comment.