Expects the user will provide a configured ServiceManager, configured with the following services: - EventManager - ModuleManager - Request - Response - RouteListener - Router - DispatchListener - ViewManager The most common workflow is: $services = new Zend\ServiceManager\ServiceManager($servicesConfig); $app = new Application($appConfig, $services); $app->bootstrap(); $response = $app->run(); $response->send(); bootstrap() opts in to the default route, dispatch, and view listeners, sets up the MvcEvent, and triggers the bootstrap event. This can be omitted if you wish to setup your own listeners and/or workflow; alternately, you can simply extend the class to override such behavior.
Inheritance: implements Zend\Mvc\ApplicationInterface, implements Zend\EventManager\EventManagerAwareInterface
コード例 #1
1
ファイル: Cli.php プロジェクト: nja78/magento2
 /**
  * Gets application commands
  *
  * @return array
  */
 protected function getApplicationCommands()
 {
     $setupCommands = [];
     $toolsCommands = [];
     $modulesCommands = [];
     $bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
     $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
     $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
     $bootstrap = Bootstrap::create(BP, $params);
     $objectManager = $bootstrap->getObjectManager();
     if (class_exists('Magento\\Setup\\Console\\CommandList')) {
         $serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager();
         $setupCommandList = new \Magento\Setup\Console\CommandList($serviceManager);
         $setupCommands = $setupCommandList->getCommands();
     }
     if (class_exists('Magento\\Tools\\Console\\CommandList')) {
         $toolsCommandList = new \Magento\Tools\Console\CommandList();
         $toolsCommands = $toolsCommandList->getCommands();
     }
     if ($objectManager->get('Magento\\Framework\\App\\DeploymentConfig')->isAvailable()) {
         $commandList = $objectManager->create('Magento\\Framework\\Console\\CommandList');
         $modulesCommands = $commandList->getCommands();
     }
     $commandsList = array_merge($setupCommands, $toolsCommands, $modulesCommands);
     return $commandsList;
 }
コード例 #2
0
 public function setup()
 {
     parent::setup();
     $config = (include 'config/application.config.php');
     $config['module_listener_options']['config_static_paths'] = array(getcwd() . '/config/test.config.php');
     if (file_exists(__DIR__ . '/config/test.config.php')) {
         $moduleConfig = (include __DIR__ . '/config/test.config.php');
         array_unshift($config['module_listener_options']['config_static_paths'], $moduleConfig);
     }
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(isset($config['service_manager']) ? $config['service_manager'] : array()));
     $this->serviceManager->setService('ApplicationConfig', $config);
     $this->serviceManager->setFactory('ServiceListener', 'Zend\\Mvc\\Service\\ServiceListenerFactory');
     $moduleManager = $this->serviceManager->get('ModuleManager');
     $moduleManager->loadModules();
     $this->routes = array();
     foreach ($moduleManager->getModules() as $m) {
         $moduleConfig = (include __DIR__ . '/../../../../' . ucfirst($m) . '/config/module.config.php');
         if (isset($moduleConfig['router'])) {
             foreach ($moduleConfig['router']['routes'] as $key => $name) {
                 $this->routes[$key] = $name;
             }
         }
     }
     $this->serviceManager->setAllowOverride(true);
     $this->application = $this->serviceManager->get('Application');
     $this->event = new MvcEvent();
     $this->event->setTarget($this->application);
     $this->event->setApplication($this->application)->setRequest($this->application->getRequest())->setResponse($this->application->getResponse())->setRouter($this->serviceManager->get('Router'));
     $this->createDatabase();
 }
コード例 #3
0
ファイル: UnitTest.php プロジェクト: ebittleman/mailgun-zf2
 public function __construct($name = null, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     $this->app = \Bootstrap::$app;
     $this->sm = $this->app->getServiceManager();
     $this->evm = $this->app->getEventManager();
 }
コード例 #4
0
 protected function getApplication()
 {
     if (null === $this->application) {
         $this->application = $this->getServiceManager()->get('Application');
         $this->application->bootstrap();
     }
     return $this->application;
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function initialize(ContextInterface $context)
 {
     if ($context instanceof ApplicationAwareInterface) {
         $context->setApplication($this->application);
     }
     if ($context instanceof ServiceLocatorAwareInterface) {
         $context->setServiceLocator($this->application->getServiceManager());
     }
 }
コード例 #6
0
 public function setUp()
 {
     $this->application = $this->getMock('Zend\\Mvc\\Application', array(), array(), '', false);
     $this->event = $this->getMock('Zend\\Mvc\\MvcEvent');
     $this->serviceManager = $this->getMock('Zend\\ServiceManager\\ServiceManager');
     $this->cli = $this->getMock('Symfony\\Component\\Console\\Application', array('run'));
     $this->serviceManager->expects($this->any())->method('get')->with('doctrine.cli')->will($this->returnValue($this->cli));
     $this->application->expects($this->any())->method('getServiceManager')->will($this->returnValue($this->serviceManager));
     $this->event->expects($this->any())->method('getTarget')->will($this->returnValue($this->application));
 }
コード例 #7
0
ファイル: BTools.php プロジェクト: Belcebur/BelceburBasic
 public function __construct(HelperPluginManager $pluginManager)
 {
     $this->pluginManager = $pluginManager;
     $this->serviceManager = $pluginManager->getServiceLocator();
     $this->app = $pluginManager->getServiceLocator()->get('Application');
     $this->request = $this->app->getRequest();
     $this->event = $this->app->getMvcEvent();
     $this->em = $this->serviceManager->get('Doctrine\\ORM\\EntityManager');
     $this->translator = $this->serviceManager->get('translator');
 }
コード例 #8
0
 /**
  * @BeforeFeature
  */
 public static function clearDatabase()
 {
     $em = self::$zendApp->getServiceManager()->get('doctrine.entitymanager.orm_default');
     $q = $em->createQuery('delete from CargoBackend\\Model\\Cargo\\Cargo');
     $q->execute();
     $q = $em->createQuery('delete from CargoBackend\\Model\\Cargo\\RouteSpecification');
     $q->execute();
     $q = $em->createQuery('delete from CargoBackend\\Model\\Cargo\\Itinerary');
     $q->execute();
 }
コード例 #9
0
 public function setUp()
 {
     $config = ['modules' => ['Zff\\Html2Pdf'], 'module_listener_options' => []];
     $serviceManager = new ServiceManager((new ServiceManagerConfig())->toArray());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     $application = new Application($config, $serviceManager);
     $application->bootstrap();
     $this->serviceManager = $serviceManager;
 }
コード例 #10
0
 public function it_aborts_bootstrap_on_console(MvcEvent $event, Application $application, ServiceLocatorInterface $serviceLocator, AccessListener $listener, EventManager $eventManager)
 {
     Console::overrideIsConsole(true);
     $application->getEventManager()->willReturn($eventManager);
     $serviceLocator->get(AccessListener::class)->willReturn($listener);
     $application->getServiceManager()->willReturn($serviceLocator);
     $event->getApplication()->willReturn($application);
     $listener->attach($eventManager)->shouldNotBeCalled();
     $this->onBootstrap($event);
 }
コード例 #11
0
 /**
  * @return \Zend\Mvc\Application
  */
 public function getApplication()
 {
     if ($this->spiffyApplication) {
         return $this->spiffyApplication;
     }
     Console::overrideIsConsole($this->getUseConsoleRequest());
     $this->spiffyApplication = SpiffyTest::getInstance()->getApplication();
     $events = $this->spiffyApplication->getEventManager();
     $events->detach($this->spiffyApplication->getServiceManager()->get('SendResponseListener'));
     return $this->spiffyApplication;
 }
コード例 #12
0
 /**
  * Return the redirect from param.
  * First checks GET then POST
  * @return string
  */
 private function getRedirectRouteFromRequest()
 {
     $request = $this->application->getRequest();
     $redirect = $request->getQuery('redirect');
     if ($redirect && $this->routeExists($redirect)) {
         return $redirect;
     }
     $redirect = $request->getPost('redirect');
     if ($redirect && $this->routeExists($redirect)) {
         return $redirect;
     }
     return false;
 }
コード例 #13
0
 /**
  * Return the redirect from param.
  * First checks GET then POST
  * @return string
  */
 private function getRedirectUrlFromRequest()
 {
     $request = $this->application->getRequest();
     $redirect = $request->getQuery('redirect');
     if ($redirect && $this->urlWhitelisted($redirect)) {
         return $redirect;
     }
     $redirect = $request->getPost('redirect');
     if ($redirect && $this->urlWhitelisted($redirect)) {
         return $redirect;
     }
     return false;
 }
コード例 #14
0
ファイル: ModuleTest.php プロジェクト: hummer2k/convarnish
 public function testOnBootstrap()
 {
     $event = new MvcEvent();
     $application = new Application([], Bootstrap::getServiceManager());
     $em = new EventManager();
     $application->setEventManager($em);
     $event->setApplication($application);
     $isConsole = Console::isConsole();
     Console::overrideIsConsole(false);
     $this->module->onBootstrap($event);
     Console::overrideIsConsole($isConsole);
     $this->assertCount(1, $em->getListeners(MvcEvent::EVENT_DISPATCH));
     $this->assertCount(1, $em->getListeners(MvcEvent::EVENT_RENDER));
 }
コード例 #15
0
ファイル: ZfHelper.php プロジェクト: brs-software/stdlib
 public static function getApplication()
 {
     self::assertZf();
     self::chdirToAppRoot();
     $configPath = self::findAppConfigPath();
     return Application::init(require $configPath);
 }
コード例 #16
0
ファイル: ZendApplication.php プロジェクト: athemcms/netis
 /**
  * @see \Zend\Mvc\Application#init()
  * @param array $configuration
  * @return RealZendApplication
  */
 public static function init($configuration = array())
 {
     Exception\ErrorException::$oldErrorHandler = set_error_handler("\\Netis\\Exception\\ErrorException::errorHandler");
     Environment::setEnv(isset($configuration['env']) ? $configuration['env'] : Environment::ENV_PRODUCTION);
     self::detectLoader($configuration);
     return parent::init($configuration);
 }
コード例 #17
0
 protected function setUp()
 {
     $bootstrap = \Zend\Mvc\Application::init(include 'config/application.config.php');
     $categoryData = array('id_category' => 1, 'name' => 'Project Manager');
     $category = new Category();
     $category->exchangeArray($categoryData);
     $resultSetCategory = new ResultSet();
     $resultSetCategory->setArrayObjectPrototype(new Category());
     $resultSetCategory->initialize(array($category));
     $mockCategoryTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select'), array(), '', false);
     $mockCategoryTableGateway->expects($this->any())->method('select')->with()->will($this->returnValue($resultSetCategory));
     $categoryTable = new CategoryTable($mockCategoryTableGateway);
     $jobData = array('id_job' => 1, 'id_category' => 1, 'type' => 'typeTest', 'company' => 'companyTest', 'logo' => 'logoTest', 'url' => 'urlTest', 'position' => 'positionTest', 'location' => 'locaitonTest', 'description' => 'descriptionTest', 'how_to_play' => 'hotToPlayTest', 'is_public' => 1, 'is_activated' => 1, 'email' => 'emailTest', 'created_at' => '2012-01-01 00:00:00', 'updated_at' => '2012-01-01 00:00:00');
     $job = new Job();
     $job->exchangeArray($jobData);
     $resultSetJob = new ResultSet();
     $resultSetJob->setArrayObjectPrototype(new Job());
     $resultSetJob->initialize(array($job));
     $mockJobTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select'), array(), '', false);
     $mockJobTableGateway->expects($this->any())->method('select')->with(array('id_category' => 1))->will($this->returnValue($resultSetJob));
     $jobTable = new JobTable($mockJobTableGateway);
     $this->controller = new IndexController($categoryTable, $jobTable);
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = $bootstrap->getMvcEvent();
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setEventManager($bootstrap->getEventManager());
     $this->controller->setServiceLocator($bootstrap->getServiceManager());
 }
コード例 #18
0
 /**
  * @dataProvider eventPropagation
  */
 public function testEventPropagationStatusIsClearedBetweenEventsDuringRun($events)
 {
     $event = new MvcEvent();
     $event->setTarget($this->application);
     $event->setApplication($this->application)->setRequest($this->application->getRequest())->setResponse($this->application->getResponse())->setRouter($this->serviceManager->get('Router'));
     $event->stopPropagation(true);
     // Intentionally not calling bootstrap; setting mvc event
     $r = new ReflectionObject($this->application);
     $eventProp = $r->getProperty('event');
     $eventProp->setAccessible(true);
     $eventProp->setValue($this->application, $event);
     // Setup listeners that stop propagation, but do nothing else
     $marker = array();
     foreach ($events as $event) {
         $marker[$event] = true;
     }
     $marker = (object) $marker;
     $listener = function ($e) use($marker) {
         $marker->{$e->getName()} = $e->propagationIsStopped();
         $e->stopPropagation(true);
     };
     $this->application->getEventManager()->attach($events, $listener);
     $this->application->run();
     foreach ($events as $event) {
         $this->assertFalse($marker->{$event}, sprintf('Assertion failed for event "%s"', $event));
     }
 }
コード例 #19
0
ファイル: Application.php プロジェクト: hschletz/braintacle
 /**
  * Set up application environment
  *
  * This sets up the PHP environment, loads the provided module and returns
  * the MVC application.
  *
  * @param string $module Module to load
  * @param bool $addTestConfig Add config for test environment (enable all debug options, no config file)
  * @param array $applicationConfig Extends default application config
  * @return \Zend\Mvc\Application
  * @codeCoverageIgnore
  */
 public static function init($module, $addTestConfig = false, $applicationConfig = array())
 {
     // Set up PHP environment.
     session_cache_limiter('nocache');
     // Default headers to prevent caching
     return \Zend\Mvc\Application::init(array_replace_recursive(static::getApplicationConfig($module, $addTestConfig), $applicationConfig));
 }
コード例 #20
0
 public function testUnlocatableControllerLoaderComposedOfAbstractFactory()
 {
     $this->setupPathController();
     $controllerLoader = $this->serviceManager->get('ControllerLoader');
     $controllerLoader->addAbstractFactory('ZendTest\\Mvc\\Controller\\TestAsset\\UnlocatableControllerLoaderAbstractFactory');
     $log = array();
     $this->application->getEventManager()->attach(MvcEvent::EVENT_DISPATCH_ERROR, function ($e) use(&$log) {
         $log['error'] = $e->getError();
     });
     $this->application->run();
     $event = $this->application->getMvcEvent();
     $dispatchListener = $this->serviceManager->get('DispatchListener');
     $return = $dispatchListener->onDispatch($event);
     $this->assertArrayHasKey('error', $log);
     $this->assertSame('error-controller-not-found', $log['error']);
 }
コード例 #21
0
 public static function init()
 {
     // Load the user-defined test configuration file, if it exists; otherwise, load
     if (is_readable(__DIR__ . '/TestConfig.php')) {
         $testConfig = (include __DIR__ . '/TestConfig.php');
     } else {
         $testConfig = (include __DIR__ . '/TestConfig.php.dist');
     }
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $application = \Zend\Mvc\Application::init($config);
     // build test database
     $entityManager = $application->getServiceManager()->get('doctrine.entitymanager.orm_default');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
     $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
     static::$application = $application;
 }
コード例 #22
0
ファイル: Cli.php プロジェクト: Doability/magento2dev
 /**
  * @param string $name  application name
  * @param string $version application version
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
 {
     $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager();
     $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager);
     if (!$generationDirectoryAccess->check()) {
         $output = new ConsoleOutput();
         $output->writeln('<error>Command line user does not have read and write permissions on var/generation directory.  Please' . ' address this issue before using Magento command line.</error>');
         exit(0);
     }
     /**
      * Temporary workaround until the compiler is able to clear the generation directory
      * @todo remove after MAGETWO-44493 resolved
      */
     if (class_exists(CompilerPreparation::class)) {
         $compilerPreparation = new CompilerPreparation($this->serviceManager, new ArgvInput(), new File());
         $compilerPreparation->handleCompilerEnvironment();
     }
     if ($version == 'UNKNOWN') {
         $directoryList = new DirectoryList(BP);
         $composerJsonFinder = new ComposerJsonFinder($directoryList);
         $productMetadata = new ProductMetadata($composerJsonFinder);
         $version = $productMetadata->getVersion();
     }
     parent::__construct($name, $version);
 }
コード例 #23
0
 public static function init()
 {
     /**
      * Load Test Config to include other modules we require
      */
     if (is_readable(__DIR__ . '/TestConfig.php')) {
         $testConfig = (include __DIR__ . '/TestConfig.php');
     } else {
         $testConfig = (include __DIR__ . '/TestConfig.php.dist');
     }
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     \Zend\Mvc\Application::init($config);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
     static::$config = $config;
 }
コード例 #24
0
 /**
  * @Then I should have the application
  */
 public function applicationExists(TableNode $table)
 {
     /** @var ApplicationManager $applicationManager */
     $applicationManager = self::$application->getServiceManager()->get('application/application-manager');
     $data = [];
     foreach ($table->getTable() as $row) {
         $data[$row[0]] = $row[1];
     }
     $application = $applicationManager->get($data['name']);
     \PHPUnit_Framework_Assert::assertInstanceOf('Continuous\\DeployAgent\\Application\\Application', $application);
     foreach ($data as $property => $value) {
         switch ($property) {
             case 'pipeline':
                 $property = 'reference';
             case 'token':
             case 'repositoryProvider':
             case 'repository':
                 \PHPUnit_Framework_Assert::assertAttributeEquals($value, $property, $application->getProvider());
                 break;
             case 'provider':
                 $provider = self::$application->getServiceManager()->get('provider/' . $value);
                 \PHPUnit_Framework_Assert::assertAttributeInstanceOf(get_class($provider), $property, $application);
                 break;
             default:
                 \PHPUnit_Framework_Assert::assertAttributeEquals($value, $property, $application);
         }
     }
 }
コード例 #25
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Start up application with supplied config...');
     $config = $input->getArgument('applicationConfig');
     $path = stream_resolve_include_path($config);
     if (!is_readable($path)) {
         throw new \InvalidArgumentException("Invalid loader path: {$config}");
     }
     // Init the application once using given config
     // This way the late static binding on the AspectKernel
     // will be on the goaop-zf2-module kernel
     \Zend\Mvc\Application::init(include $path);
     if (!class_exists(AspectKernel::class, false)) {
         $message = "Kernel was not initialized yet. Maybe missing module Go\\ZF2\\GoAopModule in config {$path}";
         throw new \InvalidArgumentException($message);
     }
     $kernel = AspectKernel::getInstance();
     $options = $kernel->getOptions();
     if (empty($options['cacheDir'])) {
         throw new \InvalidArgumentException('Cache warmer require the `cacheDir` options to be configured');
     }
     $enumerator = new Enumerator($options['appDir'], $options['includePaths'], $options['excludePaths']);
     $iterator = $enumerator->enumerate();
     $totalFiles = iterator_count($iterator);
     $output->writeln("Total <info>{$totalFiles}</info> files to process.");
     $iterator->rewind();
     set_error_handler(function ($errno, $errstr, $errfile, $errline) {
         throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
     });
     $index = 0;
     $errors = [];
     foreach ($iterator as $file) {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
             $output->writeln("Processing file <info>{$file->getRealPath()}</info>");
         }
         $isSuccess = null;
         try {
             // This will trigger creation of cache
             file_get_contents(FilterInjectorTransformer::PHP_FILTER_READ . SourceTransformingLoader::FILTER_IDENTIFIER . '/resource=' . $file->getRealPath());
             $isSuccess = true;
         } catch (\Exception $e) {
             $isSuccess = false;
             $errors[$file->getRealPath()] = $e;
         }
         if ($output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
             $output->write($isSuccess ? '.' : '<error>E</error>');
             if (++$index % 50 == 0) {
                 $output->writeln("({$index}/{$totalFiles})");
             }
         }
     }
     restore_error_handler();
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
         foreach ($errors as $file => $error) {
             $message = "File {$file} is not processed correctly due to exception: {$error->getMessage()}";
             $output->writeln($message);
         }
     }
     $output->writeln('<info>Done</info>');
 }
コード例 #26
0
ファイル: App.php プロジェクト: binarykitten/zeffmu
 /**
  * {@inheritDoc}
  * @return self
  */
 public static function init($configuration = array())
 {
     $defaults = array('module_listener_options' => array(), 'modules' => array(), 'service_manager' => array());
     $configuration = ArrayUtils::merge($defaults, $configuration);
     $configuration['modules'][] = 'ZeffMu';
     return parent::init($configuration);
 }
コード例 #27
0
 public static function createDatabase(\Zend\Mvc\Application $application)
 {
     // build test database
     $entityManager = $application->getServiceManager()->get('doctrine.entitymanager.orm_default');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
     $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
     // build audit database
     $auditEntityManager = $application->getServiceManager()->get('doctrine.entitymanager.orm_zf_doctrine_audit');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($auditEntityManager);
     $schemaTool->createSchema($auditEntityManager->getMetadataFactory()->getAllMetadata());
     // Run audit fixtures
     $loader = new ServiceLocatorAwareLoader($application->getServiceManager());
     $purger = new ORMPurger();
     $executor = new ORMExecutor($auditEntityManager, $purger);
     $loader->loadFromDirectory(__DIR__ . '/../src/Fixture');
     $executor->execute($loader->getFixtures(), true);
 }
コード例 #28
0
 public function testApplicationUsesLoggedPluginManagers()
 {
     $sm = Application::init(array('modules' => array('OcraServiceManager'), 'module_listener_options' => array('module_paths' => array(), 'config_glob_paths' => array())))->getServiceManager();
     $pluginManagers = array('ServiceManager', 'ControllerLoader', 'ControllerPluginManager', 'FilterManager', 'FormElementManager', 'HydratorManager', 'InputFilterManager', 'PaginatorPluginManager', 'RoutePluginManager', 'SerializerAdapterManager', 'ValidatorManager', 'ViewHelperManager');
     foreach ($pluginManagers as $pluginManager) {
         $this->assertInstanceOf('ProxyManager\\Proxy\\AccessInterceptorInterface', $sm->get($pluginManager));
     }
 }
コード例 #29
0
ファイル: ZFIntegrationTest.php プロジェクト: autowp/image
 public function testControllerRegistered()
 {
     $app = \Zend\Mvc\Application::init(require __DIR__ . '/_files/config/application.config.php');
     $serviceManager = $app->getServiceManager();
     $controllerManager = $serviceManager->get('ControllerManager');
     $controller = $controllerManager->get(\Autowp\Image\Controller\ConsoleController::class);
     $this->assertInstanceOf(\Autowp\Image\Controller\ConsoleController::class, $controller);
 }
コード例 #30
0
ファイル: ViewSnubber.php プロジェクト: geeh/snubbed
 /**
  *
  */
 private function createHelpers()
 {
     /** @var HelperPluginManager $viewPluginManager */
     $viewPluginManager = $this->application->getServiceManager()->get('view-helper-manager');
     foreach ($viewPluginManager->getCanonicalNames() as $name) {
         $helper = $viewPluginManager->get($name);
         $this->viewHelpers[$name] = get_class($helper);
     }
 }