From bd2a0ae2d011f7640e1007665100c7af19a6fae1 Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Mon, 15 Dec 2014 22:03:37 +0100 Subject: [PATCH 1/4] increase symfony version bandwidth --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 52fdf6a..fc4e696 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ php: env: - SYMFONY_VERSION=2.3.* - SYMFONY_VERSION=2.4.* + - SYMFONY_VERSION=2.5.* + - SYMFONY_VERSION=2.6.* - SYMFONY_VERSION=dev-master before_script: @@ -22,4 +24,4 @@ notifications: matrix: allow_failures: - - env: SYMFONY_VERSION=dev-master \ No newline at end of file + - env: SYMFONY_VERSION=dev-master From beb9533a01e8aed691c018df639eb72d7831ff07 Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Mon, 15 Dec 2014 22:44:01 +0100 Subject: [PATCH 2/4] add configuration in Readme --- README.md | 33 +++++++++++++++++++++++++- Tests/Resources/app/config/routing.php | 5 ++++ composer.json | 1 + phpunit.xml.dist | 2 +- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 Tests/Resources/app/config/routing.php diff --git a/README.md b/README.md index 315c6e4..df5a82a 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,35 @@ doctrine implementations. ## Documentation -later ... \ No newline at end of file +### Minimum Configuration + + +```yml + +doctrine_orm_phpcr_adapter: + managers: + reference-phpcr: + defaul: doctrine_phpcr.odm.default_document_manager + reference-dbal-orm: + default: doctrine.orm.default_entity_manager + adapters: + mapping: true + auto_generate_proxy_classes: %kernel.debug% + +``` + +You can add some mapping for the documents/entities as you used to know it in the ORM/ODM: + +```yml + +doctrine_orm_phpcr_adapter: + ... + mappings: + some_name: + type: annotation + dir: ../Entity + is_bundle: true + +``` + +Your will find the mapping information in the (library)[https://github.com/ElectricMaxxx/DoctrineOrmOdmAdapter] diff --git a/Tests/Resources/app/config/routing.php b/Tests/Resources/app/config/routing.php new file mode 100644 index 0000000..df051c6 --- /dev/null +++ b/Tests/Resources/app/config/routing.php @@ -0,0 +1,5 @@ + - \ No newline at end of file + From 408909a4a5c26d47debbd9ebc07fc86df690b724 Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Mon, 15 Dec 2014 23:45:48 +0100 Subject: [PATCH 3/4] add configuration tests for yml+php, add some configuration lines to Readme --- Tests/Resources/Fixtures/config/config.php | 19 +++++ Tests/Resources/Fixtures/config/config.yml | 16 +++++ .../DependencyInjection/ConfigurationTest.php | 69 +++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 Tests/Resources/Fixtures/config/config.php create mode 100644 Tests/Resources/Fixtures/config/config.yml create mode 100644 Tests/Unit/DependencyInjection/ConfigurationTest.php diff --git a/Tests/Resources/Fixtures/config/config.php b/Tests/Resources/Fixtures/config/config.php new file mode 100644 index 0000000..d02fdaf --- /dev/null +++ b/Tests/Resources/Fixtures/config/config.php @@ -0,0 +1,19 @@ +loadFromExtension('doctrine_orm_phpcr_adapter', array( + 'managers' => array( + 'reference-phpcr' => array('default' => 'doctrine_phpcr.odm.default_document_manager'), + 'reference-dbal-orm' => array('default' => 'doctrine.orm.default_entity_manager'), + ), + 'adapter' => array( + 'auto_mapping' => true, + 'auto_generate_proxy_classes' => true, + 'mappings' => array( + 'test_mapping' => array( + 'type' => 'annotation', + 'prefix' => '\Entity', + 'dir' => '%kernel.root_dir%/../Entity', + 'is_bundle' => false, + ), + ), + ), +)); diff --git a/Tests/Resources/Fixtures/config/config.yml b/Tests/Resources/Fixtures/config/config.yml new file mode 100644 index 0000000..6b8849b --- /dev/null +++ b/Tests/Resources/Fixtures/config/config.yml @@ -0,0 +1,16 @@ +doctrine_orm_phpcr_adapter: + managers: + reference-phpcr: + default: doctrine_phpcr.odm.default_document_manager + reference-dbal-orm: + default: doctrine.orm.default_entity_manager + adapter: + mapping: true + auto_generate_proxy_classes: true + mappings: + test_mapping: + type: annotation + dir: %kernel.root_dir%/../Entity + prefix: \Entity + is_bundle: true + diff --git a/Tests/Unit/DependencyInjection/ConfigurationTest.php b/Tests/Unit/DependencyInjection/ConfigurationTest.php new file mode 100644 index 0000000..500f32f --- /dev/null +++ b/Tests/Unit/DependencyInjection/ConfigurationTest.php @@ -0,0 +1,69 @@ + + */ +class ConfigurationTest extends AbstractExtensionConfigurationTestCase +{ + protected function getContainerExtension() + { + return new DoctrineOrmPhpcrAdapterExtension(); + } + + protected function getConfiguration() + { + return new Configuration(); + } + + public function testDefaultsForAllConfigFormats() + { + $expectedConfiguration = array( + 'managers' => array( + array('name' => 'default', 'service' => 'doctrine_phpcr.odm.default_document_manager', 'type' => 'reference-phpcr'), + array('name' => 'default', 'service' => 'doctrine.orm.default_entity_manager', 'type' => 'reference-dbal-orm'), + array('name' => 'default', 'service' => 'doctrine_phpcr.odm.default_document_manager', 'type' => 'reference-phpcr'), // remove that duplication, when i find that + array('name' => 'default', 'service' => 'doctrine.orm.default_entity_manager', 'type' => 'reference-dbal-orm'), + ), + 'adapter' => array( + 'auto_generate_proxy_classes' => true, + 'default_adapter_manager' => 'default', + 'adapter_managers' => array( + 'default' => array( + 'mappings' => array( + 'test_mapping' => array( + 'type' => 'annotation', + 'prefix' => '\Entity', + 'dir' => '%kernel.root_dir%/../Entity', + 'is_bundle' => false, + 'mapping' => true, + ), + ), + 'auto_mapping' => true, + 'metadata_cache_driver' => array( + 'type' => 'array', + ), + 'class_metadata_factory_name' => 'Doctrine\ORM\ODMAdapter\Mapping\ClassMetadataFactory', + ), + ), + 'proxy_dir' => '%kernel.cache_dir%/doctrine/PHPCRProxies', + 'proxy_namespace' => 'PHPCRProxies' + ), + ); + + $sources = array_map(function ($path) { + return __DIR__.'/../../Resources/Fixtures/'.$path; + }, array( + 'config/config.yml', + 'config/config.php', + )); + + $this->assertProcessedConfigurationEquals($expectedConfiguration, $sources); + } +} + From 4abfb7d4cb92fd7a4cc46c25385c63ac6e613b67 Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Mon, 15 Dec 2014 23:50:03 +0100 Subject: [PATCH 4/4] add test for existence of listener --- .../DoctrineOrmPhpcrAdapterExtensionTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tests/Unit/DependencyInjection/DoctrineOrmPhpcrAdapterExtensionTest.php b/Tests/Unit/DependencyInjection/DoctrineOrmPhpcrAdapterExtensionTest.php index 42d87bf..e42f91a 100644 --- a/Tests/Unit/DependencyInjection/DoctrineOrmPhpcrAdapterExtensionTest.php +++ b/Tests/Unit/DependencyInjection/DoctrineOrmPhpcrAdapterExtensionTest.php @@ -78,5 +78,10 @@ public function testDefaultSessionSetting() $this->assertContainerBuilderHasParameter('doctrine_orm_phpcr_adapter.sessions', array( 'default' => 'doctrine_orm_phpcr_adapter.default_session', )); + + $this->assertContainerBuilderHasService('doctrine_orm_phpcr_adapter.event.phpcr', 'Doctrine\ORM\Bundle\DoctrineOrmPhpcrAdapterBundle\Event\PhpcrListener'); + $this->assertContainerBuilderHasService('doctrine_orm_phpcr_adapter.event.orm', 'Doctrine\ORM\Bundle\DoctrineOrmPhpcrAdapterBundle\Event\OrmListener'); + $this->assertContainerBuilderHasServiceDefinitionWithTag('doctrine_orm_phpcr_adapter.event.phpcr', 'doctrine_phpcr.event_subscriber'); + $this->assertContainerBuilderHasServiceDefinitionWithTag('doctrine_orm_phpcr_adapter.event.orm', 'doctrine.event_subscriber'); } }