Skip to content
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 b251bfd commit 69252527f736c923c3123a64afdaa5c2bdd6fa09 @willdurand willdurand committed Apr 27, 2012
Showing with 16 additions and 23 deletions.
  1. +2 −0 .gitignore
  2. +3 −7 README.md
  3. +4 −13 Tests/bootstrap.php
  4. +6 −2 composer.json
  5. +1 −1 phpunit.xml.dist
View
2 .gitignore
@@ -0,0 +1,2 @@
+vendor/
+composer.lock
View
10 README.md
@@ -21,13 +21,9 @@ Resources
You can run the unit tests with the following command:
- phpunit -c src/Symfony/Component/Form/
+ phpunit
If you also want to run the unit tests that depend on other Symfony
-Components, declare the following environment variables before running
-PHPUnit:
+Components, install dev dependencies before running PHPUnit:
- export SYMFONY_EVENT_DISPATCHER=../path/to/EventDispatcher
- export SYMFONY_LOCALE=../path/to/Locale
- export SYMFONY_VALIDATOR=../path/to/Validator
- export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation
+ php composer.phar install --dev
View
17 Tests/bootstrap.php
@@ -10,22 +10,13 @@
*/
spl_autoload_register(function ($class) {
- foreach (array(
- 'SYMFONY_EVENT_DISPATCHER' => 'EventDispatcher',
- 'SYMFONY_LOCALE' => 'Locale',
- 'SYMFONY_VALIDATOR' => 'Validator',
- 'SYMFONY_HTTP_FOUNDATION' => 'HttpFoundation',
- ) 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 (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Form')) {
if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Form')).'.php')) {
require_once $file;
}
}
});
+
+if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) {
+ require_once $loader;
+}
View
8 composer.json
@@ -17,8 +17,12 @@
],
"require": {
"php": ">=5.3.2",
- "symfony/event-dispatcher": "self.version",
- "symfony/locale": "self.version"
+ "symfony/event-dispatcher": "2.1.*",
+ "symfony/locale": "2.1.*"
+ },
+ "require-dev": {
+ "symfony/validator": "2.1.*",
+ "symfony/http-foundation": "2.1.*"
},
"suggest": {
"symfony/validator": "self.version",
View
2 phpunit.xml.dist
@@ -21,8 +21,8 @@
<whitelist>
<directory>./</directory>
<exclude>
- <directory>./Resources</directory>
<directory>./Tests</directory>
+ <directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

0 comments on commit 6925252

Please sign in to comment.
Something went wrong with that request. Please try again.