From 0fe6f13be829877b67f1c8d48ebeda34f76ac119 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 19 Feb 2011 17:17:00 -0600 Subject: [PATCH] [DoctrineMongoDBBundle] Adding a "full" config example in YAML. --- .../DependencyInjection/ConfigurationTest.php | 89 +++++++++++++++++++ .../Fixtures/config/yml/full.yml | 48 ++++++++++ 2 files changed, 137 insertions(+) create mode 100644 src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/Fixtures/config/yml/full.yml diff --git a/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/ConfigurationTest.php index 52937e976251..f0380df6542a 100644 --- a/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Bundle\DoctrineMongoDBBundle\DependencyInjection\Configuration; +use Symfony\Component\Yaml\Yaml; use Symfony\Component\Config\Definition\Processor; @@ -51,6 +52,94 @@ public function testDefaults() } } + /** + * Tests a full configuration. + * + * @dataProvider fullConfigurationProvider + */ + public function testFullConfiguration($config) + { + $processor = new Processor(); + $configuration = new Configuration(); + $options = $processor->process($configuration->getConfigTree(), array($config)); + + $expected = array( + 'proxy_namespace' => 'Test_Proxies', + 'auto_generate_proxy_classes' => true, + 'hydrator_namespace' => 'Test_Hydrators', + 'auto_generate_hydrator_classes' => true, + 'default_document_manager' => 'default_dm_name', + 'default_database' => 'default_db_name', + 'metadata_cache_driver' => array( + 'type' => 'memcache', + 'class' => 'fooClass', + 'host' => 'host_val', + 'port' => 1234, + 'instance_class' => 'instance_val', + ), + 'default_connection' => 'conn1', + 'server' => 'http://server', + 'options' => array( + 'connect' => true, + 'persist' => 'persist_val', + 'timeout' => 500, + 'replicaSet' => true, + 'username' => 'username_val', + 'password' => 'password_val', + ), + 'connections' => array( + 'conn1' => array( + 'server' => null, + 'options' => array(), + ), + 'conn2' => array( + 'server' => 'http://server2', + 'options' => array(), + ), + ), + 'mappings' => array( + 'FooBundle' => array( + 'type' => 'annotations', + ), + ), + 'document_managers' => array( + 'dm1' => array( + 'mappings' => array(), + ), + 'dm2' => array( + 'default_database' => 'dm2_default_db', + 'connection' => 'dm2_connection', + 'database' => 'db1', + 'mappings' => array( + 'BarBundle' => array( + 'type' => 'yml', + 'dir' => '%kernel.cache_dir%', + 'prefix' => 'prefix_val', + 'alias' => 'alias_val', + ) + ), + 'metadata_cache_driver' => array( + 'type' => 'apc', + ) + ) + ) + ); + + //var_dump($options); + + $this->assertEquals($expected, $options); + } + + public function fullConfigurationProvider() + { + $yaml = Yaml::load(__DIR__.'/Fixtures/config/yml/full.yml'); + $yaml = $yaml['doctrine_mongo_db']; + + return array( + array($yaml), + ); + } + /** * @dataProvider optionProvider * @param array $configs The source array of configuration arrays diff --git a/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/Fixtures/config/yml/full.yml b/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/Fixtures/config/yml/full.yml new file mode 100644 index 000000000000..387aa55923bf --- /dev/null +++ b/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/Fixtures/config/yml/full.yml @@ -0,0 +1,48 @@ +doctrine_mongo_db: + proxy_namespace: Test_Proxies + auto_generate_proxy_classes: true + + hydrator_namespace: Test_Hydrators + auto_generate_hydrator_classes: true + + default_document_manager: default_dm_name + default_database: default_db_name + metadata_cache_driver: + type: memcache + class: fooClass + host: host_val + port: 1234 + instance_class: instance_val + + default_connection: conn1 + server: http://server + options: + connect: true + persist: persist_val + timeout: 500 + replicaSet: true + username: username_val + password: password_val + + connections: + conn1: ~ + conn2: + server: http://server2 + + mappings: + FooBundle: annotations + + document_managers: + dm1: ~ + dm2: + default_database: dm2_default_db + connection: dm2_connection + database: db1 + mappings: + BarBundle: + type: yml + dir: %kernel.cache_dir% + prefix: prefix_val + alias: alias_val + metadata_cache_driver: apc + \ No newline at end of file