Example #1
0
 public function getServiceConfig()
 {
     return array('invokables' => array(), 'factories' => array('product_service' => function ($sm) {
         $service = new ProductService();
         $service->setServiceManager($sm);
         $provider = new ProductProvider();
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $provider->setEntityManager($em);
         $service->setProvider($provider);
         return $service;
     }, 'category_service' => function ($sm) {
         $service = new CategoryService();
         $service->setServiceManager($sm);
         $provider = new CategoryProvider();
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $provider->setEntityManager($em);
         $service->setProvider($provider);
         return $service;
     }, 'catalog_product_form' => function ($sm) {
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $form = new ProductForm($em);
         return $form;
     }, 'catalog_category_form' => function ($sm) {
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $form = new CategoryForm($em);
         return $form;
     }, 'default_hydrator' => function ($sm) {
         $hydrator = new ClassMethods();
         return $hydrator;
     }));
 }
 public function setUp()
 {
     $this->setApplicationConfig(include 'config/application.config.php');
     $service = new ProductService();
     $formHydrator = $this->getMock('Zend\\Stdlib\\Hydrator\\HydratorInterface');
     $this->formHydrator = $formHydrator;
     $provider = $this->getMock('Catalog\\Provider\\ProductProvider');
     $serviceManager = $this->getApplicationServiceLocator();
     $this->serviceManager = $serviceManager;
     $serviceManager->setAllowOverride(true);
     $entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
     $this->entityManager = $entityManager;
     $service->setServiceManager($serviceManager);
     $service->setFormHydrator($formHydrator);
     $provider->setEntityManager($entityManager);
     $this->provider = $provider;
     $service->setProvider($provider);
     $this->service = $service;
     parent::setUp();
 }