Browse files

[Components] Tests/Autoloading fixes

* Switched to Composer to manage "dev" dependencies
* Fixed READMEs
* Excluded vendor in phpunit.xml.dist files
* Fixed message in bootstrap.php files
* Added autoloader for the component itself
  • Loading branch information...
1 parent 477dfe3 commit ffef59ac47cfb80696c545b01eeb92b12c043420 @willdurand willdurand committed Apr 27, 2012
Showing with 20 additions and 41 deletions.
  1. +2 −0 .gitignore
  2. +4 −11 README.md
  3. +4 −26 Tests/bootstrap.php
  4. +9 −3 composer.json
  5. +1 −1 phpunit.xml.dist
View
2 .gitignore
@@ -0,0 +1,2 @@
+vendor/
+composer.lock
View
15 README.md
@@ -18,16 +18,9 @@ Resources
You can run the unit tests with the following command:
- phpunit -c src/Symfony/Component/Security/
+ phpunit
If you also want to run the unit tests that depend on other Symfony
-Components, declare the following environment variables before running
-PHPUnit:
-
- export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation
- export SYMFONY_HTTP_KERNEL=../path/to/HttpKernel
- export SYMFONY_EVENT_DISPATCHER=../path/to/EventDispatcher
- export SYMFONY_FORM=../path/to/Form
- export SYMFONY_ROUTING=../path/to/Routing
- export DOCTRINE_DBAL=../path/to/doctrine-dbal
- export DOCTRINE_COMMON=../path/to/doctrine-common
+Components, install dev dependencies before running PHPUnit:
+
+ php composer.phar install --dev
View
30 Tests/bootstrap.php
@@ -10,35 +10,13 @@
*/
spl_autoload_register(function ($class) {
- foreach (array(
- 'SYMFONY_HTTP_FOUNDATION' => 'HttpFoundation',
- 'SYMFONY_HTTP_KERNEL' => 'HttpKernel',
- 'SYMFONY_EVENT_DISPATCHER' => 'EventDispatcher',
- 'SYMFONY_FORM' => 'Form',
- 'SYMFONY_ROUTING' => 'Routing',
- ) 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;
- }
- }
- }
-
- 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_COMMON']) && 0 === strpos(ltrim($class, '/'), 'Doctrine\Common')) {
- if (file_exists($file = $_SERVER['DOCTRINE_COMMON'].'/lib/'.str_replace('\\', '/', $class).'.php')) {
- require_once $file;
- }
- }
-
if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Security')) {
if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Security')).'.php')) {
require_once $file;
}
}
});
+
+if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) {
+ require_once $loader;
+}
View
12 composer.json
@@ -17,9 +17,15 @@
],
"require": {
"php": ">=5.3.2",
- "symfony/event-dispatcher": "self.version",
- "symfony/http-foundation": "self.version",
- "symfony/http-kernel": "self.version"
+ "symfony/event-dispatcher": "2.1.*",
+ "symfony/http-foundation": "2.1.*",
+ "symfony/http-kernel": "2.1.*"
+ },
+ "require-dev": {
+ "symfony/form": "2.1.*",
+ "symfony/routing": "2.1.*",
+ "doctrine/common": ">=2.1,<2.3-dev",
+ "doctrine/dbal": ">=2.1,<2.3-dev"
},
"suggest": {
"symfony/class-loader": "self.version",
View
2 phpunit.xml.dist
@@ -21,7 +21,7 @@
<whitelist>
<directory>./</directory>
<exclude>
- <directory>./Resources</directory>
+ <directory>./vendor</directory>
<directory>./Tests</directory>
</exclude>
</whitelist>

0 comments on commit ffef59a

Please sign in to comment.