[DoctrineMongoDBBundle] updated tests to reflect extension changes

This commit is contained in:
Bulat Shakirzyanov 2011-02-14 13:02:13 -05:00 committed by Fabien Potencier
parent 3623753c27
commit 31b923ff55
4 changed files with 26 additions and 16 deletions

View File

@ -70,8 +70,9 @@ abstract class AbstractMongoDBExtensionTest extends TestCase
$arguments = $definition->getArguments();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
$this->assertEquals('doctrine.odm.mongodb.default_connection', (string) $arguments[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
$this->assertEquals('doctrine.odm.mongodb.default_configuration', (string) $arguments[1]);
$this->assertEquals('default', $arguments[1]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[2]);
$this->assertEquals('doctrine.odm.mongodb.default_configuration', (string) $arguments[2]);
}
public function testSingleDocumentManagerConfiguration()
@ -81,7 +82,8 @@ abstract class AbstractMongoDBExtensionTest extends TestCase
$config = array(
'server' => 'mongodb://localhost:27017',
'options' => array('connect' => true)
'options' => array('connect' => true),
'default_database' => 'test'
);
$loader->mongodbLoad(array($config), $container);
@ -98,8 +100,9 @@ abstract class AbstractMongoDBExtensionTest extends TestCase
$arguments = $definition->getArguments();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
$this->assertEquals('doctrine.odm.mongodb.default_connection', (string) $arguments[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
$this->assertEquals('doctrine.odm.mongodb.default_configuration', (string) $arguments[1]);
$this->assertEquals('test', $arguments[1]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[2]);
$this->assertEquals('doctrine.odm.mongodb.default_configuration', (string) $arguments[2]);
}
public function testLoadSimpleSingleConnection()
@ -133,8 +136,9 @@ abstract class AbstractMongoDBExtensionTest extends TestCase
$arguments = $definition->getArguments();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
$this->assertEquals('doctrine.odm.mongodb.default_connection', (string) $arguments[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
$this->assertEquals('doctrine.odm.mongodb.default_configuration', (string) $arguments[1]);
$this->assertEquals('mydb', $arguments[1]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[2]);
$this->assertEquals('doctrine.odm.mongodb.default_configuration', (string) $arguments[2]);
}
public function testLoadSingleConnection()
@ -162,8 +166,9 @@ abstract class AbstractMongoDBExtensionTest extends TestCase
$arguments = $definition->getArguments();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
$this->assertEquals('doctrine.odm.mongodb.default_connection', (string) $arguments[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
$this->assertEquals('doctrine.odm.mongodb.default_configuration', (string) $arguments[1]);
$this->assertEquals('default', $arguments[1]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[2]);
$this->assertEquals('doctrine.odm.mongodb.default_configuration', (string) $arguments[2]);
}
public function testLoadMultipleConnections()
@ -193,8 +198,9 @@ abstract class AbstractMongoDBExtensionTest extends TestCase
$arguments = $definition->getArguments();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
$this->assertEquals('doctrine.odm.mongodb.conn1_connection', (string) $arguments[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
$this->assertEquals('doctrine.odm.mongodb.dm1_configuration', (string) $arguments[1]);
$this->assertEquals('default', $arguments[1]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[2]);
$this->assertEquals('doctrine.odm.mongodb.dm1_configuration', (string) $arguments[2]);
$definition = $container->getDefinition('doctrine.odm.mongodb.conn2_connection');
$this->assertEquals('%doctrine.odm.mongodb.connection_class%', $definition->getClass());
@ -209,8 +215,9 @@ abstract class AbstractMongoDBExtensionTest extends TestCase
$arguments = $definition->getArguments();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
$this->assertEquals('doctrine.odm.mongodb.conn2_connection', (string) $arguments[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
$this->assertEquals('doctrine.odm.mongodb.dm2_configuration', (string) $arguments[1]);
$this->assertEquals('prod2', $arguments[1]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[2]);
$this->assertEquals('doctrine.odm.mongodb.dm2_configuration', (string) $arguments[2]);
}
public function testBundleDocumentAliases()

View File

@ -27,7 +27,9 @@
</doctrine:connections>
<doctrine:document-managers>
<doctrine:document-manager id="dm1" metadata-cache-driver="xcache" connection="conn1" />
<doctrine:document-manager id="dm2" connection="conn2" />
<doctrine:document-manager id="dm2" connection="conn2">
<database>prod2</database>
</doctrine:document-manager>
</doctrine:document-managers>
</doctrine:mongodb>
</container>

View File

@ -17,3 +17,4 @@ doctrine_odm.mongodb:
metadata_cache_driver: xcache
dm2:
connection: conn2
database: prod2

View File

@ -37,6 +37,6 @@ class TestCase extends \PHPUnit_Framework_TestCase
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths));
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
return DocumentManager::create(new Connection(), $config);
return DocumentManager::create(new Connection(), 'test', $config);
}
}