added a way to run tests that depends on external libraries

This commit is contained in:
Fabien Potencier 2010-06-06 10:35:20 +02:00
parent 626b88c8f1
commit a79ad894f9
15 changed files with 209 additions and 15 deletions

22
README
View File

@ -23,6 +23,28 @@ Requirements
Symfony is only supported on PHP 5.3.0 and up.
Tests
-----
To run the Symfony test suite, you need PHPUnit 3.5 or later.
If you want to run the tests that depend on external dependencies, the test
suite needs to be able to autoload them. By default, they are autoloaded from
a `vendor/` directory under the main root directory (see `autoload.php.dist`).
To put them in a different directory, create your own `autoload.php` file.
A working `vendor/` directory looks like the following:
* `doctrine/`
* `doctrine-migrations`
* `phing/`
* `propel/`
* `swiftmailer/`
* `twig/`
* `zend/`
Note that the code coverage only works if you have all dependencies installed.
Documentation
-------------

27
autoload.php.dist Normal file
View File

@ -0,0 +1,27 @@
<?php
require_once __DIR__.'/src/Symfony/Foundation/UniversalClassLoader.php';
use Symfony\Foundation\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Doctrine\\Common' => __DIR__.'/vendor/doctrine/lib/vendor/doctrine-common/lib',
'Doctrine\\DBAL\\Migrations' => __DIR__.'/vendor/doctrine-migrations/lib',
'Doctrine\\DBAL' => __DIR__.'/vendor/doctrine/lib/vendor/doctrine-dbal/lib',
'Doctrine' => __DIR__.'/vendor/doctrine/lib',
));
$loader->registerPrefixes(array(
'Swift_' => __DIR__.'/vendor/swiftmailer/lib/classes',
'Zend_' => __DIR__.'/vendor/zend/library',
'Twig_' => __DIR__.'/vendor/twig/lib',
));
$loader->register();
// for Zend Framework & SwiftMailer
set_include_path(
__DIR__.'/vendor/zend/library'.PATH_SEPARATOR.
__DIR__.'/vendor/swiftmailer/lib'.PATH_SEPARATOR.
__DIR__.'/vendor/phing/classes'.PATH_SEPARATOR.
get_include_path()
);

View File

@ -9,12 +9,12 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/Symfony/Tests/bootstrap.php"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="Symfony Test Suite">
<directory>./tests/Symfony/</directory>
<directory>./src/Symfony/Framework/</directory>
<directory>./src/Symfony/Framework/*/Tests/</directory>
</testsuite>
</testsuites>
@ -22,13 +22,7 @@
<whitelist>
<directory>./src/Symfony/</directory>
<exclude>
<directory>./src/Symfony/Framework/DoctrineBundle</directory>
<directory>./src/Symfony/Framework/DoctrineMigrationsBundle</directory>
<directory>./src/Symfony/Framework/TwigBundle</directory>
<directory>./src/Symfony/Framework/ZendBundle</directory>
<directory>./src/Symfony/Framework/*/Resources</directory>
<file>./src/Symfony/Foundation/bootstrap.php</file>
<file>./src/Symfony/Foundation/packager.php</file>
</exclude>

View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Framework\DoctrineBundle\Tests;
class TestCase extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!class_exists('Doctrine\\Common\\Version')) {
$this->markTestSkipped('Doctrine is not available.');
}
}
}

View File

@ -9,8 +9,8 @@
* file that was distributed with this source code.
*/
require_once __DIR__.'/../../../src/Symfony/Foundation/UniversalClassLoader.php';
namespace Symfony\Framework\ProfilerBundle\Tests;
$loader = new Symfony\Foundation\UniversalClassLoader();
$loader->registerNamespace('Symfony', __DIR__.'/../../../src');
$loader->register();
class TestCase extends \PHPUnit_Framework_TestCase
{
}

View File

@ -0,0 +1,24 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Framework\PropelBundle\Tests;
class TestCase extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!file_exists($file = __DIR__.'/../../../../../vendor/propel/runtime/lib/Propel.php')) {
$this->markTestSkipped('Propel is not available.');
}
require_once $file;
}
}

View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Framework\SwiftmailerBundle\Tests;
class TestCase extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!class_exists('Swift_Mailer')) {
$this->markTestSkipped('Swiftmailer is not available.');
}
}
}

View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Framework\TwigBundle\Tests;
class TestCase extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!class_exists('Twig_Environment')) {
$this->markTestSkipped('Twig is not available.');
}
}
}

View File

@ -0,0 +1,16 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Framework\WebBundle\Tests;
class TestCase extends \PHPUnit_Framework_TestCase
{
}

View File

@ -9,18 +9,19 @@
* file that was distributed with this source code.
*/
namespace Symfony\Tests\Framework\WebBundle\Util;
namespace Symfony\Framework\WebBundle\Tests\Util;
use Symfony\Framework\WebBundle\Tests\TestCase;
use Symfony\Framework\WebBundle\Util\Mustache;
use Symfony\Framework\WebBundle\Util\Filesystem;
class MustacheTest extends \PHPUnit_Framework_TestCase
class MustacheTest extends TestCase
{
protected $dir;
public function setUp()
{
$dir = __DIR__.'/../../../../../fixtures/Symfony/Framework/WebBundle/Util';
$dir = __DIR__.'/fixtures/';
$this->dir = sys_get_temp_dir().'/mustache';
$filesystem = new Filesystem();

View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Framework\ZendBundle\Tests;
class TestCase extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!class_exists('Zend_Log')) {
$this->markTestSkipped('Zend Framework is not available.');
}
}
}

22
tests/bootstrap.php Normal file
View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__.'/../src/Symfony/Foundation/UniversalClassLoader.php';
$loader = new Symfony\Foundation\UniversalClassLoader();
$loader->registerNamespace('Symfony', __DIR__.'/../src');
$loader->register();
if (file_exists($file = __DIR__.'/../autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/../autoload.php.dist')) {
require_once $file;
}