Initial commit with Symfony 2.1+Vendors
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
47
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/BundleTest.php
vendored
Normal file
47
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/BundleTest.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests;
|
||||
|
||||
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\DoctrineValidationPass;
|
||||
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
|
||||
|
||||
class BundleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testBuildCompilerPasses()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$bundle = new DoctrineBundle();
|
||||
$bundle->build($container);
|
||||
|
||||
$config = $container->getCompilerPassConfig();
|
||||
$passes = $config->getBeforeOptimizationPasses();
|
||||
|
||||
$foundEventListener = false;
|
||||
$foundValidation = false;
|
||||
|
||||
foreach ($passes as $pass) {
|
||||
if ($pass instanceof RegisterEventListenersAndSubscribersPass) {
|
||||
$foundEventListener = true;
|
||||
} elseif ($pass instanceof DoctrineValidationPass) {
|
||||
$foundValidation = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertTrue($foundEventListener, 'RegisterEventListenersAndSubcribersPass was not found');
|
||||
$this->assertTrue($foundValidation, 'DoctrineValidationPass was not found');
|
||||
}
|
||||
}
|
59
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/ContainerTest.php
vendored
Normal file
59
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/ContainerTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests;
|
||||
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
|
||||
class ContainerTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!class_exists('Doctrine\\ORM\\Version')) {
|
||||
$this->markTestSkipped('Doctrine ORM is not available.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testContainer()
|
||||
{
|
||||
$container = $this->createYamlBundleTestContainer();
|
||||
|
||||
$this->assertInstanceOf('Symfony\Bridge\Doctrine\Logger\DbalLogger', $container->get('doctrine.dbal.logger'));
|
||||
$this->assertInstanceOf('Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector', $container->get('data_collector.doctrine'));
|
||||
$this->assertInstanceOf('Doctrine\DBAL\Configuration', $container->get('doctrine.dbal.default_connection.configuration'));
|
||||
$this->assertInstanceOf('Doctrine\Common\EventManager', $container->get('doctrine.dbal.default_connection.event_manager'));
|
||||
$this->assertInstanceOf('Doctrine\DBAL\Connection', $container->get('doctrine.dbal.default_connection'));
|
||||
$this->assertInstanceOf('Doctrine\Common\Annotations\Reader', $container->get('doctrine.orm.metadata.annotation_reader'));
|
||||
$this->assertInstanceOf('Doctrine\ORM\Configuration', $container->get('doctrine.orm.default_configuration'));
|
||||
$this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\DriverChain', $container->get('doctrine.orm.default_metadata_driver'));
|
||||
$this->assertInstanceOf('Doctrine\Common\Cache\ArrayCache', $container->get('doctrine.orm.default_metadata_cache'));
|
||||
$this->assertInstanceOf('Doctrine\Common\Cache\ArrayCache', $container->get('doctrine.orm.default_query_cache'));
|
||||
$this->assertInstanceOf('Doctrine\Common\Cache\ArrayCache', $container->get('doctrine.orm.default_result_cache'));
|
||||
$this->assertInstanceOf('Doctrine\ORM\EntityManager', $container->get('doctrine.orm.default_entity_manager'));
|
||||
$this->assertInstanceOf('Doctrine\DBAL\Connection', $container->get('database_connection'));
|
||||
$this->assertInstanceOf('Doctrine\ORM\EntityManager', $container->get('doctrine.orm.entity_manager'));
|
||||
$this->assertInstanceOf('Doctrine\Common\EventManager', $container->get('doctrine.orm.default_entity_manager.event_manager'));
|
||||
$this->assertInstanceOf('Doctrine\Common\EventManager', $container->get('doctrine.dbal.event_manager'));
|
||||
$this->assertInstanceOf('Doctrine\DBAL\Event\Listeners\MysqlSessionInit', $container->get('doctrine.dbal.default_connection.events.mysqlsessioninit'));
|
||||
$this->assertInstanceOf('Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer', $container->get('doctrine.orm.proxy_cache_warmer'));
|
||||
$this->assertInstanceOf('Doctrine\Common\Persistence\ManagerRegistry', $container->get('doctrine'));
|
||||
$this->assertInstanceOf('Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator', $container->get('doctrine.orm.validator.unique'));
|
||||
|
||||
$this->assertSame($container->get('my.platform'), $container->get('doctrine.dbal.default_connection')->getDatabasePlatform());
|
||||
|
||||
$this->assertTrue(Type::hasType('test'));
|
||||
}
|
||||
}
|
@@ -0,0 +1,854 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Doctrine\Bundle\DoctrineBundle\Tests\TestCase;
|
||||
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
abstract class AbstractDoctrineExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
abstract protected function loadFromFile(ContainerBuilder $container, $file);
|
||||
|
||||
public function testDbalOverrideDefaultConnection()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array(), array('dbal' => array('default_connection' => 'foo')), array()), $container);
|
||||
|
||||
// doctrine.dbal.default_connection
|
||||
$this->assertEquals('%doctrine.default_connection%', $container->getDefinition('doctrine')->getArgument(3), '->load() overrides existing configuration options');
|
||||
$this->assertEquals('foo', $container->getParameter('doctrine.default_connection'), '->load() overrides existing configuration options');
|
||||
|
||||
}
|
||||
|
||||
public function testDbalLoad()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('dbal' => array('connections' => array('default' => array('password' => 'foo')))), array(), array('dbal' => array('default_connection' => 'foo')), array()), $container);
|
||||
|
||||
$config = $container->getDefinition('doctrine.dbal.default_connection')->getArgument(0);
|
||||
|
||||
$this->assertEquals('foo', $config['password']);
|
||||
$this->assertEquals('root', $config['user']);
|
||||
}
|
||||
|
||||
public function testDbalLoadFromXmlMultipleConnections()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'dbal_service_multiple_connections');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
// doctrine.dbal.mysql_connection
|
||||
$config = $container->getDefinition('doctrine.dbal.mysql_connection')->getArgument(0);
|
||||
|
||||
$this->assertEquals('mysql_s3cr3t', $config['password']);
|
||||
$this->assertEquals('mysql_user', $config['user']);
|
||||
$this->assertEquals('mysql_db', $config['dbname']);
|
||||
$this->assertEquals('/path/to/mysqld.sock', $config['unix_socket']);
|
||||
|
||||
// doctrine.dbal.sqlite_connection
|
||||
$config = $container->getDefinition('doctrine.dbal.sqlite_connection')->getArgument(0);
|
||||
$this->assertArrayHasKey('memory', $config);
|
||||
|
||||
// doctrine.dbal.oci8_connection
|
||||
$config = $container->getDefinition('doctrine.dbal.oci_connection')->getArgument(0);
|
||||
$this->assertArrayHasKey('charset', $config);
|
||||
}
|
||||
|
||||
public function testDbalLoadFromXmlSingleConnections()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'dbal_service_single_connection');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
// doctrine.dbal.mysql_connection
|
||||
$config = $container->getDefinition('doctrine.dbal.default_connection')->getArgument(0);
|
||||
|
||||
$this->assertEquals('mysql_s3cr3t', $config['password']);
|
||||
$this->assertEquals('mysql_user', $config['user']);
|
||||
$this->assertEquals('mysql_db', $config['dbname']);
|
||||
$this->assertEquals('/path/to/mysqld.sock', $config['unix_socket']);
|
||||
}
|
||||
|
||||
public function testDbalLoadSingleMasterSlaveConnection()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'dbal_service_single_master_slave_connection');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
// doctrine.dbal.mysql_connection
|
||||
$param = $container->getDefinition('doctrine.dbal.default_connection')->getArgument(0);
|
||||
|
||||
$this->assertEquals('Doctrine\\DBAL\\Connections\\MasterSlaveConnection', $param['wrapperClass']);
|
||||
$this->assertEquals(
|
||||
array('user' => 'mysql_user', 'password' => 'mysql_s3cr3t', 'port' => null, 'dbname' => 'mysql_db', 'host' => 'localhost', 'unix_socket' => '/path/to/mysqld.sock'),
|
||||
$param['master']
|
||||
);
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'user' => 'slave_user', 'password' => 'slave_s3cr3t', 'port' => null, 'dbname' => 'slave_db',
|
||||
'host' => 'localhost', 'unix_socket' => '/path/to/mysqld_slave.sock'
|
||||
),
|
||||
$param['slaves']['slave1']
|
||||
);
|
||||
}
|
||||
|
||||
public function testDependencyInjectionConfigurationDefaults()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('dbal' => array('connections' => array('default' => array('password' => 'foo'))), 'orm' => array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array())))))), $container);
|
||||
|
||||
$this->assertFalse($container->getParameter('doctrine.orm.auto_generate_proxy_classes'));
|
||||
$this->assertEquals('Doctrine\ORM\Configuration', $container->getParameter('doctrine.orm.configuration.class'));
|
||||
$this->assertEquals('Doctrine\ORM\EntityManager', $container->getParameter('doctrine.orm.entity_manager.class'));
|
||||
$this->assertEquals('Proxies', $container->getParameter('doctrine.orm.proxy_namespace'));
|
||||
$this->assertEquals('Doctrine\Common\Cache\ArrayCache', $container->getParameter('doctrine.orm.cache.array.class'));
|
||||
$this->assertEquals('Doctrine\Common\Cache\ApcCache', $container->getParameter('doctrine.orm.cache.apc.class'));
|
||||
$this->assertEquals('Doctrine\Common\Cache\MemcacheCache', $container->getParameter('doctrine.orm.cache.memcache.class'));
|
||||
$this->assertEquals('localhost', $container->getParameter('doctrine.orm.cache.memcache_host'));
|
||||
$this->assertEquals('11211', $container->getParameter('doctrine.orm.cache.memcache_port'));
|
||||
$this->assertEquals('Memcache', $container->getParameter('doctrine.orm.cache.memcache_instance.class'));
|
||||
$this->assertEquals('Doctrine\Common\Cache\XcacheCache', $container->getParameter('doctrine.orm.cache.xcache.class'));
|
||||
$this->assertEquals('Doctrine\ORM\Mapping\Driver\DriverChain', $container->getParameter('doctrine.orm.metadata.driver_chain.class'));
|
||||
$this->assertEquals('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $container->getParameter('doctrine.orm.metadata.annotation.class'));
|
||||
$this->assertEquals('Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver', $container->getParameter('doctrine.orm.metadata.xml.class'));
|
||||
$this->assertEquals('Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver', $container->getParameter('doctrine.orm.metadata.yml.class'));
|
||||
|
||||
$config = array(
|
||||
'proxy_namespace' => 'MyProxies',
|
||||
'auto_generate_proxy_classes' => true,
|
||||
'default_entity_manager' => 'default',
|
||||
'entity_managers' => array(
|
||||
'default' => array(
|
||||
'mappings' => array('YamlBundle' => array()),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$container = $this->getContainer();
|
||||
$loader->load(array(array('dbal' => array('connections' => array('default' => array('password' => 'foo'))), 'orm' => $config)), $container);
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.default_connection');
|
||||
|
||||
$args = $definition->getArguments();
|
||||
$this->assertEquals('pdo_mysql', $args[0]['driver']);
|
||||
$this->assertEquals('localhost', $args[0]['host']);
|
||||
$this->assertEquals('root', $args[0]['user']);
|
||||
$this->assertEquals('doctrine.dbal.default_connection.configuration', (string) $args[1]);
|
||||
$this->assertEquals('doctrine.dbal.default_connection.event_manager', (string) $args[2]);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_entity_manager');
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass());
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass());
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$this->assertEquals(array('default' => 'doctrine.orm.default_entity_manager'), $container->getParameter('doctrine.entity_managers'), "Set of the existing EntityManagers names is incorrect.");
|
||||
$this->assertEquals('%doctrine.entity_managers%', $container->getDefinition('doctrine')->getArgument(2), "Set of the existing EntityManagers names is incorrect.");
|
||||
|
||||
$arguments = $definition->getArguments();
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
|
||||
$this->assertEquals('doctrine.dbal.default_connection', (string) $arguments[0]);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
|
||||
$this->assertEquals('doctrine.orm.default_configuration', (string) $arguments[1]);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$calls = array_values($definition->getMethodCalls());
|
||||
$this->assertEquals(array('YamlBundle' => 'Fixtures\Bundles\YamlBundle\Entity'), $calls[0][1][0]);
|
||||
$this->assertEquals('doctrine.orm.default_metadata_cache', (string) $calls[1][1][0]);
|
||||
$this->assertEquals('doctrine.orm.default_query_cache', (string) $calls[2][1][0]);
|
||||
$this->assertEquals('doctrine.orm.default_result_cache', (string) $calls[3][1][0]);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_cache');
|
||||
$this->assertEquals('%doctrine.orm.cache.array.class%', $definition->getClass());
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_query_cache');
|
||||
$this->assertEquals('%doctrine.orm.cache.array.class%', $definition->getClass());
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_result_cache');
|
||||
$this->assertEquals('%doctrine.orm.cache.array.class%', $definition->getClass());
|
||||
}
|
||||
|
||||
public function testSingleEntityManagerConfiguration()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('dbal' => array('connections' => array('default' => array('password' => 'foo'))), 'orm' => array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array())))))), $container);
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.default_connection');
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_entity_manager');
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass());
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass());
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$this->assertDICConstructorArguments($definition, array(
|
||||
new Reference('doctrine.dbal.default_connection'), new Reference('doctrine.orm.default_configuration')
|
||||
));
|
||||
}
|
||||
|
||||
public function testLoadSimpleSingleConnection()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_service_simple_single_entity_manager');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.default_connection');
|
||||
|
||||
$this->assertDICConstructorArguments($definition, array(
|
||||
array(
|
||||
'dbname' => 'db',
|
||||
'host' => 'localhost',
|
||||
'port' => null,
|
||||
'user' => 'root',
|
||||
'password' => null,
|
||||
'driver' => 'pdo_mysql',
|
||||
'driverOptions' => array(),
|
||||
),
|
||||
new Reference('doctrine.dbal.default_connection.configuration'),
|
||||
new Reference('doctrine.dbal.default_connection.event_manager'),
|
||||
array(),
|
||||
));
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_entity_manager');
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass());
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass());
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$this->assertDICConstructorArguments($definition, array(
|
||||
new Reference('doctrine.dbal.default_connection'), new Reference('doctrine.orm.default_configuration')
|
||||
));
|
||||
}
|
||||
|
||||
public function testLoadSingleConnection()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_service_single_entity_manager');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.default_connection');
|
||||
|
||||
$this->assertDICConstructorArguments($definition, array(
|
||||
array(
|
||||
'host' => 'localhost',
|
||||
'driver' => 'pdo_sqlite',
|
||||
'driverOptions' => array(),
|
||||
'user' => 'sqlite_user',
|
||||
'port' => null,
|
||||
'password' => 'sqlite_s3cr3t',
|
||||
'dbname' => 'sqlite_db',
|
||||
'memory' => true,
|
||||
),
|
||||
new Reference('doctrine.dbal.default_connection.configuration'),
|
||||
new Reference('doctrine.dbal.default_connection.event_manager'),
|
||||
array(),
|
||||
));
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_entity_manager');
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass());
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass());
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$this->assertDICConstructorArguments($definition, array(
|
||||
new Reference('doctrine.dbal.default_connection'), new Reference('doctrine.orm.default_configuration')
|
||||
));
|
||||
|
||||
$configDef = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($configDef, 'setDefaultRepositoryClassName', array('Acme\Doctrine\Repository'));
|
||||
}
|
||||
|
||||
public function testLoadMultipleConnections()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_service_multiple_entity_managers');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.conn1_connection');
|
||||
|
||||
$args = $definition->getArguments();
|
||||
$this->assertEquals('pdo_sqlite', $args[0]['driver']);
|
||||
$this->assertEquals('localhost', $args[0]['host']);
|
||||
$this->assertEquals('sqlite_user', $args[0]['user']);
|
||||
$this->assertEquals('doctrine.dbal.conn1_connection.configuration', (string) $args[1]);
|
||||
$this->assertEquals('doctrine.dbal.conn1_connection.event_manager', (string) $args[2]);
|
||||
|
||||
$this->assertEquals('doctrine.orm.em2_entity_manager', (string) $container->getAlias('doctrine.orm.entity_manager'));
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.em1_entity_manager');
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass());
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass());
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$arguments = $definition->getArguments();
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
|
||||
$this->assertEquals('doctrine.dbal.conn1_connection', (string) $arguments[0]);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
|
||||
$this->assertEquals('doctrine.orm.em1_configuration', (string) $arguments[1]);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.conn2_connection');
|
||||
|
||||
$args = $definition->getArguments();
|
||||
$this->assertEquals('pdo_sqlite', $args[0]['driver']);
|
||||
$this->assertEquals('localhost', $args[0]['host']);
|
||||
$this->assertEquals('sqlite_user', $args[0]['user']);
|
||||
$this->assertEquals('doctrine.dbal.conn2_connection.configuration', (string) $args[1]);
|
||||
$this->assertEquals('doctrine.dbal.conn2_connection.event_manager', (string) $args[2]);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.em2_entity_manager');
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass());
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass());
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$arguments = $definition->getArguments();
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
|
||||
$this->assertEquals('doctrine.dbal.conn2_connection', (string) $arguments[0]);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
|
||||
$this->assertEquals('doctrine.orm.em2_configuration', (string) $arguments[1]);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.em1_metadata_cache');
|
||||
$this->assertEquals('%doctrine.orm.cache.xcache.class%', $definition->getClass());
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.em1_query_cache');
|
||||
$this->assertEquals('%doctrine.orm.cache.array.class%', $definition->getClass());
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.em1_result_cache');
|
||||
$this->assertEquals('%doctrine.orm.cache.array.class%', $definition->getClass());
|
||||
}
|
||||
|
||||
public function testLoadLogging()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'dbal_logging');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.log_connection.configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'setSQLLogger', array(new Reference('doctrine.dbal.logger')));
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.profile_connection.configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'setSQLLogger', array(new Reference('doctrine.dbal.logger.chain.profile')));
|
||||
|
||||
$definition = $container->getDefinition('doctrine.dbal.both_connection.configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'setSQLLogger', array(new Reference('doctrine.dbal.logger.chain.both')));
|
||||
}
|
||||
|
||||
public function testBundleEntityAliases()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'setEntityNamespaces',
|
||||
array(array('YamlBundle' => 'Fixtures\Bundles\YamlBundle\Entity'))
|
||||
);
|
||||
}
|
||||
|
||||
public function testOverwriteEntityAliases()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array('alias' => 'yml')))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'setEntityNamespaces',
|
||||
array(array('yml' => 'Fixtures\Bundles\YamlBundle\Entity'))
|
||||
);
|
||||
}
|
||||
|
||||
public function testYamlBundleMappingDetection()
|
||||
{
|
||||
$container = $this->getContainer('YamlBundle');
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_yml_metadata_driver'),
|
||||
'Fixtures\Bundles\YamlBundle\Entity'
|
||||
));
|
||||
}
|
||||
|
||||
public function testXmlBundleMappingDetection()
|
||||
{
|
||||
$container = $this->getContainer('XmlBundle');
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('XmlBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_xml_metadata_driver'),
|
||||
'Fixtures\Bundles\XmlBundle\Entity'
|
||||
));
|
||||
}
|
||||
|
||||
public function testAnnotationsBundleMappingDetection()
|
||||
{
|
||||
$container = $this->getContainer('AnnotationsBundle');
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('AnnotationsBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_annotation_metadata_driver'),
|
||||
'Fixtures\Bundles\AnnotationsBundle\Entity'
|
||||
));
|
||||
}
|
||||
|
||||
public function testOrmMergeConfigs()
|
||||
{
|
||||
$container = $this->getContainer(array('XmlBundle', 'AnnotationsBundle'));
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$config1 = $this->getConnectionConfig();
|
||||
$config1['orm'] = array(
|
||||
'auto_generate_proxy_classes' => true,
|
||||
'default_entity_manager' => 'default',
|
||||
'entity_managers' => array(
|
||||
'default' => array('mappings' => array('AnnotationsBundle' => array()))
|
||||
));
|
||||
$config2 = $this->getConnectionConfig();
|
||||
$config2['orm'] = array(
|
||||
'auto_generate_proxy_classes' => false,
|
||||
'default_entity_manager' => 'default',
|
||||
'entity_managers' => array(
|
||||
'default' => array('mappings' => array('XmlBundle' => array()))
|
||||
));
|
||||
$loader->load(array($config1, $config2), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_annotation_metadata_driver'),
|
||||
'Fixtures\Bundles\AnnotationsBundle\Entity'
|
||||
));
|
||||
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_xml_metadata_driver'),
|
||||
'Fixtures\Bundles\XmlBundle\Entity'
|
||||
));
|
||||
|
||||
$configDef = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($configDef, 'setAutoGenerateProxyClasses');
|
||||
|
||||
$calls = $configDef->getMethodCalls();
|
||||
foreach ($calls as $call) {
|
||||
if ($call[0] == 'setAutoGenerateProxyClasses') {
|
||||
$this->assertFalse($container->getParameterBag()->resolveValue($call[1][0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testEntityManagerMetadataCacheDriverConfiguration()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_service_multiple_entity_managers');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.em1_metadata_cache');
|
||||
$this->assertDICDefinitionClass($definition, '%doctrine.orm.cache.xcache.class%');
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.em2_metadata_cache');
|
||||
$this->assertDICDefinitionClass($definition, '%doctrine.orm.cache.apc.class%');
|
||||
}
|
||||
|
||||
public function testEntityManagerMemcacheMetadataCacheDriverConfiguration()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_service_simple_single_entity_manager');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_cache');
|
||||
$this->assertDICDefinitionClass($definition, 'Doctrine\Common\Cache\MemcacheCache');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'setMemcache',
|
||||
array(new Reference('doctrine.orm.default_memcache_instance'))
|
||||
);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_memcache_instance');
|
||||
$this->assertDICDefinitionClass($definition, 'Memcache');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'connect', array(
|
||||
'localhost', '11211'
|
||||
));
|
||||
}
|
||||
|
||||
public function testDependencyInjectionImportsOverrideDefaults()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_imports');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$cacheDefinition = $container->getDefinition('doctrine.orm.default_metadata_cache');
|
||||
$this->assertEquals('%doctrine.orm.cache.apc.class%', $cacheDefinition->getClass());
|
||||
|
||||
$configDefinition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($configDefinition, 'setAutoGenerateProxyClasses', array('%doctrine.orm.auto_generate_proxy_classes%'));
|
||||
}
|
||||
|
||||
public function testSingleEntityManagerMultipleMappingBundleDefinitions()
|
||||
{
|
||||
$container = $this->getContainer(array('YamlBundle', 'AnnotationsBundle', 'XmlBundle'));
|
||||
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_single_em_bundle_mappings');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
|
||||
$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_annotation_metadata_driver'),
|
||||
'Fixtures\Bundles\AnnotationsBundle\Entity'
|
||||
));
|
||||
|
||||
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_yml_metadata_driver'),
|
||||
'Fixtures\Bundles\YamlBundle\Entity'
|
||||
));
|
||||
|
||||
$this->assertDICDefinitionMethodCallAt(2, $definition, 'addDriver', array(
|
||||
new Reference('doctrine.orm.default_xml_metadata_driver'),
|
||||
'Fixtures\Bundles\XmlBundle'
|
||||
));
|
||||
|
||||
$annDef = $container->getDefinition('doctrine.orm.default_annotation_metadata_driver');
|
||||
$this->assertDICConstructorArguments($annDef, array(
|
||||
new Reference('doctrine.orm.metadata.annotation_reader'),
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'AnnotationsBundle'.DIRECTORY_SEPARATOR.'Entity')
|
||||
));
|
||||
|
||||
$ymlDef = $container->getDefinition('doctrine.orm.default_yml_metadata_driver');
|
||||
$this->assertDICConstructorArguments($ymlDef, array(
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'YamlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine' => 'Fixtures\Bundles\YamlBundle\Entity')
|
||||
));
|
||||
|
||||
$xmlDef = $container->getDefinition('doctrine.orm.default_xml_metadata_driver');
|
||||
$this->assertDICConstructorArguments($xmlDef, array(
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'XmlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine' => 'Fixtures\Bundles\XmlBundle')
|
||||
));
|
||||
}
|
||||
|
||||
public function testMultipleEntityManagersMappingBundleDefinitions()
|
||||
{
|
||||
$container = $this->getContainer(array('YamlBundle', 'AnnotationsBundle', 'XmlBundle'));
|
||||
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_multiple_em_bundle_mappings');
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$this->assertEquals(array('em1' => 'doctrine.orm.em1_entity_manager', 'em2' => 'doctrine.orm.em2_entity_manager'), $container->getParameter('doctrine.entity_managers'), "Set of the existing EntityManagers names is incorrect.");
|
||||
$this->assertEquals('%doctrine.entity_managers%', $container->getDefinition('doctrine')->getArgument(2), "Set of the existing EntityManagers names is incorrect.");
|
||||
|
||||
$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
|
||||
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');
|
||||
|
||||
$this->assertDICDefinitionMethodCallAt(0, $def1, 'addDriver', array(
|
||||
new Reference('doctrine.orm.em1_annotation_metadata_driver'),
|
||||
'Fixtures\Bundles\AnnotationsBundle\Entity'
|
||||
));
|
||||
|
||||
$this->assertDICDefinitionMethodCallAt(0, $def2, 'addDriver', array(
|
||||
new Reference('doctrine.orm.em2_yml_metadata_driver'),
|
||||
'Fixtures\Bundles\YamlBundle\Entity'
|
||||
));
|
||||
|
||||
$this->assertDICDefinitionMethodCallAt(1, $def2, 'addDriver', array(
|
||||
new Reference('doctrine.orm.em2_xml_metadata_driver'),
|
||||
'Fixtures\Bundles\XmlBundle'
|
||||
));
|
||||
|
||||
$annDef = $container->getDefinition('doctrine.orm.em1_annotation_metadata_driver');
|
||||
$this->assertDICConstructorArguments($annDef, array(
|
||||
new Reference('doctrine.orm.metadata.annotation_reader'),
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'AnnotationsBundle'.DIRECTORY_SEPARATOR.'Entity')
|
||||
));
|
||||
|
||||
$ymlDef = $container->getDefinition('doctrine.orm.em2_yml_metadata_driver');
|
||||
$this->assertDICConstructorArguments($ymlDef, array(
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'YamlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine' => 'Fixtures\Bundles\YamlBundle\Entity')
|
||||
));
|
||||
|
||||
$xmlDef = $container->getDefinition('doctrine.orm.em2_xml_metadata_driver');
|
||||
$this->assertDICConstructorArguments($xmlDef, array(
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'XmlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine' => 'Fixtures\Bundles\XmlBundle')
|
||||
));
|
||||
}
|
||||
|
||||
public function testAnnotationsBundleMappingDetectionWithVendorNamespace()
|
||||
{
|
||||
$container = $this->getContainer('AnnotationsBundle', 'Vendor');
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('AnnotationsBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$calls = $container->getDefinition('doctrine.orm.default_metadata_driver')->getMethodCalls();
|
||||
$this->assertEquals('doctrine.orm.default_annotation_metadata_driver', (string) $calls[0][1][0]);
|
||||
$this->assertEquals('Fixtures\Bundles\Vendor\AnnotationsBundle\Entity', $calls[0][1][1]);
|
||||
}
|
||||
|
||||
public function testSetTypes()
|
||||
{
|
||||
$container = $this->getContainer(array('YamlBundle'));
|
||||
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
$this->loadFromFile($container, 'dbal_types');
|
||||
$this->compileContainer($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array('test' => array('class' => 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType', 'commented' => true)),
|
||||
$container->getParameter('doctrine.dbal.connection_factory.types')
|
||||
);
|
||||
$this->assertEquals('%doctrine.dbal.connection_factory.types%', $container->getDefinition('doctrine.dbal.connection_factory')->getArgument(0));
|
||||
}
|
||||
|
||||
public function testSetCustomFunctions()
|
||||
{
|
||||
$container = $this->getContainer(array('YamlBundle'));
|
||||
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
$this->loadFromFile($container, 'orm_functions');
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addCustomStringFunction', array('test_string', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction'));
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addCustomNumericFunction', array('test_numeric', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestNumericFunction'));
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addCustomDatetimeFunction', array('test_datetime', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestDatetimeFunction'));
|
||||
}
|
||||
|
||||
public function testSingleEMSetCustomFunctions()
|
||||
{
|
||||
$container = $this->getContainer(array('YamlBundle'));
|
||||
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
$this->loadFromFile($container, 'orm_single_em_dql_functions');
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addCustomStringFunction', array('test_string', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction'));
|
||||
}
|
||||
|
||||
public function testAddCustomHydrationMode()
|
||||
{
|
||||
$container = $this->getContainer(array('YamlBundle'));
|
||||
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
$this->loadFromFile($container, 'orm_hydration_mode');
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addCustomHydrationMode', array('test_hydrator', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator'));
|
||||
}
|
||||
|
||||
public function testAddFilter()
|
||||
{
|
||||
$container = $this->getContainer(array('YamlBundle'));
|
||||
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_filters');
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addFilter', array('soft_delete', 'Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\TestFilter'));
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_manager_configurator');
|
||||
$this->assertDICConstructorArguments($definition, array(array('soft_delete')));
|
||||
|
||||
// Let's create the instance to check the configurator work.
|
||||
/** @var $entityManager \Doctrine\ORM\EntityManager */
|
||||
$entityManager = $container->get('doctrine.orm.entity_manager');
|
||||
$this->assertCount(1, $entityManager->getFilters()->getEnabledFilters());
|
||||
}
|
||||
|
||||
public function testResolveTargetEntity()
|
||||
{
|
||||
$container = $this->getContainer(array('YamlBundle'));
|
||||
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
|
||||
$this->loadFromFile($container, 'orm_resolve_target_entity');
|
||||
$this->compileContainer($container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addResolveTargetEntity', array('Symfony\Component\Security\Core\User\UserInterface', 'MyUserClass', array()));
|
||||
$this->assertEquals(array('doctrine.event_listener' => array( array('event' => 'loadClassMetadata') ) ), $definition->getTags());
|
||||
}
|
||||
|
||||
protected function getContainer($bundles = 'YamlBundle', $vendor = null)
|
||||
{
|
||||
$bundles = (array) $bundles;
|
||||
|
||||
$map = array();
|
||||
foreach ($bundles as $bundle) {
|
||||
require_once __DIR__.'/Fixtures/Bundles/'.($vendor ? $vendor.'/' : '').$bundle.'/'.$bundle.'.php';
|
||||
|
||||
$map[$bundle] = 'Fixtures\\Bundles\\'.($vendor ? $vendor.'\\' : '').$bundle.'\\'.$bundle;
|
||||
}
|
||||
|
||||
return new ContainerBuilder(new ParameterBag(array(
|
||||
'kernel.debug' => false,
|
||||
'kernel.bundles' => $map,
|
||||
'kernel.cache_dir' => sys_get_temp_dir(),
|
||||
'kernel.environment' => 'test',
|
||||
'kernel.root_dir' => __DIR__.'/../../' // src dir
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assertion on the Class of a DIC Service Definition.
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\Definition $definition
|
||||
* @param string $expectedClass
|
||||
*/
|
||||
protected function assertDICDefinitionClass($definition, $expectedClass)
|
||||
{
|
||||
$this->assertEquals($expectedClass, $definition->getClass(), 'Expected Class of the DIC Container Service Definition is wrong.');
|
||||
}
|
||||
|
||||
protected function assertDICConstructorArguments($definition, $args)
|
||||
{
|
||||
$this->assertEquals($args, $definition->getArguments(), "Expected and actual DIC Service constructor arguments of definition '".$definition->getClass()."' don't match.");
|
||||
}
|
||||
|
||||
protected function assertDICDefinitionMethodCallAt($pos, $definition, $methodName, array $params = null)
|
||||
{
|
||||
$calls = $definition->getMethodCalls();
|
||||
if (isset($calls[$pos][0])) {
|
||||
$this->assertEquals($methodName, $calls[$pos][0], "Method '".$methodName."' is expected to be called at position $pos.");
|
||||
|
||||
if ($params !== null) {
|
||||
$this->assertEquals($params, $calls[$pos][1], "Expected parameters to methods '".$methodName."' do not match the actual parameters.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assertion for the DI Container, check if the given definition contains a method call with the given parameters.
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\Definition $definition
|
||||
* @param string $methodName
|
||||
* @param array $params
|
||||
*/
|
||||
protected function assertDICDefinitionMethodCallOnce($definition, $methodName, array $params = null)
|
||||
{
|
||||
$calls = $definition->getMethodCalls();
|
||||
$called = false;
|
||||
foreach ($calls as $call) {
|
||||
if ($call[0] == $methodName) {
|
||||
if ($called) {
|
||||
$this->fail("Method '".$methodName."' is expected to be called only once, a second call was registered though.");
|
||||
} else {
|
||||
$called = true;
|
||||
if ($params !== null) {
|
||||
$this->assertEquals($params, $call[1], "Expected parameters to methods '".$methodName."' do not match the actual parameters.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$called) {
|
||||
$this->fail("Method '".$methodName."' is expected to be called once, definition does not contain a call though.");
|
||||
}
|
||||
}
|
||||
|
||||
protected function compileContainer(ContainerBuilder $container)
|
||||
{
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses(array(new ResolveDefinitionTemplatesPass()));
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->compile();
|
||||
}
|
||||
|
||||
protected function getConnectionConfig()
|
||||
{
|
||||
return array('dbal' => array('connections' => array('default' => array('password' => 'foo'))));
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Fixtures\Bundles\AnnotationsBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class AnnotationsBundle extends Bundle
|
||||
{
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Fixtures\Bundles\AnnotationsBundle\Entity;
|
||||
|
||||
class Test
|
||||
{
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Fixtures\Bundles\Vendor\AnnotationsBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class AnnotationsBundle extends Bundle
|
||||
{
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Fixtures\Bundles\Vendor\AnnotationsBundle\Entity;
|
||||
|
||||
class Test
|
||||
{
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Fixtures\Bundles\XmlBundle\Entity;
|
||||
|
||||
class Test
|
||||
{
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Fixtures\Bundles\XmlBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class XmlBundle extends Bundle
|
||||
{
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Fixtures\Bundles\YamlBundle\Entity;
|
||||
|
||||
class Test
|
||||
{
|
||||
private $id;
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
Fixtures\Bundles\YamlBundle\Entity\Test:
|
||||
type: entity
|
||||
id:
|
||||
id:
|
||||
type: integer
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Fixtures\Bundles\YamlBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class YamlBundle extends Bundle
|
||||
{
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="mysql">
|
||||
<connection
|
||||
name="log"
|
||||
logging="true"
|
||||
profiling="false" />
|
||||
<connection
|
||||
name="profile"
|
||||
logging="false"
|
||||
profiling="true" />
|
||||
<connection
|
||||
name="both"
|
||||
logging="true"
|
||||
profiling="true" />
|
||||
<connection
|
||||
name="none"
|
||||
logging="false"
|
||||
profiling="false" />
|
||||
</dbal>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="mysql">
|
||||
<connection
|
||||
name="mysql"
|
||||
dbname="mysql_db"
|
||||
user="mysql_user"
|
||||
password="mysql_s3cr3t"
|
||||
unix-socket="/path/to/mysqld.sock" /><!-- -->
|
||||
<connection
|
||||
name="sqlite"
|
||||
driver="pdo_sqlite"
|
||||
dbname="sqlite_db"
|
||||
user="sqlite_user"
|
||||
password="sqlite_s3cr3t"
|
||||
memory="true" />
|
||||
<connection
|
||||
name="oci"
|
||||
driver="oci8"
|
||||
dbname="oracle_db"
|
||||
user="oracle_user"
|
||||
password="oracle_s3cr3t"
|
||||
charset="utf8" />
|
||||
</dbal>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal dbname="mysql_db" user="mysql_user" password="mysql_s3cr3t" unix-socket="/path/to/mysqld.sock" />
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal dbname="mysql_db" user="mysql_user" password="mysql_s3cr3t" unix-socket="/path/to/mysqld.sock">
|
||||
<slave name="slave1" dbname="slave_db" user="slave_user" password="slave_s3cr3t" unix-socket="/path/to/mysqld_slave.sock" />
|
||||
</dbal>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<type name="test">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType</type>
|
||||
<connection name="default" />
|
||||
</dbal>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm>
|
||||
<filter name="soft_delete" enabled="true">Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\TestFilter</filter>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="default">
|
||||
<entity-manager name="default">
|
||||
<mapping name="YamlBundle" />
|
||||
<dql>
|
||||
<string-function name="test_string">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction</string-function>
|
||||
<numeric-function name="test_numeric">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestNumericFunction</numeric-function>
|
||||
<datetime-function name="test_datetime">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestDatetimeFunction</datetime-function>
|
||||
</dql>
|
||||
</entity-manager>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="default">
|
||||
<entity-manager name="default">
|
||||
<hydrator name="test_hydrator">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator</hydrator>
|
||||
<mapping name="YamlBundle" />
|
||||
</entity-manager>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<srv:imports>
|
||||
<srv:import resource="orm_imports_import.xml" />
|
||||
</srv:imports>
|
||||
|
||||
<config>
|
||||
<orm auto-generate-proxy-classes="true" />
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm
|
||||
auto-generate-proxy-classes="false"
|
||||
default-entity-manager="default"
|
||||
>
|
||||
<entity-manager name="default" metadata-cache-driver="apc">
|
||||
<mapping name="YamlBundle" />
|
||||
</entity-manager>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="em2">
|
||||
<entity-manager name="em1">
|
||||
<mapping name="AnnotationsBundle" />
|
||||
</entity-manager>
|
||||
<entity-manager name="em2">
|
||||
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
|
||||
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
|
||||
dir="%kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
|
||||
alias="TestAlias"
|
||||
/>
|
||||
</entity-manager>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<orm proxy-dir="%kernel.cache_dir%/doctrine" proxy-namespace="DCProxy" />
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="default">
|
||||
<resolve-target-entity interface="Symfony\Component\Security\Core\User\UserInterface">MyUserClass</resolve-target-entity>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<srv:parameters>
|
||||
<srv:parameter key="doctrine.orm.proxy_namespace">Proxies</srv:parameter>
|
||||
</srv:parameters>
|
||||
|
||||
<config>
|
||||
<dbal default-connection="conn1">
|
||||
<connection
|
||||
name="conn1"
|
||||
driver="pdo_sqlite"
|
||||
dbname="sqlite_db"
|
||||
user="sqlite_user"
|
||||
password="sqlite_s3cr3t"
|
||||
memory="true" />
|
||||
<connection
|
||||
name="conn2"
|
||||
driver="pdo_sqlite"
|
||||
dbname="sqlite_db"
|
||||
user="sqlite_user"
|
||||
password="sqlite_s3cr3t"
|
||||
memory="true" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="em2" auto-generate-proxy-classes="true">
|
||||
<entity-manager name="em1" metadata-cache-driver="xcache" connection="conn1">
|
||||
<mapping name="YamlBundle" />
|
||||
</entity-manager>
|
||||
<entity-manager name="em2" connection="conn2" metadata-cache-driver="apc">
|
||||
<mapping name="YamlBundle" />
|
||||
</entity-manager>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="default">
|
||||
<entity-manager name="default">
|
||||
<metadata-cache-driver type="memcache">
|
||||
<class>Doctrine\Common\Cache\MemcacheCache</class>
|
||||
<host>localhost</host>
|
||||
<port>11211</port>
|
||||
<instance-class>Memcache</instance-class>
|
||||
</metadata-cache-driver>
|
||||
<mapping name="YamlBundle" />
|
||||
</entity-manager>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<srv:parameters>
|
||||
<srv:parameter key="doctrine.orm.proxy_namespace">Proxies</srv:parameter>
|
||||
</srv:parameters>
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection
|
||||
name="default"
|
||||
driver="pdo_sqlite"
|
||||
dbname="sqlite_db"
|
||||
user="sqlite_user"
|
||||
password="sqlite_s3cr3t"
|
||||
memory="true" />
|
||||
</dbal>
|
||||
|
||||
<orm
|
||||
default-entity-manager="default"
|
||||
auto-generate-proxy-classes="true"
|
||||
>
|
||||
<entity-manager name="default" connection="default" default-repository-class="Acme\Doctrine\Repository">
|
||||
<metadata-cache-driver type="memcache">
|
||||
<class>Doctrine\Common\Cache\MemcacheCache</class>
|
||||
<host>localhost</host>
|
||||
<port>11211</port>
|
||||
<instance-class>Memcache</instance-class>
|
||||
</metadata-cache-driver>
|
||||
<mapping name="YamlBundle" />
|
||||
</entity-manager>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm>
|
||||
<mapping name="AnnotationsBundle" />
|
||||
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
|
||||
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
|
||||
dir="%kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
|
||||
alias="TestAlias"
|
||||
/>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:srv="http://symfony.com/schema/dic/services"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm>
|
||||
<dql>
|
||||
<string-function name="test_string">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction</string-function>
|
||||
</dql>
|
||||
</orm>
|
||||
</config>
|
||||
</srv:container>
|
@@ -0,0 +1,13 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: mysql
|
||||
connections:
|
||||
log:
|
||||
logging: true
|
||||
profiling: false
|
||||
profile:
|
||||
logging: false
|
||||
profiling: true
|
||||
both:
|
||||
logging: true
|
||||
profiling: true
|
@@ -0,0 +1,18 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: mysql
|
||||
connections:
|
||||
mysql:
|
||||
dbname: mysql_db
|
||||
user: mysql_user
|
||||
password: mysql_s3cr3t
|
||||
unix_socket: /path/to/mysqld.sock
|
||||
sqlite:
|
||||
driver: pdo_sqlite
|
||||
memory: true
|
||||
oci:
|
||||
driver: oci8
|
||||
dbname: oracle_db
|
||||
user: oracle_user
|
||||
password: oracle_s3cr3t
|
||||
charset: utf8
|
@@ -0,0 +1,6 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
dbname: mysql_db
|
||||
user: mysql_user
|
||||
password: mysql_s3cr3t
|
||||
unix_socket: /path/to/mysqld.sock
|
@@ -0,0 +1,12 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
dbname: mysql_db
|
||||
user: mysql_user
|
||||
password: mysql_s3cr3t
|
||||
unix_socket: /path/to/mysqld.sock
|
||||
slaves:
|
||||
slave1:
|
||||
user: slave_user
|
||||
dbname: slave_db
|
||||
password: slave_s3cr3t
|
||||
unix_socket: /path/to/mysqld_slave.sock
|
@@ -0,0 +1,7 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
types:
|
||||
test: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType
|
||||
connections:
|
||||
default: ~
|
@@ -0,0 +1,12 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
filters:
|
||||
soft_delete:
|
||||
class: Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\TestFilter
|
||||
enabled: true
|
@@ -0,0 +1,19 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
entity_managers:
|
||||
default:
|
||||
mappings:
|
||||
YamlBundle: ~
|
||||
dql:
|
||||
string_functions:
|
||||
test_string: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction
|
||||
numeric_functions:
|
||||
test_numeric: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestNumericFunction
|
||||
datetime_functions:
|
||||
test_datetime: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestDatetimeFunction
|
@@ -0,0 +1,14 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
entity_managers:
|
||||
default:
|
||||
hydrators:
|
||||
test_hydrator: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator
|
||||
mappings:
|
||||
YamlBundle: ~
|
@@ -0,0 +1,6 @@
|
||||
imports:
|
||||
- { resource: orm_imports_import.yml }
|
||||
|
||||
doctrine:
|
||||
orm:
|
||||
auto_generate_proxy_classes: true
|
@@ -0,0 +1,15 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
auto_generate_proxy_classes: false
|
||||
default_entity_manager: default
|
||||
entity_managers:
|
||||
default:
|
||||
metadata_cache_driver: apc
|
||||
mappings:
|
||||
YamlBundle: ~
|
@@ -0,0 +1,23 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
default_entity_manager: em2
|
||||
entity_managers:
|
||||
em1:
|
||||
mappings:
|
||||
AnnotationsBundle: ~
|
||||
em2:
|
||||
mappings:
|
||||
YamlBundle:
|
||||
dir: Resources/config/doctrine
|
||||
alias: yml
|
||||
manual:
|
||||
type: xml
|
||||
prefix: Fixtures\Bundles\XmlBundle
|
||||
dir: %kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine
|
||||
alias: TestAlias
|
@@ -0,0 +1,10 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
resolve_target_entities:
|
||||
Symfony\Component\Security\Core\User\UserInterface: MyUserClass
|
@@ -0,0 +1,34 @@
|
||||
parameters:
|
||||
doctrine.orm.proxy_namespace: Proxies
|
||||
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: conn1
|
||||
connections:
|
||||
conn1:
|
||||
driver: pdo_sqlite
|
||||
dbname: sqlite_db
|
||||
user: sqlite_user
|
||||
password: sqlite_s3cr3t
|
||||
memory: true
|
||||
conn2:
|
||||
driver: pdo_sqlite
|
||||
dbname: sqlite_db
|
||||
user: sqlite_user
|
||||
password: sqlite_s3cr3t
|
||||
memory: true
|
||||
|
||||
orm:
|
||||
default_entity_manager: em2
|
||||
auto_generate_proxy_classes: true
|
||||
entity_managers:
|
||||
em1:
|
||||
metadata_cache_driver: xcache
|
||||
connection: conn1
|
||||
mappings:
|
||||
YamlBundle: ~
|
||||
em2:
|
||||
metadata_cache_driver: apc
|
||||
connection: conn2
|
||||
mappings:
|
||||
YamlBundle: ~
|
@@ -0,0 +1,19 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
default_entity_manager: default
|
||||
entity_managers:
|
||||
default:
|
||||
mappings:
|
||||
YamlBundle: ~
|
||||
metadata_cache_driver:
|
||||
type: memcache
|
||||
class: Doctrine\Common\Cache\MemcacheCache
|
||||
host: localhost
|
||||
port: 11211
|
||||
instance_class: Memcache
|
@@ -0,0 +1,27 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
driver: pdo_sqlite
|
||||
dbname: sqlite_db
|
||||
user: sqlite_user
|
||||
password: sqlite_s3cr3t
|
||||
memory: true
|
||||
|
||||
orm:
|
||||
default_entity_manager: dm2
|
||||
proxy_namespace: Proxies
|
||||
auto_generate_proxy_classes: true
|
||||
entity_managers:
|
||||
default:
|
||||
connection: default
|
||||
default_repository_class: Acme\Doctrine\Repository
|
||||
mappings:
|
||||
YamlBundle: ~
|
||||
metadata_cache_driver:
|
||||
type: memcache
|
||||
class: Doctrine\Common\Cache\MemcacheCache
|
||||
host: localhost
|
||||
port: 11211
|
||||
instance_class: Memcache
|
@@ -0,0 +1,18 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
mappings:
|
||||
AnnotationsBundle: ~
|
||||
YamlBundle:
|
||||
dir: Resources/config/doctrine
|
||||
alias: yml
|
||||
manual:
|
||||
type: xml
|
||||
prefix: Fixtures\Bundles\XmlBundle
|
||||
dir: %kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine
|
||||
alias: TestAlias
|
@@ -0,0 +1,11 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
dql:
|
||||
string_functions:
|
||||
test_string: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction
|
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
|
||||
class TestDatetimeFunction extends FunctionNode
|
||||
{
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function parse(Parser $parser)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Doctrine\ORM\Query\Filter\SQLFilter;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
|
||||
class TestFilter extends SQLFilter
|
||||
{
|
||||
/**
|
||||
* Gets the SQL query part to add to a query.
|
||||
*
|
||||
* @return string The constraint SQL if there is available, empty string otherwise
|
||||
*/
|
||||
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
|
||||
class TestNumericFunction extends FunctionNode
|
||||
{
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function parse(Parser $parser)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
|
||||
class TestStringFunction extends FunctionNode
|
||||
{
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function parse(Parser $parser)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
|
||||
class TestType extends \Doctrine\DBAL\Types\Type
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'test';
|
||||
}
|
||||
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
class XMLSchemaTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
static public function dataValidateSchemaFiles()
|
||||
{
|
||||
$schemaFiles = array();
|
||||
$di = new \DirectoryIterator(__DIR__."/Fixtures/config/xml");
|
||||
foreach ($di as $element) {
|
||||
if ($element->isFile() && substr($element->getFilename(), -4) === ".xml") {
|
||||
$schemaFiles[] = array($element->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
return $schemaFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataValidateSchemaFiles
|
||||
*/
|
||||
public function testValidateSchema($file)
|
||||
{
|
||||
$found = false;
|
||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||
$dom->load($file);
|
||||
|
||||
|
||||
$dbalElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config");
|
||||
if ($dbalElements->length) {
|
||||
$dbalDom = new \DOMDocument('1.0', 'UTF-8');
|
||||
$dbalNode = $dbalDom->importNode($dbalElements->item(0));
|
||||
$dbalDom->appendChild($dbalNode);
|
||||
|
||||
$ret = $dbalDom->schemaValidate(__DIR__."/../../Resources/config/schema/doctrine-1.0.xsd");
|
||||
$this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.");
|
||||
$found = true;
|
||||
}
|
||||
|
||||
$ormElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config");
|
||||
if ($ormElements->length) {
|
||||
$ormDom = new \DOMDocument('1.0', 'UTF-8');
|
||||
$ormNode = $ormDom->importNode($ormElements->item(0));
|
||||
$ormDom->appendChild($ormNode);
|
||||
|
||||
$ret = $ormDom->schemaValidate(__DIR__."/../../Resources/config/schema/doctrine-1.0.xsd");
|
||||
$this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.");
|
||||
$found = true;
|
||||
}
|
||||
|
||||
$this->assertTrue($found, "Neither <doctrine:orm> nor <doctrine:dbal> elements found in given XML. Are namespaces configured correctly?");
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
class XmlDoctrineExtensionTest extends AbstractDoctrineExtensionTest
|
||||
{
|
||||
protected function loadFromFile(ContainerBuilder $container, $file)
|
||||
{
|
||||
$loadXml = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/xml'));
|
||||
$loadXml->load($file.'.xml');
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
class YamlDoctrineExtensionTest extends AbstractDoctrineExtensionTest
|
||||
{
|
||||
protected function loadFromFile(ContainerBuilder $container, $file)
|
||||
{
|
||||
$loadYaml = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/yml'));
|
||||
$loadYaml->load($file.'.yml');
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests;
|
||||
|
||||
use Doctrine\Bundle\DoctrineBundle\Tests\TestCase;
|
||||
use Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory;
|
||||
use Doctrine\Bundle\DoctrineBundle\Mapping\ClassMetadataCollection;
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
|
||||
class MetadataFactoryTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!class_exists('Doctrine\\ORM\\Version')) {
|
||||
$this->markTestSkipped('Doctrine ORM is not available.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testFindNamespaceAndPathForMetadata()
|
||||
{
|
||||
$class = new ClassMetadataInfo(__CLASS__);
|
||||
$collection = new ClassMetadataCollection(array($class));
|
||||
|
||||
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
|
||||
$factory = new MetadataFactory($registry);
|
||||
|
||||
$this->setExpectedException("RuntimeException", "Can't find base path for \"Doctrine\Bundle\DoctrineBundle\Tests\MetadataFactoryTest");
|
||||
$factory->findNamespaceAndPathForMetadata($collection);
|
||||
}
|
||||
}
|
149
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/RegistryTest.php
vendored
Normal file
149
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/RegistryTest.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests;
|
||||
|
||||
use Doctrine\Bundle\DoctrineBundle\Registry;
|
||||
|
||||
class RegistryTest extends TestCase
|
||||
{
|
||||
public function testGetDefaultConnectionName()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$registry = new Registry($container, array(), array(), 'default', 'default');
|
||||
|
||||
$this->assertEquals('default', $registry->getDefaultConnectionName());
|
||||
}
|
||||
|
||||
public function testGetDefaultEntityManagerName()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$registry = new Registry($container, array(), array(), 'default', 'default');
|
||||
|
||||
$this->assertEquals('default', $registry->getDefaultEntityManagerName());
|
||||
}
|
||||
|
||||
public function testGetDefaultConnection()
|
||||
{
|
||||
$conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$container->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->equalTo('doctrine.dbal.default_connection'))
|
||||
->will($this->returnValue($conn));
|
||||
|
||||
$registry = new Registry($container, array('default' => 'doctrine.dbal.default_connection'), array(), 'default', 'default');
|
||||
|
||||
$this->assertSame($conn, $registry->getConnection());
|
||||
}
|
||||
|
||||
public function testGetConnection()
|
||||
{
|
||||
$conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$container->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->equalTo('doctrine.dbal.default_connection'))
|
||||
->will($this->returnValue($conn));
|
||||
|
||||
$registry = new Registry($container, array('default' => 'doctrine.dbal.default_connection'), array(), 'default', 'default');
|
||||
|
||||
$this->assertSame($conn, $registry->getConnection('default'));
|
||||
}
|
||||
|
||||
public function testGetUnknownConnection()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$registry = new Registry($container, array(), array(), 'default', 'default');
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException', 'Doctrine ORM Connection named "default" does not exist.');
|
||||
$registry->getConnection('default');
|
||||
}
|
||||
|
||||
public function testGetConnectionNames()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$registry = new Registry($container, array('default' => 'doctrine.dbal.default_connection'), array(), 'default', 'default');
|
||||
|
||||
$this->assertEquals(array('default' => 'doctrine.dbal.default_connection'), $registry->getConnectionNames());
|
||||
}
|
||||
|
||||
public function testGetDefaultEntityManager()
|
||||
{
|
||||
$em = new \stdClass();
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$container->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->equalTo('doctrine.orm.default_entity_manager'))
|
||||
->will($this->returnValue($em));
|
||||
|
||||
$registry = new Registry($container, array(), array('default' => 'doctrine.orm.default_entity_manager'), 'default', 'default');
|
||||
|
||||
$this->assertSame($em, $registry->getEntityManager());
|
||||
}
|
||||
|
||||
public function testGetEntityManager()
|
||||
{
|
||||
$em = new \stdClass();
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$container->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->equalTo('doctrine.orm.default_entity_manager'))
|
||||
->will($this->returnValue($em));
|
||||
|
||||
$registry = new Registry($container, array(), array('default' => 'doctrine.orm.default_entity_manager'), 'default', 'default');
|
||||
|
||||
$this->assertSame($em, $registry->getEntityManager('default'));
|
||||
}
|
||||
|
||||
public function testGetUnknownEntityManager()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$registry = new Registry($container, array(), array(), 'default', 'default');
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException', 'Doctrine ORM Manager named "default" does not exist.');
|
||||
$registry->getEntityManager('default');
|
||||
}
|
||||
|
||||
public function testResetDefaultEntityManager()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$container->expects($this->once())
|
||||
->method('set')
|
||||
->with($this->equalTo('doctrine.orm.default_entity_manager'), $this->equalTo(null));
|
||||
|
||||
$registry = new Registry($container, array(), array('default' => 'doctrine.orm.default_entity_manager'), 'default', 'default');
|
||||
$registry->resetEntityManager();
|
||||
}
|
||||
|
||||
public function testResetEntityManager()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$container->expects($this->once())
|
||||
->method('set')
|
||||
->with($this->equalTo('doctrine.orm.default_entity_manager'), $this->equalTo(null));
|
||||
|
||||
$registry = new Registry($container, array(), array('default' => 'doctrine.orm.default_entity_manager'), 'default', 'default');
|
||||
$registry->resetEntityManager('default');
|
||||
}
|
||||
|
||||
public function testResetUnknownEntityManager()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$registry = new Registry($container, array(), array(), 'default', 'default');
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException', 'Doctrine ORM Manager named "default" does not exist.');
|
||||
$registry->resetEntityManager('default');
|
||||
}
|
||||
}
|
83
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/TestCase.php
vendored
Normal file
83
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/TestCase.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Tests;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass;
|
||||
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
|
||||
|
||||
class TestCase extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Doctrine\\Common\\Version')) {
|
||||
$this->markTestSkipped('Doctrine is not available.');
|
||||
}
|
||||
}
|
||||
|
||||
public function createYamlBundleTestContainer()
|
||||
{
|
||||
$container = new ContainerBuilder(new ParameterBag(array(
|
||||
'kernel.debug' => false,
|
||||
'kernel.bundles' => array('YamlBundle' => 'Fixtures\Bundles\YamlBundle\YamlBundle'),
|
||||
'kernel.cache_dir' => sys_get_temp_dir(),
|
||||
'kernel.environment' => 'test',
|
||||
'kernel.root_dir' => __DIR__.'/../../../../' // src dir
|
||||
)));
|
||||
$container->set('annotation_reader', new AnnotationReader());
|
||||
$loader = new DoctrineExtension();
|
||||
$container->registerExtension($loader);
|
||||
$loader->load(array(array(
|
||||
'dbal' => array(
|
||||
'connections' => array(
|
||||
'default' => array(
|
||||
'driver' => 'pdo_mysql',
|
||||
'charset' => 'UTF8',
|
||||
'platform-service' => 'my.platform',
|
||||
)
|
||||
),
|
||||
'default_connection' => 'default',
|
||||
'types' => array(
|
||||
'test' => 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType',
|
||||
),
|
||||
), 'orm' => array(
|
||||
'default_entity_manager' => 'default',
|
||||
'entity_managers' => array (
|
||||
'default' => array(
|
||||
'mappings' => array('YamlBundle' => array(
|
||||
'type' => 'yml',
|
||||
'dir' => __DIR__.'/DependencyInjection/Fixtures/Bundles/YamlBundle/Resources/config/doctrine',
|
||||
'prefix' => 'Fixtures\Bundles\YamlBundle\Entity',
|
||||
)
|
||||
))),
|
||||
'resolve_target_entities' => array(
|
||||
'Symfony\Component\Security\Core\User\UserInterface' => 'stdClass',
|
||||
),
|
||||
)
|
||||
)), $container);
|
||||
|
||||
$container->setDefinition('my.platform', new \Symfony\Component\DependencyInjection\Definition('Doctrine\DBAL\Platforms\MySqlPlatform'));
|
||||
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses(array(new ResolveDefinitionTemplatesPass()));
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->compile();
|
||||
|
||||
return $container;
|
||||
}
|
||||
}
|
8
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/bootstrap.php
vendored
Normal file
8
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Tests/bootstrap.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if (!@include __DIR__ . '/../vendor/autoload.php') {
|
||||
die("You must set up the project dependencies, run the following commands:
|
||||
wget http://getcomposer.org/composer.phar
|
||||
php composer.phar install --dev
|
||||
");
|
||||
}
|
Reference in New Issue
Block a user