Permalink
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 2a64d05 commit 95be57cdc7513895424d2380897d5897e805945c @willdurand willdurand committed Apr 27, 2012
Showing with 23 additions and 35 deletions.
  1. +2 −0 .gitignore
  2. +4 −13 README.md
  3. +4 −19 Tests/bootstrap.php
  4. +12 −2 composer.json
  5. +1 −1 phpunit.xml.dist
View
@@ -0,0 +1,2 @@
+vendor/
+composer.lock
View
@@ -84,18 +84,9 @@ Resources
You can run the unit tests with the following command:
- phpunit -c src/Symfony/Component/HttpKernel/
+ 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_EVENT_DISPATCHER=../path/to/EventDispatcher
- export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation
- export SYMFONY_DEPENDENCY_INJECTION=../path/to/DependencyInjection
- export SYMFONY_CONSOLE=../path/to/Console
- export SYMFONY_BROWSER_KIT=../path/to/BrowserKit
- export SYMFONY_FINDER=../path/to/Finder
- export SYMFONY_PROCESS=../path/to/Process
- export SYMFONY_ROUTING=../path/to/Routing
- export SYMFONY_CONFIG=../path/to/Config
+Components, install dev dependencies before running PHPUnit:
+
+ php composer.phar install --dev
View
@@ -10,28 +10,13 @@
*/
spl_autoload_register(function ($class) {
- foreach (array(
- 'SYMFONY_EVENT_DISPATCHER' => 'EventDispatcher',
- 'SYMFONY_HTTP_FOUNDATION' => 'HttpFoundation',
- 'SYMFONY_DEPENDENCY_INJECTION' => 'DependencyInjection',
- 'SYMFONY_CONSOLE' => 'Console',
- 'SYMFONY_BROWSER_KIT' => 'BrowserKit',
- 'SYMFONY_FINDER' => 'Finder',
- 'SYMFONY_CLASS_LOADER' => 'ClassLoader',
- 'SYMFONY_PROCESS' => 'Process',
- 'SYMFONY_ROUTING' => 'Routing',
- 'SYMFONY_CONFIG' => 'Config',
- ) 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\HttpKernel')) {
if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\HttpKernel')).'.php')) {
require_once $file;
}
}
});
+
+if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) {
+ require_once $loader;
+}
View
@@ -17,8 +17,18 @@
],
"require": {
"php": ">=5.3.2",
- "symfony/event-dispatcher": "self.version",
- "symfony/http-foundation": "self.version"
+ "symfony/event-dispatcher": "2.1.*",
+ "symfony/http-foundation": "2.1.*"
+ },
+ "require-dev": {
+ "symfony/browser-kit": "2.1.*",
+ "symfony/class-loader": "2.1.*",
+ "symfony/config": "2.1.*",
+ "symfony/console": "2.1.*",
+ "symfony/dependency-injection": "2.1.*",
+ "symfony/finder": "2.1.*",
+ "symfony/process": "2.1.*",
+ "symfony/routing": "2.1.*"
},
"suggest": {
"symfony/browser-kit": "self.version",
View
@@ -21,8 +21,8 @@
<whitelist>
<directory>./</directory>
<exclude>
- <directory>./Resources</directory>
<directory>./Tests</directory>
+ <directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

0 comments on commit 95be57c

Please sign in to comment.