Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
[Components] Tests/Autoloading fixes
Browse files Browse the repository at this point in the history
* 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
willdurand committed May 1, 2012
1 parent 477dfe3 commit ffef59a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
vendor/
composer.lock
15 changes: 4 additions & 11 deletions README.md
Expand Up @@ -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
30 changes: 4 additions & 26 deletions Tests/bootstrap.php
Expand Up @@ -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;
}
12 changes: 9 additions & 3 deletions composer.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Expand Up @@ -21,7 +21,7 @@
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./vendor</directory>
<directory>./Tests</directory>
</exclude>
</whitelist>
Expand Down

0 comments on commit ffef59a

Please sign in to comment.