set() public method

Sets a service.
public set ( string $id, object $service, string $scope = self::SCOPE_CONTAINER )
$id string The service identifier
$service object The service instance
$scope string The scope of the service
Example #1
0
 protected function setUp()
 {
     // Global $config required by unique_id
     global $config, $phpbb_root_path, $phpEx;
     if (!is_array($config)) {
         $config = new \phpbb\config\config(array());
     }
     $config['rand_seed'] = '';
     $config['rand_seed_last_update'] = time() + 600;
     $this->request = $this->getMock('\\phpbb\\request\\request');
     $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper();
     $this->filesystem = new \phpbb\filesystem\filesystem();
     $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
     $guessers = array(new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), new \phpbb\mimetype\content_guesser(), new \phpbb\mimetype\extension_guesser());
     $guessers[2]->set_priority(-2);
     $guessers[3]->set_priority(-2);
     $this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers);
     $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx);
     $this->container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser()))));
     $this->factory = new \phpbb\files\factory($this->container);
     $plupload = new \phpbb\plupload\plupload($phpbb_root_path, $config, $this->request, new \phpbb\user($this->language, '\\phpbb\\datetime'), $this->php_ini, $this->mimetype_guesser);
     $this->container->set('files.types.form', new \phpbb\files\types\form($this->factory, $this->language, $this->php_ini, $plupload, $this->request), phpbb_mock_container_builder::SCOPE_PROTOTYPE);
     $this->container->set('files.types.local', new \phpbb\files\types\local($this->factory, $this->language, $this->php_ini, $this->request), phpbb_mock_container_builder::SCOPE_PROTOTYPE);
     $this->path = __DIR__ . '/fixture/';
     $this->phpbb_root_path = $phpbb_root_path;
 }
 /**
  * Returns the ReflectionMethod for the given controller string.
  *
  * @param string $controller
  * @return \ReflectionMethod|null
  */
 public function getReflectionMethod($controller)
 {
     if (false === strpos($controller, '::') && 2 === substr_count($controller, ':')) {
         $controller = $this->controllerNameParser->parse($controller);
     }
     if (preg_match('#(.+)::([\\w]+)#', $controller, $matches)) {
         $class = $matches[1];
         $method = $matches[2];
     } elseif (preg_match('#(.+):([\\w]+)#', $controller, $matches)) {
         $controller = $matches[1];
         $method = $matches[2];
         if ($this->container->has($controller)) {
             $this->container->enterScope('request');
             $this->container->set('request', new Request(), 'request');
             $class = ClassUtils::getRealClass(get_class($this->container->get($controller)));
             $this->container->leaveScope('request');
         }
     }
     if (isset($class) && isset($method)) {
         try {
             return new \ReflectionMethod($class, $method);
         } catch (\ReflectionException $e) {
         }
     }
     return null;
 }
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function configureIO(InputInterface $input, OutputInterface $output)
 {
     parent::configureIO($input, $output);
     if (null !== $this->container) {
         $this->container->set('console.input', $input);
         $this->container->set('console.output', $output);
     }
 }
 protected function mockLogger()
 {
     $this->mockContainer();
     // Mock the logger.factory service and a logger channel.
     $factory = $this->getMock('\\Drupal\\Core\\Logger\\LoggerChannelFactoryInterface');
     $channel = $this->getMock('\\Drupal\\Core\\Logger\\LoggerChannelInterface');
     $factory->method('get')->willReturn($channel);
     $this->container->set('logger.factory', $factory);
 }
Example #5
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     try {
         $transport = TransportFactory::create($this->modulesSettings->get('Core', 'mailer_type', 'mail'), $this->modulesSettings->get('Core', 'smtp_server'), $this->modulesSettings->get('Core', 'smtp_port', 25), $this->modulesSettings->get('Core', 'smtp_username'), $this->modulesSettings->get('Core', 'smtp_password'), $this->modulesSettings->get('Core', 'smtp_secure_layer'));
         $this->container->set('swiftmailer.mailer.default.transport', $transport);
     } catch (PDOException $e) {
         // we'll just use the mail transport thats pre-configured
     }
 }
 protected function setUp()
 {
     require_once __DIR__ . '/../Fixtures/AppKernel.php';
     $kernel = new AppKernel('test', true);
     $kernel->boot();
     $this->kernel = $kernel;
     $this->container = $kernel->getContainer();
     $entityManager = $this->prophesize(EntityManager::class);
     $this->container->set('doctrine.orm.entity_manager', $entityManager->reveal());
     $this->entityManager = $entityManager;
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $framework = $this->mockContaoFramework(null, null, ['Contao\\Encryption' => $this->mockEncryptionAdapter()]);
     $connection = $this->getMock('Doctrine\\DBAL\\Connection', [], [], '', false);
     $this->container = $this->mockContainerWithContaoScopes();
     $this->container->set('contao.framework', $framework);
     $this->container->set('database_connection', $connection);
     $this->command = new UserPasswordCommand();
     $this->command->setContainer($this->container);
     $this->command->setApplication(new Application());
 }
Example #8
0
 protected function setUp()
 {
     global $phpbb_root_path, $phpEx;
     $this->request = $this->getMock('\\phpbb\\request\\request');
     $this->filesystem = new \phpbb\filesystem\filesystem();
     $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
     $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper();
     $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx);
     $this->container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser()))));
     $this->factory = new \phpbb\files\factory($this->container);
     $this->path = __DIR__ . '/fixture/';
     $this->phpbb_root_path = $phpbb_root_path;
 }
 public function setUp()
 {
     $this->container = new Container();
     $this->container->setParameter('doctrine_mongodb.odm.persistent_collection_dir', sys_get_temp_dir());
     $this->container->setParameter('doctrine_mongodb.odm.auto_generate_persistent_collection_classes', Configuration::AUTOGENERATE_NEVER);
     $this->generatorMock = $this->getMockBuilder(PersistentCollectionGenerator::class)->getMock();
     $dm = $this->createTestDocumentManager([__DIR__ . '/../Fixtures/Cache']);
     $dm->getConfiguration()->setPersistentCollectionGenerator($this->generatorMock);
     $registryStub = $this->getMockBuilder(ManagerRegistry::class)->getMock();
     $registryStub->expects($this->any())->method('getManagers')->willReturn([$dm]);
     $this->container->set('doctrine_mongodb', $registryStub);
     $this->warmer = new PersistentCollectionCacheWarmer($this->container);
 }
 public function testConfigureOptionsResolver()
 {
     $this->builder->configureOptionsResolver(\Mockery::mock('Symfony\\Component\\OptionsResolver\\OptionsResolver')->shouldReceive('setRequired')->once()->with(array('pdo', 'table', 'fields', 'id_field'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setAllowedTypes')->once()->with(array('pdo' => 'PDO', 'table' => 'string', 'fields' => 'array', 'id_field' => 'string'))->andReturn(\Mockery::self())->getMock()->shouldReceive('addAllowedTypes')->once()->with(array('pdo' => 'string'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setNormalizers')->once()->with(new EqualsMatcher(array('pdo' => function () {
     })))->andReturn(\Mockery::self())->getMock());
     $pdo = new MockPDO(\Mockery::mock());
     $resolver = new OptionsResolver();
     $this->builder->configureOptionsResolver($resolver);
     $options = $resolver->resolve(array('pdo' => $pdo, 'table' => '', 'fields' => array(), 'id_field' => ''));
     $this->assertSame($pdo, $options['pdo']);
     $this->container->set('pdo', $pdo);
     $options = $resolver->resolve(array('pdo' => 'pdo', 'table' => '', 'fields' => array(), 'id_field' => ''));
     $this->assertSame($pdo, $options['pdo']);
 }
 /**
  * {@inheritdoc}
  */
 public function add(FieldSet $fieldSet)
 {
     $name = $fieldSet->getSetName();
     if (isset($this->serviceIds[$name])) {
         throw new InvalidArgumentException(sprintf('Unable to overwrite already registered FieldSet "%s".', $name));
     }
     if (!$fieldSet->isConfigLocked()) {
         throw new InvalidArgumentException(sprintf('Unable to register none configuration-locked FieldSet "%s".', $name));
     }
     $serviceId = 'rollerworks_search.fieldset.late_registering.' . $name;
     $this->serviceIds[$name] = $serviceId;
     $this->container->set($serviceId, $fieldSet);
     return $this;
 }
 public function testResolveFromContainer()
 {
     $mockServer1 = $this->getMock(ServerInterface::class);
     $mockRequestHandler1 = $this->getMock(RequestHandlerInterface::class);
     $this->container->set('service.foo1', $mockServer1);
     $this->container->set('service.bar1', $mockRequestHandler1);
     $exceptionHandler = $this->createExceptionHandler();
     $exe = $this->createFactory()->create('service.foo1', 'service.bar1', $exceptionHandler);
     /* @var ExecutorFakeStub $exe */
     $this->assertInstanceOf(ExecutorFakeStub::class, $exe);
     $this->assertSame($mockServer1, $exe->getServer());
     $this->assertSame($mockRequestHandler1, $exe->getRequestHandler());
     $this->assertSame($exceptionHandler, $exe->getExceptionHandler());
 }
Example #13
0
 /**
  * @dataProvider data_upload_form
  */
 public function test_upload_form($filename, $upload_ary, $expected)
 {
     $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser())));
     $filespec_local = new ReflectionProperty($filespec, 'local');
     $filespec_local->setAccessible(true);
     $filespec_local->setValue($filespec, true);
     $this->container->set('files.filespec', $filespec);
     $this->factory = new \phpbb\files\factory($this->container);
     $type_local = new \phpbb\files\types\local($this->factory, $this->language, $this->php_ini, $this->request);
     $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
     $upload->set_allowed_extensions(array('png'));
     $type_local->set_upload($upload);
     $file = $type_local->upload($filename, $upload_ary);
     $this->assertSame($expected, $file->error);
     $this->assertInstanceOf('\\phpbb\\files\\filespec', $file);
 }
Example #14
0
 /**
  * Initializes the service container
  *
  * The cached version of the service container is used when fresh, otherwise the container is built.
  */
 protected function initializeContainer()
 {
     // Retrieve container class name (applicationDevelopmentDebugProjectContainer)
     $class = $this->getContainerClass();
     // Getting cache instance ('data/cache/applicationDevelopmentDebugProjectContainer.php', true)
     $cache = new ConfigCache($this->getCacheDir() . '/' . $class . '.php', $this->_debug);
     $fresh = true;
     // On vérifie que le cache est toujours valide et si ce n'est pas le cas, on le reconstruit.
     // En mode debug, le cache est toujours reconstruit from scratch
     if (!$cache->isFresh()) {
         // On construit le container
         $container = $this->buildContainer();
         // On dump le container
         $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
         $fresh = false;
     }
     // On inclu la class du container généré
     require_once $cache;
     $this->_container = new $class();
     $this->_container->set('kernel', $this);
     // TODO cache warmer
     //if (!$fresh && 'cli' !== php_sapi_name()) {
     //    $this->_container->get('cache_warmer')->warmUp($this->_container->getParameter('application.cache_dir'));
     //}
 }
Example #15
0
 /**
  * @dataProvider data_image_upload
  */
 public function test_image_upload($is_image, $plupload_active, $config_data, $expected)
 {
     $filespec = $this->getMock('\\phpbb\\files\\filespec', array('init_error', 'is_image', 'move_file', 'is_uploaded'), array($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser, $this->plupload));
     foreach ($config_data as $key => $value) {
         $this->config[$key] = $value;
     }
     $filespec->set_upload_namespace($this->files_upload);
     $filespec->expects($this->any())->method('init_error')->willReturn(false);
     $filespec->expects($this->any())->method('is_image')->willReturn($is_image);
     $filespec->expects($this->any())->method('is_uploaded')->willReturn(true);
     $filespec->expects($this->any())->method('move_file')->willReturn(false);
     $this->container->set('files.filespec', $filespec);
     $factory_mock = $this->getMockBuilder('\\phpbb\\files\\factory')->disableOriginalConstructor()->getMock();
     $factory_mock->expects($this->any())->method('get')->willReturn($filespec);
     $this->container->set('files.types.local', new \phpbb\files\types\local($factory_mock, $this->language, $this->php_ini, $this->request));
     $plupload = $this->getMockBuilder('\\phpbb\\plupload\\plupload')->disableOriginalConstructor()->getMock();
     $plupload->expects($this->any())->method('is_active')->willReturn($plupload_active);
     if ($plupload_active) {
         $plupload->expects($this->once())->method('emit_error')->with(104, 'ATTACHED_IMAGE_NOT_IMAGE')->willReturn(false);
     }
     $this->upload = new \phpbb\attachment\upload($this->auth, $this->cache, $this->config, $this->files_upload, $this->language, $this->mimetype_guesser, $this->phpbb_dispatcher, $plupload, $this->user, $this->phpbb_root_path);
     $filedata = $this->upload->upload('foobar', 1, true, '', false, array('realname' => 'foobar.jpg', 'type' => 'jpg', 'size' => 100));
     foreach ($expected as $key => $entry) {
         $this->assertEquals($entry, $filedata[$key]);
     }
     // Reset config data
     foreach ($config_data as $key => $value) {
         $this->config->delete($key);
     }
 }
Example #16
0
 /**
  * Tests the renderAccess() method.
  *
  * @param bool $access
  *
  * @covers ::renderAccess
  * @dataProvider accessProvider
  */
 public function testRenderAccess($access)
 {
     $element = array('#url' => Url::fromRoute('entity.node.canonical', ['node' => 3]));
     $this->container->set('current_user', $this->getMock('Drupal\\Core\\Session\\AccountInterface'));
     $this->container->set('access_manager', $this->getMockAccessManager($access));
     $this->assertEquals($access, TestUrl::renderAccess($element));
 }
 public function setUp()
 {
     $this->container = new Container();
     $this->container->setParameter('doctrine_mongodb.odm.hydrator_dir', sys_get_temp_dir());
     $this->container->setParameter('doctrine_mongodb.odm.auto_generate_hydrator_classes', Configuration::AUTOGENERATE_NEVER);
     $this->hydratorMock = $this->getMockBuilder(HydratorFactory::class)->disableOriginalConstructor()->getMock();
     $dm = $this->createTestDocumentManager([__DIR__ . '/../Fixtures/Validator']);
     $r = new \ReflectionObject($dm);
     $p = $r->getProperty('hydratorFactory');
     $p->setAccessible(true);
     $p->setValue($dm, $this->hydratorMock);
     $registryStub = $this->getMockBuilder(ManagerRegistry::class)->disableOriginalConstructor()->getMock();
     $registryStub->expects($this->any())->method('getManagers')->willReturn([$dm]);
     $this->container->set('doctrine_mongodb', $registryStub);
     $this->warmer = new HydratorCacheWarmer($this->container);
 }
Example #18
0
 /**
  *  Cleanup
  * @param $controller
  */
 private function cleanup($controller = null)
 {
     //Do some doctrine cleanup on the controller container.
     $controllerContainer = $this->getControllerContainer($controller);
     if ($controllerContainer && $controllerContainer->has('doctrine')) {
         if (!$controllerContainer->get('doctrine')->getManager()->isOpen()) {
             $controllerContainer->get('doctrine')->resetManager();
         }
         $controllerContainer->get('doctrine')->getManager()->clear();
         //Close any open doctrine connections
         /** @var Connection[] $connections */
         $connections = $controllerContainer->get('doctrine')->getConnections();
         foreach ($connections as $connection) {
             $connection->close();
         }
     }
     unset($controller);
     //Clear out any stuff that doctrine has cached
     if ($this->container->has('doctrine')) {
         if (!$this->container->get('doctrine')->getManager()->isOpen()) {
             $this->container->get('doctrine')->resetManager();
             $config = $this->container->getParameter('voryx_thruway');
             if ($this->container->has($config['user_provider'])) {
                 $this->container->set($config['user_provider'], null);
             }
         }
         $this->container->get('doctrine')->getManager()->clear();
     }
 }
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $format = null;
     if (is_string($this->forceFormat)) {
         $format = $this->forceFormat;
     } else {
         $request = $event->getRequest();
         if ($this->router instanceof I18nRouter) {
             $collection = $this->router->getOriginalRouteCollection();
         } else {
             $collection = $this->router->getRouteCollection();
         }
         $route = $collection->get($request->get('_route'));
         if (!empty($route)) {
             $defaultFormat = is_null($route->getDefault('_format')) ? 'html' : $route->getDefault('_format');
         } else {
             $defaultFormat = 'html';
         }
         $format = !is_null($request->attributes->get('_format')) ? $request->attributes->get('_format') : $defaultFormat;
     }
     if (!is_null($format)) {
         $serviceName = 'vsymfo_core.service.' . strtolower($format) . '_document';
         if ($this->container->has($serviceName) && $this->container->get($serviceName) instanceof DocumentFactoryInterface) {
             $service = $this->container->get($serviceName);
         } else {
             $service = $this->container->get('vsymfo_core.service.txt_document');
         }
         $doc = $service->createDocument();
         $this->container->get('vsymfo_core.service.document')->setDefaultsToDocument($doc);
         $this->container->set($this->serviceName, $doc);
     }
 }
 /**
  * @param Notification $notification
  * @return void
  */
 public function notify(Notification $notification)
 {
     if (!$this->container->isScopeActive('request')) {
         $this->container->enterScope('request');
         $this->container->set('request', new Request(), 'request');
     }
     $ticket = $this->loadTicket($notification);
     $changeList = $this->postProcessChangesList($notification);
     foreach ($this->watchersService->getWatchers($ticket) as $watcher) {
         $userType = $watcher->getUserType();
         $user = User::fromString($userType);
         $isOroUser = $user->isOroUser();
         if ($isOroUser) {
             $loadedUser = $this->oroUserManager->findUserBy(['id' => $user->getId()]);
         } else {
             $loadedUser = $this->diamanteUserRepository->get($user->getId());
         }
         if (!$isOroUser && $notification->isTagUpdated()) {
             continue;
         }
         $message = $this->message($notification, $ticket, $isOroUser, $loadedUser->getEmail(), $changeList);
         $this->mailer->send($message);
         $reference = new MessageReference($message->getId(), $ticket, $this->configManager->get(self::EMAIL_NOTIFIER_CONFIG_PATH));
         $this->messageReferenceRepository->store($reference);
     }
 }
Example #21
0
 /**
  * Configure the session handler (only when not configured)
  *
  * @param SessionInterface $session
  */
 public function setSession(SessionInterface $session)
 {
     if ($this->getRequest()->hasSession()) {
         return;
     }
     $this->getRequest()->setSession($session);
     $this->dependencyContainer->set('session', $session);
 }
Example #22
0
 /**
  * @dataProvider data_upload_form
  */
 public function test_upload_form($upload, $expected, $plupload = array())
 {
     $this->request = $this->getMock('\\phpbb\\request\\request');
     $this->request->expects($this->any())->method('file')->willReturn($upload);
     $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser())));
     $this->container->set('files.filespec', $filespec);
     $this->factory = new \phpbb\files\factory($this->container);
     $this->plupload = $this->getMockBuilder('\\phpbb\\plupload\\plupload')->disableOriginalConstructor()->getMock();
     $this->plupload->expects($this->any())->method('handle_upload')->willReturn($plupload);
     $type_form = new \phpbb\files\types\form($this->factory, $this->language, $this->php_ini, $this->plupload, $this->request);
     $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
     $upload->set_allowed_extensions(array('png'));
     $type_form->set_upload($upload);
     $file = $type_form->upload('foobar');
     $this->assertSame($expected, $file->error);
     $this->assertInstanceOf('\\phpbb\\files\\filespec', $file);
 }
Example #23
0
 /**
  * Retrieves templating service
  *
  * @return \Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine
  */
 public function getTemplating()
 {
     if (defined('IN_MAUTIC_CONSOLE')) {
         //enter the request scope in order to be use the templating.helper.assets service
         $this->container->enterScope('request');
         $this->container->set('request', new Request(), 'request');
     }
     return $this->container->get('templating');
 }
/**
 * @param ContainerInterface $container
 * @return Translator
 */
function loadTranslator(ContainerInterface $container)
{
    $translator = new Translator('ru');
    $translator->addLoader('xlf', new XliffFileLoader());
    $translator->addResource('xlf', VENDOR_PATH . 'symfony/form/Resources/translations/validators.ru.xlf', 'ru', 'validators');
    $translator->addResource('xlf', VENDOR_PATH . 'symfony/validator/Resources/translations/validators.ru.xlf', 'ru', 'validators');
    $container->set('translator', $translator);
    return $translator;
}
 /**
  * @test
  */
 public function shouldAllowSetDefaultConfig()
 {
     $this->container->set('the_api', new \stdClass());
     $factory = new CoreGatewayFactory([], [], [], ['foo' => 'fooVal']);
     $factory->setContainer($this->container);
     $config = $factory->createConfig([]);
     $this->assertArrayHasKey('foo', $config);
     $this->assertEquals('fooVal', $config['foo']);
 }
Example #26
0
 protected function setUp()
 {
     // Global $config required by unique_id
     global $config, $phpbb_root_path, $phpEx;
     if (!is_array($config)) {
         $config = array();
     }
     $config['rand_seed'] = '';
     $config['rand_seed_last_update'] = time() + 600;
     $this->request = $this->getMock('\\phpbb\\request\\request');
     $this->filesystem = new \phpbb\filesystem\filesystem();
     $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
     $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper();
     $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx);
     $this->container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser()))));
     $this->factory = new \phpbb\files\factory($this->container);
     $this->path = __DIR__ . '/fixture/';
     $this->phpbb_root_path = $phpbb_root_path;
 }
 /**
  * @test
  */
 public function shouldAddTaggedApiWithSeveralTags()
 {
     $this->container->set('the_api', new \stdClass());
     $factory = new GatewayFactory(array(), array(), array('the_api' => array(array('factory' => 'theFactory'), array('gateway' => 'theGateway'), array('all' => true, 'prepend' => true))));
     $factory->setContainer($this->container);
     $config = $factory->createConfig(array('payum.gateway_name' => 'theGateway', 'payum.factory_name' => 'theFactory'));
     //guard
     $this->assertArrayHasKey('payum.api.the_api', $config);
     $this->assertContains('payum.api.the_api', $config['payum.prepend_apis']);
 }
Example #28
0
 /**
  * Tests that Container::getServiceIds() works properly.
  *
  * @covers ::getServiceIds
  */
 public function testGetServiceIds()
 {
     $service_definition_keys = array_keys($this->containerDefinition['services']);
     $this->assertEquals($service_definition_keys, $this->container->getServiceIds(), 'Retrieved service IDs match definition.');
     $mock_service = new MockService();
     $this->container->set('bar', $mock_service);
     $this->container->set('service.provider', $mock_service);
     $service_definition_keys[] = 'bar';
     $this->assertEquals($service_definition_keys, $this->container->getServiceIds(), 'Retrieved service IDs match definition after setting new services.');
 }
Example #29
0
 /**
  * Reboot kernel
  *
  * Services from the list of persistent services
  * are updated from service container before kernel shutdown
  * and injected into newly initialized container after kernel boot.
  */
 public function rebootKernel()
 {
     if ($this->container) {
         foreach ($this->persistentServices as $serviceName => $service) {
             if ($this->container->has($serviceName)) {
                 $this->persistentServices[$serviceName] = $this->container->get($serviceName);
             }
         }
     }
     $this->kernel->shutdown();
     $this->kernel->boot();
     $this->container = $this->kernel->getContainer();
     if ($this->container->has('profiler')) {
         $this->container->get('profiler')->enable();
     }
     foreach ($this->persistentServices as $serviceName => $service) {
         $this->container->set($serviceName, $service);
     }
 }
 /**
  * Adds mock data type plugin manager and results cache services to \Drupal.
  */
 protected function setUpDataTypePlugin()
 {
     $data_type_plugin = $this->getMockBuilder('Drupal\\search_api\\DataType\\DataTypePluginManager')->disableOriginalConstructor()->getMock();
     $data_type_plugin->expects($this->any())->method('getCustomDataTypes')->will($this->returnValue(array()));
     $results_static_cache = $this->getMockBuilder('Drupal\\search_api\\Query\\ResultsCache')->disableOriginalConstructor()->getMock();
     $results_static_cache->expects($this->any())->method('getResults')->will($this->returnValue(array()));
     $this->container = new ContainerBuilder();
     $this->container->set('plugin.manager.search_api.data_type', $data_type_plugin);
     $this->container->set('search_api.results_static_cache', $results_static_cache);
     \Drupal::setContainer($this->container);
 }