/**
  * @covers \RcmI18n\Factory\RemoteLoaderDoctrineDbLoaderFactory
  */
 function testCreateService()
 {
     $sm = new ServiceManager();
     $sm->setService('Doctrine\\ORM\\EntityManager', $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock());
     $loadPluginMgr = new LoaderPluginManager();
     $loadPluginMgr->setServiceLocator($sm);
     $unit = new RemoteLoaderDoctrineDbLoaderFactory();
     $this->assertInstanceOf('RcmI18n\\RemoteLoader\\DoctrineDbLoader', $unit->createService($loadPluginMgr));
 }
 /**
  * @covers RcmI18n\Factory\TranslateHtmlFactory
  */
 function testCreateService()
 {
     $sm = new ServiceManager();
     $sm->setService('RcmHtmlPurifier', $this->getMockBuilder('\\HtmlPurifier')->disableOriginalConstructor()->setMethods(['purify'])->getMock());
     $viewSm = new LoaderPluginManager();
     $viewSm->setServiceLocator($sm);
     $unit = new TranslateHtmlFactory();
     $this->assertInstanceOf('RcmI18n\\ViewHelper\\TranslateHtml', $unit->createService($viewSm));
 }
Exemplo n.º 3
0
 /**
  * Retrieve a service from the manager by name
  *
  * Allows passing an array of options to use when creating the instance.
  * createFromInvokable() will use these and pass them to the instance
  * constructor if not null and a non-empty array.
  *
  * @param  string $name
  * @param  array $options
  * @param  bool $usePeeringServiceManagers
  * @return object
  */
 public function get($name, $options = array(), $usePeeringServiceManagers = true)
 {
     // Canonize invokable class from name
     if (!$this->has($name) && !class_exists($name)) {
         // Lookup in default invokable list
         $cname = strtolower(str_replace(array('-', '_', ' ', '\\', '/'), '', $name));
         if (isset($this->invokableList[$cname])) {
             $invokableClass = 'Pi\\' . $this->invokableList[$cname];
             if (!class_exists($invokableClass)) {
                 $invokableClass = 'Zend\\' . $this->invokableList[$cname];
             }
             $name = $invokableClass;
             // Lookup in helper locations
         } else {
             $class = str_replace(' ', '', ucwords(str_replace(array('-', '_', '\\', '/'), ' ', $name)));
             if (class_exists('Pi\\I18n\\Translator\\Loader\\' . $class)) {
                 $name = 'Pi\\I18n\\Translator\\Loader\\' . $class;
             } else {
                 $name = 'Zend\\I18n\\Translator\\Loader\\' . $class;
             }
         }
     }
     $filter = parent::get($name, $options, $usePeeringServiceManagers);
     return $filter;
 }