From e41acbf8fcd220aaf672c743db80a3698d5d6375 Mon Sep 17 00:00:00 2001 From: Raphael Trzpit Date: Fri, 22 Apr 2016 16:57:34 +0200 Subject: [PATCH 01/11] feat: add method retrieveSomeMajoraEntitys --- app/AppKernel.php | 6 + app/config/config.yml | 12 + app/config/routing.yml | 4 +- behat.yml | 44 +-- .../Features/Context/MajoraEntityContext.php | 108 ++++++++ .../ApiBundle/Features/MajoraEntity.feature | 29 +- .../MajoraVendorMajoraNamespaceApiBundle.php | 2 +- .../ApiBundle/Resources/config/routing.yml | 4 - .../ApiBundle/Resources/config/services.xml | 4 +- .../MajoraVendorMajoraNamespaceDalBundle.php | 2 +- .../DalBundle/Resources/config/services.xml | 4 +- .../services/auto/auto_majora_entity.xml | 2 +- .../MajoraVendorMajoraNamespaceSdkBundle.php | 2 +- .../SdkBundle/Resources/config/services.xml | 4 +- .../services/auto/auto_majora_entity.xml | 2 +- .../Auto/PersonApiControllerTrait.php | 138 ++++++++++ .../Controller/PersonApiController.php | 22 ++ .../DependencyInjection/Configuration.php | 41 +++ .../SirPartnerApiExtension.php | 28 ++ .../Context/PersonApiControllerContext.php | 255 ++++++++++++++++++ .../Context/PersonApiDomainContext.php | 172 ++++++++++++ .../Context/PersonDalDomainContext.php | 177 ++++++++++++ .../Bundle/ApiBundle/Features/Person.feature | 58 ++++ .../ApiBundle/Form/Person/AbstractType.php | 52 ++++ .../ApiBundle/Form/Person/CreationType.php | 28 ++ .../ApiBundle/Form/Person/EditionType.php | 34 +++ .../ApiBundle/Resources/config/routing.yml | 10 + .../ApiBundle/Resources/config/services.xml | 16 ++ .../config/services/auto/auto_person.xml | 36 +++ .../Resources/config/services/person.xml | 18 ++ .../Resources/config/validation/person.yml | 5 + .../Bundle/ApiBundle/SirPartnerApiBundle.php | 12 + .../DataFixtures/ORM/PersonFixturesLoader.php | 55 ++++ .../DependencyInjection/Configuration.php | 41 +++ .../SirPartnerDalExtension.php | 27 ++ .../Persistence/PersonPersistenceListener.php | 67 +++++ .../Resources/config/doctrine/Person.orm.yml | 58 ++++ .../DalBundle/Resources/config/services.xml | 17 ++ .../config/services/auto/auto_person.xml | 104 +++++++ .../Resources/config/services/person.xml | 18 ++ .../Bundle/DalBundle/SirPartnerDalBundle.php | 12 + .../DependencyInjection/Configuration.php | 41 +++ .../SirPartnerSdkExtension.php | 27 ++ .../SdkBundle/Resources/config/routing.yml | 4 + .../config/routing/auto/auto_person.yml | 42 +++ .../Resources/config/routing/person.yml | 8 + .../SdkBundle/Resources/config/services.xml | 16 ++ .../config/services/auto/auto_person.xml | 102 +++++++ .../Resources/config/services/person.xml | 18 ++ .../Bundle/SdkBundle/SirPartnerSdkBundle.php | 12 + .../Component/Action/AbstractPersonAction.php | 41 +++ .../Action/Api/Person/AbstractApiAction.php | 14 + .../Action/Api/Person/CreateAction.php | 45 ++++ .../Action/Api/Person/DeleteAction.php | 28 ++ .../Action/Api/Person/UpdateAction.php | 48 ++++ .../Action/Dal/Person/AbstractDalAction.php | 16 ++ .../Action/Dal/Person/CreateAction.php | 36 +++ .../Action/Dal/Person/DeleteAction.php | 26 ++ .../Action/Dal/Person/UpdateAction.php | 30 +++ .../PersonActionDispatcherDomainTrait.php | 45 ++++ .../Action/PersonActionDispatcherDomain.php | 21 ++ .../Domain/PersonDomainInterface.php | 36 +++ src/Sir/Partner/Component/Entity/Person.php | 63 +++++ .../Component/Entity/PersonCollection.php | 19 ++ .../Partner/Component/Event/PersonEvent.php | 61 +++++ .../Partner/Component/Event/PersonEvents.php | 24 ++ .../Loader/Api/Auto/PersonApiLoaderTrait.php | 21 ++ .../Component/Loader/Api/PersonApiLoader.php | 15 ++ .../Auto/PersonDoctrineLoaderTrait.php | 20 ++ .../Loader/Doctrine/PersonDoctrineLoader.php | 15 ++ .../Graph/Auto/PersonGraphLoaderTrait.php | 21 ++ .../Loader/Graph/PersonGraphLoader.php | 15 ++ .../Loader/PersonLoaderInterface.php | 12 + .../Auto/PersonDoctrineRepositoryTrait.php | 20 ++ .../Doctrine/PersonDoctrineRepository.php | 15 ++ .../Graph/Auto/PersonGraphRepositoryTrait.php | 20 ++ .../Graph/PersonGraphRepository.php | 15 ++ .../Repository/PersonRepositoryInterface.php | 12 + .../Action/Api/Person/CreateActionTest.php | 84 ++++++ .../Action/Api/Person/DeleteActionTest.php | 39 +++ .../Action/Api/Person/UpdateActionTest.php | 72 +++++ .../Action/Dal/Person/CreateActionTest.php | 82 ++++++ .../Action/Dal/Person/DeleteActionTest.php | 71 +++++ .../Action/Dal/Person/UpdateActionTest.php | 88 ++++++ .../Tests/Entity/PersonCollectionTest.php | 45 ++++ .../Component/Tests/Entity/PersonTest.php | 128 +++++++++ .../Component/Tests/Event/PersonEventTest.php | 34 +++ .../Tests/Loader/Api/PersonApiLoaderTest.php | 30 +++ .../Loader/Doctrine/PersonDoctrineLoader.php | 31 +++ .../Auto/Person2ApiControllerTrait.php | 138 ++++++++++ .../Controller/Person2ApiController.php | 22 ++ .../DependencyInjection/Configuration.php | 41 +++ .../Sir1Partner3ApiExtension.php | 28 ++ .../Features/Context/Person2Context.php | 112 ++++++++ .../Bundle/ApiBundle/Features/Person2.feature | 30 +++ .../ApiBundle/Form/Person2/AbstractType.php | 52 ++++ .../ApiBundle/Form/Person2/CreationType.php | 28 ++ .../ApiBundle/Form/Person2/EditionType.php | 34 +++ .../ApiBundle/Resources/config/routing.yml | 2 + .../ApiBundle/Resources/config/services.xml | 17 ++ .../config/services/auto/auto_person2.xml | 36 +++ .../Resources/config/services/person2.xml | 18 ++ .../Resources/config/validation/person2.yml | 5 + .../ApiBundle/Sir1Partner3ApiBundle.php | 12 + .../ORM/Person2FixturesLoader.php | 55 ++++ .../DependencyInjection/Configuration.php | 41 +++ .../Sir1Partner3DalExtension.php | 27 ++ .../Person2PersistenceListener.php | 67 +++++ .../Resources/config/doctrine/Person2.orm.yml | 58 ++++ .../DalBundle/Resources/config/services.xml | 17 ++ .../config/services/auto/auto_person2.xml | 104 +++++++ .../Resources/config/services/person2.xml | 18 ++ .../DalBundle/Sir1Partner3DalBundle.php | 12 + .../DependencyInjection/Configuration.php | 41 +++ .../Sir1Partner3SdkExtension.php | 27 ++ .../SdkBundle/Resources/config/routing.yml | 4 + .../config/routing/auto/auto_person2.yml | 42 +++ .../Resources/config/routing/person2.yml | 8 + .../SdkBundle/Resources/config/services.xml | 17 ++ .../config/services/auto/auto_person2.xml | 102 +++++++ .../Resources/config/services/person2.xml | 18 ++ .../SdkBundle/Sir1Partner3SdkBundle.php | 12 + .../Action/AbstractPerson2Action.php | 41 +++ .../Action/Api/Person2/AbstractApiAction.php | 14 + .../Action/Api/Person2/CreateAction.php | 45 ++++ .../Action/Api/Person2/DeleteAction.php | 28 ++ .../Action/Api/Person2/UpdateAction.php | 48 ++++ .../Action/Dal/Person2/AbstractDalAction.php | 16 ++ .../Action/Dal/Person2/CreateAction.php | 36 +++ .../Action/Dal/Person2/DeleteAction.php | 26 ++ .../Action/Dal/Person2/UpdateAction.php | 30 +++ .../Person2ActionDispatcherDomainTrait.php | 45 ++++ .../Action/Person2ActionDispatcherDomain.php | 21 ++ .../Domain/Person2DomainInterface.php | 36 +++ .../Partner3/Component/Entity/Person2.php | 63 +++++ .../Component/Entity/Person2Collection.php | 19 ++ .../Partner3/Component/Event/Person2Event.php | 61 +++++ .../Component/Event/Person2Events.php | 24 ++ .../Loader/Api/Auto/Person2ApiLoaderTrait.php | 21 ++ .../Component/Loader/Api/Person2ApiLoader.php | 15 ++ .../Auto/Person2DoctrineLoaderTrait.php | 20 ++ .../Loader/Doctrine/Person2DoctrineLoader.php | 15 ++ .../Graph/Auto/Person2GraphLoaderTrait.php | 21 ++ .../Loader/Graph/Person2GraphLoader.php | 15 ++ .../Loader/Person2LoaderInterface.php | 12 + .../Auto/Person2DoctrineRepositoryTrait.php | 20 ++ .../Doctrine/Person2DoctrineRepository.php | 15 ++ .../Auto/Person2GraphRepositoryTrait.php | 20 ++ .../Graph/Person2GraphRepository.php | 15 ++ .../Repository/Person2RepositoryInterface.php | 12 + .../Action/Api/Person2/CreateActionTest.php | 84 ++++++ .../Action/Api/Person2/DeleteActionTest.php | 39 +++ .../Action/Api/Person2/UpdateActionTest.php | 72 +++++ .../Action/Dal/Person2/CreateActionTest.php | 82 ++++++ .../Action/Dal/Person2/DeleteActionTest.php | 71 +++++ .../Action/Dal/Person2/UpdateActionTest.php | 88 ++++++ .../Tests/Entity/Person2CollectionTest.php | 45 ++++ .../Component/Tests/Entity/Person2Test.php | 128 +++++++++ .../Tests/Event/Person2EventTest.php | 34 +++ .../Tests/Loader/Api/Person2ApiLoaderTest.php | 30 +++ .../Loader/Doctrine/Person2DoctrineLoader.php | 31 +++ 161 files changed, 6110 insertions(+), 51 deletions(-) create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Controller/Auto/PersonApiControllerTrait.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Controller/PersonApiController.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/DependencyInjection/Configuration.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/DependencyInjection/SirPartnerApiExtension.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiControllerContext.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiDomainContext.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonDalDomainContext.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Features/Person.feature create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Form/Person/AbstractType.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Form/Person/CreationType.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Form/Person/EditionType.php create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/routing.yml create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/services.xml create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/auto/auto_person.xml create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/person.xml create mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/validation/person.yml create mode 100644 src/Sir/Partner/Bundle/ApiBundle/SirPartnerApiBundle.php create mode 100644 src/Sir/Partner/Bundle/DalBundle/DataFixtures/ORM/PersonFixturesLoader.php create mode 100644 src/Sir/Partner/Bundle/DalBundle/DependencyInjection/Configuration.php create mode 100644 src/Sir/Partner/Bundle/DalBundle/DependencyInjection/SirPartnerDalExtension.php create mode 100644 src/Sir/Partner/Bundle/DalBundle/Persistence/PersonPersistenceListener.php create mode 100644 src/Sir/Partner/Bundle/DalBundle/Resources/config/doctrine/Person.orm.yml create mode 100644 src/Sir/Partner/Bundle/DalBundle/Resources/config/services.xml create mode 100644 src/Sir/Partner/Bundle/DalBundle/Resources/config/services/auto/auto_person.xml create mode 100644 src/Sir/Partner/Bundle/DalBundle/Resources/config/services/person.xml create mode 100644 src/Sir/Partner/Bundle/DalBundle/SirPartnerDalBundle.php create mode 100644 src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/Configuration.php create mode 100644 src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/SirPartnerSdkExtension.php create mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing.yml create mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/auto/auto_person.yml create mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/person.yml create mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/services.xml create mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/auto/auto_person.xml create mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/person.xml create mode 100644 src/Sir/Partner/Bundle/SdkBundle/SirPartnerSdkBundle.php create mode 100644 src/Sir/Partner/Component/Action/AbstractPersonAction.php create mode 100644 src/Sir/Partner/Component/Action/Api/Person/AbstractApiAction.php create mode 100644 src/Sir/Partner/Component/Action/Api/Person/CreateAction.php create mode 100644 src/Sir/Partner/Component/Action/Api/Person/DeleteAction.php create mode 100644 src/Sir/Partner/Component/Action/Api/Person/UpdateAction.php create mode 100644 src/Sir/Partner/Component/Action/Dal/Person/AbstractDalAction.php create mode 100644 src/Sir/Partner/Component/Action/Dal/Person/CreateAction.php create mode 100644 src/Sir/Partner/Component/Action/Dal/Person/DeleteAction.php create mode 100644 src/Sir/Partner/Component/Action/Dal/Person/UpdateAction.php create mode 100644 src/Sir/Partner/Component/Domain/Action/Auto/PersonActionDispatcherDomainTrait.php create mode 100644 src/Sir/Partner/Component/Domain/Action/PersonActionDispatcherDomain.php create mode 100644 src/Sir/Partner/Component/Domain/PersonDomainInterface.php create mode 100644 src/Sir/Partner/Component/Entity/Person.php create mode 100644 src/Sir/Partner/Component/Entity/PersonCollection.php create mode 100644 src/Sir/Partner/Component/Event/PersonEvent.php create mode 100644 src/Sir/Partner/Component/Event/PersonEvents.php create mode 100644 src/Sir/Partner/Component/Loader/Api/Auto/PersonApiLoaderTrait.php create mode 100644 src/Sir/Partner/Component/Loader/Api/PersonApiLoader.php create mode 100644 src/Sir/Partner/Component/Loader/Doctrine/Auto/PersonDoctrineLoaderTrait.php create mode 100644 src/Sir/Partner/Component/Loader/Doctrine/PersonDoctrineLoader.php create mode 100644 src/Sir/Partner/Component/Loader/Graph/Auto/PersonGraphLoaderTrait.php create mode 100644 src/Sir/Partner/Component/Loader/Graph/PersonGraphLoader.php create mode 100644 src/Sir/Partner/Component/Loader/PersonLoaderInterface.php create mode 100644 src/Sir/Partner/Component/Repository/Doctrine/Auto/PersonDoctrineRepositoryTrait.php create mode 100644 src/Sir/Partner/Component/Repository/Doctrine/PersonDoctrineRepository.php create mode 100644 src/Sir/Partner/Component/Repository/Graph/Auto/PersonGraphRepositoryTrait.php create mode 100644 src/Sir/Partner/Component/Repository/Graph/PersonGraphRepository.php create mode 100644 src/Sir/Partner/Component/Repository/PersonRepositoryInterface.php create mode 100644 src/Sir/Partner/Component/Tests/Action/Api/Person/CreateActionTest.php create mode 100644 src/Sir/Partner/Component/Tests/Action/Api/Person/DeleteActionTest.php create mode 100644 src/Sir/Partner/Component/Tests/Action/Api/Person/UpdateActionTest.php create mode 100644 src/Sir/Partner/Component/Tests/Action/Dal/Person/CreateActionTest.php create mode 100644 src/Sir/Partner/Component/Tests/Action/Dal/Person/DeleteActionTest.php create mode 100644 src/Sir/Partner/Component/Tests/Action/Dal/Person/UpdateActionTest.php create mode 100644 src/Sir/Partner/Component/Tests/Entity/PersonCollectionTest.php create mode 100644 src/Sir/Partner/Component/Tests/Entity/PersonTest.php create mode 100644 src/Sir/Partner/Component/Tests/Event/PersonEventTest.php create mode 100644 src/Sir/Partner/Component/Tests/Loader/Api/PersonApiLoaderTest.php create mode 100644 src/Sir/Partner/Component/Tests/Loader/Doctrine/PersonDoctrineLoader.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Controller/Auto/Person2ApiControllerTrait.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Controller/Person2ApiController.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Configuration.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Sir1Partner3ApiExtension.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/AbstractType.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/CreationType.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/EditionType.php create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/routing.yml create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services.xml create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/auto/auto_person2.xml create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/person2.xml create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/validation/person2.yml create mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Sir1Partner3ApiBundle.php create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/DataFixtures/ORM/Person2FixturesLoader.php create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Configuration.php create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Sir1Partner3DalExtension.php create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Persistence/Person2PersistenceListener.php create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Resources/config/doctrine/Person2.orm.yml create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services.xml create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/auto/auto_person2.xml create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/person2.xml create mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Sir1Partner3DalBundle.php create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Configuration.php create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Sir1Partner3SdkExtension.php create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing.yml create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/auto/auto_person2.yml create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/person2.yml create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services.xml create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/auto/auto_person2.xml create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/person2.xml create mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Sir1Partner3SdkBundle.php create mode 100644 src/Sir1/Partner3/Component/Action/AbstractPerson2Action.php create mode 100644 src/Sir1/Partner3/Component/Action/Api/Person2/AbstractApiAction.php create mode 100644 src/Sir1/Partner3/Component/Action/Api/Person2/CreateAction.php create mode 100644 src/Sir1/Partner3/Component/Action/Api/Person2/DeleteAction.php create mode 100644 src/Sir1/Partner3/Component/Action/Api/Person2/UpdateAction.php create mode 100644 src/Sir1/Partner3/Component/Action/Dal/Person2/AbstractDalAction.php create mode 100644 src/Sir1/Partner3/Component/Action/Dal/Person2/CreateAction.php create mode 100644 src/Sir1/Partner3/Component/Action/Dal/Person2/DeleteAction.php create mode 100644 src/Sir1/Partner3/Component/Action/Dal/Person2/UpdateAction.php create mode 100644 src/Sir1/Partner3/Component/Domain/Action/Auto/Person2ActionDispatcherDomainTrait.php create mode 100644 src/Sir1/Partner3/Component/Domain/Action/Person2ActionDispatcherDomain.php create mode 100644 src/Sir1/Partner3/Component/Domain/Person2DomainInterface.php create mode 100644 src/Sir1/Partner3/Component/Entity/Person2.php create mode 100644 src/Sir1/Partner3/Component/Entity/Person2Collection.php create mode 100644 src/Sir1/Partner3/Component/Event/Person2Event.php create mode 100644 src/Sir1/Partner3/Component/Event/Person2Events.php create mode 100644 src/Sir1/Partner3/Component/Loader/Api/Auto/Person2ApiLoaderTrait.php create mode 100644 src/Sir1/Partner3/Component/Loader/Api/Person2ApiLoader.php create mode 100644 src/Sir1/Partner3/Component/Loader/Doctrine/Auto/Person2DoctrineLoaderTrait.php create mode 100644 src/Sir1/Partner3/Component/Loader/Doctrine/Person2DoctrineLoader.php create mode 100644 src/Sir1/Partner3/Component/Loader/Graph/Auto/Person2GraphLoaderTrait.php create mode 100644 src/Sir1/Partner3/Component/Loader/Graph/Person2GraphLoader.php create mode 100644 src/Sir1/Partner3/Component/Loader/Person2LoaderInterface.php create mode 100644 src/Sir1/Partner3/Component/Repository/Doctrine/Auto/Person2DoctrineRepositoryTrait.php create mode 100644 src/Sir1/Partner3/Component/Repository/Doctrine/Person2DoctrineRepository.php create mode 100644 src/Sir1/Partner3/Component/Repository/Graph/Auto/Person2GraphRepositoryTrait.php create mode 100644 src/Sir1/Partner3/Component/Repository/Graph/Person2GraphRepository.php create mode 100644 src/Sir1/Partner3/Component/Repository/Person2RepositoryInterface.php create mode 100644 src/Sir1/Partner3/Component/Tests/Action/Api/Person2/CreateActionTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Action/Api/Person2/DeleteActionTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Action/Api/Person2/UpdateActionTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/CreateActionTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/DeleteActionTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/UpdateActionTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Entity/Person2CollectionTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Entity/Person2Test.php create mode 100644 src/Sir1/Partner3/Component/Tests/Event/Person2EventTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Loader/Api/Person2ApiLoaderTest.php create mode 100644 src/Sir1/Partner3/Component/Tests/Loader/Doctrine/Person2DoctrineLoader.php diff --git a/app/AppKernel.php b/app/AppKernel.php index 0ebe1c6..211d40e 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -20,6 +20,12 @@ public function registerBundles() new Acme\Lv\Bundle\ApiBundle\AcmeLvApiBundle(), new Acme\Lv\Bundle\DalBundle\AcmeLvDalBundle(), new Acme\Lv\Bundle\SdkBundle\AcmeLvSdkBundle(), + new Sir\Partner\Bundle\ApiBundle\SirPartnerApiBundle(), + new Sir\Partner\Bundle\DalBundle\SirPartnerDalBundle(), + new Sir\Partner\Bundle\SdkBundle\SirPartnerSdkBundle(), + new Sir1\Partner3\Bundle\ApiBundle\Sir1Partner3ApiBundle(), + new Sir1\Partner3\Bundle\DalBundle\Sir1Partner3DalBundle(), + new Sir1\Partner3\Bundle\SdkBundle\Sir1Partner3SdkBundle(), ]; if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { diff --git a/app/config/config.yml b/app/config/config.yml index c5bf7e1..844a10e 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -60,6 +60,18 @@ doctrine: entity_managers: default: mappings: + Sir1Partner3DalBundle: + type: yml + dir: Resources/config/doctrine + prefix: Sir1\Partner3\Component\Entity + alias: Sir1Partner3 + + SirPartnerDalBundle: + type: yml + dir: Resources/config/doctrine + prefix: Sir\Partner\Component\Entity + alias: SirPartner + AcmeLvDalBundle: type: yml dir: Resources/config/doctrine diff --git a/app/config/routing.yml b/app/config/routing.yml index fd22036..ca1eee5 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -1,2 +1,4 @@ app: - resource: "@AcmeLvSdkBundle/Resources/config/routing/auto/auto_post.yml" \ No newline at end of file + resource: "@AcmeLvSdkBundle/Resources/config/routing/auto/auto_post.yml" +persons: + resource: "@SirPartnerSdkBundle/Resources/config/routing.yml" \ No newline at end of file diff --git a/behat.yml b/behat.yml index c74727f..7993f37 100644 --- a/behat.yml +++ b/behat.yml @@ -1,44 +1,20 @@ +imports: + - app/config/parameters.yml + default: autoload: '': %paths.base%/src extensions: Behat\Symfony2Extension: ~ suites: - api_controller: - type: symfony_bundle - bundle: AcmeLvApiBundle - paths: [ %paths.base%/src/Acme/Lv/Bundle/ApiBundle/Features ] - contexts: - - Acme\Lv\Bundle\ApiBundle\Features\Context\PostApiControllerContext: - em: '@doctrine.orm.entity_manager' - router: '@router' - - Acme\Lv\Bundle\ApiBundle\Features\Context\PostRouterContext: - router: '@router' - host: 'localhost' - scheme: 'http' - baseUrl: '/web/app.php' - port: '9001' dal_domain: type: symfony_bundle - bundle: AcmeLvDalBundle - paths: [ %paths.base%/src/Acme/Lv/Bundle/ApiBundle/Features ] - contexts: - - Acme\Lv\Bundle\ApiBundle\Features\Context\PostDalDomainContext: - domain: '@acme.post.domain' - loader: '@acme.post.loader' - em: '@doctrine.orm.entity_manager' - api_domain: - type: symfony_bundle - bundle: AcmeLvDalBundle - paths: [ %paths.base%/src/Acme/Lv/Bundle/ApiBundle/Features ] + bundle: Sir1Partner3DalBundle + paths: + #- %paths.base%/src/Acme/Lv/Bundle/ApiBundle/Features + - %paths.base%/src/Sir1/Partner3/Bundle/ApiBundle/Features contexts: - - Acme\Lv\Bundle\ApiBundle\Features\Context\PostApiDomainContext: + - Sir1\Partner3\Bundle\ApiBundle\Features\Context\Person2Context: + domain: '@sir1.person2.domain' + loader: '@sir1.person2.loader' em: '@doctrine.orm.entity_manager' - domain: '@acme.post.api_domain' - loader: '@acme.post.api_loader' - - Acme\Lv\Bundle\ApiBundle\Features\Context\PostRouterContext: - router: '@router' - host: 'localhost' - scheme: 'http' - baseUrl: '/web/app.php' - port: '9001' diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php index b70f512..01c9ee8 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php @@ -3,10 +3,118 @@ namespace MajoraVendor\MajoraNamespace\Bundle\ApiBundle\Features\Context; use Behat\Behat\Context\Context; +use MajoraVendor\MajoraNamespace\Component\Entity\MajoraEntity; +use MajoraVendor\MajoraNamespace\Component\Entity\MajoraEntityCollection; +use MajoraVendor\MajoraNamespace\Component\Domain\MajoraEntityDomainInterface; +use MajoraVendor\MajoraNamespace\Component\Loader\MajoraEntityLoaderInterface; +use MajoraVendor\MajoraNamespace\Bundle\ApiBundle\Features\Context\MajoraEntityApiContext; +use Doctrine\ORM\EntityManagerInterface; /** * Defines application features from the specific context. */ class MajoraEntityContext implements Context { + + private static $totalToInsert = 3; + + /** + * @var ClientInterface + */ + private $client; + + /** + * @var MajoraEntityCollection + */ + private $majora_entitys; + + + /** + * @var MajoraEntity + */ + private $currentMajoraEntity; + + /** + * @var EntityManagerInterface + */ + protected $em; + + /** + * @var MajoraEntityDomainInterface + */ + protected $domain; + + /** + * @var MajoraEntityLoaderInterface + */ + protected $loader; + + public function __construct( + MajoraEntityDomainInterface $domain, + MajoraEntityLoaderInterface $loader, + EntityManagerInterface $em + ) { + $this->em = $em; + $this->domain = $domain; + $this->loader = $loader; + } + + /** + * @BeforeScenario + */ + public function initMajoraEntitys() + { + $this->truncateMajoraEntitys(); + for($i=0; $i<= self::$totalToInsert; $i++){ + $this->em->persist(new MajoraEntity()); + } + $this->em->flush(); + } + + /** + * @Given I have some majora_entitiys + * + */ + public function retrieveSomeMajoraEntitys() + { + $this->majora_entitys = $this->em->getRepository(MajoraEntity::class)->findAll(); + } + + /** + * @When I create a new majora_entity + */ + public function createMajoraEntity() + { + $this->currentMajoraEntity = $this->domain->create(new MajoraEntity()); + } + + /** + * @Then I retrieve new majora_entity id + */ + public function testMajoraEntityId() + { + return $this->currentMajoraEntity->getId() != null; + } + + /** + * @AfterScenario + */ + public function terminateMajoraEntitys() + { + $this->truncateMajoraEntitys(); + } + + /** + * Trucate all table data + * @throws \Doctrine\DBAL\DBALException + */ + private function truncateMajoraEntitys() + { + $connection = $this->em->getConnection(); + $connection->query('SET FOREIGN_KEY_CHECKS=0'); + $this->em->createQuery('DELETE FROM MajoraVendor\MajoraNamespace\Component\Entity\MajoraEntity')->execute(); + $connection->query('SET FOREIGN_KEY_CHECKS=1'); + $this->em->flush(); + } + } diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/MajoraEntity.feature b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/MajoraEntity.feature index 39d6465..eaef9fb 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/MajoraEntity.feature +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/MajoraEntity.feature @@ -1,4 +1,31 @@ +# @MajoraGenerator({"force_generation": true}) @MajoraEntity Feature: MajoraEntity Crud. - In order to manage MajoraEntity + In order to manage majora_entity As a user + I need to be able to create, update, delete and retrieve majora_entity. + + Scenario: Create + Given I have some majora_entitys + When I create a new majora_entity + Then I retrieve new majora_entity id + + Scenario: ReadAll + Given I have some majora_entitys + When I get the majora_entitys list + Then I should see a list of majora_entity + + Scenario: Read + Given I have created a new majora_entity + When I show this majora_entity by id + Then I should see this majora_entity + + Scenario: delete + Given I have created a new majora_entity + When I delete this majora_entity + Then I should see the same majora_entity list that before + + Scenario: Update + Given I have created a new majora_entity + When I update this majora_entity with a new id + Then i should see the same majora_entity with this new id value diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php index 08eeb5a..758b83a 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php @@ -5,7 +5,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; /** - * @MajoraGenerator({"register_bundle": {"target": "\\ApiAppKernel"}}) + * @MajoraGenerator({"register_bundle": {"target": "\\AppKernel"}}) */ class MajoraVendorMajoraNamespaceApiBundle extends Bundle { diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Resources/config/routing.yml b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Resources/config/routing.yml index cfab09a..f319881 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Resources/config/routing.yml +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Resources/config/routing.yml @@ -1,6 +1,2 @@ -# @MajoraGenerator({"include_routing": {"target": "@ApplicationApiAppBundle/Resources/config/routing.yml"}}) -# @MajoraGenerator({"include_routing": {"route": "majora_vendor_majora_namespace_api"}}) -# @MajoraGenerator({"include_routing": {"resource": "@MajoraVendorMajoraNamespaceApiBundle/Resources/config/routing.yml"}}) - majora_vendor_majora_namespace_sdk: resource: "@MajoraVendorMajoraNamespaceSdkBundle/Resources/config/routing.yml" diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Resources/config/services.xml b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Resources/config/services.xml index eaceadc..92bff1d 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Resources/config/services.xml +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Resources/config/services.xml @@ -3,11 +3,11 @@ - + + + diff --git a/src/Sir/Partner/Bundle/ApiBundle/Controller/Auto/PersonApiControllerTrait.php b/src/Sir/Partner/Bundle/ApiBundle/Controller/Auto/PersonApiControllerTrait.php new file mode 100644 index 0000000..9d93a62 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Controller/Auto/PersonApiControllerTrait.php @@ -0,0 +1,138 @@ +query->all(), + array_flip(array('scope', 'limit', 'offset')) + ); + + return $this->createJsonResponse( + $this->container->get('sir.person.loader')->retrieveAll( + $this->container->get('majora.inflector')->normalize($queryFilters, 'camelize'), + $request->query->get('limit'), + $request->query->get('offset') + ), + $request->query->get('scope') + ); + } + + /** + * Returns a single Person by id. + * + * @param int $id requested Person id + * @param Request $request + * + * @return JsonResponse + */ + public function getAction($id, Request $request) + { + $person = $this->retrieveOr404($id, 'sir.person.loader'); + + return $this->createJsonResponse( + $person, + $request->query->get('scope') + ); + } + + /** + * Creates a new Person. + * + * @param Request $request + * + * @return JsonResponse + */ + public function postAction(Request $request) + { + // submit + $this->assertSubmitedFormIsValid($request, + $form = $this->container->get('form.factory')->createNamed( + '', + CreationType::class, + null, + array('method' => 'POST') + ) + ); + + // resolve use case + $person = $form->getData()->resolve(); + + return $this->createJsonResponse( + $person, + $request->query->get('scope'), + 201 + ); + } + + /** + * Updates a single Person by id. + * + * @param int $id requested Person id + * @param Request $request + * + * @return JsonResponse + */ + public function putAction($id, Request $request) + { + // submit + $this->assertSubmitedFormIsValid($request, + $form = $this->container->get('form.factory')->createNamed( + '', + EditionType::class, + null, + array( + 'method' => 'PUT', + 'entity' => $this->retrieveOr404($id, 'sir.person.loader'), + ) + ) + ); + + // resolve use case + $form->getData()->resolve(); + + return $this->createJsonNoContentResponse(); + } + + /** + * Delete a single Person by id. + * + * @param int $id requested Person id + * + * @return JsonResponse + */ + public function deleteAction($id) + { + $this->container->get('sir.person.domain')->delete( + $this->retrieveOr404($id, 'sir.person.loader') + ); + + return $this->createJsonNoContentResponse(); + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/Controller/PersonApiController.php b/src/Sir/Partner/Bundle/ApiBundle/Controller/PersonApiController.php new file mode 100644 index 0000000..2d0f5c9 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Controller/PersonApiController.php @@ -0,0 +1,22 @@ +root('sir_partner_api') + * ->children() + * ->scalarNode('...') + * ->isRequired() + * ->end() + * ->arrayNode() + * ->addDefaultsIfNotSet() + * ->children() + * // more nodes here + * ->end() + * ->end() + * ->end() + * ; + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $treeBuilder->root('sir_partner_api'); + + return $treeBuilder; + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/DependencyInjection/SirPartnerApiExtension.php b/src/Sir/Partner/Bundle/ApiBundle/DependencyInjection/SirPartnerApiExtension.php new file mode 100644 index 0000000..f0e6471 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/DependencyInjection/SirPartnerApiExtension.php @@ -0,0 +1,28 @@ +processConfiguration($configuration, $configs); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiControllerContext.php b/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiControllerContext.php new file mode 100644 index 0000000..c21da63 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiControllerContext.php @@ -0,0 +1,255 @@ +router = $router; + $this->em = $em; + + $this->client = new Client(); + $this->persons = new PersonCollection(); + } + + /** + * @AfterScenario + */ + public function removePersons() + { + foreach ($this->persons as $person) { + $this->em->remove($person); + } + $this->em->flush(); + } + + /** + * @Given I have theses persons: + */ + public function iHaveThesesPersons(PersonCollection $persons) + { + // Fill persons table. + foreach ($persons as $person) { + $this->em->persist($person); + } + $this->em->flush(); + $this->persons = $persons; + } + + /** + * @Transform table:person_key, person_id + * @Transform table:person_id + */ + public function castPersonsTable(TableNode $personsTable) + { + $persons = new PersonCollection(); + foreach ($personsTable->getHash() as $personHash) { + $person = new Person(); + $person->setId($personHash['person_id']); + if (isset($personHash['person_key'])) { + $persons->set($personHash['person_key'], $person); + continue; + } + $persons->add($person); + } + + return $persons; + } + + /** + * @Given I get the person list + */ + public function iGetThePersonList() + { + $response = $this->client->request( + 'GET', + $this->router->generate( + 'acme_api_person_collection', + [], + UrlGeneratorInterface::ABSOLUTE_URL + ), + [] + ); + + if ($response->getStatusCode() != Response::HTTP_OK) { + throw new \Exception( + sprintf( + 'Wrong status code : %s given, %s expected', + $response->getStatusCode(), + Response::HTTP_OK + ) + ); + } + + $data = json_decode($response->getBody()->getContents()); + $this->personList = new PersonCollection(); + $this->personList->denormalize($data); + } + + /** + * @Then I should see theses persons: + * @Then I should see this person: + */ + public function iShouldSeeThesesPersons(PersonCollection $persons) + { + foreach ($persons as $person) { + if (!$this->personList->search(['id' => $person->getId()])->count()) { + $personId = $person->getId(); + throw new \Exception("The person $personId was not found."); + } + } + } + + /** + * @Then I should not see theses persons: + * @Then I should not see this person: + */ + public function iShouldNotSeeThesesPersons(PersonCollection $persons) + { + foreach ($persons as $person) { + if ($this->personList->search(['id' => $person->getId()])->count()) { + $personId = $person->getId(); + throw new \Exception("The person $personId was found."); + } + } + } + + /** + * @Given I create this person: + * @Given I create theses persons: + */ + public function iCreateThisPerson(PersonCollection $persons) + { + foreach ($persons as $person) { + $response = $this->client->request( + 'POST', + $this->router->generate( + 'acme_api_person_create', + [], + UrlGeneratorInterface::ABSOLUTE_URL + ), + ['form_params' => $person->serialize()] + ); + + if ($response->getStatusCode() != Response::HTTP_CREATED) { + throw new \Exception( + sprintf( + 'Wrong status code : %s given, %s expected', + $response->getStatusCode(), + Response::HTTP_CREATED + ) + ); + } + + // Parse the answer and add the created person to the personlist so we can delete it after the scenario. + $data = (array) json_decode($response->getBody()->getContents()); + $person->denormalize($data); + $person = $this->em->getReference('Sir\Partner\Component\Entity\Person', $person->getId()); + $this->persons->add($person); + } + } + + /** + * @Given I update the :key person with theses values: + */ + public function iUpdateTheKeyPerson($key, PersonCollection $persons) + { + $oldPerson = $this->persons->get($key); + + if (!$oldPerson) { + throw new \Exception("The person \"$key\" was not found."); + } + + foreach ($persons as $person) { + $response = $this->client->request( + 'PUT', + $this->router->generate( + 'acme_api_person_update', + ['id' => $oldPerson->getId()], + UrlGeneratorInterface::ABSOLUTE_URL + ), + ['form_params' => $person->serialize()] + ); + + if ($response->getStatusCode() != Response::HTTP_NO_CONTENT) { + throw new \Exception( + sprintf( + 'Wrong status code : %s given, %s expected', + $response->getStatusCode(), + Response::HTTP_NO_CONTENT + ) + ); + } + } + } + + /** + * @Given I delete the :key person + */ + public function iDeleteTheKeyPerson($key) + { + $oldPerson = $this->persons->get($key); + + if (!$oldPerson) { + throw new \Exception("The person \"$key\" was not found."); + } + + $response = $this->client->request( + 'DELETE', + $this->router->generate( + 'acme_api_person_delete', + ['id' => $oldPerson->getId()], + UrlGeneratorInterface::ABSOLUTE_URL + ), + [] + ); + + if ($response->getStatusCode() != Response::HTTP_NO_CONTENT) { + throw new \Exception( + sprintf( + 'Wrong status code : %s given, %s expected', + $response->getStatusCode(), + Response::HTTP_NO_CONTENT + ) + ); + } + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiDomainContext.php b/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiDomainContext.php new file mode 100644 index 0000000..0463794 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiDomainContext.php @@ -0,0 +1,172 @@ +domain = $domain; + $this->loader = $loader; + $this->em = $em; + + $this->persons = new PersonCollection(); + } + + /** + * @AfterScenario + */ + public function removePersons() + { + foreach ($this->persons as $person) { + $this->em->remove($person); + } + $this->em->flush(); + } + + /** + * @Given I have theses persons: + */ + public function iHaveThesesPersons(PersonCollection $persons) + { + // Fill persons table. + foreach ($persons as $person) { + $this->em->persist($person); + } + $this->em->flush(); + $this->persons = $persons; + } + + /** + * @Transform table:person_key,person_id + * @Transform table:person_id + */ + public function castPersonsTable(TableNode $personsTable) + { + $persons = new PersonCollection(); + foreach ($personsTable->getHash() as $personHash) { + $person = new Person(); + $person->setId($personHash['person_id']); + if (isset($personHash['person_key'])) { + $persons->set($personHash['person_key'], $person); + continue; + } + $persons->add($person); + } + + return $persons; + } + + /** + * @Given I get the person list + */ + public function iGetThePersonList() + { + $this->personList = $this->loader->retrieveAll(); + } + + /** + * @Then I should see theses persons: + * @Then I should see this person: + */ + public function iShouldSeeThesesPersons(PersonCollection $persons) + { + foreach ($persons as $person) { + if (!$this->personList->search(['id' => $person->getId()])->count()) { + $personId = $person->getId(); + throw new \Exception(sprintf('The person %s was not found.', $personId)); + } + } + } + + /** + * @Then I should not see theses persons: + * @Then I should not see this person: + */ + public function iShouldNotSeeThesesPersons(PersonCollection $persons) + { + foreach ($persons as $person) { + if ($this->personList->search(['id' => $person->getId()])->count()) { + $personId = $person->getId(); + throw new \Exception(sprintf('The person %s was found.', $personId)); + } + } + } + + /** + * @Given I create this person: + * @Given I create theses persons: + */ + public function iCreateThisPerson(PersonCollection $persons) + { + foreach ($persons as $person) { + $person = $this->domain->create($person->serialize()); + $person = $this->em->getReference('Sir\Partner\Component\Entity\Person', $person->getId()); + $this->persons->add($person); + } + } + + /** + * @Given I update the :key person with theses values: + */ + public function iUpdateTheKeyPerson($key, PersonCollection $persons) + { + $oldPerson = $this->persons->get($key); + + if (!$oldPerson) { + throw new \Exception(sprintf('The person %s was not found.', $key)); + } + + foreach ($persons as $person) { + $this->domain->update($oldPerson, $person->serialize()); + } + } + + /** + * @Given I delete the :key person + */ + public function iDeleteTheKeyPerson($key) + { + $oldPerson = $this->persons->get($key); + + if (!$oldPerson) { + throw new \Exception(sprintf('The person %s was not found.', $key)); + } + + $this->domain->delete($oldPerson); + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonDalDomainContext.php b/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonDalDomainContext.php new file mode 100644 index 0000000..3a50d3f --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonDalDomainContext.php @@ -0,0 +1,177 @@ +domain = $domain; + $this->loader = $loader; + $this->em = $em; + + $this->persons = new PersonCollection(); + } + + /** + * @BeforeScenario + */ + public function BeforeScenario() + { + $this->em->getConnection(); + $this->em->beginTransaction(); + } + + /** + * @AfterScenario + */ + public function AfterScenario() + { + $this->em->rollback(); + $this->em->close(); + } + + /** + * @Given I have theses persons: + */ + public function iHaveThesesPersons(PersonCollection $persons) + { + // Fill persons table. + foreach ($persons as $person) { + $this->em->persist($person); + } + $this->em->flush(); + $this->persons = $persons; + } + + /** + * @Transform table:person_key,person_id + * @Transform table:person_id + */ + public function castPersonsTable(TableNode $personsTable) + { + $persons = new PersonCollection(); + foreach ($personsTable->getHash() as $personHash) { + $person = new Person(); + $person->setId($personHash['person_id']); + if (isset($personHash['person_key'])) { + $persons->set($personHash['person_key'], $person); + continue; + } + $persons->add($person); + } + + return $persons; + } + + /** + * @Given I get the person list + */ + public function iGetThePersonList() + { + $this->personList = $this->loader->retrieveAll(); + } + + /** + * @Then I should see theses persons: + * @Then I should see this person: + */ + public function iShouldSeeThesesPersons(PersonCollection $persons) + { + foreach ($persons as $person) { + if (!$this->personList->search(['id' => $person->getId()])->count()) { + $personId = $person->getId(); + throw new \Exception(sprintf('The person %s was not found.', $personId)); + } + } + } + + /** + * @Then I should not see theses persons: + * @Then I should not see this person: + */ + public function iShouldNotSeeThesesPersons(PersonCollection $persons) + { + foreach ($persons as $person) { + if ($this->personList->search(['id' => $person->getId()])->count()) { + $personId = $person->getId(); + throw new \Exception(sprintf('The person %s was found.', $personId)); + } + } + } + + /** + * @Given I create this person: + * @Given I create theses persons: + */ + public function iCreateThisPerson(PersonCollection $persons) + { + foreach ($persons as $person) { + $this->domain->create($person->serialize()); + } + } + + /** + * @Given I update the :key person with theses values: + */ + public function iUpdateTheKeyPerson($key, PersonCollection $persons) + { + $oldPerson = $this->persons->get($key); + + if (!$oldPerson) { + throw new \Exception(sprintf('The person %s was not found.', $key)); + } + + foreach ($persons as $person) { + $this->domain->update($oldPerson, $person->serialize()); + } + } + + /** + * @Given I delete the :key person + */ + public function iDeleteTheKeyPerson($key) + { + $oldPerson = $this->persons->get($key); + + if (!$oldPerson) { + throw new \Exception(sprintf('The person %s was not found.', $key)); + } + + $this->domain->delete($oldPerson); + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/Features/Person.feature b/src/Sir/Partner/Bundle/ApiBundle/Features/Person.feature new file mode 100644 index 0000000..e3c3a17 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Features/Person.feature @@ -0,0 +1,58 @@ +# @MajoraGenerator({"force_generation": true}) +@Person +Feature: Person Crud. + In order to manage person + As a user + I need to be able to create, update, delete and retrieve person. + + Background: Fixtures + Given I have theses persons: + | person_key | person_id | + | person_1 | 1 | + | person_2 | 2 | + | person_3 | 3 | + + Scenario: Read + Given I get the person list + Then I should see theses persons: + | person_id | + | 1 | + | 2 | + | 3 | + + Scenario: Create + Given I create theses persons: + | person_id | + | 4 | + And I get the person list + Then I should see theses persons: + | person_id | + | 1 | + | 2 | + | 3 | + | 4 | + + Scenario: Update + Given I update the "person_2" person with theses values: + | person_id | + | 4 | + And I get the person list + Then I should see theses persons: + | person_id | + | 1 | + | 4 | + | 3 | + And I should not see theses persons: + | person_id | + | 2 | + + Scenario: Delete + Given I delete the "person_2" person + And I get the person list + Then I should see theses persons: + | person_id | + | 1 | + | 3 | + And I should not see theses persons: + | person_id | + | 2 | diff --git a/src/Sir/Partner/Bundle/ApiBundle/Form/Person/AbstractType.php b/src/Sir/Partner/Bundle/ApiBundle/Form/Person/AbstractType.php new file mode 100644 index 0000000..c38537d --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Form/Person/AbstractType.php @@ -0,0 +1,52 @@ +personDomain = $personDomain; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'csrf_protection' => false, + 'allow_extra_fields' => true, + 'cascade_validation' => false, + )); + } + + /** + * Person form prototype definition. + * + * @warning : function auto generated by MajoraGeneratorBundle, implement your own logic here ! + * + * @see FormInterface::buildForm() + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/Form/Person/CreationType.php b/src/Sir/Partner/Bundle/ApiBundle/Form/Person/CreationType.php new file mode 100644 index 0000000..d2a3571 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Form/Person/CreationType.php @@ -0,0 +1,28 @@ +setDefaults(array( + 'data_class' => CreateAction::class, + 'empty_data' => function (FormInterface $form) { + return $this->personDomain->getAction('create'); + }, + )); + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/Form/Person/EditionType.php b/src/Sir/Partner/Bundle/ApiBundle/Form/Person/EditionType.php new file mode 100644 index 0000000..b3c4731 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Form/Person/EditionType.php @@ -0,0 +1,34 @@ +setDefaults(array( + 'data_class' => UpdateAction::class, + 'empty_data' => function (FormInterface $form) { + return $this->personDomain->getAction( + 'update', + $form->getConfig()->getOption('entity') + ); + }, + )); + $resolver->setRequired('entity'); + $resolver->setAllowedTypes('entity', Person::class); + } +} diff --git a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/routing.yml b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/routing.yml new file mode 100644 index 0000000..bdc6dad --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/routing.yml @@ -0,0 +1,10 @@ +# @MajoraGenerator({"include_routing": {"target": "@SirPartnerApiBundle/Resources/config/routing.yml"}}) +# @MajoraGenerator({"include_routing": {"route": "sir_partner_api"}}) +# @MajoraGenerator({"include_routing": {"resource": "@SirPartnerApiBundle/Resources/config/routing.yml"}}) + +sir_partner_sdk: + resource: "@SirPartnerSdkBundle/Resources/config/routing.yml" + +sir_partner_api: + resource: "@SirPartnerApiBundle/Resources/config/routing.yml" + \ No newline at end of file diff --git a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services.xml b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services.xml new file mode 100644 index 0000000..245bbe2 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/auto/auto_person.xml b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/auto/auto_person.xml new file mode 100644 index 0000000..9a2b9fc --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/auto/auto_person.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/person.xml b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/person.xml new file mode 100644 index 0000000..5214e5c --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/person.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/validation/person.yml b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/validation/person.yml new file mode 100644 index 0000000..0a8bde4 --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/validation/person.yml @@ -0,0 +1,5 @@ +Sir\Partner\Component\Entity\Person: + properties: ~ + # example: + # - NotBlank: + # groups: [creation] diff --git a/src/Sir/Partner/Bundle/ApiBundle/SirPartnerApiBundle.php b/src/Sir/Partner/Bundle/ApiBundle/SirPartnerApiBundle.php new file mode 100644 index 0000000..a456fea --- /dev/null +++ b/src/Sir/Partner/Bundle/ApiBundle/SirPartnerApiBundle.php @@ -0,0 +1,12 @@ +container = $container; + } + + /** + * @see FixtureInterface::load() + */ + public function load(ObjectManager $manager) + { + $personDomain = $this->container->get('sir.person.domain'); + + // reference there Persons data you want to create + $majoraEntities = array( + // 'person_1' => array( + // 'hello' => 'world', + // 'foo' => 'bar', + // ) + ); + + foreach ($majoraEntities as $reference => $personData) { + $this->addReference( + $reference, + $personDomain + ->getAction('create') + ->deserialize($personData) + ->resolve() + ); + } + } +} diff --git a/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/Configuration.php b/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000..1780cb5 --- /dev/null +++ b/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/Configuration.php @@ -0,0 +1,41 @@ +root('sir_partner_dal') + * ->children() + * ->scalarNode('...') + * ->isRequired() + * ->end() + * ->arrayNode() + * ->addDefaultsIfNotSet() + * ->children() + * // more nodes here + * ->end() + * ->end() + * ->end() + * ; + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $treeBuilder->root('sir_partner_dal'); + + return $treeBuilder; + } +} diff --git a/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/SirPartnerDalExtension.php b/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/SirPartnerDalExtension.php new file mode 100644 index 0000000..f262ab7 --- /dev/null +++ b/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/SirPartnerDalExtension.php @@ -0,0 +1,27 @@ +processConfiguration(new Configuration(), $configs); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/Sir/Partner/Bundle/DalBundle/Persistence/PersonPersistenceListener.php b/src/Sir/Partner/Bundle/DalBundle/Persistence/PersonPersistenceListener.php new file mode 100644 index 0000000..e3cc5f4 --- /dev/null +++ b/src/Sir/Partner/Bundle/DalBundle/Persistence/PersonPersistenceListener.php @@ -0,0 +1,67 @@ +personRepository = $personRepository; + } + + /** + * @see EventSubscriberInterface::getSubscribedEvents() + * + * @codeCoverageIgnore + */ + public static function getSubscribedEvents() + { + return array( + PersonEvents::SIR_PERSON_CREATED => array('onWritePerson', -100), + PersonEvents::SIR_PERSON_EDITED => array('onWritePerson', -100), + PersonEvents::SIR_PERSON_DELETED => array('onDeletePerson', -100), + ); + } + + /** + * Person writting event handler. + * + * @param PersonEvent $event + */ + public function onWritePerson(PersonEvent $event) + { + $this->personRepository->persist( + $event->getPerson() + ); + } + + /** + * Person deletion event handler. + * + * @param PersonEvent $event + */ + public function onDeletePerson(PersonEvent $event) + { + $this->personRepository->remove( + $event->getPerson() + ); + } +} diff --git a/src/Sir/Partner/Bundle/DalBundle/Resources/config/doctrine/Person.orm.yml b/src/Sir/Partner/Bundle/DalBundle/Resources/config/doctrine/Person.orm.yml new file mode 100644 index 0000000..91a062c --- /dev/null +++ b/src/Sir/Partner/Bundle/DalBundle/Resources/config/doctrine/Person.orm.yml @@ -0,0 +1,58 @@ +# @MajoraGenerator({"register_doctrine_em": {"target": "/config/config.yml"}}) +# @MajoraGenerator({"register_doctrine_em": {"em": "default"}}) +# @MajoraGenerator({"register_doctrine_em": {"prefix": "Sir\\Partner\\Component\\Entity"}}) +# @MajoraGenerator({"register_doctrine_em": {"bundle": "SirPartnerDalBundle"}}) +# @MajoraGenerator({"register_doctrine_em": {"alias": "SirPartner"}}) + +Sir\Partner\Component\Entity\Person: + type: entity + repositoryClass: Sir\Partner\Component\Repository\Doctrine\PersonDoctrineRepository + table: sir_partner_person + actAs: + Timestampable: ~ + id: + id: + type: integer + generator: { strategy: AUTO } + fields: + + # your other Person properties here + + createdAt: + type: datetime + column: created_at + gedmo: + timestampable: + on: create + updatedAt: + type: datetime + column: updated_at + gedmo: + timestampable: + on: update + + # manyToOne: + # example: + # targetEntity: Example + # inversedBy: persons + # joinColumn: + # name: example_id + # referencedColumnName: id + + # oneToMany: + # examples: + # targetEntity: Example + # mappedBy: person + # cascade: ['persist', 'remove'] + + # manyToMany: + # examples: + # targetEntity: Example + # joinTable: + # name: sir_partner_person_example + # joinColumns: + # person_id: + # referencedColumnName: id + # inverseJoinColumns: + # example_id: + # referencedColumnName: id diff --git a/src/Sir/Partner/Bundle/DalBundle/Resources/config/services.xml b/src/Sir/Partner/Bundle/DalBundle/Resources/config/services.xml new file mode 100644 index 0000000..05ee986 --- /dev/null +++ b/src/Sir/Partner/Bundle/DalBundle/Resources/config/services.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/auto/auto_person.xml b/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/auto/auto_person.xml new file mode 100644 index 0000000..ea2ad99 --- /dev/null +++ b/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/auto/auto_person.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SirPartner:Person + default + + + + + + + + + + + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/person.xml b/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/person.xml new file mode 100644 index 0000000..5214e5c --- /dev/null +++ b/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/person.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/DalBundle/SirPartnerDalBundle.php b/src/Sir/Partner/Bundle/DalBundle/SirPartnerDalBundle.php new file mode 100644 index 0000000..b41dab8 --- /dev/null +++ b/src/Sir/Partner/Bundle/DalBundle/SirPartnerDalBundle.php @@ -0,0 +1,12 @@ +root('sir_partner_sdk') + * ->children() + * ->scalarNode('...') + * ->isRequired() + * ->end() + * ->arrayNode() + * ->addDefaultsIfNotSet() + * ->children() + * // more nodes here + * ->end() + * ->end() + * ->end() + * ; + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $treeBuilder->root('sir_partner_sdk'); + + return $treeBuilder; + } +} diff --git a/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/SirPartnerSdkExtension.php b/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/SirPartnerSdkExtension.php new file mode 100644 index 0000000..8c3d0b9 --- /dev/null +++ b/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/SirPartnerSdkExtension.php @@ -0,0 +1,27 @@ +processConfiguration(new Configuration(), $configs); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing.yml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing.yml new file mode 100644 index 0000000..1634d4d --- /dev/null +++ b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing.yml @@ -0,0 +1,4 @@ + +sir_person_sdk: + resource: "routing/person.yml" + prefix: /persons diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/auto/auto_person.yml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/auto/auto_person.yml new file mode 100644 index 0000000..632d064 --- /dev/null +++ b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/auto/auto_person.yml @@ -0,0 +1,42 @@ +# @MajoraGenerator({"force_generation": true}) + +sir_api_person_collection: + path: / + defaults: + _controller: SirPartnerApiBundle:PersonApi:cget + methods: + - GET + +sir_api_person_create: + path: / + defaults: + _controller: SirPartnerApiBundle:PersonApi:post + methods: + - POST + +sir_api_person_read: + path: /{id} + defaults: + _controller: SirPartnerApiBundle:PersonApi:get + requirements: + id: \d+ + methods: + - GET + +sir_api_person_update: + path: /{id} + defaults: + _controller: SirPartnerApiBundle:PersonApi:put + requirements: + id: \d+ + methods: + - PUT + +sir_api_person_delete: + path: /{id} + defaults: + _controller: SirPartnerApiBundle:PersonApi:delete + requirements: + id: \d+ + methods: + - DELETE diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/person.yml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/person.yml new file mode 100644 index 0000000..b2be205 --- /dev/null +++ b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/person.yml @@ -0,0 +1,8 @@ +# @MajoraGenerator({"include_routing": {"target": "../routing.yml"}}) +# @MajoraGenerator({"include_routing": {"route": "sir_person_sdk"}}) +# @MajoraGenerator({"include_routing": {"resource": "routing/person.yml"}}) +# @MajoraGenerator({"include_routing": {"prefix": "/persons"}}) + +# generated routes +auto_sir_person_sdk: + resource: "@SirPartnerSdkBundle/Resources/config/routing/auto/auto_person.yml" diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services.xml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services.xml new file mode 100644 index 0000000..245bbe2 --- /dev/null +++ b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/auto/auto_person.xml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/auto/auto_person.xml new file mode 100644 index 0000000..2e227af --- /dev/null +++ b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/auto/auto_person.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + sir_api_person_collection + sir_api_person_create + sir_api_person_read + sir_api_person_update + sir_api_person_delete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/person.xml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/person.xml new file mode 100644 index 0000000..5214e5c --- /dev/null +++ b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/person.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/Sir/Partner/Bundle/SdkBundle/SirPartnerSdkBundle.php b/src/Sir/Partner/Bundle/SdkBundle/SirPartnerSdkBundle.php new file mode 100644 index 0000000..0209006 --- /dev/null +++ b/src/Sir/Partner/Bundle/SdkBundle/SirPartnerSdkBundle.php @@ -0,0 +1,12 @@ +person = $person; + + return $this; + } + + /** + * Return related Person if defined. + * + * @return Person|null $person + */ + public function getPerson() + { + return $this->person; + } +} diff --git a/src/Sir/Partner/Component/Action/Api/Person/AbstractApiAction.php b/src/Sir/Partner/Component/Action/Api/Person/AbstractApiAction.php new file mode 100644 index 0000000..11ef771 --- /dev/null +++ b/src/Sir/Partner/Component/Action/Api/Person/AbstractApiAction.php @@ -0,0 +1,14 @@ +getRestApiClient()->post( + array(), + $this->serialize() + ); + + // parsing response + $this->person = $this->getSerializer()->deserialize( + (string) $response->getBody(), + Person::class, + 'json' + ); + + return $this->person; + } +} diff --git a/src/Sir/Partner/Component/Action/Api/Person/DeleteAction.php b/src/Sir/Partner/Component/Action/Api/Person/DeleteAction.php new file mode 100644 index 0000000..bf4d81c --- /dev/null +++ b/src/Sir/Partner/Component/Action/Api/Person/DeleteAction.php @@ -0,0 +1,28 @@ +getRestApiClient()->delete( + array('id' => $this->person->getId()) + ); + } +} diff --git a/src/Sir/Partner/Component/Action/Api/Person/UpdateAction.php b/src/Sir/Partner/Component/Action/Api/Person/UpdateAction.php new file mode 100644 index 0000000..085b2f9 --- /dev/null +++ b/src/Sir/Partner/Component/Action/Api/Person/UpdateAction.php @@ -0,0 +1,48 @@ +getRestApiClient()->put( + array('id' => $this->person->getId()), + $this->serialize() + ); + + // Generic Person hydration from this action magic accessors + $this->person = $this->getSerializer()->deserialize( + (string) $this->getSerializer()->serialize($this, 'json'), + Person::class, + 'json' + ); + } +} diff --git a/src/Sir/Partner/Component/Action/Dal/Person/AbstractDalAction.php b/src/Sir/Partner/Component/Action/Dal/Person/AbstractDalAction.php new file mode 100644 index 0000000..b8d2189 --- /dev/null +++ b/src/Sir/Partner/Component/Action/Dal/Person/AbstractDalAction.php @@ -0,0 +1,16 @@ +person = new Person(); + $this->person->deserialize($this->serialize()); + + $this->assertEntityIsValid($this->person, array('Person', 'creation')); + + $this->fireEvent( + PersonEvents::SIR_PERSON_CREATED, + new PersonEvent($this->person, $this) + ); + + return $this->person; + } +} diff --git a/src/Sir/Partner/Component/Action/Dal/Person/DeleteAction.php b/src/Sir/Partner/Component/Action/Dal/Person/DeleteAction.php new file mode 100644 index 0000000..75d9e1d --- /dev/null +++ b/src/Sir/Partner/Component/Action/Dal/Person/DeleteAction.php @@ -0,0 +1,26 @@ +fireEvent( + PersonEvents::SIR_PERSON_DELETED, + new PersonEvent($this->person, $this) + ); + } +} diff --git a/src/Sir/Partner/Component/Action/Dal/Person/UpdateAction.php b/src/Sir/Partner/Component/Action/Dal/Person/UpdateAction.php new file mode 100644 index 0000000..3f560d9 --- /dev/null +++ b/src/Sir/Partner/Component/Action/Dal/Person/UpdateAction.php @@ -0,0 +1,30 @@ +person->deserialize($this->serialize()); + + $this->assertEntityIsValid($this->person, array('Person', 'edition')); + + $this->fireEvent( + PersonEvents::SIR_PERSON_EDITED, + new PersonEvent($this->person, $this) + ); + } +} diff --git a/src/Sir/Partner/Component/Domain/Action/Auto/PersonActionDispatcherDomainTrait.php b/src/Sir/Partner/Component/Domain/Action/Auto/PersonActionDispatcherDomainTrait.php new file mode 100644 index 0000000..9097307 --- /dev/null +++ b/src/Sir/Partner/Component/Domain/Action/Auto/PersonActionDispatcherDomainTrait.php @@ -0,0 +1,45 @@ +getAction('create', null, ...$arguments) + ->resolve() + ; + } + /** + * @see PersonDomainInterface::update() + */ + public function update(Person $person, ...$arguments) + { + return $this->getAction('update', $person, ...$arguments) + ->resolve() + ; + } + /** + * @see PersonDomainInterface::delete() + */ + public function delete(Person $person, ...$arguments) + { + return $this->getAction('delete', $person, ...$arguments) + ->resolve() + ; + } +} diff --git a/src/Sir/Partner/Component/Domain/Action/PersonActionDispatcherDomain.php b/src/Sir/Partner/Component/Domain/Action/PersonActionDispatcherDomain.php new file mode 100644 index 0000000..501eb81 --- /dev/null +++ b/src/Sir/Partner/Component/Domain/Action/PersonActionDispatcherDomain.php @@ -0,0 +1,21 @@ + 'id', + 'default' => array('id'), + ); + } + + /** + * Returns Person id. + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Define Person id. + * + * @param int $id + * + * @return self + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + // ************************************************* + // + // Class auto generated by MajoraGeneratorBundle + // Implement your own logic here ! + // + // ************************************************* +} diff --git a/src/Sir/Partner/Component/Entity/PersonCollection.php b/src/Sir/Partner/Component/Entity/PersonCollection.php new file mode 100644 index 0000000..9caf4c1 --- /dev/null +++ b/src/Sir/Partner/Component/Entity/PersonCollection.php @@ -0,0 +1,19 @@ +person = $person; + $this->action = $action; + } + + /** + * return related. + * + * @return Person + */ + public function getPerson() + { + return $this->person; + } + + /** + * @see BroadcastableEventInterface::getSubject() + */ + public function getSubject() + { + return $this->getPerson(); + } + + /** + * @see BroadcastableEventInterface::getAction() + */ + public function getAction() + { + return $this->action; + } +} diff --git a/src/Sir/Partner/Component/Event/PersonEvents.php b/src/Sir/Partner/Component/Event/PersonEvents.php new file mode 100644 index 0000000..e8ae714 --- /dev/null +++ b/src/Sir/Partner/Component/Event/PersonEvents.php @@ -0,0 +1,24 @@ + array( + array(), + array(), + $person = (new Person())->setId(42), + $person, + ), + + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + array $incommingData, + array $expectedRequestData, + Person $createdPerson, + Person $expectedPerson + ) { + // Rest Client mock + $restClient = $this->prophesize(RestApiClient::class); + $restClient + ->post(array(), $expectedRequestData) + ->willReturn(new Response()) + ->shouldBeCalled() + ; + + // Serializer mock + $serializer = $this->prophesize(SerializerInterface::class); + $serializer + ->deserialize(Argument::any(), Person::class, Argument::any()) + ->willReturn($createdPerson) + ; + + // Action + $action = new CreateAction(); + $action->setSerializer($serializer->reveal()); + $action->setRestApiClient($restClient->reveal()); + $action->deserialize($incommingData); + + $this->assertEquals( + $expectedPerson, + $action->resolve() + ); + } +} diff --git a/src/Sir/Partner/Component/Tests/Action/Api/Person/DeleteActionTest.php b/src/Sir/Partner/Component/Tests/Action/Api/Person/DeleteActionTest.php new file mode 100644 index 0000000..45dc622 --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Action/Api/Person/DeleteActionTest.php @@ -0,0 +1,39 @@ +prophesize(RestApiClient::class); + $restClient + ->delete(array('id' => 42)) + ->willReturn(new Response()) + ->shouldBeCalled() + ; + + // Action + $action = new DeleteAction(); + $action->init((new Person())->setId(42)); + $action->setRestApiClient($restClient->reveal()); + + $action->resolve(); + } +} diff --git a/src/Sir/Partner/Component/Tests/Action/Api/Person/UpdateActionTest.php b/src/Sir/Partner/Component/Tests/Action/Api/Person/UpdateActionTest.php new file mode 100644 index 0000000..b77f1e2 --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Action/Api/Person/UpdateActionTest.php @@ -0,0 +1,72 @@ + array( + (new Person())->setId(42), + array(), + array(), + ), + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + Person $currentPerson, + array $incommingData, + array $expectedRequestData + ) { + // Rest Client mock + $restClient = $this->prophesize(RestApiClient::class); + $restClient + ->put( + array('id' => $currentPerson->getId()), + $expectedRequestData + ) + ->willReturn(new Response()) + ->shouldBeCalled() + ; + + // Action + $action = new UpdateAction(); + $action->init($currentPerson); + $action->setRestApiClient($restClient->reveal()); + $action->deserialize($incommingData); + + $action->resolve(); + } +} diff --git a/src/Sir/Partner/Component/Tests/Action/Dal/Person/CreateActionTest.php b/src/Sir/Partner/Component/Tests/Action/Dal/Person/CreateActionTest.php new file mode 100644 index 0000000..faccc38 --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Action/Dal/Person/CreateActionTest.php @@ -0,0 +1,82 @@ + array( + array(), + new Person(), + ), + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + array $incommingData, + Person $expectedPerson + ) { + // Validator + $validator = $this->prophesize(ValidatorInterface::class); + $validator + ->validate( + Argument::type(Person::class), + null, + array('Person', 'creation') + ) + ->shouldBeCalled() + ; + + // Event dispatcher + $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); + $eventDispatcher + ->dispatch( + PersonEvents::SIR_PERSON_CREATED, + Argument::type(PersonEvent::class) + ) + ->shouldBeCalled() + ; + + // Action + $action = new CreateAction(); + $action->setEventDispatcher($eventDispatcher->reveal()); + $action->setValidator($validator->reveal()); + $action->deserialize($incommingData); + + $this->assertEquals( + $expectedPerson, + $action->resolve() + ); + } +} diff --git a/src/Sir/Partner/Component/Tests/Action/Dal/Person/DeleteActionTest.php b/src/Sir/Partner/Component/Tests/Action/Dal/Person/DeleteActionTest.php new file mode 100644 index 0000000..3efca73 --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Action/Dal/Person/DeleteActionTest.php @@ -0,0 +1,71 @@ + array( + new Person(), + ), + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + Person $givenPerson + ) { + $asserter = $this; + + // Event dispatcher + $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); + $eventDispatcher + ->dispatch( + PersonEvents::SIR_PERSON_DELETED, + Argument::type(PersonEvent::class) + ) + ->will(function ($args) use ($asserter, $givenPerson) { + $asserter->assertEquals( + $givenPerson, + $args[1]->getPerson() + ); + }) + ->shouldBeCalled() + ; + + // Action + $action = new DeleteAction(); + $action->setEventDispatcher($eventDispatcher->reveal()); + $action->init($givenPerson); + + $action->resolve(); + } +} diff --git a/src/Sir/Partner/Component/Tests/Action/Dal/Person/UpdateActionTest.php b/src/Sir/Partner/Component/Tests/Action/Dal/Person/UpdateActionTest.php new file mode 100644 index 0000000..a5bb346 --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Action/Dal/Person/UpdateActionTest.php @@ -0,0 +1,88 @@ + array( + array(), + (new Person())->setId(42), + ), + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + array $incommingData, + Person $givenPerson + ) { + $asserter = $this; + + // Validator + $validator = $this->prophesize(ValidatorInterface::class); + $validator + ->validate( + Argument::type(Person::class), + null, + array('Person', 'edition') + ) + ->shouldBeCalled() + ; + + // Event dispatcher + $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); + $eventDispatcher + ->dispatch( + PersonEvents::SIR_PERSON_EDITED, + Argument::type(PersonEvent::class) + ) + ->will(function ($args) use ($asserter, $givenPerson) { + $asserter->assertEquals( + $givenPerson, + $args[1]->getPerson() + ); + }) + ->shouldBeCalled() + ; + + // Action + $action = new UpdateAction(); + $action->setValidator($validator->reveal()); + $action->deserialize($incommingData); + $action->setEventDispatcher($eventDispatcher->reveal()); + $action->init($givenPerson); + + $action->resolve(); + } +} diff --git a/src/Sir/Partner/Component/Tests/Entity/PersonCollectionTest.php b/src/Sir/Partner/Component/Tests/Entity/PersonCollectionTest.php new file mode 100644 index 0000000..9c8e8d4 --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Entity/PersonCollectionTest.php @@ -0,0 +1,45 @@ +deserialize(array( + 'person_1' => array('id' => 42), + 'person_2' => array('id' => 66), + )); + + $this->assertInstanceOf( + Person::class, + $personCollection->get('person_1'), + 'Deserialization process hydrate a related entity class object and index it under given key.' + ); + $this->assertInstanceOf( + Person::class, + $personCollection->get('person_2'), + 'Deserialization process hydrate a related entity class object and index it under given key.' + ); + $this->assertEquals( + array( + 'person_1' => 42, + 'person_2' => 66, + ), + $personCollection->serialize('id'), + 'Serialization scopes are transmitted to related entity serialization process.' + ); + } +} diff --git a/src/Sir/Partner/Component/Tests/Entity/PersonTest.php b/src/Sir/Partner/Component/Tests/Entity/PersonTest.php new file mode 100644 index 0000000..c7a835e --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Entity/PersonTest.php @@ -0,0 +1,128 @@ +person = new Person(); + $this->reflector = new \ReflectionClass($this->person); + } + + /** + * Provider for accessor tests. + * + * @return array + */ + public function propertyMapProvider() + { + return array( + 'id' => array('id', 42), + ); + } + + /** + * Tests setters. + * + * @dataProvider propertyMapProvider + */ + public function testSet($propertyName, $definedValue) + { + $property = $this->reflector->getProperty($propertyName); + $property->setAccessible(true); + + $method = 'set'.ucfirst($propertyName); + $this->person->$method($definedValue); + $this->assertEquals( + $definedValue, + $property->getValue($this->person), + sprintf('Person::%s() defines "%s" property current value.', + $method, + $propertyName + ) + ); + } + + /** + * Tests getters. + * + * @dataProvider propertyMapProvider + */ + public function testGet($propertyName, $expectedValue) + { + $property = $this->reflector->getProperty($propertyName); + $property->setAccessible(true); + $property->setValue($this->person, $expectedValue); + + $method = 'get'.ucfirst($propertyName); + $this->assertEquals( + $expectedValue, + $this->person->$method(), + sprintf('Person::%s() returns current defined "%s" property value.', + $method, + $propertyName + ) + ); + } + + /** + * Provider for serialization tests. + * + * @return array() + */ + public function serializationCasesProvider() + { + return array( + 'id' => array('id', 'int'), + 'default' => array('default', array('id')), + ); + } + + /** + * Tests serialization scopes. + * + * @dataProvider serializationCasesProvider + */ + public function testSerializationScopes($scope, $expectedKeys) + { + $this->person->setId(42); + $personData = $this->person->serialize($scope); + + if (!is_array($expectedKeys)) { + return $this->assertInternalType( + $expectedKeys, + $personData, + sprintf('Person "%s" scope provides a single value as %s.', $scope, $expectedKeys) + ); + } + + foreach ($expectedKeys as $expectedKey) { + $this->assertArrayHasKey( + $expectedKey, + $personData, + sprintf('Person "%s" scope provides an array with "%s" key.', $scope, $expectedKey) + ); + } + } +} diff --git a/src/Sir/Partner/Component/Tests/Event/PersonEventTest.php b/src/Sir/Partner/Component/Tests/Event/PersonEventTest.php new file mode 100644 index 0000000..f83babd --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Event/PersonEventTest.php @@ -0,0 +1,34 @@ +prophesize(AbstractPersonAction::class)->reveal(); + + // Event + $event = new PersonEvent( + $person = new Person(), + $action + ); + + // Assertions + $this->assertSame($person, $event->getPerson()); + $this->assertSame($person, $event->getSubject()); + $this->assertSame($action, $event->getAction()); + } +} diff --git a/src/Sir/Partner/Component/Tests/Loader/Api/PersonApiLoaderTest.php b/src/Sir/Partner/Component/Tests/Loader/Api/PersonApiLoaderTest.php new file mode 100644 index 0000000..83a7cdb --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Loader/Api/PersonApiLoaderTest.php @@ -0,0 +1,30 @@ +prophesize(RestApiClient::class); + $restApiClient->send()->shouldNotBeCalled(); + + $serializer = $this->prophesize(SerializerInterface::class); + $serializer->deserialize()->shouldNotBeCalled(); + + $loader = new PersonApiLoader( + $restApiClient->reveal(), + $serializer->reveal() + ); + } +} diff --git a/src/Sir/Partner/Component/Tests/Loader/Doctrine/PersonDoctrineLoader.php b/src/Sir/Partner/Component/Tests/Loader/Doctrine/PersonDoctrineLoader.php new file mode 100644 index 0000000..5db6afc --- /dev/null +++ b/src/Sir/Partner/Component/Tests/Loader/Doctrine/PersonDoctrineLoader.php @@ -0,0 +1,31 @@ +prophesize(PersonRepositoryInterface::class); + $repository->save()->shouldNotBeCalled(); + + $loader = new PersonDoctrineLoader(); + $loader->setUp( + Person::class, + array('majora' => 'entity'), + PersonCollection::class, + $repository->reveal() + ); + } +} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Auto/Person2ApiControllerTrait.php b/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Auto/Person2ApiControllerTrait.php new file mode 100644 index 0000000..ca21dd6 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Auto/Person2ApiControllerTrait.php @@ -0,0 +1,138 @@ +query->all(), + array_flip(array('scope', 'limit', 'offset')) + ); + + return $this->createJsonResponse( + $this->container->get('sir1.person2.loader')->retrieveAll( + $this->container->get('majora.inflector')->normalize($queryFilters, 'camelize'), + $request->query->get('limit'), + $request->query->get('offset') + ), + $request->query->get('scope') + ); + } + + /** + * Returns a single Person2 by id. + * + * @param int $id requested Person2 id + * @param Request $request + * + * @return JsonResponse + */ + public function getAction($id, Request $request) + { + $person2 = $this->retrieveOr404($id, 'sir1.person2.loader'); + + return $this->createJsonResponse( + $person2, + $request->query->get('scope') + ); + } + + /** + * Creates a new Person2. + * + * @param Request $request + * + * @return JsonResponse + */ + public function postAction(Request $request) + { + // submit + $this->assertSubmitedFormIsValid($request, + $form = $this->container->get('form.factory')->createNamed( + '', + CreationType::class, + null, + array('method' => 'POST') + ) + ); + + // resolve use case + $person2 = $form->getData()->resolve(); + + return $this->createJsonResponse( + $person2, + $request->query->get('scope'), + 201 + ); + } + + /** + * Updates a single Person2 by id. + * + * @param int $id requested Person2 id + * @param Request $request + * + * @return JsonResponse + */ + public function putAction($id, Request $request) + { + // submit + $this->assertSubmitedFormIsValid($request, + $form = $this->container->get('form.factory')->createNamed( + '', + EditionType::class, + null, + array( + 'method' => 'PUT', + 'entity' => $this->retrieveOr404($id, 'sir1.person2.loader'), + ) + ) + ); + + // resolve use case + $form->getData()->resolve(); + + return $this->createJsonNoContentResponse(); + } + + /** + * Delete a single Person2 by id. + * + * @param int $id requested Person2 id + * + * @return JsonResponse + */ + public function deleteAction($id) + { + $this->container->get('sir1.person2.domain')->delete( + $this->retrieveOr404($id, 'sir1.person2.loader') + ); + + return $this->createJsonNoContentResponse(); + } +} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Person2ApiController.php b/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Person2ApiController.php new file mode 100644 index 0000000..a23b59c --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Person2ApiController.php @@ -0,0 +1,22 @@ +root('sir1_partner3_api') + * ->children() + * ->scalarNode('...') + * ->isRequired() + * ->end() + * ->arrayNode() + * ->addDefaultsIfNotSet() + * ->children() + * // more nodes here + * ->end() + * ->end() + * ->end() + * ; + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $treeBuilder->root('sir1_partner3_api'); + + return $treeBuilder; + } +} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Sir1Partner3ApiExtension.php b/src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Sir1Partner3ApiExtension.php new file mode 100644 index 0000000..b33fab2 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Sir1Partner3ApiExtension.php @@ -0,0 +1,28 @@ +processConfiguration($configuration, $configs); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php new file mode 100644 index 0000000..533a9b0 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php @@ -0,0 +1,112 @@ +em = $em; + $this->domain = $domain; + $this->loader = $loader; + } + + /** + * @BeforeScenario + */ + public function initPerson2s() + { + $this->truncatePerson2s(); + for($i=0; $i<= self::$totalToInsert; $i++){ + $this->em->persist(new Person2()); + } + $this->em->flush(); + } + + /** + * @When I create a new person2 + */ + public function createPerson2() + { + $this->currentPerson2 = $this->domain->create(new Person2()); + } + + /** + * @Then I retrieve new person2 id + */ + public function testPerson2Id() + { + var_dump($this->currentPerson2); + return $this->currentPerson2->getId() != null; + } + + /** + * @AfterScenario + */ + public function terminatePerson2s() + { + $this->truncatePerson2s(); + } + + /** + * Trucate all table data + * @throws \Doctrine\DBAL\DBALException + */ + private function truncatePerson2s() + { + $connection = $this->em->getConnection(); + $connection->query('SET FOREIGN_KEY_CHECKS=0'); + $this->em->createQuery('DELETE FROM Sir1\Partner3\Component\Entity\Person2')->execute(); + $connection->query('SET FOREIGN_KEY_CHECKS=1'); + $this->em->flush(); + } + +} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature new file mode 100644 index 0000000..b7e7701 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature @@ -0,0 +1,30 @@ +@Person2 +Feature: Person2 Crud. + In order to manage person2 + As a user + I need to be able to create, update, delete and retrieve person2. + + Scenario: Create + Given I have some person2s + When I create a new person2 + Then I retrieve new person2 id + +# Scenario: ReadAll +# Given I have some person2s +# When I get the person2s list +# Then I should see a list of person2 +# +# Scenario: Read +# Given I have created a new person2 +# When I show this person2 by id +# Then I should see this person2 +# +# Scenario: delete +# Given I have created a new person2 +# When I delete this person2 +# Then I should not see this person2 in the list +# +# Scenario: Update +# Given I have created a new person2 +# When I update this person2 with a new id +# Then I should see the same person2 with this new id value diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/AbstractType.php b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/AbstractType.php new file mode 100644 index 0000000..4d6fb81 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/AbstractType.php @@ -0,0 +1,52 @@ +person2Domain = $person2Domain; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'csrf_protection' => false, + 'allow_extra_fields' => true, + 'cascade_validation' => false, + )); + } + + /** + * Person2 form prototype definition. + * + * @warning : function auto generated by MajoraGeneratorBundle, implement your own logic here ! + * + * @see FormInterface::buildForm() + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + } +} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/CreationType.php b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/CreationType.php new file mode 100644 index 0000000..f8110e4 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/CreationType.php @@ -0,0 +1,28 @@ +setDefaults(array( + 'data_class' => CreateAction::class, + 'empty_data' => function (FormInterface $form) { + return $this->person2Domain->getAction('create'); + }, + )); + } +} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/EditionType.php b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/EditionType.php new file mode 100644 index 0000000..f997266 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/EditionType.php @@ -0,0 +1,34 @@ +setDefaults(array( + 'data_class' => UpdateAction::class, + 'empty_data' => function (FormInterface $form) { + return $this->person2Domain->getAction( + 'update', + $form->getConfig()->getOption('entity') + ); + }, + )); + $resolver->setRequired('entity'); + $resolver->setAllowedTypes('entity', Person2::class); + } +} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/routing.yml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/routing.yml new file mode 100644 index 0000000..c87fac3 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/routing.yml @@ -0,0 +1,2 @@ +sir1_partner3_sdk: + resource: "@Sir1Partner3SdkBundle/Resources/config/routing.yml" diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services.xml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services.xml new file mode 100644 index 0000000..369892f --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/auto/auto_person2.xml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/auto/auto_person2.xml new file mode 100644 index 0000000..ca6e65f --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/auto/auto_person2.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/person2.xml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/person2.xml new file mode 100644 index 0000000..1ab77ad --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/person2.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/validation/person2.yml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/validation/person2.yml new file mode 100644 index 0000000..1dd0172 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/validation/person2.yml @@ -0,0 +1,5 @@ +Sir1\Partner3\Component\Entity\Person2: + properties: ~ + # example: + # - NotBlank: + # groups: [creation] diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Sir1Partner3ApiBundle.php b/src/Sir1/Partner3/Bundle/ApiBundle/Sir1Partner3ApiBundle.php new file mode 100644 index 0000000..1894056 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Sir1Partner3ApiBundle.php @@ -0,0 +1,12 @@ +container = $container; + } + + /** + * @see FixtureInterface::load() + */ + public function load(ObjectManager $manager) + { + $person2Domain = $this->container->get('sir1.person2.domain'); + + // reference there Person2s data you want to create + $majoraEntities = array( + // 'person2_1' => array( + // 'hello' => 'world', + // 'foo' => 'bar', + // ) + ); + + foreach ($majoraEntities as $reference => $person2Data) { + $this->addReference( + $reference, + $person2Domain + ->getAction('create') + ->deserialize($person2Data) + ->resolve() + ); + } + } +} diff --git a/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Configuration.php b/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000..666cfe2 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Configuration.php @@ -0,0 +1,41 @@ +root('sir1_partner3_dal') + * ->children() + * ->scalarNode('...') + * ->isRequired() + * ->end() + * ->arrayNode() + * ->addDefaultsIfNotSet() + * ->children() + * // more nodes here + * ->end() + * ->end() + * ->end() + * ; + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $treeBuilder->root('sir1_partner3_dal'); + + return $treeBuilder; + } +} diff --git a/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Sir1Partner3DalExtension.php b/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Sir1Partner3DalExtension.php new file mode 100644 index 0000000..1086f7b --- /dev/null +++ b/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Sir1Partner3DalExtension.php @@ -0,0 +1,27 @@ +processConfiguration(new Configuration(), $configs); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Persistence/Person2PersistenceListener.php b/src/Sir1/Partner3/Bundle/DalBundle/Persistence/Person2PersistenceListener.php new file mode 100644 index 0000000..89a4c55 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/DalBundle/Persistence/Person2PersistenceListener.php @@ -0,0 +1,67 @@ +person2Repository = $person2Repository; + } + + /** + * @see EventSubscriberInterface::getSubscribedEvents() + * + * @codeCoverageIgnore + */ + public static function getSubscribedEvents() + { + return array( + Person2Events::SIR1_PERSON2_CREATED => array('onWritePerson2', -100), + Person2Events::SIR1_PERSON2_EDITED => array('onWritePerson2', -100), + Person2Events::SIR1_PERSON2_DELETED => array('onDeletePerson2', -100), + ); + } + + /** + * Person2 writting event handler. + * + * @param Person2Event $event + */ + public function onWritePerson2(Person2Event $event) + { + $this->person2Repository->persist( + $event->getPerson2() + ); + } + + /** + * Person2 deletion event handler. + * + * @param Person2Event $event + */ + public function onDeletePerson2(Person2Event $event) + { + $this->person2Repository->remove( + $event->getPerson2() + ); + } +} diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/doctrine/Person2.orm.yml b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/doctrine/Person2.orm.yml new file mode 100644 index 0000000..e4f5fa5 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/doctrine/Person2.orm.yml @@ -0,0 +1,58 @@ +# @MajoraGenerator({"register_doctrine_em": {"target": "/config/config.yml"}}) +# @MajoraGenerator({"register_doctrine_em": {"em": "default"}}) +# @MajoraGenerator({"register_doctrine_em": {"prefix": "Sir1\\Partner3\\Component\\Entity"}}) +# @MajoraGenerator({"register_doctrine_em": {"bundle": "Sir1Partner3DalBundle"}}) +# @MajoraGenerator({"register_doctrine_em": {"alias": "Sir1Partner3"}}) + +Sir1\Partner3\Component\Entity\Person2: + type: entity + repositoryClass: Sir1\Partner3\Component\Repository\Doctrine\Person2DoctrineRepository + table: sir1_partner3_person2 + actAs: + Timestampable: ~ + id: + id: + type: integer + generator: { strategy: AUTO } + fields: + + # your other Person2 properties here + + createdAt: + type: datetime + column: created_at + gedmo: + timestampable: + on: create + updatedAt: + type: datetime + column: updated_at + gedmo: + timestampable: + on: update + + # manyToOne: + # example: + # targetEntity: Example + # inversedBy: person2s + # joinColumn: + # name: example_id + # referencedColumnName: id + + # oneToMany: + # examples: + # targetEntity: Example + # mappedBy: person2 + # cascade: ['persist', 'remove'] + + # manyToMany: + # examples: + # targetEntity: Example + # joinTable: + # name: sir1_partner3_person2_example + # joinColumns: + # person2_id: + # referencedColumnName: id + # inverseJoinColumns: + # example_id: + # referencedColumnName: id diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services.xml b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services.xml new file mode 100644 index 0000000..369892f --- /dev/null +++ b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/auto/auto_person2.xml b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/auto/auto_person2.xml new file mode 100644 index 0000000..3cda1fa --- /dev/null +++ b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/auto/auto_person2.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sir1Partner3:Person2 + default + + + + + + + + + + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/person2.xml b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/person2.xml new file mode 100644 index 0000000..1ab77ad --- /dev/null +++ b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/person2.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Sir1Partner3DalBundle.php b/src/Sir1/Partner3/Bundle/DalBundle/Sir1Partner3DalBundle.php new file mode 100644 index 0000000..ec9698e --- /dev/null +++ b/src/Sir1/Partner3/Bundle/DalBundle/Sir1Partner3DalBundle.php @@ -0,0 +1,12 @@ +root('sir1_partner3_sdk') + * ->children() + * ->scalarNode('...') + * ->isRequired() + * ->end() + * ->arrayNode() + * ->addDefaultsIfNotSet() + * ->children() + * // more nodes here + * ->end() + * ->end() + * ->end() + * ; + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $treeBuilder->root('sir1_partner3_sdk'); + + return $treeBuilder; + } +} diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Sir1Partner3SdkExtension.php b/src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Sir1Partner3SdkExtension.php new file mode 100644 index 0000000..330dceb --- /dev/null +++ b/src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Sir1Partner3SdkExtension.php @@ -0,0 +1,27 @@ +processConfiguration(new Configuration(), $configs); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing.yml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing.yml new file mode 100644 index 0000000..edace8b --- /dev/null +++ b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing.yml @@ -0,0 +1,4 @@ + +sir1_person2_sdk: + resource: "routing/person2.yml" + prefix: /person2s diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/auto/auto_person2.yml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/auto/auto_person2.yml new file mode 100644 index 0000000..afaacfa --- /dev/null +++ b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/auto/auto_person2.yml @@ -0,0 +1,42 @@ +# @MajoraGenerator({"force_generation": true}) + +sir1_api_person2_collection: + path: / + defaults: + _controller: Sir1Partner3ApiBundle:Person2Api:cget + methods: + - GET + +sir1_api_person2_create: + path: / + defaults: + _controller: Sir1Partner3ApiBundle:Person2Api:post + methods: + - POST + +sir1_api_person2_read: + path: /{id} + defaults: + _controller: Sir1Partner3ApiBundle:Person2Api:get + requirements: + id: \d+ + methods: + - GET + +sir1_api_person2_update: + path: /{id} + defaults: + _controller: Sir1Partner3ApiBundle:Person2Api:put + requirements: + id: \d+ + methods: + - PUT + +sir1_api_person2_delete: + path: /{id} + defaults: + _controller: Sir1Partner3ApiBundle:Person2Api:delete + requirements: + id: \d+ + methods: + - DELETE diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/person2.yml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/person2.yml new file mode 100644 index 0000000..c118c97 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/person2.yml @@ -0,0 +1,8 @@ +# @MajoraGenerator({"include_routing": {"target": "../routing.yml"}}) +# @MajoraGenerator({"include_routing": {"route": "sir1_person2_sdk"}}) +# @MajoraGenerator({"include_routing": {"resource": "routing/person2.yml"}}) +# @MajoraGenerator({"include_routing": {"prefix": "/person2s"}}) + +# generated routes +auto_sir1_person2_sdk: + resource: "@Sir1Partner3SdkBundle/Resources/config/routing/auto/auto_person2.yml" diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services.xml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services.xml new file mode 100644 index 0000000..369892f --- /dev/null +++ b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/auto/auto_person2.xml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/auto/auto_person2.xml new file mode 100644 index 0000000..6875f88 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/auto/auto_person2.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + sir1_api_person2_collection + sir1_api_person2_create + sir1_api_person2_read + sir1_api_person2_update + sir1_api_person2_delete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/person2.xml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/person2.xml new file mode 100644 index 0000000..1ab77ad --- /dev/null +++ b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/person2.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Sir1Partner3SdkBundle.php b/src/Sir1/Partner3/Bundle/SdkBundle/Sir1Partner3SdkBundle.php new file mode 100644 index 0000000..c11da54 --- /dev/null +++ b/src/Sir1/Partner3/Bundle/SdkBundle/Sir1Partner3SdkBundle.php @@ -0,0 +1,12 @@ +person2 = $person2; + + return $this; + } + + /** + * Return related Person2 if defined. + * + * @return Person2|null $person2 + */ + public function getPerson2() + { + return $this->person2; + } +} diff --git a/src/Sir1/Partner3/Component/Action/Api/Person2/AbstractApiAction.php b/src/Sir1/Partner3/Component/Action/Api/Person2/AbstractApiAction.php new file mode 100644 index 0000000..028b50a --- /dev/null +++ b/src/Sir1/Partner3/Component/Action/Api/Person2/AbstractApiAction.php @@ -0,0 +1,14 @@ +getRestApiClient()->post( + array(), + $this->serialize() + ); + + // parsing response + $this->person2 = $this->getSerializer()->deserialize( + (string) $response->getBody(), + Person2::class, + 'json' + ); + + return $this->person2; + } +} diff --git a/src/Sir1/Partner3/Component/Action/Api/Person2/DeleteAction.php b/src/Sir1/Partner3/Component/Action/Api/Person2/DeleteAction.php new file mode 100644 index 0000000..7e86a41 --- /dev/null +++ b/src/Sir1/Partner3/Component/Action/Api/Person2/DeleteAction.php @@ -0,0 +1,28 @@ +getRestApiClient()->delete( + array('id' => $this->person2->getId()) + ); + } +} diff --git a/src/Sir1/Partner3/Component/Action/Api/Person2/UpdateAction.php b/src/Sir1/Partner3/Component/Action/Api/Person2/UpdateAction.php new file mode 100644 index 0000000..af1e6c3 --- /dev/null +++ b/src/Sir1/Partner3/Component/Action/Api/Person2/UpdateAction.php @@ -0,0 +1,48 @@ +getRestApiClient()->put( + array('id' => $this->person2->getId()), + $this->serialize() + ); + + // Generic Person2 hydration from this action magic accessors + $this->person2 = $this->getSerializer()->deserialize( + (string) $this->getSerializer()->serialize($this, 'json'), + Person2::class, + 'json' + ); + } +} diff --git a/src/Sir1/Partner3/Component/Action/Dal/Person2/AbstractDalAction.php b/src/Sir1/Partner3/Component/Action/Dal/Person2/AbstractDalAction.php new file mode 100644 index 0000000..a16864b --- /dev/null +++ b/src/Sir1/Partner3/Component/Action/Dal/Person2/AbstractDalAction.php @@ -0,0 +1,16 @@ +person2 = new Person2(); + $this->person2->deserialize($this->serialize()); + + $this->assertEntityIsValid($this->person2, array('Person2', 'creation')); + + $this->fireEvent( + Person2Events::SIR1_PERSON2_CREATED, + new Person2Event($this->person2, $this) + ); + + return $this->person2; + } +} diff --git a/src/Sir1/Partner3/Component/Action/Dal/Person2/DeleteAction.php b/src/Sir1/Partner3/Component/Action/Dal/Person2/DeleteAction.php new file mode 100644 index 0000000..e8b4627 --- /dev/null +++ b/src/Sir1/Partner3/Component/Action/Dal/Person2/DeleteAction.php @@ -0,0 +1,26 @@ +fireEvent( + Person2Events::SIR1_PERSON2_DELETED, + new Person2Event($this->person2, $this) + ); + } +} diff --git a/src/Sir1/Partner3/Component/Action/Dal/Person2/UpdateAction.php b/src/Sir1/Partner3/Component/Action/Dal/Person2/UpdateAction.php new file mode 100644 index 0000000..62d0a3b --- /dev/null +++ b/src/Sir1/Partner3/Component/Action/Dal/Person2/UpdateAction.php @@ -0,0 +1,30 @@ +person2->deserialize($this->serialize()); + + $this->assertEntityIsValid($this->person2, array('Person2', 'edition')); + + $this->fireEvent( + Person2Events::SIR1_PERSON2_EDITED, + new Person2Event($this->person2, $this) + ); + } +} diff --git a/src/Sir1/Partner3/Component/Domain/Action/Auto/Person2ActionDispatcherDomainTrait.php b/src/Sir1/Partner3/Component/Domain/Action/Auto/Person2ActionDispatcherDomainTrait.php new file mode 100644 index 0000000..1c5725f --- /dev/null +++ b/src/Sir1/Partner3/Component/Domain/Action/Auto/Person2ActionDispatcherDomainTrait.php @@ -0,0 +1,45 @@ +getAction('create', null, ...$arguments) + ->resolve() + ; + } + /** + * @see Person2DomainInterface::update() + */ + public function update(Person2 $person2, ...$arguments) + { + return $this->getAction('update', $person2, ...$arguments) + ->resolve() + ; + } + /** + * @see Person2DomainInterface::delete() + */ + public function delete(Person2 $person2, ...$arguments) + { + return $this->getAction('delete', $person2, ...$arguments) + ->resolve() + ; + } +} diff --git a/src/Sir1/Partner3/Component/Domain/Action/Person2ActionDispatcherDomain.php b/src/Sir1/Partner3/Component/Domain/Action/Person2ActionDispatcherDomain.php new file mode 100644 index 0000000..1c88d87 --- /dev/null +++ b/src/Sir1/Partner3/Component/Domain/Action/Person2ActionDispatcherDomain.php @@ -0,0 +1,21 @@ + 'id', + 'default' => array('id'), + ); + } + + /** + * Returns Person2 id. + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Define Person2 id. + * + * @param int $id + * + * @return self + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + // ************************************************* + // + // Class auto generated by MajoraGeneratorBundle + // Implement your own logic here ! + // + // ************************************************* +} diff --git a/src/Sir1/Partner3/Component/Entity/Person2Collection.php b/src/Sir1/Partner3/Component/Entity/Person2Collection.php new file mode 100644 index 0000000..36ed0cd --- /dev/null +++ b/src/Sir1/Partner3/Component/Entity/Person2Collection.php @@ -0,0 +1,19 @@ +person2 = $person2; + $this->action = $action; + } + + /** + * return related. + * + * @return Person2 + */ + public function getPerson2() + { + return $this->person2; + } + + /** + * @see BroadcastableEventInterface::getSubject() + */ + public function getSubject() + { + return $this->getPerson2(); + } + + /** + * @see BroadcastableEventInterface::getAction() + */ + public function getAction() + { + return $this->action; + } +} diff --git a/src/Sir1/Partner3/Component/Event/Person2Events.php b/src/Sir1/Partner3/Component/Event/Person2Events.php new file mode 100644 index 0000000..1e7abb4 --- /dev/null +++ b/src/Sir1/Partner3/Component/Event/Person2Events.php @@ -0,0 +1,24 @@ + array( + array(), + array(), + $person2 = (new Person2())->setId(42), + $person2, + ), + + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + array $incommingData, + array $expectedRequestData, + Person2 $createdPerson2, + Person2 $expectedPerson2 + ) { + // Rest Client mock + $restClient = $this->prophesize(RestApiClient::class); + $restClient + ->post(array(), $expectedRequestData) + ->willReturn(new Response()) + ->shouldBeCalled() + ; + + // Serializer mock + $serializer = $this->prophesize(SerializerInterface::class); + $serializer + ->deserialize(Argument::any(), Person2::class, Argument::any()) + ->willReturn($createdPerson2) + ; + + // Action + $action = new CreateAction(); + $action->setSerializer($serializer->reveal()); + $action->setRestApiClient($restClient->reveal()); + $action->deserialize($incommingData); + + $this->assertEquals( + $expectedPerson2, + $action->resolve() + ); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/DeleteActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/DeleteActionTest.php new file mode 100644 index 0000000..f507a4d --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/DeleteActionTest.php @@ -0,0 +1,39 @@ +prophesize(RestApiClient::class); + $restClient + ->delete(array('id' => 42)) + ->willReturn(new Response()) + ->shouldBeCalled() + ; + + // Action + $action = new DeleteAction(); + $action->init((new Person2())->setId(42)); + $action->setRestApiClient($restClient->reveal()); + + $action->resolve(); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/UpdateActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/UpdateActionTest.php new file mode 100644 index 0000000..8b9622d --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/UpdateActionTest.php @@ -0,0 +1,72 @@ + array( + (new Person2())->setId(42), + array(), + array(), + ), + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + Person2 $currentPerson2, + array $incommingData, + array $expectedRequestData + ) { + // Rest Client mock + $restClient = $this->prophesize(RestApiClient::class); + $restClient + ->put( + array('id' => $currentPerson2->getId()), + $expectedRequestData + ) + ->willReturn(new Response()) + ->shouldBeCalled() + ; + + // Action + $action = new UpdateAction(); + $action->init($currentPerson2); + $action->setRestApiClient($restClient->reveal()); + $action->deserialize($incommingData); + + $action->resolve(); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/CreateActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/CreateActionTest.php new file mode 100644 index 0000000..d8a57fb --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/CreateActionTest.php @@ -0,0 +1,82 @@ + array( + array(), + new Person2(), + ), + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + array $incommingData, + Person2 $expectedPerson2 + ) { + // Validator + $validator = $this->prophesize(ValidatorInterface::class); + $validator + ->validate( + Argument::type(Person2::class), + null, + array('Person2', 'creation') + ) + ->shouldBeCalled() + ; + + // Event dispatcher + $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); + $eventDispatcher + ->dispatch( + Person2Events::SIR1_PERSON2_CREATED, + Argument::type(Person2Event::class) + ) + ->shouldBeCalled() + ; + + // Action + $action = new CreateAction(); + $action->setEventDispatcher($eventDispatcher->reveal()); + $action->setValidator($validator->reveal()); + $action->deserialize($incommingData); + + $this->assertEquals( + $expectedPerson2, + $action->resolve() + ); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/DeleteActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/DeleteActionTest.php new file mode 100644 index 0000000..c66d1d7 --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/DeleteActionTest.php @@ -0,0 +1,71 @@ + array( + new Person2(), + ), + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + Person2 $givenPerson2 + ) { + $asserter = $this; + + // Event dispatcher + $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); + $eventDispatcher + ->dispatch( + Person2Events::SIR1_PERSON2_DELETED, + Argument::type(Person2Event::class) + ) + ->will(function ($args) use ($asserter, $givenPerson2) { + $asserter->assertEquals( + $givenPerson2, + $args[1]->getPerson2() + ); + }) + ->shouldBeCalled() + ; + + // Action + $action = new DeleteAction(); + $action->setEventDispatcher($eventDispatcher->reveal()); + $action->init($givenPerson2); + + $action->resolve(); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/UpdateActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/UpdateActionTest.php new file mode 100644 index 0000000..10dbb6c --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/UpdateActionTest.php @@ -0,0 +1,88 @@ + array( + array(), + (new Person2())->setId(42), + ), + ); + } + + /** + * Tests resolve() function. + * + * @dataProvider resolvingCasesProvider + */ + public function testResolve( + array $incommingData, + Person2 $givenPerson2 + ) { + $asserter = $this; + + // Validator + $validator = $this->prophesize(ValidatorInterface::class); + $validator + ->validate( + Argument::type(Person2::class), + null, + array('Person2', 'edition') + ) + ->shouldBeCalled() + ; + + // Event dispatcher + $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); + $eventDispatcher + ->dispatch( + Person2Events::SIR1_PERSON2_EDITED, + Argument::type(Person2Event::class) + ) + ->will(function ($args) use ($asserter, $givenPerson2) { + $asserter->assertEquals( + $givenPerson2, + $args[1]->getPerson2() + ); + }) + ->shouldBeCalled() + ; + + // Action + $action = new UpdateAction(); + $action->setValidator($validator->reveal()); + $action->deserialize($incommingData); + $action->setEventDispatcher($eventDispatcher->reveal()); + $action->init($givenPerson2); + + $action->resolve(); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Entity/Person2CollectionTest.php b/src/Sir1/Partner3/Component/Tests/Entity/Person2CollectionTest.php new file mode 100644 index 0000000..0efa6f9 --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Entity/Person2CollectionTest.php @@ -0,0 +1,45 @@ +deserialize(array( + 'person2_1' => array('id' => 42), + 'person2_2' => array('id' => 66), + )); + + $this->assertInstanceOf( + Person2::class, + $person2Collection->get('person2_1'), + 'Deserialization process hydrate a related entity class object and index it under given key.' + ); + $this->assertInstanceOf( + Person2::class, + $person2Collection->get('person2_2'), + 'Deserialization process hydrate a related entity class object and index it under given key.' + ); + $this->assertEquals( + array( + 'person2_1' => 42, + 'person2_2' => 66, + ), + $person2Collection->serialize('id'), + 'Serialization scopes are transmitted to related entity serialization process.' + ); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Entity/Person2Test.php b/src/Sir1/Partner3/Component/Tests/Entity/Person2Test.php new file mode 100644 index 0000000..85dedf5 --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Entity/Person2Test.php @@ -0,0 +1,128 @@ +person2 = new Person2(); + $this->reflector = new \ReflectionClass($this->person2); + } + + /** + * Provider for accessor tests. + * + * @return array + */ + public function propertyMapProvider() + { + return array( + 'id' => array('id', 42), + ); + } + + /** + * Tests setters. + * + * @dataProvider propertyMapProvider + */ + public function testSet($propertyName, $definedValue) + { + $property = $this->reflector->getProperty($propertyName); + $property->setAccessible(true); + + $method = 'set'.ucfirst($propertyName); + $this->person2->$method($definedValue); + $this->assertEquals( + $definedValue, + $property->getValue($this->person2), + sprintf('Person2::%s() defines "%s" property current value.', + $method, + $propertyName + ) + ); + } + + /** + * Tests getters. + * + * @dataProvider propertyMapProvider + */ + public function testGet($propertyName, $expectedValue) + { + $property = $this->reflector->getProperty($propertyName); + $property->setAccessible(true); + $property->setValue($this->person2, $expectedValue); + + $method = 'get'.ucfirst($propertyName); + $this->assertEquals( + $expectedValue, + $this->person2->$method(), + sprintf('Person2::%s() returns current defined "%s" property value.', + $method, + $propertyName + ) + ); + } + + /** + * Provider for serialization tests. + * + * @return array() + */ + public function serializationCasesProvider() + { + return array( + 'id' => array('id', 'int'), + 'default' => array('default', array('id')), + ); + } + + /** + * Tests serialization scopes. + * + * @dataProvider serializationCasesProvider + */ + public function testSerializationScopes($scope, $expectedKeys) + { + $this->person2->setId(42); + $person2Data = $this->person2->serialize($scope); + + if (!is_array($expectedKeys)) { + return $this->assertInternalType( + $expectedKeys, + $person2Data, + sprintf('Person2 "%s" scope provides a single value as %s.', $scope, $expectedKeys) + ); + } + + foreach ($expectedKeys as $expectedKey) { + $this->assertArrayHasKey( + $expectedKey, + $person2Data, + sprintf('Person2 "%s" scope provides an array with "%s" key.', $scope, $expectedKey) + ); + } + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Event/Person2EventTest.php b/src/Sir1/Partner3/Component/Tests/Event/Person2EventTest.php new file mode 100644 index 0000000..5189286 --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Event/Person2EventTest.php @@ -0,0 +1,34 @@ +prophesize(AbstractPerson2Action::class)->reveal(); + + // Event + $event = new Person2Event( + $person2 = new Person2(), + $action + ); + + // Assertions + $this->assertSame($person2, $event->getPerson2()); + $this->assertSame($person2, $event->getSubject()); + $this->assertSame($action, $event->getAction()); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Loader/Api/Person2ApiLoaderTest.php b/src/Sir1/Partner3/Component/Tests/Loader/Api/Person2ApiLoaderTest.php new file mode 100644 index 0000000..2a91d8f --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Loader/Api/Person2ApiLoaderTest.php @@ -0,0 +1,30 @@ +prophesize(RestApiClient::class); + $restApiClient->send()->shouldNotBeCalled(); + + $serializer = $this->prophesize(SerializerInterface::class); + $serializer->deserialize()->shouldNotBeCalled(); + + $loader = new Person2ApiLoader( + $restApiClient->reveal(), + $serializer->reveal() + ); + } +} diff --git a/src/Sir1/Partner3/Component/Tests/Loader/Doctrine/Person2DoctrineLoader.php b/src/Sir1/Partner3/Component/Tests/Loader/Doctrine/Person2DoctrineLoader.php new file mode 100644 index 0000000..d505da9 --- /dev/null +++ b/src/Sir1/Partner3/Component/Tests/Loader/Doctrine/Person2DoctrineLoader.php @@ -0,0 +1,31 @@ +prophesize(Person2RepositoryInterface::class); + $repository->save()->shouldNotBeCalled(); + + $loader = new Person2DoctrineLoader(); + $loader->setUp( + Person2::class, + array('majora' => 'entity'), + Person2Collection::class, + $repository->reveal() + ); + } +} From 168bbac786741e5d3a8bcb211bf30f41eae4b535 Mon Sep 17 00:00:00 2001 From: holoflins Date: Fri, 29 Jul 2016 12:41:59 +0200 Subject: [PATCH 02/11] feat: add method getMajoraEntityList and compareListMajoraEntitys --- .../Features/Context/MajoraEntityContext.php | 22 ++++++++++++++- .../Features/Context/Person2Context.php | 28 ++++++++++++++++++- .../Bundle/ApiBundle/Features/Person2.feature | 20 ++++++------- 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php index 01c9ee8..09b5e8e 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php @@ -28,12 +28,16 @@ class MajoraEntityContext implements Context */ private $majora_entitys; - /** * @var MajoraEntity */ private $currentMajoraEntity; + /** + * @var MajoraEntityCollection + */ + private $currentMajoraEntitys; + /** * @var EntityManagerInterface */ @@ -88,6 +92,14 @@ public function createMajoraEntity() $this->currentMajoraEntity = $this->domain->create(new MajoraEntity()); } + /** + * @When I get the majora_entitys list + */ + public function getMajoraEntityList() + { + $this->currentMajoraEntitys = $this->loader->retrieveAll(); + } + /** * @Then I retrieve new majora_entity id */ @@ -96,6 +108,14 @@ public function testMajoraEntityId() return $this->currentMajoraEntity->getId() != null; } + /** + * @Then I should see a list of majora_entitys + */ + public function compareListMajoraEntitys() + { + return $this->currentMajoraEntitys === $this->majora_entitys; + } + /** * @AfterScenario */ diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php index 533a9b0..3fbb33e 100644 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php @@ -34,6 +34,8 @@ class Person2Context implements Context */ private $currentPerson2; + private $currentPerson2s; + /** * @var EntityManagerInterface */ @@ -71,6 +73,15 @@ public function initPerson2s() $this->em->flush(); } + /** + * @Given I have some person2s + * + */ + public function retrieveSomePerson2s() + { + $this->person2s = $this->em->getRepository(Person2::class)->findAll(); + } + /** * @When I create a new person2 */ @@ -79,15 +90,30 @@ public function createPerson2() $this->currentPerson2 = $this->domain->create(new Person2()); } + /** + * @When I get the person2s list + */ + public function getPerson2List() + { + $this->currentPerson2s = $this->loader->retrieveAll(); + } + /** * @Then I retrieve new person2 id */ public function testPerson2Id() { - var_dump($this->currentPerson2); return $this->currentPerson2->getId() != null; } + /** + * @Then I should see a list of person2 + */ + public function compareListPerson2s() + { + return $this->currentPerson2s === $this->person2s; + } + /** * @AfterScenario */ diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature index b7e7701..c5e8e33 100644 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature @@ -9,16 +9,16 @@ Feature: Person2 Crud. When I create a new person2 Then I retrieve new person2 id -# Scenario: ReadAll -# Given I have some person2s -# When I get the person2s list -# Then I should see a list of person2 -# -# Scenario: Read -# Given I have created a new person2 -# When I show this person2 by id -# Then I should see this person2 -# + Scenario: ReadAll + Given I have some person2s + When I get the person2s list + Then I should see a list of person2 + + Scenario: Read + Given I have created a new person2 + When I show this person2 by id + Then I should see this person2 + # Scenario: delete # Given I have created a new person2 # When I delete this person2 From 588656998f83a5549b44ab2ac84e2fb2a8dc916a Mon Sep 17 00:00:00 2001 From: holoflins Date: Fri, 29 Jul 2016 13:16:29 +0200 Subject: [PATCH 03/11] feat: add suite test to delete scenario --- .../Features/Context/MajoraEntityContext.php | 34 +++++++++++++++++++ .../Features/Context/Person2Context.php | 32 ++++++++++++++++- .../Bundle/ApiBundle/Features/Person2.feature | 16 ++++----- 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php index 09b5e8e..02a0c62 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php @@ -38,6 +38,11 @@ class MajoraEntityContext implements Context */ private $currentMajoraEntitys; + /** + * @var int + */ + private $memoryId; + /** * @var EntityManagerInterface */ @@ -84,6 +89,19 @@ public function retrieveSomeMajoraEntitys() $this->majora_entitys = $this->em->getRepository(MajoraEntity::class)->findAll(); } + /** + * @Given I have created a new majora_entity + */ + public function insertMajoraEntity() + { + $this->currentMajoraEntity = new MajoraEntity(); + $this->em->getRepository(MajoraEntity::class)->persist($this->currentMajoraEntity); + $this->em->flush(); + $this->em->refresh($this->currentMajoraEntity); + + $this->memoryId = $this->currentMajoraEntity->getId(); + } + /** * @When I create a new majora_entity */ @@ -100,6 +118,14 @@ public function getMajoraEntityList() $this->currentMajoraEntitys = $this->loader->retrieveAll(); } + /** + * @When I delete this majora_entity + */ + public function deleteMajoraEntity() + { + $this->domain->delete($this->currentMajoraEntity); + } + /** * @Then I retrieve new majora_entity id */ @@ -116,6 +142,14 @@ public function compareListMajoraEntitys() return $this->currentMajoraEntitys === $this->majora_entitys; } + /** + * @Then I should not see this majora_entity + */ + public function checkMajoraEntityDeleted() + { + return is_null($this->em->getRepository(MajoraEntity::class)->find($this->memoryId)); + } + /** * @AfterScenario */ diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php index 3fbb33e..3a2b801 100644 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php @@ -36,6 +36,8 @@ class Person2Context implements Context private $currentPerson2s; + private $memoryId; + /** * @var EntityManagerInterface */ @@ -75,13 +77,25 @@ public function initPerson2s() /** * @Given I have some person2s - * */ public function retrieveSomePerson2s() { $this->person2s = $this->em->getRepository(Person2::class)->findAll(); } + /** + * @Given I have created a new person2 + */ + public function insertPerson2() + { + $this->currentPerson2 = new Person2(); + $this->em->getRepository(Person2::class)->persist($this->currentPerson2); + $this->em->flush(); + $this->em->refresh($this->currentPerson2); + + $this->memoryId = $this->currentPerson2->getId(); + } + /** * @When I create a new person2 */ @@ -98,6 +112,14 @@ public function getPerson2List() $this->currentPerson2s = $this->loader->retrieveAll(); } + /** + * @When I delete this Person2 + */ + public function deletePerson2() + { + $this->domain->delete($this->currentPerson2); + } + /** * @Then I retrieve new person2 id */ @@ -114,6 +136,14 @@ public function compareListPerson2s() return $this->currentPerson2s === $this->person2s; } + /** + * @Then I should not see this person2 + */ + public function checkPerson2Deleted() + { + return is_null($this->em->getRepository(Person2::class)->find($this->memoryId)); + } + /** * @AfterScenario */ diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature index c5e8e33..4138b04 100644 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature @@ -14,16 +14,16 @@ Feature: Person2 Crud. When I get the person2s list Then I should see a list of person2 - Scenario: Read + #Scenario: Read + # Given I have created a new person2 + # When I show this person2 by id + # Then I should see this person2 + + Scenario: delete Given I have created a new person2 - When I show this person2 by id - Then I should see this person2 + When I delete this person2 + Then I should not see this person2 -# Scenario: delete -# Given I have created a new person2 -# When I delete this person2 -# Then I should not see this person2 in the list -# # Scenario: Update # Given I have created a new person2 # When I update this person2 with a new id From 1c80c38989241780b7e76161b07486b4e22b62d8 Mon Sep 17 00:00:00 2001 From: holoflins Date: Fri, 29 Jul 2016 14:44:00 +0200 Subject: [PATCH 04/11] feat: add update methods to update scenario --- .../Features/Context/MajoraEntityContext.php | 40 +++++++++++++- .../ApiBundle/Features/MajoraEntity.feature | 8 +-- .../Features/Context/Person2Context.php | 54 +++++++++++++++++-- .../Bundle/ApiBundle/Features/Person2.feature | 16 +++--- 4 files changed, 100 insertions(+), 18 deletions(-) diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php index 02a0c62..3c79cec 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php @@ -33,6 +33,11 @@ class MajoraEntityContext implements Context */ private $currentMajoraEntity; + /** + * @var MajoraEntity + */ + private $loadedMajoraEntity; + /** * @var MajoraEntityCollection */ @@ -81,7 +86,7 @@ public function initMajoraEntitys() } /** - * @Given I have some majora_entitiys + * @Given I have some majora_entitys * */ public function retrieveSomeMajoraEntitys() @@ -118,6 +123,14 @@ public function getMajoraEntityList() $this->currentMajoraEntitys = $this->loader->retrieveAll(); } + /** + * @When I get this majora_entity by id + */ + public function getMajoraEntity() + { + $this->loadedMajoraEntity = $this->em->getRepository(MajoraEntity::class)->find($this->memoryId); + } + /** * @When I delete this majora_entity */ @@ -126,6 +139,15 @@ public function deleteMajoraEntity() $this->domain->delete($this->currentMajoraEntity); } + /** + * @When I update this majora_entity with a new id + */ + public function updateMajoraEntity() + { + $this->memoryId = $this->currentMajoraEntity->getId(); + $this->domain->update($this->currentMajoraEntity, array("id" => ($this->currentMajoraEntity->getId() + 1))); + } + /** * @Then I retrieve new majora_entity id */ @@ -142,6 +164,14 @@ public function compareListMajoraEntitys() return $this->currentMajoraEntitys === $this->majora_entitys; } + /** + * @Then I should see this majora_entity + */ + public function compareMajoraEntity() + { + return $this->loadedMajoraEntity === $this->currentMajoraEntity; + } + /** * @Then I should not see this majora_entity */ @@ -150,6 +180,14 @@ public function checkMajoraEntityDeleted() return is_null($this->em->getRepository(MajoraEntity::class)->find($this->memoryId)); } + /** + * @Then I should see the same majora_entity with this new id value + */ + public function checkMajoraEntityAsUpdated() + { + return $this->memoryId === $this->currentMajoraEntity->getId() + 1; + } + /** * @AfterScenario */ diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/MajoraEntity.feature b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/MajoraEntity.feature index eaef9fb..fe8106f 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/MajoraEntity.feature +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/MajoraEntity.feature @@ -13,19 +13,19 @@ Feature: MajoraEntity Crud. Scenario: ReadAll Given I have some majora_entitys When I get the majora_entitys list - Then I should see a list of majora_entity + Then I should see a list of majora_entitys Scenario: Read Given I have created a new majora_entity - When I show this majora_entity by id + When I get this majora_entity by id Then I should see this majora_entity Scenario: delete Given I have created a new majora_entity When I delete this majora_entity - Then I should see the same majora_entity list that before + Then I should not see this majora_entity Scenario: Update Given I have created a new majora_entity When I update this majora_entity with a new id - Then i should see the same majora_entity with this new id value + Then I should see the same majora_entity with this new id value diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php index 3a2b801..b0fc509 100644 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php @@ -28,14 +28,24 @@ class Person2Context implements Context */ private $person2s; - /** * @var Person2 */ private $currentPerson2; + /** + * @var Person2 + */ + private $loadedPerson2; + + /** + * @var Person2Collection + */ private $currentPerson2s; + /** + * @var int + */ private $memoryId; /** @@ -77,6 +87,7 @@ public function initPerson2s() /** * @Given I have some person2s + * */ public function retrieveSomePerson2s() { @@ -113,13 +124,30 @@ public function getPerson2List() } /** - * @When I delete this Person2 + * @When I get this person2 by id + */ + public function getPerson2() + { + $this->loadedPerson2 = $this->em->getRepository(Person2::class)->find($this->memoryId); + } + + /** + * @When I delete this person2 */ public function deletePerson2() { $this->domain->delete($this->currentPerson2); } - + + /** + * @When I update this person2 with a new id + */ + public function updatePerson2() + { + $this->memoryId = $this->currentPerson2->getId(); + $this->domain->update($this->currentPerson2, array("id" => ($this->currentPerson2->getId() + 1))); + } + /** * @Then I retrieve new person2 id */ @@ -129,13 +157,21 @@ public function testPerson2Id() } /** - * @Then I should see a list of person2 + * @Then I should see a list of person2s */ public function compareListPerson2s() { return $this->currentPerson2s === $this->person2s; } + /** + * @Then I should see this person2 + */ + public function comparePerson2() + { + return $this->loadedPerson2 === $this->currentPerson2; + } + /** * @Then I should not see this person2 */ @@ -143,7 +179,15 @@ public function checkPerson2Deleted() { return is_null($this->em->getRepository(Person2::class)->find($this->memoryId)); } - + + /** + * @Then I should see the same person2 with this new id value + */ + public function checkPerson2AsUpdated() + { + return $this->memoryId === $this->currentPerson2->getId() + 1; + } + /** * @AfterScenario */ diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature index 4138b04..34b9014 100644 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature +++ b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature @@ -14,17 +14,17 @@ Feature: Person2 Crud. When I get the person2s list Then I should see a list of person2 - #Scenario: Read - # Given I have created a new person2 - # When I show this person2 by id - # Then I should see this person2 + Scenario: Read + Given I have created a new person2 + When I get this person2 by id + Then I should see this person2 Scenario: delete Given I have created a new person2 When I delete this person2 Then I should not see this person2 -# Scenario: Update -# Given I have created a new person2 -# When I update this person2 with a new id -# Then I should see the same person2 with this new id value + Scenario: Update + Given I have created a new person2 + When I update this person2 with a new id + Then I should see the same person2 with this new id value From 9f17df8ed32a584fea6dd13ccc89b80610fc03ac Mon Sep 17 00:00:00 2001 From: holoflins Date: Fri, 29 Jul 2016 16:06:59 +0200 Subject: [PATCH 05/11] feat: add example skeletons generation --- app/AppKernel.php | 12 +- app/config/config.yml | 18 +- app/config/routing.yml | 4 - behat.yml | 11 +- .../Lv/Bundle/ApiBundle/AcmeLvApiBundle.php | 12 - .../Context/PostApiControllerContext.php | 255 ------------------ .../Features/Context/PostApiDomainContext.php | 172 ------------ .../Features/Context/PostDalDomainContext.php | 177 ------------ .../Features/Context/PostRouterContext.php | 24 -- .../Lv/Bundle/ApiBundle/Features/Post.feature | 57 ---- .../ApiBundle/Resources/config/routing.yml | 6 - .../ApiBundle/Resources/config/services.xml | 19 -- .../config/services/auto/auto_post.xml | 36 --- .../Lv/Bundle/DalBundle/AcmeLvDalBundle.php | 12 - .../DataFixtures/ORM/PostFixturesLoader.php | 55 ---- .../Persistence/PostPersistenceListener.php | 67 ----- .../Resources/config/doctrine/Post.orm.yml | 62 ----- .../DalBundle/Resources/config/services.xml | 19 -- .../config/services/auto/auto_post.xml | 104 ------- .../Lv/Bundle/SdkBundle/AcmeLvSdkBundle.php | 12 - .../SdkBundle/Resources/config/routing.yml | 0 .../Resources/config/routing/post.yml | 8 - .../SdkBundle/Resources/config/services.xml | 19 -- .../config/services/auto/auto_post.xml | 102 ------- .../Component/Action/AbstractPostAction.php | 41 --- .../Action/Api/Post/AbstractApiAction.php | 14 - .../Action/Api/Post/UpdateAction.php | 48 ---- .../Action/Dal/Post/AbstractDalAction.php | 16 -- .../Action/Dal/Post/CreateAction.php | 36 --- .../Action/Dal/Post/UpdateAction.php | 30 --- .../Auto/PostActionDispatcherDomainTrait.php | 47 ---- .../Action/PostActionDispatcherDomain.php | 21 -- .../Component/Domain/PostDomainInterface.php | 36 --- src/Acme/Lv/Component/Entity/Post.php | 92 ------- src/Acme/Lv/Component/Event/PostEvent.php | 61 ----- src/Acme/Lv/Component/Event/PostEvents.php | 24 -- .../Lv/Component/Loader/Api/PostApiLoader.php | 15 -- .../Loader/Doctrine/PostDoctrineLoader.php | 15 -- .../Loader/Graph/PostGraphLoader.php | 15 -- .../Component/Loader/PostLoaderInterface.php | 12 - .../Doctrine/PostDoctrineRepository.php | 15 -- .../Repository/Graph/PostGraphRepository.php | 15 -- .../Repository/PostRepositoryInterface.php | 12 - .../Action/Api/Post/CreateActionTest.php | 84 ------ .../Tests/Entity/PostCollectionTest.php | 45 ---- .../Lv/Component/Tests/Entity/PostTest.php | 128 --------- .../Component/Tests/Event/PostEventTest.php | 34 --- .../Loader/Doctrine/PostDoctrineLoader.php | 31 --- .../Auto/EntityApiControllerTrait.php} | 44 +-- .../Controller/EntityApiController.php} | 10 +- .../DependencyInjection/Configuration.php | 8 +- .../LvExampleApiExtension.php} | 4 +- .../Features/Context/EntityContext.php | 212 +++++++++++++++ .../Bundle/ApiBundle/Features/Entity.feature | 30 +++ .../ApiBundle/Form/Entity}/AbstractType.php | 19 +- .../ApiBundle/Form/Entity}/CreationType.php | 8 +- .../ApiBundle/Form/Entity}/EditionType.php | 12 +- .../Bundle/ApiBundle/LvExampleApiBundle.php} | 4 +- .../ApiBundle/Resources/config/routing.yml | 2 + .../ApiBundle}/Resources/config/services.xml | 2 +- .../config/services/auto/auto_entity.xml | 36 +++ .../Resources/config/services/entity.xml} | 4 +- .../Resources/config/validation/entity.yml} | 2 +- .../ORM/EntityFixturesLoader.php} | 20 +- .../DependencyInjection/Configuration.php | 8 +- .../LvExampleDalExtension.php} | 4 +- .../Bundle/DalBundle/LvExampleDalBundle.php} | 4 +- .../Persistence/EntityPersistenceListener.php | 67 +++++ .../Resources/config/doctrine/Entity.orm.yml} | 22 +- .../DalBundle/Resources/config/services.xml | 2 +- .../config/services/auto/auto_entity.xml | 104 +++++++ .../Resources/config/services/entity.xml} | 4 +- .../DependencyInjection/Configuration.php | 8 +- .../LvExampleSdkExtension.php} | 4 +- .../Bundle/SdkBundle/LvExampleSdkBundle.php} | 4 +- .../SdkBundle/Resources/config/routing.yml | 4 + .../config/routing/auto/auto_entity.yml} | 20 +- .../Resources/config/routing/entity.yml | 8 + .../SdkBundle}/Resources/config/services.xml | 2 +- .../config/services/auto/auto_entity.xml | 102 +++++++ .../Resources/config/services/entity.xml} | 4 +- .../Component/Action/AbstractEntityAction.php | 41 +++ .../Action/Api/Entity/AbstractApiAction.php | 14 + .../Action/Api/Entity}/CreateAction.php | 16 +- .../Action/Api/Entity}/DeleteAction.php | 6 +- .../Action/Api/Entity}/UpdateAction.php | 16 +- .../Action/Dal/Entity/AbstractDalAction.php | 16 ++ .../Action/Dal/Entity/CreateAction.php | 36 +++ .../Action/Dal/Entity}/DeleteAction.php | 12 +- .../Action/Dal/Entity/UpdateAction.php | 30 +++ .../EntityActionDispatcherDomainTrait.php | 45 ++++ .../Action/EntityActionDispatcherDomain.php | 21 ++ .../Domain/EntityDomainInterface.php | 36 +++ .../Example/Component/Entity/Entity.php} | 10 +- .../Component/Entity/EntityCollection.php} | 8 +- .../Example/Component/Event/EntityEvent.php | 61 +++++ .../Example/Component/Event/EntityEvents.php | 24 ++ .../Loader/Api/Auto/EntityApiLoaderTrait.php} | 6 +- .../Component/Loader/Api/EntityApiLoader.php | 15 ++ .../Auto/EntityDoctrineLoaderTrait.php} | 6 +- .../Loader/Doctrine/EntityDoctrineLoader.php | 15 ++ .../Loader/EntityLoaderInterface.php | 12 + .../Graph/Auto/EntityGraphLoaderTrait.php} | 6 +- .../Loader/Graph/EntityGraphLoader.php | 15 ++ .../Auto/EntityDoctrineRepositoryTrait.php} | 6 +- .../Doctrine/EntityDoctrineRepository.php | 15 ++ .../Repository/EntityRepositoryInterface.php | 12 + .../Auto/EntityGraphRepositoryTrait.php} | 6 +- .../Graph/EntityGraphRepository.php | 15 ++ .../Action/Api/Entity}/CreateActionTest.php | 28 +- .../Action/Api/Entity}/DeleteActionTest.php | 12 +- .../Action/Api/Entity}/UpdateActionTest.php | 22 +- .../Action/Dal/Entity}/CreateActionTest.php | 30 +-- .../Action/Dal/Entity}/DeleteActionTest.php | 32 +-- .../Action/Dal/Entity}/UpdateActionTest.php | 36 +-- .../Tests/Entity/EntityCollectionTest.php | 45 ++++ .../Component/Tests/Entity/EntityTest.php} | 42 +-- .../Component/Tests/Event/EntityEventTest.php | 34 +++ .../Tests/Loader/Api/EntityApiLoaderTest.php} | 10 +- .../Loader/Doctrine/EntityDoctrineLoader.php | 31 +++ .../Auto/PersonApiControllerTrait.php | 138 ---------- .../Controller/PersonApiController.php | 22 -- .../DependencyInjection/Configuration.php | 41 --- .../SirPartnerApiExtension.php | 28 -- .../Context/PersonApiControllerContext.php | 255 ------------------ .../Context/PersonApiDomainContext.php | 172 ------------ .../Context/PersonDalDomainContext.php | 177 ------------ .../Bundle/ApiBundle/Features/Person.feature | 58 ---- .../ApiBundle/Form/Person/AbstractType.php | 52 ---- .../ApiBundle/Form/Person/CreationType.php | 28 -- .../ApiBundle/Form/Person/EditionType.php | 34 --- .../ApiBundle/Resources/config/routing.yml | 10 - .../ApiBundle/Resources/config/services.xml | 16 -- .../config/services/auto/auto_person.xml | 36 --- .../Resources/config/services/person.xml | 18 -- .../Resources/config/validation/person.yml | 5 - .../DependencyInjection/Configuration.php | 41 --- .../SirPartnerDalExtension.php | 27 -- .../Persistence/PersonPersistenceListener.php | 67 ----- .../config/services/auto/auto_person.xml | 104 ------- .../Resources/config/services/person.xml | 18 -- .../DependencyInjection/Configuration.php | 41 --- .../SirPartnerSdkExtension.php | 27 -- .../SdkBundle/Resources/config/routing.yml | 4 - .../config/routing/auto/auto_person.yml | 42 --- .../Resources/config/routing/person.yml | 8 - .../SdkBundle/Resources/config/services.xml | 16 -- .../config/services/auto/auto_person.xml | 102 ------- .../Resources/config/services/person.xml | 18 -- .../Component/Action/AbstractPersonAction.php | 41 --- .../Action/Api/Person/AbstractApiAction.php | 14 - .../Action/Api/Person/CreateAction.php | 45 ---- .../Action/Api/Person/DeleteAction.php | 28 -- .../Action/Dal/Person/AbstractDalAction.php | 16 -- .../Action/Dal/Person/CreateAction.php | 36 --- .../Action/Dal/Person/DeleteAction.php | 26 -- .../Action/Dal/Person/UpdateAction.php | 30 --- .../PersonActionDispatcherDomainTrait.php | 45 ---- .../Action/PersonActionDispatcherDomain.php | 21 -- .../Domain/PersonDomainInterface.php | 36 --- .../Component/Entity/PersonCollection.php | 19 -- .../Partner/Component/Event/PersonEvent.php | 61 ----- .../Partner/Component/Event/PersonEvents.php | 24 -- .../Loader/Api/Auto/PersonApiLoaderTrait.php | 21 -- .../Component/Loader/Api/PersonApiLoader.php | 15 -- .../Auto/PersonDoctrineLoaderTrait.php | 20 -- .../Loader/Doctrine/PersonDoctrineLoader.php | 15 -- .../Graph/Auto/PersonGraphLoaderTrait.php | 21 -- .../Loader/Graph/PersonGraphLoader.php | 15 -- .../Loader/PersonLoaderInterface.php | 12 - .../Auto/PersonDoctrineRepositoryTrait.php | 20 -- .../Doctrine/PersonDoctrineRepository.php | 15 -- .../Graph/Auto/PersonGraphRepositoryTrait.php | 20 -- .../Graph/PersonGraphRepository.php | 15 -- .../Repository/PersonRepositoryInterface.php | 12 - .../Action/Api/Person/DeleteActionTest.php | 39 --- .../Action/Api/Person/UpdateActionTest.php | 72 ----- .../Action/Dal/Person/CreateActionTest.php | 82 ------ .../Action/Dal/Person/DeleteActionTest.php | 71 ----- .../Action/Dal/Person/UpdateActionTest.php | 88 ------ .../Tests/Entity/PersonCollectionTest.php | 45 ---- .../Component/Tests/Event/PersonEventTest.php | 34 --- .../Tests/Loader/Api/PersonApiLoaderTest.php | 30 --- .../Loader/Doctrine/PersonDoctrineLoader.php | 31 --- .../Auto/Person2ApiControllerTrait.php | 138 ---------- .../Controller/Person2ApiController.php | 22 -- .../DependencyInjection/Configuration.php | 41 --- .../Sir1Partner3ApiExtension.php | 28 -- .../Features/Context/Person2Context.php | 212 --------------- .../Bundle/ApiBundle/Features/Person2.feature | 30 --- .../ApiBundle/Form/Person2/AbstractType.php | 52 ---- .../ApiBundle/Form/Person2/CreationType.php | 28 -- .../ApiBundle/Form/Person2/EditionType.php | 34 --- .../ApiBundle/Resources/config/routing.yml | 2 - .../config/services/auto/auto_person2.xml | 36 --- .../Resources/config/services/person2.xml | 18 -- .../Resources/config/validation/person2.yml | 5 - .../ApiBundle/Sir1Partner3ApiBundle.php | 12 - .../ORM/Person2FixturesLoader.php | 55 ---- .../DependencyInjection/Configuration.php | 41 --- .../Sir1Partner3DalExtension.php | 27 -- .../Person2PersistenceListener.php | 67 ----- .../Resources/config/doctrine/Person2.orm.yml | 58 ---- .../config/services/auto/auto_person2.xml | 104 ------- .../Resources/config/services/person2.xml | 18 -- .../DalBundle/Sir1Partner3DalBundle.php | 12 - .../DependencyInjection/Configuration.php | 41 --- .../Sir1Partner3SdkExtension.php | 27 -- .../SdkBundle/Resources/config/routing.yml | 4 - .../config/routing/auto/auto_person2.yml | 42 --- .../Resources/config/routing/person2.yml | 8 - .../SdkBundle/Resources/config/services.xml | 17 -- .../config/services/auto/auto_person2.xml | 102 ------- .../Resources/config/services/person2.xml | 18 -- .../SdkBundle/Sir1Partner3SdkBundle.php | 12 - .../Action/AbstractPerson2Action.php | 41 --- .../Action/Api/Person2/AbstractApiAction.php | 14 - .../Action/Api/Person2/CreateAction.php | 45 ---- .../Action/Api/Person2/DeleteAction.php | 28 -- .../Action/Api/Person2/UpdateAction.php | 48 ---- .../Action/Dal/Person2/AbstractDalAction.php | 16 -- .../Action/Dal/Person2/CreateAction.php | 36 --- .../Action/Dal/Person2/DeleteAction.php | 26 -- .../Action/Dal/Person2/UpdateAction.php | 30 --- .../Person2ActionDispatcherDomainTrait.php | 45 ---- .../Action/Person2ActionDispatcherDomain.php | 21 -- .../Domain/Person2DomainInterface.php | 36 --- .../Partner3/Component/Entity/Person2.php | 63 ----- .../Component/Entity/Person2Collection.php | 19 -- .../Partner3/Component/Event/Person2Event.php | 61 ----- .../Component/Event/Person2Events.php | 24 -- .../Loader/Api/Auto/Person2ApiLoaderTrait.php | 21 -- .../Component/Loader/Api/Person2ApiLoader.php | 15 -- .../Auto/Person2DoctrineLoaderTrait.php | 20 -- .../Loader/Doctrine/Person2DoctrineLoader.php | 15 -- .../Graph/Auto/Person2GraphLoaderTrait.php | 21 -- .../Loader/Graph/Person2GraphLoader.php | 15 -- .../Loader/Person2LoaderInterface.php | 12 - .../Auto/Person2DoctrineRepositoryTrait.php | 20 -- .../Doctrine/Person2DoctrineRepository.php | 15 -- .../Auto/Person2GraphRepositoryTrait.php | 20 -- .../Graph/Person2GraphRepository.php | 15 -- .../Repository/Person2RepositoryInterface.php | 12 - .../Action/Api/Person2/CreateActionTest.php | 84 ------ .../Action/Api/Person2/DeleteActionTest.php | 39 --- .../Action/Api/Person2/UpdateActionTest.php | 72 ----- .../Action/Dal/Person2/CreateActionTest.php | 82 ------ .../Action/Dal/Person2/DeleteActionTest.php | 71 ----- .../Action/Dal/Person2/UpdateActionTest.php | 88 ------ .../Tests/Entity/Person2CollectionTest.php | 45 ---- .../Component/Tests/Entity/Person2Test.php | 128 --------- .../Tests/Event/Person2EventTest.php | 34 --- .../Tests/Loader/Api/Person2ApiLoaderTest.php | 30 --- .../Loader/Doctrine/Person2DoctrineLoader.php | 31 --- 254 files changed, 1375 insertions(+), 7915 deletions(-) delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/AcmeLvApiBundle.php delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostApiControllerContext.php delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostApiDomainContext.php delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostDalDomainContext.php delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostRouterContext.php delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/Features/Post.feature delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/Resources/config/routing.yml delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/Resources/config/services.xml delete mode 100644 src/Acme/Lv/Bundle/ApiBundle/Resources/config/services/auto/auto_post.xml delete mode 100644 src/Acme/Lv/Bundle/DalBundle/AcmeLvDalBundle.php delete mode 100644 src/Acme/Lv/Bundle/DalBundle/DataFixtures/ORM/PostFixturesLoader.php delete mode 100644 src/Acme/Lv/Bundle/DalBundle/Persistence/PostPersistenceListener.php delete mode 100644 src/Acme/Lv/Bundle/DalBundle/Resources/config/doctrine/Post.orm.yml delete mode 100644 src/Acme/Lv/Bundle/DalBundle/Resources/config/services.xml delete mode 100644 src/Acme/Lv/Bundle/DalBundle/Resources/config/services/auto/auto_post.xml delete mode 100644 src/Acme/Lv/Bundle/SdkBundle/AcmeLvSdkBundle.php delete mode 100644 src/Acme/Lv/Bundle/SdkBundle/Resources/config/routing.yml delete mode 100644 src/Acme/Lv/Bundle/SdkBundle/Resources/config/routing/post.yml delete mode 100644 src/Acme/Lv/Bundle/SdkBundle/Resources/config/services.xml delete mode 100644 src/Acme/Lv/Bundle/SdkBundle/Resources/config/services/auto/auto_post.xml delete mode 100644 src/Acme/Lv/Component/Action/AbstractPostAction.php delete mode 100644 src/Acme/Lv/Component/Action/Api/Post/AbstractApiAction.php delete mode 100644 src/Acme/Lv/Component/Action/Api/Post/UpdateAction.php delete mode 100644 src/Acme/Lv/Component/Action/Dal/Post/AbstractDalAction.php delete mode 100644 src/Acme/Lv/Component/Action/Dal/Post/CreateAction.php delete mode 100644 src/Acme/Lv/Component/Action/Dal/Post/UpdateAction.php delete mode 100644 src/Acme/Lv/Component/Domain/Action/Auto/PostActionDispatcherDomainTrait.php delete mode 100644 src/Acme/Lv/Component/Domain/Action/PostActionDispatcherDomain.php delete mode 100644 src/Acme/Lv/Component/Domain/PostDomainInterface.php delete mode 100644 src/Acme/Lv/Component/Entity/Post.php delete mode 100644 src/Acme/Lv/Component/Event/PostEvent.php delete mode 100644 src/Acme/Lv/Component/Event/PostEvents.php delete mode 100644 src/Acme/Lv/Component/Loader/Api/PostApiLoader.php delete mode 100644 src/Acme/Lv/Component/Loader/Doctrine/PostDoctrineLoader.php delete mode 100644 src/Acme/Lv/Component/Loader/Graph/PostGraphLoader.php delete mode 100644 src/Acme/Lv/Component/Loader/PostLoaderInterface.php delete mode 100644 src/Acme/Lv/Component/Repository/Doctrine/PostDoctrineRepository.php delete mode 100644 src/Acme/Lv/Component/Repository/Graph/PostGraphRepository.php delete mode 100644 src/Acme/Lv/Component/Repository/PostRepositoryInterface.php delete mode 100644 src/Acme/Lv/Component/Tests/Action/Api/Post/CreateActionTest.php delete mode 100644 src/Acme/Lv/Component/Tests/Entity/PostCollectionTest.php delete mode 100644 src/Acme/Lv/Component/Tests/Entity/PostTest.php delete mode 100644 src/Acme/Lv/Component/Tests/Event/PostEventTest.php delete mode 100644 src/Acme/Lv/Component/Tests/Loader/Doctrine/PostDoctrineLoader.php rename src/{Acme/Lv/Bundle/ApiBundle/Controller/Auto/PostApiControllerTrait.php => Lv/Example/Bundle/ApiBundle/Controller/Auto/EntityApiControllerTrait.php} (71%) rename src/{Acme/Lv/Bundle/ApiBundle/Controller/PostApiController.php => Lv/Example/Bundle/ApiBundle/Controller/EntityApiController.php} (58%) rename src/{Acme/Lv => Lv/Example}/Bundle/ApiBundle/DependencyInjection/Configuration.php (82%) rename src/{Acme/Lv/Bundle/ApiBundle/DependencyInjection/AcmeLvApiExtension.php => Lv/Example/Bundle/ApiBundle/DependencyInjection/LvExampleApiExtension.php} (88%) create mode 100644 src/Lv/Example/Bundle/ApiBundle/Features/Context/EntityContext.php create mode 100644 src/Lv/Example/Bundle/ApiBundle/Features/Entity.feature rename src/{Acme/Lv/Bundle/ApiBundle/Form/Post => Lv/Example/Bundle/ApiBundle/Form/Entity}/AbstractType.php (65%) rename src/{Acme/Lv/Bundle/ApiBundle/Form/Post => Lv/Example/Bundle/ApiBundle/Form/Entity}/CreationType.php (69%) rename src/{Acme/Lv/Bundle/ApiBundle/Form/Post => Lv/Example/Bundle/ApiBundle/Form/Entity}/EditionType.php (67%) rename src/{Sir/Partner/Bundle/DalBundle/SirPartnerDalBundle.php => Lv/Example/Bundle/ApiBundle/LvExampleApiBundle.php} (62%) create mode 100644 src/Lv/Example/Bundle/ApiBundle/Resources/config/routing.yml rename src/{Sir/Partner/Bundle/DalBundle => Lv/Example/Bundle/ApiBundle}/Resources/config/services.xml (87%) create mode 100644 src/Lv/Example/Bundle/ApiBundle/Resources/config/services/auto/auto_entity.xml rename src/{Acme/Lv/Bundle/ApiBundle/Resources/config/services/post.xml => Lv/Example/Bundle/ApiBundle/Resources/config/services/entity.xml} (84%) rename src/{Acme/Lv/Bundle/ApiBundle/Resources/config/validation/post.yml => Lv/Example/Bundle/ApiBundle/Resources/config/validation/entity.yml} (73%) rename src/{Sir/Partner/Bundle/DalBundle/DataFixtures/ORM/PersonFixturesLoader.php => Lv/Example/Bundle/DalBundle/DataFixtures/ORM/EntityFixturesLoader.php} (66%) rename src/{Acme/Lv => Lv/Example}/Bundle/DalBundle/DependencyInjection/Configuration.php (82%) rename src/{Acme/Lv/Bundle/DalBundle/DependencyInjection/AcmeLvDalExtension.php => Lv/Example/Bundle/DalBundle/DependencyInjection/LvExampleDalExtension.php} (85%) rename src/{Sir/Partner/Bundle/SdkBundle/SirPartnerSdkBundle.php => Lv/Example/Bundle/DalBundle/LvExampleDalBundle.php} (62%) create mode 100644 src/Lv/Example/Bundle/DalBundle/Persistence/EntityPersistenceListener.php rename src/{Sir/Partner/Bundle/DalBundle/Resources/config/doctrine/Person.orm.yml => Lv/Example/Bundle/DalBundle/Resources/config/doctrine/Entity.orm.yml} (67%) rename src/{Sir1/Partner3 => Lv/Example}/Bundle/DalBundle/Resources/config/services.xml (87%) create mode 100644 src/Lv/Example/Bundle/DalBundle/Resources/config/services/auto/auto_entity.xml rename src/{Acme/Lv/Bundle/DalBundle/Resources/config/services/post.xml => Lv/Example/Bundle/DalBundle/Resources/config/services/entity.xml} (84%) rename src/{Acme/Lv => Lv/Example}/Bundle/SdkBundle/DependencyInjection/Configuration.php (82%) rename src/{Acme/Lv/Bundle/SdkBundle/DependencyInjection/AcmeLvSdkExtension.php => Lv/Example/Bundle/SdkBundle/DependencyInjection/LvExampleSdkExtension.php} (85%) rename src/{Sir/Partner/Bundle/ApiBundle/SirPartnerApiBundle.php => Lv/Example/Bundle/SdkBundle/LvExampleSdkBundle.php} (62%) create mode 100644 src/Lv/Example/Bundle/SdkBundle/Resources/config/routing.yml rename src/{Acme/Lv/Bundle/SdkBundle/Resources/config/routing/auto/auto_post.yml => Lv/Example/Bundle/SdkBundle/Resources/config/routing/auto/auto_entity.yml} (52%) create mode 100644 src/Lv/Example/Bundle/SdkBundle/Resources/config/routing/entity.yml rename src/{Sir1/Partner3/Bundle/ApiBundle => Lv/Example/Bundle/SdkBundle}/Resources/config/services.xml (87%) create mode 100644 src/Lv/Example/Bundle/SdkBundle/Resources/config/services/auto/auto_entity.xml rename src/{Acme/Lv/Bundle/SdkBundle/Resources/config/services/post.xml => Lv/Example/Bundle/SdkBundle/Resources/config/services/entity.xml} (84%) create mode 100644 src/Lv/Example/Component/Action/AbstractEntityAction.php create mode 100644 src/Lv/Example/Component/Action/Api/Entity/AbstractApiAction.php rename src/{Acme/Lv/Component/Action/Api/Post => Lv/Example/Component/Action/Api/Entity}/CreateAction.php (73%) rename src/{Acme/Lv/Component/Action/Api/Post => Lv/Example/Component/Action/Api/Entity}/DeleteAction.php (76%) rename src/{Sir/Partner/Component/Action/Api/Person => Lv/Example/Component/Action/Api/Entity}/UpdateAction.php (70%) create mode 100644 src/Lv/Example/Component/Action/Dal/Entity/AbstractDalAction.php create mode 100644 src/Lv/Example/Component/Action/Dal/Entity/CreateAction.php rename src/{Acme/Lv/Component/Action/Dal/Post => Lv/Example/Component/Action/Dal/Entity}/DeleteAction.php (50%) create mode 100644 src/Lv/Example/Component/Action/Dal/Entity/UpdateAction.php create mode 100644 src/Lv/Example/Component/Domain/Action/Auto/EntityActionDispatcherDomainTrait.php create mode 100644 src/Lv/Example/Component/Domain/Action/EntityActionDispatcherDomain.php create mode 100644 src/Lv/Example/Component/Domain/EntityDomainInterface.php rename src/{Sir/Partner/Component/Entity/Person.php => Lv/Example/Component/Entity/Entity.php} (86%) rename src/{Acme/Lv/Component/Entity/PostCollection.php => Lv/Example/Component/Entity/EntityCollection.php} (57%) create mode 100644 src/Lv/Example/Component/Event/EntityEvent.php create mode 100644 src/Lv/Example/Component/Event/EntityEvents.php rename src/{Acme/Lv/Component/Loader/Api/Auto/PostApiLoaderTrait.php => Lv/Example/Component/Loader/Api/Auto/EntityApiLoaderTrait.php} (70%) create mode 100644 src/Lv/Example/Component/Loader/Api/EntityApiLoader.php rename src/{Acme/Lv/Component/Loader/Doctrine/Auto/PostDoctrineLoaderTrait.php => Lv/Example/Component/Loader/Doctrine/Auto/EntityDoctrineLoaderTrait.php} (67%) create mode 100644 src/Lv/Example/Component/Loader/Doctrine/EntityDoctrineLoader.php create mode 100644 src/Lv/Example/Component/Loader/EntityLoaderInterface.php rename src/{Acme/Lv/Component/Loader/Graph/Auto/PostGraphLoaderTrait.php => Lv/Example/Component/Loader/Graph/Auto/EntityGraphLoaderTrait.php} (71%) create mode 100644 src/Lv/Example/Component/Loader/Graph/EntityGraphLoader.php rename src/{Acme/Lv/Component/Repository/Doctrine/Auto/PostDoctrineRepositoryTrait.php => Lv/Example/Component/Repository/Doctrine/Auto/EntityDoctrineRepositoryTrait.php} (66%) create mode 100644 src/Lv/Example/Component/Repository/Doctrine/EntityDoctrineRepository.php create mode 100644 src/Lv/Example/Component/Repository/EntityRepositoryInterface.php rename src/{Acme/Lv/Component/Repository/Graph/Auto/PostGraphRepositoryTrait.php => Lv/Example/Component/Repository/Graph/Auto/EntityGraphRepositoryTrait.php} (66%) create mode 100644 src/Lv/Example/Component/Repository/Graph/EntityGraphRepository.php rename src/{Sir/Partner/Component/Tests/Action/Api/Person => Lv/Example/Component/Tests/Action/Api/Entity}/CreateActionTest.php (72%) rename src/{Acme/Lv/Component/Tests/Action/Api/Post => Lv/Example/Component/Tests/Action/Api/Entity}/DeleteActionTest.php (69%) rename src/{Acme/Lv/Component/Tests/Action/Api/Post => Lv/Example/Component/Tests/Action/Api/Entity}/UpdateActionTest.php (72%) rename src/{Acme/Lv/Component/Tests/Action/Dal/Post => Lv/Example/Component/Tests/Action/Dal/Entity}/CreateActionTest.php (68%) rename src/{Acme/Lv/Component/Tests/Action/Dal/Post => Lv/Example/Component/Tests/Action/Dal/Entity}/DeleteActionTest.php (59%) rename src/{Acme/Lv/Component/Tests/Action/Dal/Post => Lv/Example/Component/Tests/Action/Dal/Entity}/UpdateActionTest.php (64%) create mode 100644 src/Lv/Example/Component/Tests/Entity/EntityCollectionTest.php rename src/{Sir/Partner/Component/Tests/Entity/PersonTest.php => Lv/Example/Component/Tests/Entity/EntityTest.php} (69%) create mode 100644 src/Lv/Example/Component/Tests/Event/EntityEventTest.php rename src/{Acme/Lv/Component/Tests/Loader/Api/PostApiLoaderTest.php => Lv/Example/Component/Tests/Loader/Api/EntityApiLoaderTest.php} (68%) create mode 100644 src/Lv/Example/Component/Tests/Loader/Doctrine/EntityDoctrineLoader.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Controller/Auto/PersonApiControllerTrait.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Controller/PersonApiController.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/DependencyInjection/Configuration.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/DependencyInjection/SirPartnerApiExtension.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiControllerContext.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonApiDomainContext.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Features/Context/PersonDalDomainContext.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Features/Person.feature delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Form/Person/AbstractType.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Form/Person/CreationType.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Form/Person/EditionType.php delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/routing.yml delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/services.xml delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/auto/auto_person.xml delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/person.xml delete mode 100644 src/Sir/Partner/Bundle/ApiBundle/Resources/config/validation/person.yml delete mode 100644 src/Sir/Partner/Bundle/DalBundle/DependencyInjection/Configuration.php delete mode 100644 src/Sir/Partner/Bundle/DalBundle/DependencyInjection/SirPartnerDalExtension.php delete mode 100644 src/Sir/Partner/Bundle/DalBundle/Persistence/PersonPersistenceListener.php delete mode 100644 src/Sir/Partner/Bundle/DalBundle/Resources/config/services/auto/auto_person.xml delete mode 100644 src/Sir/Partner/Bundle/DalBundle/Resources/config/services/person.xml delete mode 100644 src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/Configuration.php delete mode 100644 src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/SirPartnerSdkExtension.php delete mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing.yml delete mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/auto/auto_person.yml delete mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/person.yml delete mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/services.xml delete mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/auto/auto_person.xml delete mode 100644 src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/person.xml delete mode 100644 src/Sir/Partner/Component/Action/AbstractPersonAction.php delete mode 100644 src/Sir/Partner/Component/Action/Api/Person/AbstractApiAction.php delete mode 100644 src/Sir/Partner/Component/Action/Api/Person/CreateAction.php delete mode 100644 src/Sir/Partner/Component/Action/Api/Person/DeleteAction.php delete mode 100644 src/Sir/Partner/Component/Action/Dal/Person/AbstractDalAction.php delete mode 100644 src/Sir/Partner/Component/Action/Dal/Person/CreateAction.php delete mode 100644 src/Sir/Partner/Component/Action/Dal/Person/DeleteAction.php delete mode 100644 src/Sir/Partner/Component/Action/Dal/Person/UpdateAction.php delete mode 100644 src/Sir/Partner/Component/Domain/Action/Auto/PersonActionDispatcherDomainTrait.php delete mode 100644 src/Sir/Partner/Component/Domain/Action/PersonActionDispatcherDomain.php delete mode 100644 src/Sir/Partner/Component/Domain/PersonDomainInterface.php delete mode 100644 src/Sir/Partner/Component/Entity/PersonCollection.php delete mode 100644 src/Sir/Partner/Component/Event/PersonEvent.php delete mode 100644 src/Sir/Partner/Component/Event/PersonEvents.php delete mode 100644 src/Sir/Partner/Component/Loader/Api/Auto/PersonApiLoaderTrait.php delete mode 100644 src/Sir/Partner/Component/Loader/Api/PersonApiLoader.php delete mode 100644 src/Sir/Partner/Component/Loader/Doctrine/Auto/PersonDoctrineLoaderTrait.php delete mode 100644 src/Sir/Partner/Component/Loader/Doctrine/PersonDoctrineLoader.php delete mode 100644 src/Sir/Partner/Component/Loader/Graph/Auto/PersonGraphLoaderTrait.php delete mode 100644 src/Sir/Partner/Component/Loader/Graph/PersonGraphLoader.php delete mode 100644 src/Sir/Partner/Component/Loader/PersonLoaderInterface.php delete mode 100644 src/Sir/Partner/Component/Repository/Doctrine/Auto/PersonDoctrineRepositoryTrait.php delete mode 100644 src/Sir/Partner/Component/Repository/Doctrine/PersonDoctrineRepository.php delete mode 100644 src/Sir/Partner/Component/Repository/Graph/Auto/PersonGraphRepositoryTrait.php delete mode 100644 src/Sir/Partner/Component/Repository/Graph/PersonGraphRepository.php delete mode 100644 src/Sir/Partner/Component/Repository/PersonRepositoryInterface.php delete mode 100644 src/Sir/Partner/Component/Tests/Action/Api/Person/DeleteActionTest.php delete mode 100644 src/Sir/Partner/Component/Tests/Action/Api/Person/UpdateActionTest.php delete mode 100644 src/Sir/Partner/Component/Tests/Action/Dal/Person/CreateActionTest.php delete mode 100644 src/Sir/Partner/Component/Tests/Action/Dal/Person/DeleteActionTest.php delete mode 100644 src/Sir/Partner/Component/Tests/Action/Dal/Person/UpdateActionTest.php delete mode 100644 src/Sir/Partner/Component/Tests/Entity/PersonCollectionTest.php delete mode 100644 src/Sir/Partner/Component/Tests/Event/PersonEventTest.php delete mode 100644 src/Sir/Partner/Component/Tests/Loader/Api/PersonApiLoaderTest.php delete mode 100644 src/Sir/Partner/Component/Tests/Loader/Doctrine/PersonDoctrineLoader.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Controller/Auto/Person2ApiControllerTrait.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Controller/Person2ApiController.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Configuration.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Sir1Partner3ApiExtension.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/AbstractType.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/CreationType.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/EditionType.php delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/routing.yml delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/auto/auto_person2.xml delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/person2.xml delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/validation/person2.yml delete mode 100644 src/Sir1/Partner3/Bundle/ApiBundle/Sir1Partner3ApiBundle.php delete mode 100644 src/Sir1/Partner3/Bundle/DalBundle/DataFixtures/ORM/Person2FixturesLoader.php delete mode 100644 src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Configuration.php delete mode 100644 src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Sir1Partner3DalExtension.php delete mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Persistence/Person2PersistenceListener.php delete mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Resources/config/doctrine/Person2.orm.yml delete mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/auto/auto_person2.xml delete mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/person2.xml delete mode 100644 src/Sir1/Partner3/Bundle/DalBundle/Sir1Partner3DalBundle.php delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Configuration.php delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Sir1Partner3SdkExtension.php delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing.yml delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/auto/auto_person2.yml delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/person2.yml delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services.xml delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/auto/auto_person2.xml delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/person2.xml delete mode 100644 src/Sir1/Partner3/Bundle/SdkBundle/Sir1Partner3SdkBundle.php delete mode 100644 src/Sir1/Partner3/Component/Action/AbstractPerson2Action.php delete mode 100644 src/Sir1/Partner3/Component/Action/Api/Person2/AbstractApiAction.php delete mode 100644 src/Sir1/Partner3/Component/Action/Api/Person2/CreateAction.php delete mode 100644 src/Sir1/Partner3/Component/Action/Api/Person2/DeleteAction.php delete mode 100644 src/Sir1/Partner3/Component/Action/Api/Person2/UpdateAction.php delete mode 100644 src/Sir1/Partner3/Component/Action/Dal/Person2/AbstractDalAction.php delete mode 100644 src/Sir1/Partner3/Component/Action/Dal/Person2/CreateAction.php delete mode 100644 src/Sir1/Partner3/Component/Action/Dal/Person2/DeleteAction.php delete mode 100644 src/Sir1/Partner3/Component/Action/Dal/Person2/UpdateAction.php delete mode 100644 src/Sir1/Partner3/Component/Domain/Action/Auto/Person2ActionDispatcherDomainTrait.php delete mode 100644 src/Sir1/Partner3/Component/Domain/Action/Person2ActionDispatcherDomain.php delete mode 100644 src/Sir1/Partner3/Component/Domain/Person2DomainInterface.php delete mode 100644 src/Sir1/Partner3/Component/Entity/Person2.php delete mode 100644 src/Sir1/Partner3/Component/Entity/Person2Collection.php delete mode 100644 src/Sir1/Partner3/Component/Event/Person2Event.php delete mode 100644 src/Sir1/Partner3/Component/Event/Person2Events.php delete mode 100644 src/Sir1/Partner3/Component/Loader/Api/Auto/Person2ApiLoaderTrait.php delete mode 100644 src/Sir1/Partner3/Component/Loader/Api/Person2ApiLoader.php delete mode 100644 src/Sir1/Partner3/Component/Loader/Doctrine/Auto/Person2DoctrineLoaderTrait.php delete mode 100644 src/Sir1/Partner3/Component/Loader/Doctrine/Person2DoctrineLoader.php delete mode 100644 src/Sir1/Partner3/Component/Loader/Graph/Auto/Person2GraphLoaderTrait.php delete mode 100644 src/Sir1/Partner3/Component/Loader/Graph/Person2GraphLoader.php delete mode 100644 src/Sir1/Partner3/Component/Loader/Person2LoaderInterface.php delete mode 100644 src/Sir1/Partner3/Component/Repository/Doctrine/Auto/Person2DoctrineRepositoryTrait.php delete mode 100644 src/Sir1/Partner3/Component/Repository/Doctrine/Person2DoctrineRepository.php delete mode 100644 src/Sir1/Partner3/Component/Repository/Graph/Auto/Person2GraphRepositoryTrait.php delete mode 100644 src/Sir1/Partner3/Component/Repository/Graph/Person2GraphRepository.php delete mode 100644 src/Sir1/Partner3/Component/Repository/Person2RepositoryInterface.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Action/Api/Person2/CreateActionTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Action/Api/Person2/DeleteActionTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Action/Api/Person2/UpdateActionTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/CreateActionTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/DeleteActionTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/UpdateActionTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Entity/Person2CollectionTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Entity/Person2Test.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Event/Person2EventTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Loader/Api/Person2ApiLoaderTest.php delete mode 100644 src/Sir1/Partner3/Component/Tests/Loader/Doctrine/Person2DoctrineLoader.php diff --git a/app/AppKernel.php b/app/AppKernel.php index 211d40e..f8eee24 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -17,15 +17,9 @@ public function registerBundles() new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Majora\Bundle\FrameworkExtraBundle\MajoraFrameworkExtraBundle($this), - new Acme\Lv\Bundle\ApiBundle\AcmeLvApiBundle(), - new Acme\Lv\Bundle\DalBundle\AcmeLvDalBundle(), - new Acme\Lv\Bundle\SdkBundle\AcmeLvSdkBundle(), - new Sir\Partner\Bundle\ApiBundle\SirPartnerApiBundle(), - new Sir\Partner\Bundle\DalBundle\SirPartnerDalBundle(), - new Sir\Partner\Bundle\SdkBundle\SirPartnerSdkBundle(), - new Sir1\Partner3\Bundle\ApiBundle\Sir1Partner3ApiBundle(), - new Sir1\Partner3\Bundle\DalBundle\Sir1Partner3DalBundle(), - new Sir1\Partner3\Bundle\SdkBundle\Sir1Partner3SdkBundle(), + new Lv\Example\Bundle\ApiBundle\LvExampleApiBundle(), + new Lv\Example\Bundle\SdkBundle\LvExampleSdkBundle(), + new Lv\Example\Bundle\DalBundle\LvExampleDalBundle(), ]; if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { diff --git a/app/config/config.yml b/app/config/config.yml index 844a10e..df55751 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -60,23 +60,11 @@ doctrine: entity_managers: default: mappings: - Sir1Partner3DalBundle: + LvExampleDalBundle: type: yml dir: Resources/config/doctrine - prefix: Sir1\Partner3\Component\Entity - alias: Sir1Partner3 - - SirPartnerDalBundle: - type: yml - dir: Resources/config/doctrine - prefix: Sir\Partner\Component\Entity - alias: SirPartner - - AcmeLvDalBundle: - type: yml - dir: Resources/config/doctrine - prefix: Acme\Lv\Component\Entity - alias: AcmeLv + prefix: Lv\Example\Component\Entity + alias: LvExample # Swiftmailer Configuration swiftmailer: diff --git a/app/config/routing.yml b/app/config/routing.yml index ca1eee5..e69de29 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -1,4 +0,0 @@ -app: - resource: "@AcmeLvSdkBundle/Resources/config/routing/auto/auto_post.yml" -persons: - resource: "@SirPartnerSdkBundle/Resources/config/routing.yml" \ No newline at end of file diff --git a/behat.yml b/behat.yml index 7993f37..4d67ff5 100644 --- a/behat.yml +++ b/behat.yml @@ -9,12 +9,11 @@ default: suites: dal_domain: type: symfony_bundle - bundle: Sir1Partner3DalBundle + bundle: LvExampleDalBundle paths: - #- %paths.base%/src/Acme/Lv/Bundle/ApiBundle/Features - - %paths.base%/src/Sir1/Partner3/Bundle/ApiBundle/Features + - %paths.base%/src/Lv/Example/Bundle/ApiBundle/Features contexts: - - Sir1\Partner3\Bundle\ApiBundle\Features\Context\Person2Context: - domain: '@sir1.person2.domain' - loader: '@sir1.person2.loader' + - Lv\Example\Bundle\ApiBundle\Features\Context\EntityContext: + domain: '@lv.entity.domain' + loader: '@Lv.entity.loader' em: '@doctrine.orm.entity_manager' diff --git a/src/Acme/Lv/Bundle/ApiBundle/AcmeLvApiBundle.php b/src/Acme/Lv/Bundle/ApiBundle/AcmeLvApiBundle.php deleted file mode 100644 index d51b5d0..0000000 --- a/src/Acme/Lv/Bundle/ApiBundle/AcmeLvApiBundle.php +++ /dev/null @@ -1,12 +0,0 @@ -router = $router; - $this->em = $em; - - $this->client = new Client(); - $this->posts = new PostCollection(); - } - - /** - * @AfterScenario - */ - public function removePosts() - { - foreach ($this->posts as $post) { - $this->em->remove($post); - } - $this->em->flush(); - } - - /** - * @Given I have theses posts: - */ - public function iHaveThesesPosts(PostCollection $posts) - { - // Fill posts table. - foreach ($posts as $post) { - $this->em->persist($post); - } - $this->em->flush(); - $this->posts = $posts; - } - - /** - * @Transform table:key,name - * @Transform table:name - */ - public function castPostsTable(TableNode $postsTable) - { - $posts = new PostCollection(); - foreach ($postsTable->getHash() as $postHash) { - $post = new Post(); - $post->setName($postHash['name']); - if (isset($postHash['key'])) { - $posts->set($postHash['key'], $post); - continue; - } - $posts->add($post); - } - - return $posts; - } - - /** - * @Given I get the post list - */ - public function iGetThePostList() - { - $response = $this->client->request( - 'GET', - $this->router->generate( - 'acme_api_post_collection', - [], - UrlGeneratorInterface::ABSOLUTE_URL - ), - [] - ); - - if ($response->getStatusCode() != Response::HTTP_OK) { - throw new \Exception( - sprintf( - 'Wrong status code : %s given, %s expected', - $response->getStatusCode(), - Response::HTTP_OK - ) - ); - } - - $data = json_decode($response->getBody()->getContents()); - $this->postList = new PostCollection(); - $this->postList->denormalize($data); - } - - /** - * @Then I should see theses posts: - * @Then I should see this post: - */ - public function iShouldSeeThesesPosts(PostCollection $posts) - { - foreach ($posts as $post) { - if (!$this->postList->search(['name' => $post->getName()])->count()) { - $postName = $post->getName(); - throw new \Exception("The post $postName was not found."); - } - } - } - - /** - * @Then I should not see theses posts: - * @Then I should not see this post: - */ - public function iShouldNotSeeThesesPosts(PostCollection $posts) - { - foreach ($posts as $post) { - if ($this->postList->search(['name' => $post->getName()])->count()) { - $postName = $post->getName(); - throw new \Exception("The post $postName was found."); - } - } - } - - /** - * @Given I create this post: - * @Given I create theses posts: - */ - public function iCreateThisPost(PostCollection $posts) - { - foreach ($posts as $post) { - $response = $this->client->request( - 'POST', - $this->router->generate( - 'acme_api_post_create', - [], - UrlGeneratorInterface::ABSOLUTE_URL - ), - ['form_params' => $post->serialize()] - ); - - if ($response->getStatusCode() != Response::HTTP_CREATED) { - throw new \Exception( - sprintf( - 'Wrong status code : %s given, %s expected', - $response->getStatusCode(), - Response::HTTP_CREATED - ) - ); - } - - // Parse the answer and add the created post to the postlist so we can delete it after the scenario. - $data = (array) json_decode($response->getBody()->getContents()); - $post->denormalize($data); - $post = $this->em->getReference('Acme\Lv\Component\Entity\Post', $post->getId()); - $this->posts->add($post); - } - } - - /** - * @Given I update the :key post with theses values: - */ - public function iUpdateTheKeyPost($key, PostCollection $posts) - { - $oldPost = $this->posts->get($key); - - if (!$oldPost) { - throw new \Exception("The post \"$key\" was not found."); - } - - foreach ($posts as $post) { - $response = $this->client->request( - 'PUT', - $this->router->generate( - 'acme_api_post_update', - ['id' => $oldPost->getId()], - UrlGeneratorInterface::ABSOLUTE_URL - ), - ['form_params' => $post->serialize()] - ); - - if ($response->getStatusCode() != Response::HTTP_NO_CONTENT) { - throw new \Exception( - sprintf( - 'Wrong status code : %s given, %s expected', - $response->getStatusCode(), - Response::HTTP_NO_CONTENT - ) - ); - } - } - } - - /** - * @Given I delete the :key post - */ - public function iDeleteTheKeyPost($key) - { - $oldPost = $this->posts->get($key); - - if (!$oldPost) { - throw new \Exception("The post \"$key\" was not found."); - } - - $response = $this->client->request( - 'DELETE', - $this->router->generate( - 'acme_api_post_delete', - ['id' => $oldPost->getId()], - UrlGeneratorInterface::ABSOLUTE_URL - ), - [] - ); - - if ($response->getStatusCode() != Response::HTTP_NO_CONTENT) { - throw new \Exception( - sprintf( - 'Wrong status code : %s given, %s expected', - $response->getStatusCode(), - Response::HTTP_NO_CONTENT - ) - ); - } - } -} diff --git a/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostApiDomainContext.php b/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostApiDomainContext.php deleted file mode 100644 index 06b7ad0..0000000 --- a/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostApiDomainContext.php +++ /dev/null @@ -1,172 +0,0 @@ -domain = $domain; - $this->loader = $loader; - $this->em = $em; - - $this->posts = new PostCollection(); - } - - /** - * @AfterScenario - */ - public function removePosts() - { - foreach ($this->posts as $post) { - $this->em->remove($post); - } - $this->em->flush(); - } - - /** - * @Given I have theses posts: - */ - public function iHaveThesesPosts(PostCollection $posts) - { - // Fill posts table. - foreach ($posts as $post) { - $this->em->persist($post); - } - $this->em->flush(); - $this->posts = $posts; - } - - /** - * @Transform table:key,name - * @Transform table:name - */ - public function castPostsTable(TableNode $postsTable) - { - $posts = new PostCollection(); - foreach ($postsTable->getHash() as $postHash) { - $post = new Post(); - $post->setName($postHash['name']); - if (isset($postHash['key'])) { - $posts->set($postHash['key'], $post); - continue; - } - $posts->add($post); - } - - return $posts; - } - - /** - * @Given I get the post list - */ - public function iGetThePostList() - { - $this->postList = $this->loader->retrieveAll(); - } - - /** - * @Then I should see theses posts: - * @Then I should see this post: - */ - public function iShouldSeeThesesPosts(PostCollection $posts) - { - foreach ($posts as $post) { - if (!$this->postList->search(['name' => $post->getName()])->count()) { - $postName = $post->getName(); - throw new \Exception(sprintf('The post %s was not found.', $postName)); - } - } - } - - /** - * @Then I should not see theses posts: - * @Then I should not see this post: - */ - public function iShouldNotSeeThesesPosts(PostCollection $posts) - { - foreach ($posts as $post) { - if ($this->postList->search(['name' => $post->getName()])->count()) { - $postName = $post->getName(); - throw new \Exception(sprintf('The post %s was found.', $postName)); - } - } - } - - /** - * @Given I create this post: - * @Given I create theses posts: - */ - public function iCreateThisPost(PostCollection $posts) - { - foreach ($posts as $post) { - $post = $this->domain->create($post->serialize()); - $post = $this->em->getReference('Acme\Lv\Component\Entity\Post', $post->getId()); - $this->posts->add($post); - } - } - - /** - * @Given I update the :key post with theses values: - */ - public function iUpdateTheKeyPost($key, PostCollection $posts) - { - $oldPost = $this->posts->get($key); - - if (!$oldPost) { - throw new \Exception(sprintf('The post %s was not found.', $key)); - } - - foreach ($posts as $post) { - $this->domain->update($oldPost, $post->serialize()); - } - } - - /** - * @Given I delete the :key post - */ - public function iDeleteTheKeyPost($key) - { - $oldPost = $this->posts->get($key); - - if (!$oldPost) { - throw new \Exception(sprintf('The post %s was not found.', $key)); - } - - $this->domain->delete($oldPost); - } -} diff --git a/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostDalDomainContext.php b/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostDalDomainContext.php deleted file mode 100644 index 374dba2..0000000 --- a/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostDalDomainContext.php +++ /dev/null @@ -1,177 +0,0 @@ -domain = $domain; - $this->loader = $loader; - $this->em = $em; - - $this->posts = new PostCollection(); - } - - /** - * @BeforeScenario - */ - public function BeforeScenario() - { - $this->em->getConnection(); - $this->em->beginTransaction(); - } - - /** - * @AfterScenario - */ - public function AfterScenario() - { - $this->em->rollback(); - $this->em->close(); - } - - /** - * @Given I have theses posts: - */ - public function iHaveThesesPosts(PostCollection $posts) - { - // Fill posts table. - foreach ($posts as $post) { - $this->em->persist($post); - } - $this->em->flush(); - $this->posts = $posts; - } - - /** - * @Transform table:key,name - * @Transform table:name - */ - public function castPostsTable(TableNode $postsTable) - { - $posts = new PostCollection(); - foreach ($postsTable->getHash() as $postHash) { - $post = new Post(); - $post->setName($postHash['name']); - if (isset($postHash['key'])) { - $posts->set($postHash['key'], $post); - continue; - } - $posts->add($post); - } - - return $posts; - } - - /** - * @Given I get the post list - */ - public function iGetThePostList() - { - $this->postList = $this->loader->retrieveAll(); - } - - /** - * @Then I should see theses posts: - * @Then I should see this post: - */ - public function iShouldSeeThesesPosts(PostCollection $posts) - { - foreach ($posts as $post) { - if (!$this->postList->search(['name' => $post->getName()])->count()) { - $postName = $post->getName(); - throw new \Exception(sprintf('The post %s was not found.', $postName)); - } - } - } - - /** - * @Then I should not see theses posts: - * @Then I should not see this post: - */ - public function iShouldNotSeeThesesPosts(PostCollection $posts) - { - foreach ($posts as $post) { - if ($this->postList->search(['name' => $post->getName()])->count()) { - $postName = $post->getName(); - throw new \Exception(sprintf('The post %s was found.', $postName)); - } - } - } - - /** - * @Given I create this post: - * @Given I create theses posts: - */ - public function iCreateThisPost(PostCollection $posts) - { - foreach ($posts as $post) { - $this->domain->create($post->serialize()); - } - } - - /** - * @Given I update the :key post with theses values: - */ - public function iUpdateTheKeyPost($key, PostCollection $posts) - { - $oldPost = $this->posts->get($key); - - if (!$oldPost) { - throw new \Exception(sprintf('The post %s was not found.', $key)); - } - - foreach ($posts as $post) { - $this->domain->update($oldPost, $post->serialize()); - } - } - - /** - * @Given I delete the :key post - */ - public function iDeleteTheKeyPost($key) - { - $oldPost = $this->posts->get($key); - - if (!$oldPost) { - throw new \Exception(sprintf('The post %s was not found.', $key)); - } - - $this->domain->delete($oldPost); - } -} diff --git a/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostRouterContext.php b/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostRouterContext.php deleted file mode 100644 index c900582..0000000 --- a/src/Acme/Lv/Bundle/ApiBundle/Features/Context/PostRouterContext.php +++ /dev/null @@ -1,24 +0,0 @@ -getContext(); - $context->setHost($host); - $context->setScheme($scheme); - $context->setBaseUrl($baseUrl); - $setPortMethodName = 'set'.ucfirst($scheme).'Port'; - $context->$setPortMethodName($port); - } -} diff --git a/src/Acme/Lv/Bundle/ApiBundle/Features/Post.feature b/src/Acme/Lv/Bundle/ApiBundle/Features/Post.feature deleted file mode 100644 index 31f600a..0000000 --- a/src/Acme/Lv/Bundle/ApiBundle/Features/Post.feature +++ /dev/null @@ -1,57 +0,0 @@ -@Post -Feature: Post Crud. - In order to manage Post - As an admin user - I need to be able to create, update, delete and retrieve posts. - - Background: Fixtures - Given I have theses posts: - | key | name | - | post_1 | Gérard | - | post_2 | Michel | - | post_3 | André | - - Scenario: Read - Given I get the post list - Then I should see theses posts: - | name | - | Gérard | - | Michel | - | André | - - Scenario: Create - Given I create theses posts: - | name | - | Clark | - And I get the post list - Then I should see theses posts: - | name | - | Gérard | - | Michel | - | André | - | Clark | - - Scenario: Update - Given I update the "post_2" post with theses values: - | name | - | Bruce | - And I get the post list - Then I should see theses posts: - | name | - | Gérard | - | Bruce | - | André | - And I should not see theses posts: - | name | - | Michel | - - Scenario: Delete - Given I delete the "post_2" post - And I get the post list - Then I should see theses posts: - | name | - | Gérard | - | André | - And I should not see theses posts: - | name | - | Michel | diff --git a/src/Acme/Lv/Bundle/ApiBundle/Resources/config/routing.yml b/src/Acme/Lv/Bundle/ApiBundle/Resources/config/routing.yml deleted file mode 100644 index 4d40a9c..0000000 --- a/src/Acme/Lv/Bundle/ApiBundle/Resources/config/routing.yml +++ /dev/null @@ -1,6 +0,0 @@ -# @MajoraGenerator({"include_routing": {"target": "@ApplicationApiAppBundle/Resources/config/routing.yml"}}) -# @MajoraGenerator({"include_routing": {"route": "acme_lv_api"}}) -# @MajoraGenerator({"include_routing": {"resource": "@AcmeLvApiBundle/Resources/config/routing.yml"}}) - -acme_lv_sdk: - resource: "@AcmeLvSdkBundle/Resources/config/routing.yml" diff --git a/src/Acme/Lv/Bundle/ApiBundle/Resources/config/services.xml b/src/Acme/Lv/Bundle/ApiBundle/Resources/config/services.xml deleted file mode 100644 index a5c64f3..0000000 --- a/src/Acme/Lv/Bundle/ApiBundle/Resources/config/services.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - diff --git a/src/Acme/Lv/Bundle/ApiBundle/Resources/config/services/auto/auto_post.xml b/src/Acme/Lv/Bundle/ApiBundle/Resources/config/services/auto/auto_post.xml deleted file mode 100644 index 1b2ac8c..0000000 --- a/src/Acme/Lv/Bundle/ApiBundle/Resources/config/services/auto/auto_post.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Acme/Lv/Bundle/DalBundle/AcmeLvDalBundle.php b/src/Acme/Lv/Bundle/DalBundle/AcmeLvDalBundle.php deleted file mode 100644 index c587383..0000000 --- a/src/Acme/Lv/Bundle/DalBundle/AcmeLvDalBundle.php +++ /dev/null @@ -1,12 +0,0 @@ -container = $container; - } - - /** - * @see FixtureInterface::load() - */ - public function load(ObjectManager $manager) - { - $postDomain = $this->container->get('acme.post.domain'); - - // reference there Posts data you want to create - $majoraEntities = array( - // 'post_1' => array( - // 'hello' => 'world', - // 'foo' => 'bar', - // ) - ); - - foreach ($majoraEntities as $reference => $postData) { - $this->addReference( - $reference, - $postDomain - ->getAction('create') - ->deserialize($postData) - ->resolve() - ); - } - } -} diff --git a/src/Acme/Lv/Bundle/DalBundle/Persistence/PostPersistenceListener.php b/src/Acme/Lv/Bundle/DalBundle/Persistence/PostPersistenceListener.php deleted file mode 100644 index dd59be6..0000000 --- a/src/Acme/Lv/Bundle/DalBundle/Persistence/PostPersistenceListener.php +++ /dev/null @@ -1,67 +0,0 @@ -postRepository = $postRepository; - } - - /** - * @see EventSubscriberInterface::getSubscribedEvents() - * - * @codeCoverageIgnore - */ - public static function getSubscribedEvents() - { - return array( - PostEvents::ACME_POST_CREATED => array('onWritePost', -100), - PostEvents::ACME_POST_EDITED => array('onWritePost', -100), - PostEvents::ACME_POST_DELETED => array('onDeletePost', -100), - ); - } - - /** - * Post writting event handler. - * - * @param PostEvent $event - */ - public function onWritePost(PostEvent $event) - { - $this->postRepository->persist( - $event->getPost() - ); - } - - /** - * Post deletion event handler. - * - * @param PostEvent $event - */ - public function onDeletePost(PostEvent $event) - { - $this->postRepository->remove( - $event->getPost() - ); - } -} diff --git a/src/Acme/Lv/Bundle/DalBundle/Resources/config/doctrine/Post.orm.yml b/src/Acme/Lv/Bundle/DalBundle/Resources/config/doctrine/Post.orm.yml deleted file mode 100644 index 2c86b77..0000000 --- a/src/Acme/Lv/Bundle/DalBundle/Resources/config/doctrine/Post.orm.yml +++ /dev/null @@ -1,62 +0,0 @@ -# @MajoraGenerator({"register_doctrine_em": {"target": "/config/config.yml"}}) -# @MajoraGenerator({"register_doctrine_em": {"em": "default"}}) -# @MajoraGenerator({"register_doctrine_em": {"prefix": "Acme\\Lv\\Component\\Entity"}}) -# @MajoraGenerator({"register_doctrine_em": {"bundle": "AcmeLvDalBundle"}}) -# @MajoraGenerator({"register_doctrine_em": {"alias": "AcmeLv"}}) - -Acme\Lv\Component\Entity\Post: - type: entity - repositoryClass: Acme\Lv\Component\Repository\Doctrine\PostDoctrineRepository - table: acme_lv_post - actAs: - Timestampable: ~ - id: - id: - type: integer - generator: { strategy: AUTO } - fields: - - # your other Post properties here - - name: - type: string - column: name - - createdAt: - type: datetime - column: created_at - gedmo: - timestampable: - on: create - updatedAt: - type: datetime - column: updated_at - gedmo: - timestampable: - on: update - - # manyToOne: - # example: - # targetEntity: Example - # inversedBy: posts - # joinColumn: - # name: example_id - # referencedColumnName: id - - # oneToMany: - # examples: - # targetEntity: Example - # mappedBy: post - # cascade: ['persist', 'remove'] - - # manyToMany: - # examples: - # targetEntity: Example - # joinTable: - # name: acme_lv_post_example - # joinColumns: - # post_id: - # referencedColumnName: id - # inverseJoinColumns: - # example_id: - # referencedColumnName: id diff --git a/src/Acme/Lv/Bundle/DalBundle/Resources/config/services.xml b/src/Acme/Lv/Bundle/DalBundle/Resources/config/services.xml deleted file mode 100644 index a5c64f3..0000000 --- a/src/Acme/Lv/Bundle/DalBundle/Resources/config/services.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - diff --git a/src/Acme/Lv/Bundle/DalBundle/Resources/config/services/auto/auto_post.xml b/src/Acme/Lv/Bundle/DalBundle/Resources/config/services/auto/auto_post.xml deleted file mode 100644 index 8b3cfe2..0000000 --- a/src/Acme/Lv/Bundle/DalBundle/Resources/config/services/auto/auto_post.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AcmeLv:Post - default - - - - - - - - - - - - - - - - - - - - diff --git a/src/Acme/Lv/Bundle/SdkBundle/AcmeLvSdkBundle.php b/src/Acme/Lv/Bundle/SdkBundle/AcmeLvSdkBundle.php deleted file mode 100644 index 3e2fca2..0000000 --- a/src/Acme/Lv/Bundle/SdkBundle/AcmeLvSdkBundle.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/src/Acme/Lv/Bundle/SdkBundle/Resources/config/services/auto/auto_post.xml b/src/Acme/Lv/Bundle/SdkBundle/Resources/config/services/auto/auto_post.xml deleted file mode 100644 index 25e244b..0000000 --- a/src/Acme/Lv/Bundle/SdkBundle/Resources/config/services/auto/auto_post.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - acme_api_post_collection - acme_api_post_create - acme_api_post_read - acme_api_post_update - acme_api_post_delete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Acme/Lv/Component/Action/AbstractPostAction.php b/src/Acme/Lv/Component/Action/AbstractPostAction.php deleted file mode 100644 index 8546ac0..0000000 --- a/src/Acme/Lv/Component/Action/AbstractPostAction.php +++ /dev/null @@ -1,41 +0,0 @@ -post = $post; - - return $this; - } - - /** - * Return related Post if defined. - * - * @return Post|null $post - */ - public function getPost() - { - return $this->post; - } -} diff --git a/src/Acme/Lv/Component/Action/Api/Post/AbstractApiAction.php b/src/Acme/Lv/Component/Action/Api/Post/AbstractApiAction.php deleted file mode 100644 index 4c6d66a..0000000 --- a/src/Acme/Lv/Component/Action/Api/Post/AbstractApiAction.php +++ /dev/null @@ -1,14 +0,0 @@ -getRestApiClient()->put( - array('id' => $this->post->getId()), - $this->serialize() - ); - - // Generic Post hydration from this action magic accessors - $this->post = $this->getSerializer()->deserialize( - (string) $this->getSerializer()->serialize($this, 'json'), - Post::class, - 'json' - ); - } -} diff --git a/src/Acme/Lv/Component/Action/Dal/Post/AbstractDalAction.php b/src/Acme/Lv/Component/Action/Dal/Post/AbstractDalAction.php deleted file mode 100644 index dca66b9..0000000 --- a/src/Acme/Lv/Component/Action/Dal/Post/AbstractDalAction.php +++ /dev/null @@ -1,16 +0,0 @@ -post = new Post(); - $this->post->deserialize($this->serialize()); - - $this->assertEntityIsValid($this->post, array('Post', 'creation')); - - $this->fireEvent( - PostEvents::ACME_POST_CREATED, - new PostEvent($this->post, $this) - ); - - return $this->post; - } -} diff --git a/src/Acme/Lv/Component/Action/Dal/Post/UpdateAction.php b/src/Acme/Lv/Component/Action/Dal/Post/UpdateAction.php deleted file mode 100644 index db30be7..0000000 --- a/src/Acme/Lv/Component/Action/Dal/Post/UpdateAction.php +++ /dev/null @@ -1,30 +0,0 @@ -post->deserialize($this->serialize()); - - $this->assertEntityIsValid($this->post, array('Post', 'edition')); - - $this->fireEvent( - PostEvents::ACME_POST_EDITED, - new PostEvent($this->post, $this) - ); - } -} diff --git a/src/Acme/Lv/Component/Domain/Action/Auto/PostActionDispatcherDomainTrait.php b/src/Acme/Lv/Component/Domain/Action/Auto/PostActionDispatcherDomainTrait.php deleted file mode 100644 index b189159..0000000 --- a/src/Acme/Lv/Component/Domain/Action/Auto/PostActionDispatcherDomainTrait.php +++ /dev/null @@ -1,47 +0,0 @@ -getAction('create', null, ...$arguments) - ->resolve() - ; - } - - /** - * @see PostDomainInterface::update() - */ - public function update(Post $post, ...$arguments) - { - return $this->getAction('update', $post, ...$arguments) - ->resolve() - ; - } - - /** - * @see PostDomainInterface::delete() - */ - public function delete(Post $post, ...$arguments) - { - return $this->getAction('delete', $post, ...$arguments) - ->resolve() - ; - } -} diff --git a/src/Acme/Lv/Component/Domain/Action/PostActionDispatcherDomain.php b/src/Acme/Lv/Component/Domain/Action/PostActionDispatcherDomain.php deleted file mode 100644 index 2efcb97..0000000 --- a/src/Acme/Lv/Component/Domain/Action/PostActionDispatcherDomain.php +++ /dev/null @@ -1,21 +0,0 @@ - 'id', - 'default' => array('id', 'name', 'createdAt', 'updatedAt'), - ); - } - - /** - * Returns Post id. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Define Post id. - * - * @param int $id - * - * @return self - */ - public function setId($id) - { - $this->id = $id; - - return $this; - } - - /** - * Returns Post name. - * - * @return int - */ - public function getName() - { - return $this->name; - } - - /** - * Define Post name. - * - * @param int $name - * - * @return self - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - // ************************************************* - // - // Class auto generated by MajoraGeneratorBundle - // Implement your own logic here ! - // - // ************************************************* -} diff --git a/src/Acme/Lv/Component/Event/PostEvent.php b/src/Acme/Lv/Component/Event/PostEvent.php deleted file mode 100644 index 2d16d49..0000000 --- a/src/Acme/Lv/Component/Event/PostEvent.php +++ /dev/null @@ -1,61 +0,0 @@ -post = $post; - $this->action = $action; - } - - /** - * return related. - * - * @return Post - */ - public function getPost() - { - return $this->post; - } - - /** - * @see BroadcastableEventInterface::getSubject() - */ - public function getSubject() - { - return $this->getPost(); - } - - /** - * @see BroadcastableEventInterface::getAction() - */ - public function getAction() - { - return $this->action; - } -} diff --git a/src/Acme/Lv/Component/Event/PostEvents.php b/src/Acme/Lv/Component/Event/PostEvents.php deleted file mode 100644 index 4870926..0000000 --- a/src/Acme/Lv/Component/Event/PostEvents.php +++ /dev/null @@ -1,24 +0,0 @@ - array( - array(), - array(), - $post = (new Post())->setId(42), - $post, - ), - - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - array $incommingData, - array $expectedRequestData, - Post $createdPost, - Post $expectedPost - ) { - // Rest Client mock - $restClient = $this->prophesize(RestApiClient::class); - $restClient - ->post(array(), $expectedRequestData) - ->willReturn(new Response()) - ->shouldBeCalled() - ; - - // Serializer mock - $serializer = $this->prophesize(SerializerInterface::class); - $serializer - ->deserialize(Argument::any(), Post::class, Argument::any()) - ->willReturn($createdPost) - ; - - // Action - $action = new CreateAction(); - $action->setSerializer($serializer->reveal()); - $action->setRestApiClient($restClient->reveal()); - $action->deserialize($incommingData); - - $this->assertEquals( - $expectedPost, - $action->resolve() - ); - } -} diff --git a/src/Acme/Lv/Component/Tests/Entity/PostCollectionTest.php b/src/Acme/Lv/Component/Tests/Entity/PostCollectionTest.php deleted file mode 100644 index 83ec09b..0000000 --- a/src/Acme/Lv/Component/Tests/Entity/PostCollectionTest.php +++ /dev/null @@ -1,45 +0,0 @@ -deserialize(array( - 'post_1' => array('id' => 42), - 'post_2' => array('id' => 66), - )); - - $this->assertInstanceOf( - Post::class, - $postCollection->get('post_1'), - 'Deserialization process hydrate a related entity class object and index it under given key.' - ); - $this->assertInstanceOf( - Post::class, - $postCollection->get('post_2'), - 'Deserialization process hydrate a related entity class object and index it under given key.' - ); - $this->assertEquals( - array( - 'post_1' => 42, - 'post_2' => 66, - ), - $postCollection->serialize('id'), - 'Serialization scopes are transmitted to related entity serialization process.' - ); - } -} diff --git a/src/Acme/Lv/Component/Tests/Entity/PostTest.php b/src/Acme/Lv/Component/Tests/Entity/PostTest.php deleted file mode 100644 index 11c940b..0000000 --- a/src/Acme/Lv/Component/Tests/Entity/PostTest.php +++ /dev/null @@ -1,128 +0,0 @@ -post = new Post(); - $this->reflector = new \ReflectionClass($this->post); - } - - /** - * Provider for accessor tests. - * - * @return array - */ - public function propertyMapProvider() - { - return array( - 'id' => array('id', 42), - ); - } - - /** - * Tests setters. - * - * @dataProvider propertyMapProvider - */ - public function testSet($propertyName, $definedValue) - { - $property = $this->reflector->getProperty($propertyName); - $property->setAccessible(true); - - $method = 'set'.ucfirst($propertyName); - $this->post->$method($definedValue); - $this->assertEquals( - $definedValue, - $property->getValue($this->post), - sprintf('Post::%s() defines "%s" property current value.', - $method, - $propertyName - ) - ); - } - - /** - * Tests getters. - * - * @dataProvider propertyMapProvider - */ - public function testGet($propertyName, $expectedValue) - { - $property = $this->reflector->getProperty($propertyName); - $property->setAccessible(true); - $property->setValue($this->post, $expectedValue); - - $method = 'get'.ucfirst($propertyName); - $this->assertEquals( - $expectedValue, - $this->post->$method(), - sprintf('Post::%s() returns current defined "%s" property value.', - $method, - $propertyName - ) - ); - } - - /** - * Provider for serialization tests. - * - * @return array() - */ - public function serializationCasesProvider() - { - return array( - 'id' => array('id', 'int'), - 'default' => array('default', array('id')), - ); - } - - /** - * Tests serialization scopes. - * - * @dataProvider serializationCasesProvider - */ - public function testSerializationScopes($scope, $expectedKeys) - { - $this->post->setId(42); - $postData = $this->post->serialize($scope); - - if (!is_array($expectedKeys)) { - return $this->assertInternalType( - $expectedKeys, - $postData, - sprintf('Post "%s" scope provides a single value as %s.', $scope, $expectedKeys) - ); - } - - foreach ($expectedKeys as $expectedKey) { - $this->assertArrayHasKey( - $expectedKey, - $postData, - sprintf('Post "%s" scope provides an array with "%s" key.', $scope, $expectedKey) - ); - } - } -} diff --git a/src/Acme/Lv/Component/Tests/Event/PostEventTest.php b/src/Acme/Lv/Component/Tests/Event/PostEventTest.php deleted file mode 100644 index d9ab04d..0000000 --- a/src/Acme/Lv/Component/Tests/Event/PostEventTest.php +++ /dev/null @@ -1,34 +0,0 @@ -prophesize(AbstractPostAction::class)->reveal(); - - // Event - $event = new PostEvent( - $post = new Post(), - $action - ); - - // Assertions - $this->assertSame($post, $event->getPost()); - $this->assertSame($post, $event->getSubject()); - $this->assertSame($action, $event->getAction()); - } -} diff --git a/src/Acme/Lv/Component/Tests/Loader/Doctrine/PostDoctrineLoader.php b/src/Acme/Lv/Component/Tests/Loader/Doctrine/PostDoctrineLoader.php deleted file mode 100644 index 0ec259f..0000000 --- a/src/Acme/Lv/Component/Tests/Loader/Doctrine/PostDoctrineLoader.php +++ /dev/null @@ -1,31 +0,0 @@ -prophesize(PostRepositoryInterface::class); - $repository->save()->shouldNotBeCalled(); - - $loader = new PostDoctrineLoader(); - $loader->setUp( - Post::class, - array('majora' => 'entity'), - PostCollection::class, - $repository->reveal() - ); - } -} diff --git a/src/Acme/Lv/Bundle/ApiBundle/Controller/Auto/PostApiControllerTrait.php b/src/Lv/Example/Bundle/ApiBundle/Controller/Auto/EntityApiControllerTrait.php similarity index 71% rename from src/Acme/Lv/Bundle/ApiBundle/Controller/Auto/PostApiControllerTrait.php rename to src/Lv/Example/Bundle/ApiBundle/Controller/Auto/EntityApiControllerTrait.php index 7471255..71f9721 100644 --- a/src/Acme/Lv/Bundle/ApiBundle/Controller/Auto/PostApiControllerTrait.php +++ b/src/Lv/Example/Bundle/ApiBundle/Controller/Auto/EntityApiControllerTrait.php @@ -1,27 +1,27 @@ createJsonResponse( - $this->container->get('acme.post.loader')->retrieveAll( + $this->container->get('lv.entity.loader')->retrieveAll( $this->container->get('majora.inflector')->normalize($queryFilters, 'camelize'), $request->query->get('limit'), $request->query->get('offset') @@ -45,25 +45,25 @@ public function cgetAction(Request $request) } /** - * Returns a single Post by id. + * Returns a single Entity by id. * - * @param int $id requested Post id + * @param int $id requested Entity id * @param Request $request * * @return JsonResponse */ public function getAction($id, Request $request) { - $post = $this->retrieveOr404($id, 'acme.post.loader'); + $entity = $this->retrieveOr404($id, 'lv.entity.loader'); return $this->createJsonResponse( - $post, + $entity, $request->query->get('scope') ); } /** - * Creates a new Post. + * Creates a new Entity. * * @param Request $request * @@ -82,19 +82,19 @@ public function postAction(Request $request) ); // resolve use case - $post = $form->getData()->resolve(); + $entity = $form->getData()->resolve(); return $this->createJsonResponse( - $post, + $entity, $request->query->get('scope'), 201 ); } /** - * Updates a single Post by id. + * Updates a single Entity by id. * - * @param int $id requested Post id + * @param int $id requested Entity id * @param Request $request * * @return JsonResponse @@ -109,7 +109,7 @@ public function putAction($id, Request $request) null, array( 'method' => 'PUT', - 'entity' => $this->retrieveOr404($id, 'acme.post.loader'), + 'entity' => $this->retrieveOr404($id, 'lv.entity.loader'), ) ) ); @@ -121,16 +121,16 @@ public function putAction($id, Request $request) } /** - * Delete a single Post by id. + * Delete a single Entity by id. * - * @param int $id requested Post id + * @param int $id requested Entity id * * @return JsonResponse */ public function deleteAction($id) { - $this->container->get('acme.post.domain')->delete( - $this->retrieveOr404($id, 'acme.post.loader') + $this->container->get('lv.entity.domain')->delete( + $this->retrieveOr404($id, 'lv.entity.loader') ); return $this->createJsonNoContentResponse(); diff --git a/src/Acme/Lv/Bundle/ApiBundle/Controller/PostApiController.php b/src/Lv/Example/Bundle/ApiBundle/Controller/EntityApiController.php similarity index 58% rename from src/Acme/Lv/Bundle/ApiBundle/Controller/PostApiController.php rename to src/Lv/Example/Bundle/ApiBundle/Controller/EntityApiController.php index a48576d..38975cc 100644 --- a/src/Acme/Lv/Bundle/ApiBundle/Controller/PostApiController.php +++ b/src/Lv/Example/Bundle/ApiBundle/Controller/EntityApiController.php @@ -1,12 +1,12 @@ root('acme_lv_api') + * $treeBuilder->root('lv_example_api') * ->children() * ->scalarNode('...') * ->isRequired() @@ -34,7 +34,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); - $treeBuilder->root('acme_lv_api'); + $treeBuilder->root('lv_example_api'); return $treeBuilder; } diff --git a/src/Acme/Lv/Bundle/ApiBundle/DependencyInjection/AcmeLvApiExtension.php b/src/Lv/Example/Bundle/ApiBundle/DependencyInjection/LvExampleApiExtension.php similarity index 88% rename from src/Acme/Lv/Bundle/ApiBundle/DependencyInjection/AcmeLvApiExtension.php rename to src/Lv/Example/Bundle/ApiBundle/DependencyInjection/LvExampleApiExtension.php index 6e49676..0b26511 100644 --- a/src/Acme/Lv/Bundle/ApiBundle/DependencyInjection/AcmeLvApiExtension.php +++ b/src/Lv/Example/Bundle/ApiBundle/DependencyInjection/LvExampleApiExtension.php @@ -1,6 +1,6 @@ em = $em; + $this->domain = $domain; + $this->loader = $loader; + } + + /** + * @BeforeScenario + */ + public function initEntitys() + { + $this->truncateEntitys(); + for($i=0; $i<= self::$totalToInsert; $i++){ + $this->em->persist(new Entity()); + } + $this->em->flush(); + } + + /** + * @Given I have some entitys + * + */ + public function retrieveSomeEntitys() + { + $this->entitys = $this->em->getRepository(Entity::class)->findAll(); + } + + /** + * @Given I have created a new entity + */ + public function insertEntity() + { + $this->currentEntity = new Entity(); + $this->em->getRepository(Entity::class)->persist($this->currentEntity); + $this->em->flush(); + $this->em->refresh($this->currentEntity); + + $this->memoryId = $this->currentEntity->getId(); + } + + /** + * @When I create a new entity + */ + public function createEntity() + { + $this->currentEntity = $this->domain->create(new Entity()); + } + + /** + * @When I get the entitys list + */ + public function getEntityList() + { + $this->currentEntitys = $this->loader->retrieveAll(); + } + + /** + * @When I get this entity by id + */ + public function getEntity() + { + $this->loadedEntity = $this->em->getRepository(Entity::class)->find($this->memoryId); + } + + /** + * @When I delete this entity + */ + public function deleteEntity() + { + $this->domain->delete($this->currentEntity); + } + + /** + * @When I update this entity with a new id + */ + public function updateEntity() + { + $this->memoryId = $this->currentEntity->getId(); + $this->domain->update($this->currentEntity, array("id" => ($this->currentEntity->getId() + 1))); + } + + /** + * @Then I retrieve new entity id + */ + public function testEntityId() + { + return $this->currentEntity->getId() != null; + } + + /** + * @Then I should see a list of entitys + */ + public function compareListEntitys() + { + return $this->currentEntitys === $this->entitys; + } + + /** + * @Then I should see this entity + */ + public function compareEntity() + { + return $this->loadedEntity === $this->currentEntity; + } + + /** + * @Then I should not see this entity + */ + public function checkEntityDeleted() + { + return is_null($this->em->getRepository(Entity::class)->find($this->memoryId)); + } + + /** + * @Then I should see the same entity with this new id value + */ + public function checkEntityAsUpdated() + { + return $this->memoryId === $this->currentEntity->getId() + 1; + } + + /** + * @AfterScenario + */ + public function terminateEntitys() + { + $this->truncateEntitys(); + } + + /** + * Trucate all table data + * @throws \Doctrine\DBAL\DBALException + */ + private function truncateEntitys() + { + $connection = $this->em->getConnection(); + $connection->query('SET FOREIGN_KEY_CHECKS=0'); + $this->em->createQuery('DELETE FROM Lv\Example\Component\Entity\Entity')->execute(); + $connection->query('SET FOREIGN_KEY_CHECKS=1'); + $this->em->flush(); + } + +} diff --git a/src/Lv/Example/Bundle/ApiBundle/Features/Entity.feature b/src/Lv/Example/Bundle/ApiBundle/Features/Entity.feature new file mode 100644 index 0000000..f2aa744 --- /dev/null +++ b/src/Lv/Example/Bundle/ApiBundle/Features/Entity.feature @@ -0,0 +1,30 @@ +@Entity +Feature: Entity Crud. + In order to manage entity + As a user + I need to be able to create, update, delete and retrieve entity. + + Scenario: Create + Given I have some entitys + When I create a new entity + Then I retrieve new entity id + + Scenario: ReadAll + Given I have some entitys + When I get the entitys list + Then I should see a list of entitys + + Scenario: Read + Given I have created a new entity + When I get this entity by id + Then I should see this entity + + Scenario: delete + Given I have created a new entity + When I delete this entity + Then I should not see this entity + + Scenario: Update + Given I have created a new entity + When I update this entity with a new id + Then I should see the same entity with this new id value diff --git a/src/Acme/Lv/Bundle/ApiBundle/Form/Post/AbstractType.php b/src/Lv/Example/Bundle/ApiBundle/Form/Entity/AbstractType.php similarity index 65% rename from src/Acme/Lv/Bundle/ApiBundle/Form/Post/AbstractType.php rename to src/Lv/Example/Bundle/ApiBundle/Form/Entity/AbstractType.php index 5fd2ead..d00fec4 100644 --- a/src/Acme/Lv/Bundle/ApiBundle/Form/Post/AbstractType.php +++ b/src/Lv/Example/Bundle/ApiBundle/Form/Entity/AbstractType.php @@ -1,30 +1,30 @@ postDomain = $postDomain; + $this->entityDomain = $entityDomain; } /** @@ -40,7 +40,7 @@ public function configureOptions(OptionsResolver $resolver) } /** - * Post form prototype definition. + * Entity form prototype definition. * * @warning : function auto generated by MajoraGeneratorBundle, implement your own logic here ! * @@ -48,6 +48,5 @@ public function configureOptions(OptionsResolver $resolver) */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('name'); } } diff --git a/src/Acme/Lv/Bundle/ApiBundle/Form/Post/CreationType.php b/src/Lv/Example/Bundle/ApiBundle/Form/Entity/CreationType.php similarity index 69% rename from src/Acme/Lv/Bundle/ApiBundle/Form/Post/CreationType.php rename to src/Lv/Example/Bundle/ApiBundle/Form/Entity/CreationType.php index 1b01d6a..e0bab99 100644 --- a/src/Acme/Lv/Bundle/ApiBundle/Form/Post/CreationType.php +++ b/src/Lv/Example/Bundle/ApiBundle/Form/Entity/CreationType.php @@ -1,13 +1,13 @@ setDefaults(array( 'data_class' => CreateAction::class, 'empty_data' => function (FormInterface $form) { - return $this->postDomain->getAction('create'); + return $this->entityDomain->getAction('create'); }, )); } diff --git a/src/Acme/Lv/Bundle/ApiBundle/Form/Post/EditionType.php b/src/Lv/Example/Bundle/ApiBundle/Form/Entity/EditionType.php similarity index 67% rename from src/Acme/Lv/Bundle/ApiBundle/Form/Post/EditionType.php rename to src/Lv/Example/Bundle/ApiBundle/Form/Entity/EditionType.php index 096713f..6978bc1 100644 --- a/src/Acme/Lv/Bundle/ApiBundle/Form/Post/EditionType.php +++ b/src/Lv/Example/Bundle/ApiBundle/Form/Entity/EditionType.php @@ -1,14 +1,14 @@ setDefaults(array( 'data_class' => UpdateAction::class, 'empty_data' => function (FormInterface $form) { - return $this->postDomain->getAction( + return $this->entityDomain->getAction( 'update', $form->getConfig()->getOption('entity') ); }, )); $resolver->setRequired('entity'); - $resolver->setAllowedTypes('entity', Post::class); + $resolver->setAllowedTypes('entity', Entity::class); } } diff --git a/src/Sir/Partner/Bundle/DalBundle/SirPartnerDalBundle.php b/src/Lv/Example/Bundle/ApiBundle/LvExampleApiBundle.php similarity index 62% rename from src/Sir/Partner/Bundle/DalBundle/SirPartnerDalBundle.php rename to src/Lv/Example/Bundle/ApiBundle/LvExampleApiBundle.php index b41dab8..20adbce 100644 --- a/src/Sir/Partner/Bundle/DalBundle/SirPartnerDalBundle.php +++ b/src/Lv/Example/Bundle/ApiBundle/LvExampleApiBundle.php @@ -1,12 +1,12 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Acme/Lv/Bundle/ApiBundle/Resources/config/services/post.xml b/src/Lv/Example/Bundle/ApiBundle/Resources/config/services/entity.xml similarity index 84% rename from src/Acme/Lv/Bundle/ApiBundle/Resources/config/services/post.xml rename to src/Lv/Example/Bundle/ApiBundle/Resources/config/services/entity.xml index 66a033f..cedde9c 100644 --- a/src/Acme/Lv/Bundle/ApiBundle/Resources/config/services/post.xml +++ b/src/Lv/Example/Bundle/ApiBundle/Resources/config/services/entity.xml @@ -1,13 +1,13 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LvExample:Entity + default + + + + + + + + + + + + + + + + + + + + diff --git a/src/Acme/Lv/Bundle/DalBundle/Resources/config/services/post.xml b/src/Lv/Example/Bundle/DalBundle/Resources/config/services/entity.xml similarity index 84% rename from src/Acme/Lv/Bundle/DalBundle/Resources/config/services/post.xml rename to src/Lv/Example/Bundle/DalBundle/Resources/config/services/entity.xml index 66a033f..cedde9c 100644 --- a/src/Acme/Lv/Bundle/DalBundle/Resources/config/services/post.xml +++ b/src/Lv/Example/Bundle/DalBundle/Resources/config/services/entity.xml @@ -1,13 +1,13 @@ - + - + + + + + + + + + + + + + + lv_api_entity_collection + lv_api_entity_create + lv_api_entity_read + lv_api_entity_update + lv_api_entity_delete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Acme/Lv/Bundle/SdkBundle/Resources/config/services/post.xml b/src/Lv/Example/Bundle/SdkBundle/Resources/config/services/entity.xml similarity index 84% rename from src/Acme/Lv/Bundle/SdkBundle/Resources/config/services/post.xml rename to src/Lv/Example/Bundle/SdkBundle/Resources/config/services/entity.xml index 66a033f..cedde9c 100644 --- a/src/Acme/Lv/Bundle/SdkBundle/Resources/config/services/post.xml +++ b/src/Lv/Example/Bundle/SdkBundle/Resources/config/services/entity.xml @@ -1,13 +1,13 @@ - + - + - diff --git a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/auto/auto_person.xml b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/auto/auto_person.xml deleted file mode 100644 index 9a2b9fc..0000000 --- a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/auto/auto_person.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/person.xml b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/person.xml deleted file mode 100644 index 5214e5c..0000000 --- a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/services/person.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/validation/person.yml b/src/Sir/Partner/Bundle/ApiBundle/Resources/config/validation/person.yml deleted file mode 100644 index 0a8bde4..0000000 --- a/src/Sir/Partner/Bundle/ApiBundle/Resources/config/validation/person.yml +++ /dev/null @@ -1,5 +0,0 @@ -Sir\Partner\Component\Entity\Person: - properties: ~ - # example: - # - NotBlank: - # groups: [creation] diff --git a/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/Configuration.php b/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/Configuration.php deleted file mode 100644 index 1780cb5..0000000 --- a/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/Configuration.php +++ /dev/null @@ -1,41 +0,0 @@ -root('sir_partner_dal') - * ->children() - * ->scalarNode('...') - * ->isRequired() - * ->end() - * ->arrayNode() - * ->addDefaultsIfNotSet() - * ->children() - * // more nodes here - * ->end() - * ->end() - * ->end() - * ; - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $treeBuilder->root('sir_partner_dal'); - - return $treeBuilder; - } -} diff --git a/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/SirPartnerDalExtension.php b/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/SirPartnerDalExtension.php deleted file mode 100644 index f262ab7..0000000 --- a/src/Sir/Partner/Bundle/DalBundle/DependencyInjection/SirPartnerDalExtension.php +++ /dev/null @@ -1,27 +0,0 @@ -processConfiguration(new Configuration(), $configs); - - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.xml'); - } -} diff --git a/src/Sir/Partner/Bundle/DalBundle/Persistence/PersonPersistenceListener.php b/src/Sir/Partner/Bundle/DalBundle/Persistence/PersonPersistenceListener.php deleted file mode 100644 index e3cc5f4..0000000 --- a/src/Sir/Partner/Bundle/DalBundle/Persistence/PersonPersistenceListener.php +++ /dev/null @@ -1,67 +0,0 @@ -personRepository = $personRepository; - } - - /** - * @see EventSubscriberInterface::getSubscribedEvents() - * - * @codeCoverageIgnore - */ - public static function getSubscribedEvents() - { - return array( - PersonEvents::SIR_PERSON_CREATED => array('onWritePerson', -100), - PersonEvents::SIR_PERSON_EDITED => array('onWritePerson', -100), - PersonEvents::SIR_PERSON_DELETED => array('onDeletePerson', -100), - ); - } - - /** - * Person writting event handler. - * - * @param PersonEvent $event - */ - public function onWritePerson(PersonEvent $event) - { - $this->personRepository->persist( - $event->getPerson() - ); - } - - /** - * Person deletion event handler. - * - * @param PersonEvent $event - */ - public function onDeletePerson(PersonEvent $event) - { - $this->personRepository->remove( - $event->getPerson() - ); - } -} diff --git a/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/auto/auto_person.xml b/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/auto/auto_person.xml deleted file mode 100644 index ea2ad99..0000000 --- a/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/auto/auto_person.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SirPartner:Person - default - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/person.xml b/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/person.xml deleted file mode 100644 index 5214e5c..0000000 --- a/src/Sir/Partner/Bundle/DalBundle/Resources/config/services/person.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/Configuration.php b/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/Configuration.php deleted file mode 100644 index f19abfa..0000000 --- a/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/Configuration.php +++ /dev/null @@ -1,41 +0,0 @@ -root('sir_partner_sdk') - * ->children() - * ->scalarNode('...') - * ->isRequired() - * ->end() - * ->arrayNode() - * ->addDefaultsIfNotSet() - * ->children() - * // more nodes here - * ->end() - * ->end() - * ->end() - * ; - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $treeBuilder->root('sir_partner_sdk'); - - return $treeBuilder; - } -} diff --git a/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/SirPartnerSdkExtension.php b/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/SirPartnerSdkExtension.php deleted file mode 100644 index 8c3d0b9..0000000 --- a/src/Sir/Partner/Bundle/SdkBundle/DependencyInjection/SirPartnerSdkExtension.php +++ /dev/null @@ -1,27 +0,0 @@ -processConfiguration(new Configuration(), $configs); - - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.xml'); - } -} diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing.yml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing.yml deleted file mode 100644 index 1634d4d..0000000 --- a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing.yml +++ /dev/null @@ -1,4 +0,0 @@ - -sir_person_sdk: - resource: "routing/person.yml" - prefix: /persons diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/auto/auto_person.yml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/auto/auto_person.yml deleted file mode 100644 index 632d064..0000000 --- a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/auto/auto_person.yml +++ /dev/null @@ -1,42 +0,0 @@ -# @MajoraGenerator({"force_generation": true}) - -sir_api_person_collection: - path: / - defaults: - _controller: SirPartnerApiBundle:PersonApi:cget - methods: - - GET - -sir_api_person_create: - path: / - defaults: - _controller: SirPartnerApiBundle:PersonApi:post - methods: - - POST - -sir_api_person_read: - path: /{id} - defaults: - _controller: SirPartnerApiBundle:PersonApi:get - requirements: - id: \d+ - methods: - - GET - -sir_api_person_update: - path: /{id} - defaults: - _controller: SirPartnerApiBundle:PersonApi:put - requirements: - id: \d+ - methods: - - PUT - -sir_api_person_delete: - path: /{id} - defaults: - _controller: SirPartnerApiBundle:PersonApi:delete - requirements: - id: \d+ - methods: - - DELETE diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/person.yml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/person.yml deleted file mode 100644 index b2be205..0000000 --- a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/routing/person.yml +++ /dev/null @@ -1,8 +0,0 @@ -# @MajoraGenerator({"include_routing": {"target": "../routing.yml"}}) -# @MajoraGenerator({"include_routing": {"route": "sir_person_sdk"}}) -# @MajoraGenerator({"include_routing": {"resource": "routing/person.yml"}}) -# @MajoraGenerator({"include_routing": {"prefix": "/persons"}}) - -# generated routes -auto_sir_person_sdk: - resource: "@SirPartnerSdkBundle/Resources/config/routing/auto/auto_person.yml" diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services.xml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services.xml deleted file mode 100644 index 245bbe2..0000000 --- a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/auto/auto_person.xml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/auto/auto_person.xml deleted file mode 100644 index 2e227af..0000000 --- a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/auto/auto_person.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - sir_api_person_collection - sir_api_person_create - sir_api_person_read - sir_api_person_update - sir_api_person_delete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/person.xml b/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/person.xml deleted file mode 100644 index 5214e5c..0000000 --- a/src/Sir/Partner/Bundle/SdkBundle/Resources/config/services/person.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sir/Partner/Component/Action/AbstractPersonAction.php b/src/Sir/Partner/Component/Action/AbstractPersonAction.php deleted file mode 100644 index a611b21..0000000 --- a/src/Sir/Partner/Component/Action/AbstractPersonAction.php +++ /dev/null @@ -1,41 +0,0 @@ -person = $person; - - return $this; - } - - /** - * Return related Person if defined. - * - * @return Person|null $person - */ - public function getPerson() - { - return $this->person; - } -} diff --git a/src/Sir/Partner/Component/Action/Api/Person/AbstractApiAction.php b/src/Sir/Partner/Component/Action/Api/Person/AbstractApiAction.php deleted file mode 100644 index 11ef771..0000000 --- a/src/Sir/Partner/Component/Action/Api/Person/AbstractApiAction.php +++ /dev/null @@ -1,14 +0,0 @@ -getRestApiClient()->post( - array(), - $this->serialize() - ); - - // parsing response - $this->person = $this->getSerializer()->deserialize( - (string) $response->getBody(), - Person::class, - 'json' - ); - - return $this->person; - } -} diff --git a/src/Sir/Partner/Component/Action/Api/Person/DeleteAction.php b/src/Sir/Partner/Component/Action/Api/Person/DeleteAction.php deleted file mode 100644 index bf4d81c..0000000 --- a/src/Sir/Partner/Component/Action/Api/Person/DeleteAction.php +++ /dev/null @@ -1,28 +0,0 @@ -getRestApiClient()->delete( - array('id' => $this->person->getId()) - ); - } -} diff --git a/src/Sir/Partner/Component/Action/Dal/Person/AbstractDalAction.php b/src/Sir/Partner/Component/Action/Dal/Person/AbstractDalAction.php deleted file mode 100644 index b8d2189..0000000 --- a/src/Sir/Partner/Component/Action/Dal/Person/AbstractDalAction.php +++ /dev/null @@ -1,16 +0,0 @@ -person = new Person(); - $this->person->deserialize($this->serialize()); - - $this->assertEntityIsValid($this->person, array('Person', 'creation')); - - $this->fireEvent( - PersonEvents::SIR_PERSON_CREATED, - new PersonEvent($this->person, $this) - ); - - return $this->person; - } -} diff --git a/src/Sir/Partner/Component/Action/Dal/Person/DeleteAction.php b/src/Sir/Partner/Component/Action/Dal/Person/DeleteAction.php deleted file mode 100644 index 75d9e1d..0000000 --- a/src/Sir/Partner/Component/Action/Dal/Person/DeleteAction.php +++ /dev/null @@ -1,26 +0,0 @@ -fireEvent( - PersonEvents::SIR_PERSON_DELETED, - new PersonEvent($this->person, $this) - ); - } -} diff --git a/src/Sir/Partner/Component/Action/Dal/Person/UpdateAction.php b/src/Sir/Partner/Component/Action/Dal/Person/UpdateAction.php deleted file mode 100644 index 3f560d9..0000000 --- a/src/Sir/Partner/Component/Action/Dal/Person/UpdateAction.php +++ /dev/null @@ -1,30 +0,0 @@ -person->deserialize($this->serialize()); - - $this->assertEntityIsValid($this->person, array('Person', 'edition')); - - $this->fireEvent( - PersonEvents::SIR_PERSON_EDITED, - new PersonEvent($this->person, $this) - ); - } -} diff --git a/src/Sir/Partner/Component/Domain/Action/Auto/PersonActionDispatcherDomainTrait.php b/src/Sir/Partner/Component/Domain/Action/Auto/PersonActionDispatcherDomainTrait.php deleted file mode 100644 index 9097307..0000000 --- a/src/Sir/Partner/Component/Domain/Action/Auto/PersonActionDispatcherDomainTrait.php +++ /dev/null @@ -1,45 +0,0 @@ -getAction('create', null, ...$arguments) - ->resolve() - ; - } - /** - * @see PersonDomainInterface::update() - */ - public function update(Person $person, ...$arguments) - { - return $this->getAction('update', $person, ...$arguments) - ->resolve() - ; - } - /** - * @see PersonDomainInterface::delete() - */ - public function delete(Person $person, ...$arguments) - { - return $this->getAction('delete', $person, ...$arguments) - ->resolve() - ; - } -} diff --git a/src/Sir/Partner/Component/Domain/Action/PersonActionDispatcherDomain.php b/src/Sir/Partner/Component/Domain/Action/PersonActionDispatcherDomain.php deleted file mode 100644 index 501eb81..0000000 --- a/src/Sir/Partner/Component/Domain/Action/PersonActionDispatcherDomain.php +++ /dev/null @@ -1,21 +0,0 @@ -person = $person; - $this->action = $action; - } - - /** - * return related. - * - * @return Person - */ - public function getPerson() - { - return $this->person; - } - - /** - * @see BroadcastableEventInterface::getSubject() - */ - public function getSubject() - { - return $this->getPerson(); - } - - /** - * @see BroadcastableEventInterface::getAction() - */ - public function getAction() - { - return $this->action; - } -} diff --git a/src/Sir/Partner/Component/Event/PersonEvents.php b/src/Sir/Partner/Component/Event/PersonEvents.php deleted file mode 100644 index e8ae714..0000000 --- a/src/Sir/Partner/Component/Event/PersonEvents.php +++ /dev/null @@ -1,24 +0,0 @@ -prophesize(RestApiClient::class); - $restClient - ->delete(array('id' => 42)) - ->willReturn(new Response()) - ->shouldBeCalled() - ; - - // Action - $action = new DeleteAction(); - $action->init((new Person())->setId(42)); - $action->setRestApiClient($restClient->reveal()); - - $action->resolve(); - } -} diff --git a/src/Sir/Partner/Component/Tests/Action/Api/Person/UpdateActionTest.php b/src/Sir/Partner/Component/Tests/Action/Api/Person/UpdateActionTest.php deleted file mode 100644 index b77f1e2..0000000 --- a/src/Sir/Partner/Component/Tests/Action/Api/Person/UpdateActionTest.php +++ /dev/null @@ -1,72 +0,0 @@ - array( - (new Person())->setId(42), - array(), - array(), - ), - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - Person $currentPerson, - array $incommingData, - array $expectedRequestData - ) { - // Rest Client mock - $restClient = $this->prophesize(RestApiClient::class); - $restClient - ->put( - array('id' => $currentPerson->getId()), - $expectedRequestData - ) - ->willReturn(new Response()) - ->shouldBeCalled() - ; - - // Action - $action = new UpdateAction(); - $action->init($currentPerson); - $action->setRestApiClient($restClient->reveal()); - $action->deserialize($incommingData); - - $action->resolve(); - } -} diff --git a/src/Sir/Partner/Component/Tests/Action/Dal/Person/CreateActionTest.php b/src/Sir/Partner/Component/Tests/Action/Dal/Person/CreateActionTest.php deleted file mode 100644 index faccc38..0000000 --- a/src/Sir/Partner/Component/Tests/Action/Dal/Person/CreateActionTest.php +++ /dev/null @@ -1,82 +0,0 @@ - array( - array(), - new Person(), - ), - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - array $incommingData, - Person $expectedPerson - ) { - // Validator - $validator = $this->prophesize(ValidatorInterface::class); - $validator - ->validate( - Argument::type(Person::class), - null, - array('Person', 'creation') - ) - ->shouldBeCalled() - ; - - // Event dispatcher - $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); - $eventDispatcher - ->dispatch( - PersonEvents::SIR_PERSON_CREATED, - Argument::type(PersonEvent::class) - ) - ->shouldBeCalled() - ; - - // Action - $action = new CreateAction(); - $action->setEventDispatcher($eventDispatcher->reveal()); - $action->setValidator($validator->reveal()); - $action->deserialize($incommingData); - - $this->assertEquals( - $expectedPerson, - $action->resolve() - ); - } -} diff --git a/src/Sir/Partner/Component/Tests/Action/Dal/Person/DeleteActionTest.php b/src/Sir/Partner/Component/Tests/Action/Dal/Person/DeleteActionTest.php deleted file mode 100644 index 3efca73..0000000 --- a/src/Sir/Partner/Component/Tests/Action/Dal/Person/DeleteActionTest.php +++ /dev/null @@ -1,71 +0,0 @@ - array( - new Person(), - ), - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - Person $givenPerson - ) { - $asserter = $this; - - // Event dispatcher - $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); - $eventDispatcher - ->dispatch( - PersonEvents::SIR_PERSON_DELETED, - Argument::type(PersonEvent::class) - ) - ->will(function ($args) use ($asserter, $givenPerson) { - $asserter->assertEquals( - $givenPerson, - $args[1]->getPerson() - ); - }) - ->shouldBeCalled() - ; - - // Action - $action = new DeleteAction(); - $action->setEventDispatcher($eventDispatcher->reveal()); - $action->init($givenPerson); - - $action->resolve(); - } -} diff --git a/src/Sir/Partner/Component/Tests/Action/Dal/Person/UpdateActionTest.php b/src/Sir/Partner/Component/Tests/Action/Dal/Person/UpdateActionTest.php deleted file mode 100644 index a5bb346..0000000 --- a/src/Sir/Partner/Component/Tests/Action/Dal/Person/UpdateActionTest.php +++ /dev/null @@ -1,88 +0,0 @@ - array( - array(), - (new Person())->setId(42), - ), - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - array $incommingData, - Person $givenPerson - ) { - $asserter = $this; - - // Validator - $validator = $this->prophesize(ValidatorInterface::class); - $validator - ->validate( - Argument::type(Person::class), - null, - array('Person', 'edition') - ) - ->shouldBeCalled() - ; - - // Event dispatcher - $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); - $eventDispatcher - ->dispatch( - PersonEvents::SIR_PERSON_EDITED, - Argument::type(PersonEvent::class) - ) - ->will(function ($args) use ($asserter, $givenPerson) { - $asserter->assertEquals( - $givenPerson, - $args[1]->getPerson() - ); - }) - ->shouldBeCalled() - ; - - // Action - $action = new UpdateAction(); - $action->setValidator($validator->reveal()); - $action->deserialize($incommingData); - $action->setEventDispatcher($eventDispatcher->reveal()); - $action->init($givenPerson); - - $action->resolve(); - } -} diff --git a/src/Sir/Partner/Component/Tests/Entity/PersonCollectionTest.php b/src/Sir/Partner/Component/Tests/Entity/PersonCollectionTest.php deleted file mode 100644 index 9c8e8d4..0000000 --- a/src/Sir/Partner/Component/Tests/Entity/PersonCollectionTest.php +++ /dev/null @@ -1,45 +0,0 @@ -deserialize(array( - 'person_1' => array('id' => 42), - 'person_2' => array('id' => 66), - )); - - $this->assertInstanceOf( - Person::class, - $personCollection->get('person_1'), - 'Deserialization process hydrate a related entity class object and index it under given key.' - ); - $this->assertInstanceOf( - Person::class, - $personCollection->get('person_2'), - 'Deserialization process hydrate a related entity class object and index it under given key.' - ); - $this->assertEquals( - array( - 'person_1' => 42, - 'person_2' => 66, - ), - $personCollection->serialize('id'), - 'Serialization scopes are transmitted to related entity serialization process.' - ); - } -} diff --git a/src/Sir/Partner/Component/Tests/Event/PersonEventTest.php b/src/Sir/Partner/Component/Tests/Event/PersonEventTest.php deleted file mode 100644 index f83babd..0000000 --- a/src/Sir/Partner/Component/Tests/Event/PersonEventTest.php +++ /dev/null @@ -1,34 +0,0 @@ -prophesize(AbstractPersonAction::class)->reveal(); - - // Event - $event = new PersonEvent( - $person = new Person(), - $action - ); - - // Assertions - $this->assertSame($person, $event->getPerson()); - $this->assertSame($person, $event->getSubject()); - $this->assertSame($action, $event->getAction()); - } -} diff --git a/src/Sir/Partner/Component/Tests/Loader/Api/PersonApiLoaderTest.php b/src/Sir/Partner/Component/Tests/Loader/Api/PersonApiLoaderTest.php deleted file mode 100644 index 83a7cdb..0000000 --- a/src/Sir/Partner/Component/Tests/Loader/Api/PersonApiLoaderTest.php +++ /dev/null @@ -1,30 +0,0 @@ -prophesize(RestApiClient::class); - $restApiClient->send()->shouldNotBeCalled(); - - $serializer = $this->prophesize(SerializerInterface::class); - $serializer->deserialize()->shouldNotBeCalled(); - - $loader = new PersonApiLoader( - $restApiClient->reveal(), - $serializer->reveal() - ); - } -} diff --git a/src/Sir/Partner/Component/Tests/Loader/Doctrine/PersonDoctrineLoader.php b/src/Sir/Partner/Component/Tests/Loader/Doctrine/PersonDoctrineLoader.php deleted file mode 100644 index 5db6afc..0000000 --- a/src/Sir/Partner/Component/Tests/Loader/Doctrine/PersonDoctrineLoader.php +++ /dev/null @@ -1,31 +0,0 @@ -prophesize(PersonRepositoryInterface::class); - $repository->save()->shouldNotBeCalled(); - - $loader = new PersonDoctrineLoader(); - $loader->setUp( - Person::class, - array('majora' => 'entity'), - PersonCollection::class, - $repository->reveal() - ); - } -} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Auto/Person2ApiControllerTrait.php b/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Auto/Person2ApiControllerTrait.php deleted file mode 100644 index ca21dd6..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Auto/Person2ApiControllerTrait.php +++ /dev/null @@ -1,138 +0,0 @@ -query->all(), - array_flip(array('scope', 'limit', 'offset')) - ); - - return $this->createJsonResponse( - $this->container->get('sir1.person2.loader')->retrieveAll( - $this->container->get('majora.inflector')->normalize($queryFilters, 'camelize'), - $request->query->get('limit'), - $request->query->get('offset') - ), - $request->query->get('scope') - ); - } - - /** - * Returns a single Person2 by id. - * - * @param int $id requested Person2 id - * @param Request $request - * - * @return JsonResponse - */ - public function getAction($id, Request $request) - { - $person2 = $this->retrieveOr404($id, 'sir1.person2.loader'); - - return $this->createJsonResponse( - $person2, - $request->query->get('scope') - ); - } - - /** - * Creates a new Person2. - * - * @param Request $request - * - * @return JsonResponse - */ - public function postAction(Request $request) - { - // submit - $this->assertSubmitedFormIsValid($request, - $form = $this->container->get('form.factory')->createNamed( - '', - CreationType::class, - null, - array('method' => 'POST') - ) - ); - - // resolve use case - $person2 = $form->getData()->resolve(); - - return $this->createJsonResponse( - $person2, - $request->query->get('scope'), - 201 - ); - } - - /** - * Updates a single Person2 by id. - * - * @param int $id requested Person2 id - * @param Request $request - * - * @return JsonResponse - */ - public function putAction($id, Request $request) - { - // submit - $this->assertSubmitedFormIsValid($request, - $form = $this->container->get('form.factory')->createNamed( - '', - EditionType::class, - null, - array( - 'method' => 'PUT', - 'entity' => $this->retrieveOr404($id, 'sir1.person2.loader'), - ) - ) - ); - - // resolve use case - $form->getData()->resolve(); - - return $this->createJsonNoContentResponse(); - } - - /** - * Delete a single Person2 by id. - * - * @param int $id requested Person2 id - * - * @return JsonResponse - */ - public function deleteAction($id) - { - $this->container->get('sir1.person2.domain')->delete( - $this->retrieveOr404($id, 'sir1.person2.loader') - ); - - return $this->createJsonNoContentResponse(); - } -} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Person2ApiController.php b/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Person2ApiController.php deleted file mode 100644 index a23b59c..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Controller/Person2ApiController.php +++ /dev/null @@ -1,22 +0,0 @@ -root('sir1_partner3_api') - * ->children() - * ->scalarNode('...') - * ->isRequired() - * ->end() - * ->arrayNode() - * ->addDefaultsIfNotSet() - * ->children() - * // more nodes here - * ->end() - * ->end() - * ->end() - * ; - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $treeBuilder->root('sir1_partner3_api'); - - return $treeBuilder; - } -} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Sir1Partner3ApiExtension.php b/src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Sir1Partner3ApiExtension.php deleted file mode 100644 index b33fab2..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/DependencyInjection/Sir1Partner3ApiExtension.php +++ /dev/null @@ -1,28 +0,0 @@ -processConfiguration($configuration, $configs); - - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.xml'); - } -} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php deleted file mode 100644 index b0fc509..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Context/Person2Context.php +++ /dev/null @@ -1,212 +0,0 @@ -em = $em; - $this->domain = $domain; - $this->loader = $loader; - } - - /** - * @BeforeScenario - */ - public function initPerson2s() - { - $this->truncatePerson2s(); - for($i=0; $i<= self::$totalToInsert; $i++){ - $this->em->persist(new Person2()); - } - $this->em->flush(); - } - - /** - * @Given I have some person2s - * - */ - public function retrieveSomePerson2s() - { - $this->person2s = $this->em->getRepository(Person2::class)->findAll(); - } - - /** - * @Given I have created a new person2 - */ - public function insertPerson2() - { - $this->currentPerson2 = new Person2(); - $this->em->getRepository(Person2::class)->persist($this->currentPerson2); - $this->em->flush(); - $this->em->refresh($this->currentPerson2); - - $this->memoryId = $this->currentPerson2->getId(); - } - - /** - * @When I create a new person2 - */ - public function createPerson2() - { - $this->currentPerson2 = $this->domain->create(new Person2()); - } - - /** - * @When I get the person2s list - */ - public function getPerson2List() - { - $this->currentPerson2s = $this->loader->retrieveAll(); - } - - /** - * @When I get this person2 by id - */ - public function getPerson2() - { - $this->loadedPerson2 = $this->em->getRepository(Person2::class)->find($this->memoryId); - } - - /** - * @When I delete this person2 - */ - public function deletePerson2() - { - $this->domain->delete($this->currentPerson2); - } - - /** - * @When I update this person2 with a new id - */ - public function updatePerson2() - { - $this->memoryId = $this->currentPerson2->getId(); - $this->domain->update($this->currentPerson2, array("id" => ($this->currentPerson2->getId() + 1))); - } - - /** - * @Then I retrieve new person2 id - */ - public function testPerson2Id() - { - return $this->currentPerson2->getId() != null; - } - - /** - * @Then I should see a list of person2s - */ - public function compareListPerson2s() - { - return $this->currentPerson2s === $this->person2s; - } - - /** - * @Then I should see this person2 - */ - public function comparePerson2() - { - return $this->loadedPerson2 === $this->currentPerson2; - } - - /** - * @Then I should not see this person2 - */ - public function checkPerson2Deleted() - { - return is_null($this->em->getRepository(Person2::class)->find($this->memoryId)); - } - - /** - * @Then I should see the same person2 with this new id value - */ - public function checkPerson2AsUpdated() - { - return $this->memoryId === $this->currentPerson2->getId() + 1; - } - - /** - * @AfterScenario - */ - public function terminatePerson2s() - { - $this->truncatePerson2s(); - } - - /** - * Trucate all table data - * @throws \Doctrine\DBAL\DBALException - */ - private function truncatePerson2s() - { - $connection = $this->em->getConnection(); - $connection->query('SET FOREIGN_KEY_CHECKS=0'); - $this->em->createQuery('DELETE FROM Sir1\Partner3\Component\Entity\Person2')->execute(); - $connection->query('SET FOREIGN_KEY_CHECKS=1'); - $this->em->flush(); - } - -} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature b/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature deleted file mode 100644 index 34b9014..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Features/Person2.feature +++ /dev/null @@ -1,30 +0,0 @@ -@Person2 -Feature: Person2 Crud. - In order to manage person2 - As a user - I need to be able to create, update, delete and retrieve person2. - - Scenario: Create - Given I have some person2s - When I create a new person2 - Then I retrieve new person2 id - - Scenario: ReadAll - Given I have some person2s - When I get the person2s list - Then I should see a list of person2 - - Scenario: Read - Given I have created a new person2 - When I get this person2 by id - Then I should see this person2 - - Scenario: delete - Given I have created a new person2 - When I delete this person2 - Then I should not see this person2 - - Scenario: Update - Given I have created a new person2 - When I update this person2 with a new id - Then I should see the same person2 with this new id value diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/AbstractType.php b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/AbstractType.php deleted file mode 100644 index 4d6fb81..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/AbstractType.php +++ /dev/null @@ -1,52 +0,0 @@ -person2Domain = $person2Domain; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(array( - 'csrf_protection' => false, - 'allow_extra_fields' => true, - 'cascade_validation' => false, - )); - } - - /** - * Person2 form prototype definition. - * - * @warning : function auto generated by MajoraGeneratorBundle, implement your own logic here ! - * - * @see FormInterface::buildForm() - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - } -} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/CreationType.php b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/CreationType.php deleted file mode 100644 index f8110e4..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/CreationType.php +++ /dev/null @@ -1,28 +0,0 @@ -setDefaults(array( - 'data_class' => CreateAction::class, - 'empty_data' => function (FormInterface $form) { - return $this->person2Domain->getAction('create'); - }, - )); - } -} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/EditionType.php b/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/EditionType.php deleted file mode 100644 index f997266..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Form/Person2/EditionType.php +++ /dev/null @@ -1,34 +0,0 @@ -setDefaults(array( - 'data_class' => UpdateAction::class, - 'empty_data' => function (FormInterface $form) { - return $this->person2Domain->getAction( - 'update', - $form->getConfig()->getOption('entity') - ); - }, - )); - $resolver->setRequired('entity'); - $resolver->setAllowedTypes('entity', Person2::class); - } -} diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/routing.yml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/routing.yml deleted file mode 100644 index c87fac3..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/routing.yml +++ /dev/null @@ -1,2 +0,0 @@ -sir1_partner3_sdk: - resource: "@Sir1Partner3SdkBundle/Resources/config/routing.yml" diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/auto/auto_person2.xml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/auto/auto_person2.xml deleted file mode 100644 index ca6e65f..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/auto/auto_person2.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/person2.xml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/person2.xml deleted file mode 100644 index 1ab77ad..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/services/person2.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/validation/person2.yml b/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/validation/person2.yml deleted file mode 100644 index 1dd0172..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Resources/config/validation/person2.yml +++ /dev/null @@ -1,5 +0,0 @@ -Sir1\Partner3\Component\Entity\Person2: - properties: ~ - # example: - # - NotBlank: - # groups: [creation] diff --git a/src/Sir1/Partner3/Bundle/ApiBundle/Sir1Partner3ApiBundle.php b/src/Sir1/Partner3/Bundle/ApiBundle/Sir1Partner3ApiBundle.php deleted file mode 100644 index 1894056..0000000 --- a/src/Sir1/Partner3/Bundle/ApiBundle/Sir1Partner3ApiBundle.php +++ /dev/null @@ -1,12 +0,0 @@ -container = $container; - } - - /** - * @see FixtureInterface::load() - */ - public function load(ObjectManager $manager) - { - $person2Domain = $this->container->get('sir1.person2.domain'); - - // reference there Person2s data you want to create - $majoraEntities = array( - // 'person2_1' => array( - // 'hello' => 'world', - // 'foo' => 'bar', - // ) - ); - - foreach ($majoraEntities as $reference => $person2Data) { - $this->addReference( - $reference, - $person2Domain - ->getAction('create') - ->deserialize($person2Data) - ->resolve() - ); - } - } -} diff --git a/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Configuration.php b/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Configuration.php deleted file mode 100644 index 666cfe2..0000000 --- a/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Configuration.php +++ /dev/null @@ -1,41 +0,0 @@ -root('sir1_partner3_dal') - * ->children() - * ->scalarNode('...') - * ->isRequired() - * ->end() - * ->arrayNode() - * ->addDefaultsIfNotSet() - * ->children() - * // more nodes here - * ->end() - * ->end() - * ->end() - * ; - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $treeBuilder->root('sir1_partner3_dal'); - - return $treeBuilder; - } -} diff --git a/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Sir1Partner3DalExtension.php b/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Sir1Partner3DalExtension.php deleted file mode 100644 index 1086f7b..0000000 --- a/src/Sir1/Partner3/Bundle/DalBundle/DependencyInjection/Sir1Partner3DalExtension.php +++ /dev/null @@ -1,27 +0,0 @@ -processConfiguration(new Configuration(), $configs); - - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.xml'); - } -} diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Persistence/Person2PersistenceListener.php b/src/Sir1/Partner3/Bundle/DalBundle/Persistence/Person2PersistenceListener.php deleted file mode 100644 index 89a4c55..0000000 --- a/src/Sir1/Partner3/Bundle/DalBundle/Persistence/Person2PersistenceListener.php +++ /dev/null @@ -1,67 +0,0 @@ -person2Repository = $person2Repository; - } - - /** - * @see EventSubscriberInterface::getSubscribedEvents() - * - * @codeCoverageIgnore - */ - public static function getSubscribedEvents() - { - return array( - Person2Events::SIR1_PERSON2_CREATED => array('onWritePerson2', -100), - Person2Events::SIR1_PERSON2_EDITED => array('onWritePerson2', -100), - Person2Events::SIR1_PERSON2_DELETED => array('onDeletePerson2', -100), - ); - } - - /** - * Person2 writting event handler. - * - * @param Person2Event $event - */ - public function onWritePerson2(Person2Event $event) - { - $this->person2Repository->persist( - $event->getPerson2() - ); - } - - /** - * Person2 deletion event handler. - * - * @param Person2Event $event - */ - public function onDeletePerson2(Person2Event $event) - { - $this->person2Repository->remove( - $event->getPerson2() - ); - } -} diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/doctrine/Person2.orm.yml b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/doctrine/Person2.orm.yml deleted file mode 100644 index e4f5fa5..0000000 --- a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/doctrine/Person2.orm.yml +++ /dev/null @@ -1,58 +0,0 @@ -# @MajoraGenerator({"register_doctrine_em": {"target": "/config/config.yml"}}) -# @MajoraGenerator({"register_doctrine_em": {"em": "default"}}) -# @MajoraGenerator({"register_doctrine_em": {"prefix": "Sir1\\Partner3\\Component\\Entity"}}) -# @MajoraGenerator({"register_doctrine_em": {"bundle": "Sir1Partner3DalBundle"}}) -# @MajoraGenerator({"register_doctrine_em": {"alias": "Sir1Partner3"}}) - -Sir1\Partner3\Component\Entity\Person2: - type: entity - repositoryClass: Sir1\Partner3\Component\Repository\Doctrine\Person2DoctrineRepository - table: sir1_partner3_person2 - actAs: - Timestampable: ~ - id: - id: - type: integer - generator: { strategy: AUTO } - fields: - - # your other Person2 properties here - - createdAt: - type: datetime - column: created_at - gedmo: - timestampable: - on: create - updatedAt: - type: datetime - column: updated_at - gedmo: - timestampable: - on: update - - # manyToOne: - # example: - # targetEntity: Example - # inversedBy: person2s - # joinColumn: - # name: example_id - # referencedColumnName: id - - # oneToMany: - # examples: - # targetEntity: Example - # mappedBy: person2 - # cascade: ['persist', 'remove'] - - # manyToMany: - # examples: - # targetEntity: Example - # joinTable: - # name: sir1_partner3_person2_example - # joinColumns: - # person2_id: - # referencedColumnName: id - # inverseJoinColumns: - # example_id: - # referencedColumnName: id diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/auto/auto_person2.xml b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/auto/auto_person2.xml deleted file mode 100644 index 3cda1fa..0000000 --- a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/auto/auto_person2.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Sir1Partner3:Person2 - default - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/person2.xml b/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/person2.xml deleted file mode 100644 index 1ab77ad..0000000 --- a/src/Sir1/Partner3/Bundle/DalBundle/Resources/config/services/person2.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sir1/Partner3/Bundle/DalBundle/Sir1Partner3DalBundle.php b/src/Sir1/Partner3/Bundle/DalBundle/Sir1Partner3DalBundle.php deleted file mode 100644 index ec9698e..0000000 --- a/src/Sir1/Partner3/Bundle/DalBundle/Sir1Partner3DalBundle.php +++ /dev/null @@ -1,12 +0,0 @@ -root('sir1_partner3_sdk') - * ->children() - * ->scalarNode('...') - * ->isRequired() - * ->end() - * ->arrayNode() - * ->addDefaultsIfNotSet() - * ->children() - * // more nodes here - * ->end() - * ->end() - * ->end() - * ; - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $treeBuilder->root('sir1_partner3_sdk'); - - return $treeBuilder; - } -} diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Sir1Partner3SdkExtension.php b/src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Sir1Partner3SdkExtension.php deleted file mode 100644 index 330dceb..0000000 --- a/src/Sir1/Partner3/Bundle/SdkBundle/DependencyInjection/Sir1Partner3SdkExtension.php +++ /dev/null @@ -1,27 +0,0 @@ -processConfiguration(new Configuration(), $configs); - - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.xml'); - } -} diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing.yml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing.yml deleted file mode 100644 index edace8b..0000000 --- a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing.yml +++ /dev/null @@ -1,4 +0,0 @@ - -sir1_person2_sdk: - resource: "routing/person2.yml" - prefix: /person2s diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/auto/auto_person2.yml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/auto/auto_person2.yml deleted file mode 100644 index afaacfa..0000000 --- a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/auto/auto_person2.yml +++ /dev/null @@ -1,42 +0,0 @@ -# @MajoraGenerator({"force_generation": true}) - -sir1_api_person2_collection: - path: / - defaults: - _controller: Sir1Partner3ApiBundle:Person2Api:cget - methods: - - GET - -sir1_api_person2_create: - path: / - defaults: - _controller: Sir1Partner3ApiBundle:Person2Api:post - methods: - - POST - -sir1_api_person2_read: - path: /{id} - defaults: - _controller: Sir1Partner3ApiBundle:Person2Api:get - requirements: - id: \d+ - methods: - - GET - -sir1_api_person2_update: - path: /{id} - defaults: - _controller: Sir1Partner3ApiBundle:Person2Api:put - requirements: - id: \d+ - methods: - - PUT - -sir1_api_person2_delete: - path: /{id} - defaults: - _controller: Sir1Partner3ApiBundle:Person2Api:delete - requirements: - id: \d+ - methods: - - DELETE diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/person2.yml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/person2.yml deleted file mode 100644 index c118c97..0000000 --- a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/routing/person2.yml +++ /dev/null @@ -1,8 +0,0 @@ -# @MajoraGenerator({"include_routing": {"target": "../routing.yml"}}) -# @MajoraGenerator({"include_routing": {"route": "sir1_person2_sdk"}}) -# @MajoraGenerator({"include_routing": {"resource": "routing/person2.yml"}}) -# @MajoraGenerator({"include_routing": {"prefix": "/person2s"}}) - -# generated routes -auto_sir1_person2_sdk: - resource: "@Sir1Partner3SdkBundle/Resources/config/routing/auto/auto_person2.yml" diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services.xml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services.xml deleted file mode 100644 index 369892f..0000000 --- a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/auto/auto_person2.xml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/auto/auto_person2.xml deleted file mode 100644 index 6875f88..0000000 --- a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/auto/auto_person2.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - sir1_api_person2_collection - sir1_api_person2_create - sir1_api_person2_read - sir1_api_person2_update - sir1_api_person2_delete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/person2.xml b/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/person2.xml deleted file mode 100644 index 1ab77ad..0000000 --- a/src/Sir1/Partner3/Bundle/SdkBundle/Resources/config/services/person2.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sir1/Partner3/Bundle/SdkBundle/Sir1Partner3SdkBundle.php b/src/Sir1/Partner3/Bundle/SdkBundle/Sir1Partner3SdkBundle.php deleted file mode 100644 index c11da54..0000000 --- a/src/Sir1/Partner3/Bundle/SdkBundle/Sir1Partner3SdkBundle.php +++ /dev/null @@ -1,12 +0,0 @@ -person2 = $person2; - - return $this; - } - - /** - * Return related Person2 if defined. - * - * @return Person2|null $person2 - */ - public function getPerson2() - { - return $this->person2; - } -} diff --git a/src/Sir1/Partner3/Component/Action/Api/Person2/AbstractApiAction.php b/src/Sir1/Partner3/Component/Action/Api/Person2/AbstractApiAction.php deleted file mode 100644 index 028b50a..0000000 --- a/src/Sir1/Partner3/Component/Action/Api/Person2/AbstractApiAction.php +++ /dev/null @@ -1,14 +0,0 @@ -getRestApiClient()->post( - array(), - $this->serialize() - ); - - // parsing response - $this->person2 = $this->getSerializer()->deserialize( - (string) $response->getBody(), - Person2::class, - 'json' - ); - - return $this->person2; - } -} diff --git a/src/Sir1/Partner3/Component/Action/Api/Person2/DeleteAction.php b/src/Sir1/Partner3/Component/Action/Api/Person2/DeleteAction.php deleted file mode 100644 index 7e86a41..0000000 --- a/src/Sir1/Partner3/Component/Action/Api/Person2/DeleteAction.php +++ /dev/null @@ -1,28 +0,0 @@ -getRestApiClient()->delete( - array('id' => $this->person2->getId()) - ); - } -} diff --git a/src/Sir1/Partner3/Component/Action/Api/Person2/UpdateAction.php b/src/Sir1/Partner3/Component/Action/Api/Person2/UpdateAction.php deleted file mode 100644 index af1e6c3..0000000 --- a/src/Sir1/Partner3/Component/Action/Api/Person2/UpdateAction.php +++ /dev/null @@ -1,48 +0,0 @@ -getRestApiClient()->put( - array('id' => $this->person2->getId()), - $this->serialize() - ); - - // Generic Person2 hydration from this action magic accessors - $this->person2 = $this->getSerializer()->deserialize( - (string) $this->getSerializer()->serialize($this, 'json'), - Person2::class, - 'json' - ); - } -} diff --git a/src/Sir1/Partner3/Component/Action/Dal/Person2/AbstractDalAction.php b/src/Sir1/Partner3/Component/Action/Dal/Person2/AbstractDalAction.php deleted file mode 100644 index a16864b..0000000 --- a/src/Sir1/Partner3/Component/Action/Dal/Person2/AbstractDalAction.php +++ /dev/null @@ -1,16 +0,0 @@ -person2 = new Person2(); - $this->person2->deserialize($this->serialize()); - - $this->assertEntityIsValid($this->person2, array('Person2', 'creation')); - - $this->fireEvent( - Person2Events::SIR1_PERSON2_CREATED, - new Person2Event($this->person2, $this) - ); - - return $this->person2; - } -} diff --git a/src/Sir1/Partner3/Component/Action/Dal/Person2/DeleteAction.php b/src/Sir1/Partner3/Component/Action/Dal/Person2/DeleteAction.php deleted file mode 100644 index e8b4627..0000000 --- a/src/Sir1/Partner3/Component/Action/Dal/Person2/DeleteAction.php +++ /dev/null @@ -1,26 +0,0 @@ -fireEvent( - Person2Events::SIR1_PERSON2_DELETED, - new Person2Event($this->person2, $this) - ); - } -} diff --git a/src/Sir1/Partner3/Component/Action/Dal/Person2/UpdateAction.php b/src/Sir1/Partner3/Component/Action/Dal/Person2/UpdateAction.php deleted file mode 100644 index 62d0a3b..0000000 --- a/src/Sir1/Partner3/Component/Action/Dal/Person2/UpdateAction.php +++ /dev/null @@ -1,30 +0,0 @@ -person2->deserialize($this->serialize()); - - $this->assertEntityIsValid($this->person2, array('Person2', 'edition')); - - $this->fireEvent( - Person2Events::SIR1_PERSON2_EDITED, - new Person2Event($this->person2, $this) - ); - } -} diff --git a/src/Sir1/Partner3/Component/Domain/Action/Auto/Person2ActionDispatcherDomainTrait.php b/src/Sir1/Partner3/Component/Domain/Action/Auto/Person2ActionDispatcherDomainTrait.php deleted file mode 100644 index 1c5725f..0000000 --- a/src/Sir1/Partner3/Component/Domain/Action/Auto/Person2ActionDispatcherDomainTrait.php +++ /dev/null @@ -1,45 +0,0 @@ -getAction('create', null, ...$arguments) - ->resolve() - ; - } - /** - * @see Person2DomainInterface::update() - */ - public function update(Person2 $person2, ...$arguments) - { - return $this->getAction('update', $person2, ...$arguments) - ->resolve() - ; - } - /** - * @see Person2DomainInterface::delete() - */ - public function delete(Person2 $person2, ...$arguments) - { - return $this->getAction('delete', $person2, ...$arguments) - ->resolve() - ; - } -} diff --git a/src/Sir1/Partner3/Component/Domain/Action/Person2ActionDispatcherDomain.php b/src/Sir1/Partner3/Component/Domain/Action/Person2ActionDispatcherDomain.php deleted file mode 100644 index 1c88d87..0000000 --- a/src/Sir1/Partner3/Component/Domain/Action/Person2ActionDispatcherDomain.php +++ /dev/null @@ -1,21 +0,0 @@ - 'id', - 'default' => array('id'), - ); - } - - /** - * Returns Person2 id. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Define Person2 id. - * - * @param int $id - * - * @return self - */ - public function setId($id) - { - $this->id = $id; - - return $this; - } - - // ************************************************* - // - // Class auto generated by MajoraGeneratorBundle - // Implement your own logic here ! - // - // ************************************************* -} diff --git a/src/Sir1/Partner3/Component/Entity/Person2Collection.php b/src/Sir1/Partner3/Component/Entity/Person2Collection.php deleted file mode 100644 index 36ed0cd..0000000 --- a/src/Sir1/Partner3/Component/Entity/Person2Collection.php +++ /dev/null @@ -1,19 +0,0 @@ -person2 = $person2; - $this->action = $action; - } - - /** - * return related. - * - * @return Person2 - */ - public function getPerson2() - { - return $this->person2; - } - - /** - * @see BroadcastableEventInterface::getSubject() - */ - public function getSubject() - { - return $this->getPerson2(); - } - - /** - * @see BroadcastableEventInterface::getAction() - */ - public function getAction() - { - return $this->action; - } -} diff --git a/src/Sir1/Partner3/Component/Event/Person2Events.php b/src/Sir1/Partner3/Component/Event/Person2Events.php deleted file mode 100644 index 1e7abb4..0000000 --- a/src/Sir1/Partner3/Component/Event/Person2Events.php +++ /dev/null @@ -1,24 +0,0 @@ - array( - array(), - array(), - $person2 = (new Person2())->setId(42), - $person2, - ), - - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - array $incommingData, - array $expectedRequestData, - Person2 $createdPerson2, - Person2 $expectedPerson2 - ) { - // Rest Client mock - $restClient = $this->prophesize(RestApiClient::class); - $restClient - ->post(array(), $expectedRequestData) - ->willReturn(new Response()) - ->shouldBeCalled() - ; - - // Serializer mock - $serializer = $this->prophesize(SerializerInterface::class); - $serializer - ->deserialize(Argument::any(), Person2::class, Argument::any()) - ->willReturn($createdPerson2) - ; - - // Action - $action = new CreateAction(); - $action->setSerializer($serializer->reveal()); - $action->setRestApiClient($restClient->reveal()); - $action->deserialize($incommingData); - - $this->assertEquals( - $expectedPerson2, - $action->resolve() - ); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/DeleteActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/DeleteActionTest.php deleted file mode 100644 index f507a4d..0000000 --- a/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/DeleteActionTest.php +++ /dev/null @@ -1,39 +0,0 @@ -prophesize(RestApiClient::class); - $restClient - ->delete(array('id' => 42)) - ->willReturn(new Response()) - ->shouldBeCalled() - ; - - // Action - $action = new DeleteAction(); - $action->init((new Person2())->setId(42)); - $action->setRestApiClient($restClient->reveal()); - - $action->resolve(); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/UpdateActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/UpdateActionTest.php deleted file mode 100644 index 8b9622d..0000000 --- a/src/Sir1/Partner3/Component/Tests/Action/Api/Person2/UpdateActionTest.php +++ /dev/null @@ -1,72 +0,0 @@ - array( - (new Person2())->setId(42), - array(), - array(), - ), - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - Person2 $currentPerson2, - array $incommingData, - array $expectedRequestData - ) { - // Rest Client mock - $restClient = $this->prophesize(RestApiClient::class); - $restClient - ->put( - array('id' => $currentPerson2->getId()), - $expectedRequestData - ) - ->willReturn(new Response()) - ->shouldBeCalled() - ; - - // Action - $action = new UpdateAction(); - $action->init($currentPerson2); - $action->setRestApiClient($restClient->reveal()); - $action->deserialize($incommingData); - - $action->resolve(); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/CreateActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/CreateActionTest.php deleted file mode 100644 index d8a57fb..0000000 --- a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/CreateActionTest.php +++ /dev/null @@ -1,82 +0,0 @@ - array( - array(), - new Person2(), - ), - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - array $incommingData, - Person2 $expectedPerson2 - ) { - // Validator - $validator = $this->prophesize(ValidatorInterface::class); - $validator - ->validate( - Argument::type(Person2::class), - null, - array('Person2', 'creation') - ) - ->shouldBeCalled() - ; - - // Event dispatcher - $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); - $eventDispatcher - ->dispatch( - Person2Events::SIR1_PERSON2_CREATED, - Argument::type(Person2Event::class) - ) - ->shouldBeCalled() - ; - - // Action - $action = new CreateAction(); - $action->setEventDispatcher($eventDispatcher->reveal()); - $action->setValidator($validator->reveal()); - $action->deserialize($incommingData); - - $this->assertEquals( - $expectedPerson2, - $action->resolve() - ); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/DeleteActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/DeleteActionTest.php deleted file mode 100644 index c66d1d7..0000000 --- a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/DeleteActionTest.php +++ /dev/null @@ -1,71 +0,0 @@ - array( - new Person2(), - ), - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - Person2 $givenPerson2 - ) { - $asserter = $this; - - // Event dispatcher - $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); - $eventDispatcher - ->dispatch( - Person2Events::SIR1_PERSON2_DELETED, - Argument::type(Person2Event::class) - ) - ->will(function ($args) use ($asserter, $givenPerson2) { - $asserter->assertEquals( - $givenPerson2, - $args[1]->getPerson2() - ); - }) - ->shouldBeCalled() - ; - - // Action - $action = new DeleteAction(); - $action->setEventDispatcher($eventDispatcher->reveal()); - $action->init($givenPerson2); - - $action->resolve(); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/UpdateActionTest.php b/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/UpdateActionTest.php deleted file mode 100644 index 10dbb6c..0000000 --- a/src/Sir1/Partner3/Component/Tests/Action/Dal/Person2/UpdateActionTest.php +++ /dev/null @@ -1,88 +0,0 @@ - array( - array(), - (new Person2())->setId(42), - ), - ); - } - - /** - * Tests resolve() function. - * - * @dataProvider resolvingCasesProvider - */ - public function testResolve( - array $incommingData, - Person2 $givenPerson2 - ) { - $asserter = $this; - - // Validator - $validator = $this->prophesize(ValidatorInterface::class); - $validator - ->validate( - Argument::type(Person2::class), - null, - array('Person2', 'edition') - ) - ->shouldBeCalled() - ; - - // Event dispatcher - $eventDispatcher = $this->prophesize(EventDispatcherInterface::class); - $eventDispatcher - ->dispatch( - Person2Events::SIR1_PERSON2_EDITED, - Argument::type(Person2Event::class) - ) - ->will(function ($args) use ($asserter, $givenPerson2) { - $asserter->assertEquals( - $givenPerson2, - $args[1]->getPerson2() - ); - }) - ->shouldBeCalled() - ; - - // Action - $action = new UpdateAction(); - $action->setValidator($validator->reveal()); - $action->deserialize($incommingData); - $action->setEventDispatcher($eventDispatcher->reveal()); - $action->init($givenPerson2); - - $action->resolve(); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Entity/Person2CollectionTest.php b/src/Sir1/Partner3/Component/Tests/Entity/Person2CollectionTest.php deleted file mode 100644 index 0efa6f9..0000000 --- a/src/Sir1/Partner3/Component/Tests/Entity/Person2CollectionTest.php +++ /dev/null @@ -1,45 +0,0 @@ -deserialize(array( - 'person2_1' => array('id' => 42), - 'person2_2' => array('id' => 66), - )); - - $this->assertInstanceOf( - Person2::class, - $person2Collection->get('person2_1'), - 'Deserialization process hydrate a related entity class object and index it under given key.' - ); - $this->assertInstanceOf( - Person2::class, - $person2Collection->get('person2_2'), - 'Deserialization process hydrate a related entity class object and index it under given key.' - ); - $this->assertEquals( - array( - 'person2_1' => 42, - 'person2_2' => 66, - ), - $person2Collection->serialize('id'), - 'Serialization scopes are transmitted to related entity serialization process.' - ); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Entity/Person2Test.php b/src/Sir1/Partner3/Component/Tests/Entity/Person2Test.php deleted file mode 100644 index 85dedf5..0000000 --- a/src/Sir1/Partner3/Component/Tests/Entity/Person2Test.php +++ /dev/null @@ -1,128 +0,0 @@ -person2 = new Person2(); - $this->reflector = new \ReflectionClass($this->person2); - } - - /** - * Provider for accessor tests. - * - * @return array - */ - public function propertyMapProvider() - { - return array( - 'id' => array('id', 42), - ); - } - - /** - * Tests setters. - * - * @dataProvider propertyMapProvider - */ - public function testSet($propertyName, $definedValue) - { - $property = $this->reflector->getProperty($propertyName); - $property->setAccessible(true); - - $method = 'set'.ucfirst($propertyName); - $this->person2->$method($definedValue); - $this->assertEquals( - $definedValue, - $property->getValue($this->person2), - sprintf('Person2::%s() defines "%s" property current value.', - $method, - $propertyName - ) - ); - } - - /** - * Tests getters. - * - * @dataProvider propertyMapProvider - */ - public function testGet($propertyName, $expectedValue) - { - $property = $this->reflector->getProperty($propertyName); - $property->setAccessible(true); - $property->setValue($this->person2, $expectedValue); - - $method = 'get'.ucfirst($propertyName); - $this->assertEquals( - $expectedValue, - $this->person2->$method(), - sprintf('Person2::%s() returns current defined "%s" property value.', - $method, - $propertyName - ) - ); - } - - /** - * Provider for serialization tests. - * - * @return array() - */ - public function serializationCasesProvider() - { - return array( - 'id' => array('id', 'int'), - 'default' => array('default', array('id')), - ); - } - - /** - * Tests serialization scopes. - * - * @dataProvider serializationCasesProvider - */ - public function testSerializationScopes($scope, $expectedKeys) - { - $this->person2->setId(42); - $person2Data = $this->person2->serialize($scope); - - if (!is_array($expectedKeys)) { - return $this->assertInternalType( - $expectedKeys, - $person2Data, - sprintf('Person2 "%s" scope provides a single value as %s.', $scope, $expectedKeys) - ); - } - - foreach ($expectedKeys as $expectedKey) { - $this->assertArrayHasKey( - $expectedKey, - $person2Data, - sprintf('Person2 "%s" scope provides an array with "%s" key.', $scope, $expectedKey) - ); - } - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Event/Person2EventTest.php b/src/Sir1/Partner3/Component/Tests/Event/Person2EventTest.php deleted file mode 100644 index 5189286..0000000 --- a/src/Sir1/Partner3/Component/Tests/Event/Person2EventTest.php +++ /dev/null @@ -1,34 +0,0 @@ -prophesize(AbstractPerson2Action::class)->reveal(); - - // Event - $event = new Person2Event( - $person2 = new Person2(), - $action - ); - - // Assertions - $this->assertSame($person2, $event->getPerson2()); - $this->assertSame($person2, $event->getSubject()); - $this->assertSame($action, $event->getAction()); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Loader/Api/Person2ApiLoaderTest.php b/src/Sir1/Partner3/Component/Tests/Loader/Api/Person2ApiLoaderTest.php deleted file mode 100644 index 2a91d8f..0000000 --- a/src/Sir1/Partner3/Component/Tests/Loader/Api/Person2ApiLoaderTest.php +++ /dev/null @@ -1,30 +0,0 @@ -prophesize(RestApiClient::class); - $restApiClient->send()->shouldNotBeCalled(); - - $serializer = $this->prophesize(SerializerInterface::class); - $serializer->deserialize()->shouldNotBeCalled(); - - $loader = new Person2ApiLoader( - $restApiClient->reveal(), - $serializer->reveal() - ); - } -} diff --git a/src/Sir1/Partner3/Component/Tests/Loader/Doctrine/Person2DoctrineLoader.php b/src/Sir1/Partner3/Component/Tests/Loader/Doctrine/Person2DoctrineLoader.php deleted file mode 100644 index d505da9..0000000 --- a/src/Sir1/Partner3/Component/Tests/Loader/Doctrine/Person2DoctrineLoader.php +++ /dev/null @@ -1,31 +0,0 @@ -prophesize(Person2RepositoryInterface::class); - $repository->save()->shouldNotBeCalled(); - - $loader = new Person2DoctrineLoader(); - $loader->setUp( - Person2::class, - array('majora' => 'entity'), - Person2Collection::class, - $repository->reveal() - ); - } -} From 94ce4c50692aaab5d534aff59bacf2133e4359b9 Mon Sep 17 00:00:00 2001 From: Raphael Trzpit Date: Fri, 29 Jul 2016 16:34:52 +0200 Subject: [PATCH 06/11] README --- README.md | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bc4401f..5fec6e7 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,29 @@ -BehatSandbox -======================== +# Behat Skeleton -Basic implementations with Majora Skeleton +Ceci est un example pour l'implémentation d'un skeleton Majora avec un bootstrap pour les tests Behat. -3 suites for the post entity: - - post_dal_domain (to test internal domain) - - post_api_controller (to test api) - - post_api_domain (to test sdk) +Pour faire fonctionner les tests behat, il vous faudra configurer le fichier behat.yml à la racine de votre projet de la manière suivante : -1 feature in Lv\Acme\Bundle\ApiBundle\Features +```yml +imports: + - app/config/parameters.yml -4 contexts: - - PostContext : basic actions for every suite - - PostApiContext : context to test the api - - PostDomainContext : context to test the dal and api domains - - PostRouterContext : just to configure majora router, perhaps not needed, obviously must be refacto as an extension if needed. +default: + autoload: + '': %paths.base%/src + extensions: + Behat\Symfony2Extension: ~ # Using the Symfony Extension + suites: + dal_domain: # Name your suite as you wish. + type: symfony_bundle + bundle: LvExampleDalBundle # Your generated bundle + paths: + - %paths.base%/src/Lv/Example/Bundle/ApiBundle/Features # Path to your generated features + contexts: + - Lv\Example\Bundle\ApiBundle\Features\Context\EntityContext: # Class of your generated entity context + domain: '@lv.entity.domain' # Domain service of your generated entity (majora_vendor.majora_entity.domain) + loader: '@Lv.entity.loader' # Loader service of your generated entity (majora_vendor.majora_entity.domain) + em: '@doctrine.orm.entity_manager' # Doctrine entity manager +``` +Libre à vous ensuite de compléter ces tests avec vos règles métiers. From f8ea0816cf368fa157ca236e4c44a3c25af404b9 Mon Sep 17 00:00:00 2001 From: Raphael Trzpit Date: Fri, 29 Jul 2016 17:52:41 +0200 Subject: [PATCH 07/11] Add generator annotation for behat.yml --- .../Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php | 1 + 1 file changed, 1 insertion(+) diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php index 758b83a..e7cdf12 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php @@ -6,6 +6,7 @@ /** * @MajoraGenerator({"register_bundle": {"target": "\\AppKernel"}}) + * @MajoraGenerator({"register_behat": {"target": "behat.yml", "context": "MajoraVendor\\MajoraNamespace\\Bundle\\ApiBundle\\Features\\Context\\MajoraEntityContext", "path": "%paths.base%/src/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features", "domain": "@MajoraVendor.MajoraEntity.domain", "loader": "@MajoraVendor.MajoraEntity.loader"}}) */ class MajoraVendorMajoraNamespaceApiBundle extends Bundle { From ffe845112076c236629343654ddf962d769f52fb Mon Sep 17 00:00:00 2001 From: Raphael Trzpit Date: Fri, 29 Jul 2016 17:56:27 +0200 Subject: [PATCH 08/11] Update majora generator --- composer.json | 2 +- composer.lock | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index a8cfb20..3ea6dd0 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require-dev": { "sensio/generator-bundle": "^3.0", "symfony/phpunit-bridge": "^3.0", - "majora/generator-bundle": "dev-master", + "majora/generator-bundle": "dev-feature/add-behat-generator", "behat/behat": "dev-master", "behat/symfony2-extension": "dev-master", "behat/mink-extension": "^2.1", diff --git a/composer.lock b/composer.lock index d6b9ef4..ac1f563 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "5cdf383ad2b9247c93eba68c440cd164", - "content-hash": "4107798a24c21254032eef520c2ef0f7", + "hash": "c3972cbf42f891378c9d935c8a97384f", + "content-hash": "4fbd5a18f391b40a50b4fd1294193e7a", "packages": [ { "name": "behat/transliterator", @@ -2676,20 +2676,20 @@ }, { "name": "majora/generator-bundle", - "version": "dev-master", + "version": "dev-feature/add-behat-generator", "source": { "type": "git", "url": "https://github.com/LinkValue/MajoraGeneratorBundle.git", - "reference": "73b1563455aaf76acfd77bd789479bacef53ec47" + "reference": "9571e962426be7417e7116a45d455448cc78bdf7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/LinkValue/MajoraGeneratorBundle/zipball/73b1563455aaf76acfd77bd789479bacef53ec47", - "reference": "73b1563455aaf76acfd77bd789479bacef53ec47", + "url": "https://api.github.com/repos/LinkValue/MajoraGeneratorBundle/zipball/9571e962426be7417e7116a45d455448cc78bdf7", + "reference": "9571e962426be7417e7116a45d455448cc78bdf7", "shasum": "" }, "require": { - "majora/framework-extra-bundle": ">=1.0", + "majora/framework-extra-bundle": "*", "php": ">=5.6", "sensio/generator-bundle": ">=2.7" }, @@ -2724,7 +2724,7 @@ "generator", "symfony" ], - "time": "2016-03-11 08:35:35" + "time": "2016-07-29 15:50:31" }, { "name": "sensio/generator-bundle", From 32bd9018fcf834068249ebd841b4f4a2db5a7e5f Mon Sep 17 00:00:00 2001 From: Raphael Trzpit Date: Fri, 29 Jul 2016 17:57:47 +0200 Subject: [PATCH 09/11] Move annotation to EntityContext --- .../Bundle/ApiBundle/Features/Context/MajoraEntityContext.php | 1 + .../Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php index 3c79cec..727aa72 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php @@ -12,6 +12,7 @@ /** * Defines application features from the specific context. + * @MajoraGenerator({"register_behat": {"target": "behat.yml", "context": "MajoraVendor\\MajoraNamespace\\Bundle\\ApiBundle\\Features\\Context\\MajoraEntityContext", "path": "%paths.base%/src/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features", "domain": "@MajoraVendor.MajoraEntity.domain", "loader": "@MajoraVendor.MajoraEntity.loader"}}) */ class MajoraEntityContext implements Context { diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php index e7cdf12..758b83a 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/MajoraVendorMajoraNamespaceApiBundle.php @@ -6,7 +6,6 @@ /** * @MajoraGenerator({"register_bundle": {"target": "\\AppKernel"}}) - * @MajoraGenerator({"register_behat": {"target": "behat.yml", "context": "MajoraVendor\\MajoraNamespace\\Bundle\\ApiBundle\\Features\\Context\\MajoraEntityContext", "path": "%paths.base%/src/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features", "domain": "@MajoraVendor.MajoraEntity.domain", "loader": "@MajoraVendor.MajoraEntity.loader"}}) */ class MajoraVendorMajoraNamespaceApiBundle extends Bundle { From 5f3a9e1720b7b83f7a30d3fe620138f1ab33db9e Mon Sep 17 00:00:00 2001 From: Raphael Trzpit Date: Fri, 29 Jul 2016 18:05:29 +0200 Subject: [PATCH 10/11] Update composer.lock --- composer.lock | 8 ++++---- .../ApiBundle/Features/Context/MajoraEntityContext.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index ac1f563..2c728ce 100644 --- a/composer.lock +++ b/composer.lock @@ -2680,12 +2680,12 @@ "source": { "type": "git", "url": "https://github.com/LinkValue/MajoraGeneratorBundle.git", - "reference": "9571e962426be7417e7116a45d455448cc78bdf7" + "reference": "0ff9561e9bf07426213fd28eae5ef83937456ef9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/LinkValue/MajoraGeneratorBundle/zipball/9571e962426be7417e7116a45d455448cc78bdf7", - "reference": "9571e962426be7417e7116a45d455448cc78bdf7", + "url": "https://api.github.com/repos/LinkValue/MajoraGeneratorBundle/zipball/0ff9561e9bf07426213fd28eae5ef83937456ef9", + "reference": "0ff9561e9bf07426213fd28eae5ef83937456ef9", "shasum": "" }, "require": { @@ -2724,7 +2724,7 @@ "generator", "symfony" ], - "time": "2016-07-29 15:50:31" + "time": "2016-07-29 16:00:48" }, { "name": "sensio/generator-bundle", diff --git a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php index 727aa72..a6802a9 100644 --- a/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php +++ b/skeletons/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features/Context/MajoraEntityContext.php @@ -12,7 +12,7 @@ /** * Defines application features from the specific context. - * @MajoraGenerator({"register_behat": {"target": "behat.yml", "context": "MajoraVendor\\MajoraNamespace\\Bundle\\ApiBundle\\Features\\Context\\MajoraEntityContext", "path": "%paths.base%/src/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features", "domain": "@MajoraVendor.MajoraEntity.domain", "loader": "@MajoraVendor.MajoraEntity.loader"}}) + * @MajoraGenerator({"register_behat": {"target": "/config/behat.yml", "context": "MajoraVendor\\MajoraNamespace\\Bundle\\ApiBundle\\Features\\Context\\MajoraEntityContext", "path": "%paths.base%/src/MajoraVendor/MajoraNamespace/Bundle/ApiBundle/Features", "domain": "MajoraVendor.MajoraEntity.domain", "loader": "MajoraVendor.MajoraEntity.loader"}}) */ class MajoraEntityContext implements Context { From 241887f9f64b3ce3fe273b68563b9790ad87cd78 Mon Sep 17 00:00:00 2001 From: Raphael Trzpit Date: Fri, 29 Jul 2016 18:16:15 +0200 Subject: [PATCH 11/11] Changes behat.yml --- app/config/behat.yml | 19 +++++++++++++++++++ behat.yml | 19 +------------------ 2 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 app/config/behat.yml diff --git a/app/config/behat.yml b/app/config/behat.yml new file mode 100644 index 0000000..2779ed3 --- /dev/null +++ b/app/config/behat.yml @@ -0,0 +1,19 @@ +imports: + - app/config/parameters.yml + +default: + autoload: + '': %paths.base%/src + extensions: + Behat\Symfony2Extension: ~ + suites: + dal_domain: + type: symfony_bundle + bundle: Sir1Partner3DalBundle + paths: + - %paths.base%/src/Sir1/Partner3/Bundle/ApiBundle/Features + contexts: + - Sir1\Partner3\Bundle\ApiBundle\Features\Context\Person2Context: + domain: '@sir1.person2.domain' + loader: '@sir1.person2.loader' + em: '@doctrine.orm.entity_manager' diff --git a/behat.yml b/behat.yml index 4d67ff5..d18676f 100644 --- a/behat.yml +++ b/behat.yml @@ -1,19 +1,2 @@ imports: - - app/config/parameters.yml - -default: - autoload: - '': %paths.base%/src - extensions: - Behat\Symfony2Extension: ~ - suites: - dal_domain: - type: symfony_bundle - bundle: LvExampleDalBundle - paths: - - %paths.base%/src/Lv/Example/Bundle/ApiBundle/Features - contexts: - - Lv\Example\Bundle\ApiBundle\Features\Context\EntityContext: - domain: '@lv.entity.domain' - loader: '@Lv.entity.loader' - em: '@doctrine.orm.entity_manager' + - app/config/behat.yml