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 f03173e commit 5a4ea5224ab23560e727dcc17290798a0500f6d6 @willdurand willdurand committed Apr 27, 2012
Showing with 15 additions and 18 deletions.
  1. +2 −0 .gitignore
  2. +3 −5 README.md
  3. +4 −12 Tests/bootstrap.php
  4. +5 −1 composer.json
  5. +1 −0 phpunit.xml.dist
View
2 .gitignore
@@ -0,0 +1,2 @@
+vendor/
+composer.lock
View
8 README.md
@@ -18,11 +18,9 @@ provided by the HttpKernel component.
You can run the unit tests with the following command:
- phpunit -c src/Symfony/Component/BrowserKit/
+ 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_PROCESS=../path/to/Process
- export SYMFONY_DOM_CRAWLER=../path/to/DomCrawler
+ php composer.phar install --dev
View
16 Tests/bootstrap.php
@@ -10,21 +10,13 @@
*/
spl_autoload_register(function ($class) {
- foreach (array(
- 'SYMFONY_PROCESS' => 'Process',
- 'SYMFONY_DOM_CRAWLER' => 'DomCrawler',
- 'SYMFONY_CSS_SELECTOR' => 'CssSelector',
- ) 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\BrowserKit')) {
if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\BrowserKit')).'.php')) {
require_once $file;
}
}
});
+
+if (file_exists($loader = __DIR__.'/../vendor/autoload.php')) {
+ require_once $loader;
+}
View
6 composer.json
@@ -17,7 +17,11 @@
],
"require": {
"php": ">=5.3.2",
- "symfony/dom-crawler": "self.version"
+ "symfony/dom-crawler": "2.1.*"
+ },
+ "require-dev": {
+ "symfony/process": "2.1.*",
+ "symfony/css-selector": "2.1.*"
},
"suggest": {
"symfony/process": "self.version"
View
1 phpunit.xml.dist
@@ -23,6 +23,7 @@
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
+ <directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

0 comments on commit 5a4ea52

Please sign in to comment.