Skip to content

Commit

Permalink
moved component and bridge unit tests to the src/ directory
Browse files Browse the repository at this point in the history
This is the first step to make each Symfony Component and Bridge self-contained.
  • Loading branch information
fabpot committed Mar 29, 2012
1 parent 3e95126 commit fea6b79
Show file tree
Hide file tree
Showing 861 changed files with 4,045 additions and 1,216 deletions.
2 changes: 1 addition & 1 deletion check_cs
Expand Up @@ -26,7 +26,7 @@ $finder
->name('*.xml')
->name('*.xml.dist')
->name('*.yml')
->in(array(__DIR__.'/src', __DIR__.'/tests'))
->in(__DIR__.'/src')
->notName(basename(__FILE__))
->exclude('.git')
->exclude('vendor')
Expand Down
9 changes: 6 additions & 3 deletions phpunit.xml.dist
Expand Up @@ -9,11 +9,12 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
bootstrap="autoload.php.dist"
>
<testsuites>
<testsuite name="Symfony Test Suite">
<directory>./tests/Symfony/</directory>
<directory>./src/Symfony/Bridge/*/Tests/</directory>
<directory>./src/Symfony/Component/*/Tests/</directory>
<directory>./src/Symfony/Bundle/*/Tests/</directory>
</testsuite>
</testsuites>
Expand All @@ -29,8 +30,10 @@
<whitelist>
<directory>./src/Symfony/</directory>
<exclude>
<directory>./src/Symfony/Bundle/*/Resources</directory>
<directory>./src/Symfony/Bridge/*/Tests</directory>
<directory>./src/Symfony/Component/*/Tests</directory>
<directory>./src/Symfony/Bundle/*/Tests</directory>
<directory>./src/Symfony/Bundle/*/Resources</directory>
<directory>./src/Symfony/Component/*/Resources</directory>
<directory>./src/Symfony/Component/*/*/Resources</directory>
</exclude>
Expand Down
26 changes: 24 additions & 2 deletions src/Symfony/Bridge/Doctrine/README.md
Expand Up @@ -4,9 +4,31 @@ Doctrine Bridge
Provides integration for [Doctrine](http://www.doctrine-project.org/) with
various Symfony2 components.

Twig Bridge
===========

Provides integration for [Twig](http://twig.sensiolabs.org/) with various
Symfony2 components.

Resources
---------

Unit tests:
You can run the unit tests with the following command:

phpunit -c src/Symfony/Bridge/Doctrine/

If you also want to run the unit tests that depend on other Symfony
Components, declare the following environment variables before running
PHPUnit:

https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Bridge/Doctrine
export DOCTRINE_COMMON=../path/to/doctrine-common
export DOCTRINE_DBAL=../path/to/doctrine-dbal
export DOCTRINE_ORM=../path/to/doctrine
export DOCTRINE_FIXTURES=../path/to/doctrine-fixtures
export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation
export SYMFONY_DEPENDENCY_INJECTION=../path/to/DependencyInjection
export SYMFONY_FORM=../path/to/Form
export SYMFONY_SECURITY=../path/to/Security
export SYMFONY_VALIDATOR=../path/to/Validator
export SYMFONY_HTTP_KERNEL=../path/to/HttpKernel
export SYMFONY_EVENT_DISPATCHER=../path/to/EventDispatcher
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Doctrine\Bundle\DoctrineBundle\Tests;
namespace Symfony\Bridge\Doctrine\Tests;

use Symfony\Bridge\Doctrine\ContainerAwareEventManager;
use Symfony\Component\DependencyInjection\Container;
Expand All @@ -18,6 +18,10 @@ class ContainerAwareEventManagerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Symfony\Component\DependencyInjection\Container')) {
$this->markTestSkipped('The "DependencyInjection" component is not available');
}

$this->container = new Container();
$this->evm = new ContainerAwareEventManager($this->container);
}
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Tests\Bridge\Doctrine\DataCollector;
namespace Symfony\Bridge\Doctrine\Tests\DataCollector;

use Doctrine\DBAL\Platforms\MySqlPlatform;
use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector;
Expand All @@ -18,6 +18,17 @@

class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Doctrine\DBAL\Platforms\MySqlPlatform')) {
$this->markTestSkipped('Doctrine DBAL is not available.');
}

if (!class_exists('Symfony\Component\HttpKernel\HttpKernel')) {
$this->markTestSkipped('The "HttpKernel" component is not available');
}
}

public function testCollectConnections()
{
$c = $this->createCollector(array());
Expand Down
Expand Up @@ -9,15 +9,19 @@
* file that was distributed with this source code.
*/

namespace Symfony\Tests\Bridge\Doctrine\DataFixtures;
namespace Symfony\Bridge\Doctrine\Tests\DataFixtures;

use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Symfony\Tests\Bridge\Doctrine\Fixtures\ContainerAwareFixture;
use Symfony\Bridge\Doctrine\Tests\Fixtures\ContainerAwareFixture;

class ContainerAwareLoaderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Symfony\Component\DependencyInjection\Container')) {
$this->markTestSkipped('The "DependencyInjection" component is not available');
}

if (!class_exists('Doctrine\Common\DataFixtures\Loader')) {
$this->markTestSkipped('Doctrine Data Fixtures is not available.');
}
Expand Down
Expand Up @@ -9,13 +9,20 @@
* file that was distributed with this source code.
*/

namespace Symfony\Tests\Bridge\Doctrine\DependencyInjection\Compiler;
namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection\Compiler;

use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class RegisterEventListenersAndSubscribersPassTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Symfony\Component\DependencyInjection\Container')) {
$this->markTestSkipped('The "DependencyInjection" component is not available');
}
}

public function testProcessEventListenersWithPriorities()
{
$container = $this->createBuilder();
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Tests\Bridge\Doctrine;
namespace Symfony\Bridge\Doctrine\Tests;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
Expand All @@ -19,8 +19,16 @@ abstract class DoctrineOrmTestCase extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Doctrine\\Common\\Version')) {
$this->markTestSkipped('Doctrine is not available.');
if (!class_exists('Doctrine\Common\Version')) {
$this->markTestSkipped('Doctrine Common is not available.');
}

if (!class_exists('Doctrine\DBAL\Platforms\MySqlPlatform')) {
$this->markTestSkipped('Doctrine DBAL is not available.');
}

if (!class_exists('Doctrine\ORM\EntityManager')) {
$this->markTestSkipped('Doctrine ORM is not available.');
}
}

Expand All @@ -33,7 +41,7 @@ static public function createTestEntityManager($paths = array())
self::markTestSkipped('This test requires SQLite support in your environment');
}
$config = new \Doctrine\ORM\Configuration();
$config->setEntityNamespaces(array('SymfonyTestsDoctrine' => 'Symfony\Tests\Bridge\Doctrine\Fixtures'));
$config->setEntityNamespaces(array('SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'));
$config->setAutoGenerateProxyClasses(true);
$config->setProxyDir(\sys_get_temp_dir());
$config->setProxyNamespace('SymfonyTests\Doctrine');
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\ORM\Mapping AS ORM;

Expand All @@ -18,7 +18,7 @@ class AssociationEntity

/**
* @ORM\ManyToOne(targetEntity="SingleIdentEntity")
* @var \Symfony\Tests\Bridge\Doctrine\Form\Fixtures\SingleIdentEntity
* @var \Symfony\Bridge\Doctrine\Tests\Form\Fixtures\SingleIdentEntity
*/
public $single;

Expand All @@ -28,7 +28,7 @@ class AssociationEntity
* @ORM\JoinColumn(name="composite_id1", referencedColumnName="id1"),
* @ORM\JoinColumn(name="composite_id2", referencedColumnName="id2")
* })
* @var \Symfony\Tests\Bridge\Doctrine\Form\Fixtures\CompositeIdentEntity
* @var \Symfony\Bridge\Doctrine\Tests\Form\Fixtures\CompositeIdentEntity
*/
public $composite;
}
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
Expand Down
Expand Up @@ -9,32 +9,31 @@
* file that was distributed with this source code.
*/

namespace Symfony\Tests\Bridge\Doctrine\Form\ChoiceList;
namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList;

require_once __DIR__.'/../../DoctrineOrmTestCase.php';
require_once __DIR__.'/../../Fixtures/ItemGroupEntity.php';
require_once __DIR__.'/../../Fixtures/SingleIdentEntity.php';
require_once __DIR__.'/../../Fixtures/NoToStringSingleIdentEntity.php';

use Symfony\Tests\Bridge\Doctrine\DoctrineOrmTestCase;
use Symfony\Tests\Bridge\Doctrine\Fixtures\ItemGroupEntity;
use Symfony\Tests\Bridge\Doctrine\Fixtures\SingleIdentEntity;
use Symfony\Tests\Bridge\Doctrine\Fixtures\NoToStringSingleIdentEntity;
use Symfony\Bridge\Doctrine\Tests\DoctrineOrmTestCase;
use Symfony\Bridge\Doctrine\Tests\Fixtures\ItemGroupEntity;
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIdentEntity;
use Symfony\Bridge\Doctrine\Tests\Fixtures\NoToStringSingleIdentEntity;
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList;
use Symfony\Component\Form\Extension\Core\View\ChoiceView;

class EntityChoiceListTest extends DoctrineOrmTestCase
{
const ITEM_GROUP_CLASS = 'Symfony\Tests\Bridge\Doctrine\Fixtures\ItemGroupEntity';
const ITEM_GROUP_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\ItemGroupEntity';

const SINGLE_IDENT_CLASS = 'Symfony\Tests\Bridge\Doctrine\Fixtures\SingleIdentEntity';
const SINGLE_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIdentEntity';

const COMPOSITE_IDENT_CLASS = 'Symfony\Tests\Bridge\Doctrine\Fixtures\CompositeIdentEntity';
const COMPOSITE_IDENT_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIdentEntity';

private $em;

protected function setUp()
{
if (!class_exists('Symfony\Component\Form\Form')) {
$this->markTestSkipped('The "Form" component is not available');
}

parent::setUp();

$this->em = $this->createTestEntityManager();
Expand All @@ -49,7 +48,7 @@ protected function tearDown()

/**
* @expectedException Symfony\Component\Form\Exception\FormException
* @expectedMessage Entity "Symfony\Tests\Bridge\Doctrine\Fixtures\SingleIdentEntity" passed to the choice field must have a "__toString()" method defined (or you can also override the "property" option).
* @expectedMessage Entity "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIdentEntity" passed to the choice field must have a "__toString()" method defined (or you can also override the "property" option).
*/
public function testEntitesMustHaveAToStringMethod()
{
Expand Down

0 comments on commit fea6b79

Please sign in to comment.