/** * Loads the config */ private function loadConfig() { $directories = [BASE_DIR . '/config', '/etc/blackhole-bot/']; $locator = new FileLocator($directories); $loader = new YamlConfigLoader($locator); $this->container->set('config', (new Processor())->processConfiguration($this, $loader->load($locator->locate('blackhole.yml')))); }
protected function setUp() { $this->container = new Container(); $this->container->set('doctrine.orm.entity_manager', EntityManager::create(array('driver' => 'pdo_sqlite', 'memory' => true), Setup::createAnnotationMetadataConfiguration(array()))); $this->bundle = new DateIntervalBundle(); $this->bundle->setContainer($this->container); }
public function createContainer($client, $handler) { $container = new Container(); $container->set('gbprod.elasticsearch_extra.put_index_mappings_handler', $handler); $container->set('m6web_elasticsearch.client.my_client', $client); return $container; }
protected function setUp() { parent::setUp(); $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface'); $this->container = new ContainerBuilder(); $this->container->addScope(new Scope('request')); $this->container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request'); $this->container->register('templating.helper.assets', $this->getMockClass('Symfony\\Component\\Templating\\Helper\\AssetsHelper')); $this->container->register('templating.helper.router', $this->getMockClass('Symfony\\Bundle\\FrameworkBundle\\Templating\\Helper\\RouterHelper')) ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'))); $this->container->register('twig', 'Twig_Environment'); $this->container->register('templating.engine.twig', $this->getMockClass('Symfony\\Bundle\\TwigBundle\\TwigEngine')) ->addArgument(new Definition($this->getMockClass('Twig_Environment'))) ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\Templating\\TemplateNameParserInterface'))) ->addArgument(new Definition($this->getMockClass('Symfony\Component\Config\FileLocatorInterface'))) ->addArgument(new Definition($this->getMockClass('Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables'), array(new Definition($this->getMockClass('Symfony\\Component\\DependencyInjection\\Container'))))); $this->container->setParameter('kernel.bundles', array()); $this->container->setParameter('kernel.cache_dir', __DIR__); $this->container->setParameter('kernel.debug', false); $this->container->setParameter('kernel.root_dir', __DIR__); $this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')) ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface'))); $this->container->setParameter('data_collector.templates', array()); $this->container->set('kernel', $this->kernel); }
/** * Mock the controller. * * @return \PHPUnit_Framework_MockObject_MockObject|PackageController */ private function prepareController() { $manager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->setMethods(null)->getMock(); $config = new Config(); $config->merge(array('repositories' => array('packagist' => false))); $loader = new RootPackageLoader($manager, $config); $rootPackage = $loader->load(json_decode($this->readFixture('composer.json'), true)); $loader = new ArrayLoader(); $json = json_decode($this->readFixture('installed.json'), true); $packages = []; foreach ($json as $package) { $packages[] = $loader->load($package); } $manager->setLocalRepository(new WritableArrayRepository($packages)); $composer = $this->getMockBuilder(Composer::class)->setMethods(['getPackage', 'getRepositoryManager'])->getMock(); $composer->method('getPackage')->willReturn($rootPackage); $composer->method('getRepositoryManager')->willReturn($manager); $controller = $this->getMockBuilder(PackageController::class)->setMethods(['getComposer', 'forward'])->getMock(); $controller->method('getComposer')->willReturn($composer); $home = $this->getMock(HomePathDeterminator::class, ['homeDir']); $home->method('homeDir')->willReturn($this->getTempDir()); $composerJson = $this->provideFixture('composer.json'); $this->provideFixture('composer.lock'); $this->provideFixture('installed.json', 'vendor/composer/installed.json'); $container = new Container(); $container->set('tenside.home', $home); $container->set('tenside.composer_json', new ComposerJson($composerJson)); /** @var PackageController $controller */ $controller->setContainer($container); return $controller; }
protected function setUp() { $this->controller = $controller = $this->getMock("Thelia\\Controller\\BaseController", ["getParser", "render", "renderRaw"]); /** * Reset static :: $formDefinition on controllers */ $this->definitionReflection = $reflection = (new \ReflectionObject($this->controller))->getProperty('formDefinition'); $reflection->setAccessible(true); $this->formDefinition = $reflection->getValue(); $reflection->setValue(null); /** * Add the test type to the factory and * the form to the container */ $factory = new FormFactoryBuilder(); $factory->addExtension(new CoreExtension()); $factory->addType(new TestType()); /** * Construct the container */ $container = new Container(); $container->set("thelia.form_factory_builder", $factory); $container->set("thelia.translator", new Translator($container)); $container->setParameter("thelia.parser.forms", array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm")); $request = new Request(); $request->setSession(new Session(new MockArraySessionStorage())); $container->set("request", $request); $container->set("thelia.forms.validator_builder", new ValidatorBuilder()); $container->set("event_dispatcher", new EventDispatcher()); $this->controller->setContainer($container); }
protected function setUp() { $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface'); $translator->expects($this->any())->method('trans')->will($this->returnArgument(0)); $registry = $this->getMockForAbstractClass('Doctrine\\Common\\Persistence\\ManagerRegistry', [], '', false); $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($this->em)); $this->formFactory = Forms::createFormFactoryBuilder()->addExtensions([new PreloadedExtension(['oro_type_filter' => new FilterType($translator), 'oro_type_choice_filter' => new ChoiceFilterType($translator), 'entity' => new EntityType($registry), 'oro_type_entity_filter' => new EntityFilterType($translator)], []), new CsrfExtension($this->getMock('Symfony\\Component\\Form\\Extension\\Csrf\\CsrfProvider\\CsrfProviderInterface'))])->getFormFactory(); $classMetaData = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetaData->expects($this->any())->method('getName')->will($this->returnValue('OroSegment:Segment')); $classMetaData->expects($this->any())->method('getIdentifier')->will($this->returnValue(['id'])); $this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValue($classMetaData)); $this->dynamicSegmentQueryBuilder = $this->getMockBuilder('Oro\\Bundle\\SegmentBundle\\Query\\DynamicSegmentQueryBuilder')->disableOriginalConstructor()->getMock(); $this->staticSegmentQueryBuilder = $this->getMockBuilder('Oro\\Bundle\\SegmentBundle\\Query\\StaticSegmentQueryBuilder')->disableOriginalConstructor()->getMock(); $this->entityNameProvider = $this->getMock('Oro\\Bundle\\SegmentBundle\\Provider\\EntityNameProvider'); $this->entityNameProvider->expects($this->any())->method('getEntityName')->will($this->returnValue('Namespace\\Entity')); $this->entityConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock(); $this->extendConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock(); $configManager = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock(); $this->entityConfigProvider->expects($this->any())->method('getConfigManager')->will($this->returnValue($configManager)); $configManager->expects($this->any())->method('getEntityManager')->will($this->returnValue($this->em)); $staticQBServiceID = uniqid('static'); $dynamicQBServiceID = uniqid('dynamic'); $container = new Container(); $container->set($staticQBServiceID, $this->staticSegmentQueryBuilder); $container->set($dynamicQBServiceID, $this->dynamicSegmentQueryBuilder); $this->filter = new SegmentFilter($this->formFactory, new FilterUtility(), new ServiceLink($container, $dynamicQBServiceID), new ServiceLink($container, $staticQBServiceID), $this->entityNameProvider, $this->entityConfigProvider, $this->extendConfigProvider); $this->filter->init('segment', ['entity' => '']); }
private function getContainer($eventDispatcher) { $container = new Container(); $container->set('fm_elfinder.loader', $this->getElFinderLoaderMock()); $container->set('http_kernel', $this->getHttpKernelMock()); $container->set('event_dispatcher', $eventDispatcher); return $container; }
public function testCall() { $service = $this->getCallbackMock(); $service->expects($this->once())->method('__invoke'); $this->container->set('foo_api', $service); $this->binding->on('foo', '0', 'foo_api'); $this->binding->call(new Request('foo', '0', [])); }
public function testMapping() { $this->container->set("value_from_the_container", 123); $plan = $this->getBuildPlanOfObjectUsing("value_from_the_container"); $serializedPlan = $this->haringo->serializeBuildPlan($plan); $unserializedPlan = $this->haringo->deserializeBuildPlan($serializedPlan); $builtObject = $this->haringo->buildObjectBasedOn($unserializedPlan); $this->assertEquals(123, $builtObject->val); }
/** * Retrieve the 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'); }
public function testShouldInitializeDependencies() { $dependency = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $object = $this->getMock('Oro\\Component\\Layout\\Tests\\Unit\\Extension\\Theme\\Stubs\\LayoutUpdateWithDependency'); $object->expects($this->once())->method('setContainer')->with($this->identicalTo($dependency)); $this->container->set('dependency_service_id', $dependency); $this->initializer->addKnownDependency('\\Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', 'setContainer', 'dependency_service_id'); $this->initializer->initialize($object); }
public function testPutFast() { $job = $this->getMockBuilder(Job::class)->getMock(); $registry = $this->getMockBuilder(QueueManagerRegistry::class)->disableOriginalConstructor()->getMock(); $registry->expects($this->once())->method('put')->with('test_worker', [])->willReturn($job); $this->container->set('mcfedr_queue_manager.registry', $registry); $putJob = $this->manager->put('test_worker', []); $this->assertEquals($job, $putJob); }
protected function createContext() { $container = new Container(new ParameterBag()); $helper = new Helper($container); $httpKernel = new Kernel($container); $container->set('simple_http.helper', $helper); $container->set('simple_http.kernel', $httpKernel); return [$helper, $httpKernel, $container]; }
/** * Returns a valid Container * * @return \Symfony\Component\DependencyInjection\Container */ protected function getContainer(MockGenerator $mg, Pheanstalk $pheanstalk) { $container = new Container(); $container->setParameter('kernel.root_dir', sys_get_temp_dir()); $container->set('pheanstalk', $pheanstalk); $container->set('logger', $mg->getLoggerMock()); $container->set('pheanstalk.queue.tube_collection', $this->mg->getTubeColletionMock(array($mg->getTubeMock()))); return $container; }
/** * @return Container */ private function buildContainer(\Swift_Transport $transport, \Swift_Transport $realTransport, $name = 'default') { $mailer = new \Swift_Mailer($transport); $container = new Container(); $container->set(sprintf('swiftmailer.mailer.%s', $name), $mailer); $container->set(sprintf('swiftmailer.mailer.%s.transport.real', $name), $realTransport); $container->setParameter('swiftmailer.mailers', array($name => $mailer)); $container->setParameter(sprintf('swiftmailer.mailer.%s.spool.enabled', $name), true); return $container; }
protected function getContainer() { $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface'); $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $container = new Container(); $container->set('kernel', $kernel); $container->set('twig', $twig); $container->setParameter('kernel.root_dir', sys_get_temp_dir()); return $container; }
protected function setUp() { $this->publisher = $this->getMock('Oro\\Bundle\\SyncBundle\\Wamp\\TopicPublisher'); $this->securityContext = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface'); $this->generator = new TagGeneratorChain(); $container = new Container(); $container->set('generator', $this->generator); $container->set('security', $this->securityContext); $this->sender = new TopicSender($this->publisher, new ServiceLink($container, 'generator'), new ServiceLink($container, 'security')); }
public function setup() { $container = new Container(); $this->resetter = $this->getMockBuilder('\\FOS\\ElasticaBundle\\Resetter')->disableOriginalConstructor()->setMethods(array('resetIndex', 'resetIndexType'))->getMock(); $container->set('fos_elastica.resetter', $this->resetter); $this->indexManager = $this->getMockBuilder('\\FOS\\ElasticaBundle\\IndexManager')->disableOriginalConstructor()->setMethods(array('getAllIndexes'))->getMock(); $container->set('fos_elastica.index_manager', $this->indexManager); $this->command = new ResetCommand(); $this->command->setContainer($container); }
/** * @expectedException \Giftcards\Encryption\CipherText\Rotator\RotatorNotFoundException */ public function testGetWhereNotThere() { $rotator1 = \Mockery::mock('Giftcards\\Encryption\\CipherText\\Rotator\\RotatorInterface'); $rotator1Name = $this->getFaker()->unique()->word; $rotator2 = \Mockery::mock('Giftcards\\Encryption\\CipherText\\Rotator\\RotatorInterface'); $rotator2Name = $this->getFaker()->unique()->word; $rotator3 = \Mockery::mock('Giftcards\\Encryption\\CipherText\\Rotator\\RotatorInterface'); $rotator3Name = $this->getFaker()->unique()->word; $this->container->set('rotator2', $rotator2); $this->registry->set($rotator1Name, $rotator1)->setServiceId($rotator2Name, 'rotator2')->set($rotator3Name, $rotator3)->get($this->getFaker()->unique()->word); }
/** * Skip classes for deleting expired tokens that do not implement AuthCodeManagerInterface or TokenManagerInterface. */ public function testItShouldNotRemoveExpiredTokensForOtherClasses() { $this->container->set('fos_oauth_server.access_token_manager', new \stdClass()); $this->container->set('fos_oauth_server.refresh_token_manager', new \stdClass()); $this->container->set('fos_oauth_server.auth_code_manager', new \stdClass()); $tester = new CommandTester($this->command); $tester->execute(array('command' => $this->command->getName())); $display = $tester->getDisplay(); $this->assertNotRegExp(sprintf('\'Removed (\\d)+ items from %s storage.\'', 'Access token'), $display); $this->assertNotRegExp(sprintf('\'Removed (\\d)+ items from %s storage.\'', 'Refresh token'), $display); $this->assertNotRegExp(sprintf('\'Removed (\\d)+ items from %s storage.\'', 'Auth code'), $display); }
protected function getContainer() { $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface'); $kernel->expects($this->any())->method('getBundle')->will($this->returnValue($this->getBundle())); $filesystem = $this->getMock('Symfony\\Component\\HttpKernel\\Util\\Filesystem'); $filesystem->expects($this->any())->method('isAbsolutePath')->will($this->returnValue(true)); $container = new Container(); $container->set('kernel', $kernel); $container->set('filesystem', $filesystem); $container->setParameter('kernel.root_dir', sys_get_temp_dir()); return $container; }
/** * @test */ public function shouldReturnChainFilter() { $filterLoader1 = $this->createFilterLoaderMock(); $filterLoader1->expects($this->once())->method('load')->will($this->returnValue(new Filter())); $filterLoader2 = $this->createFilterLoaderMock(); $filterLoader2->expects($this->once())->method('load')->will($this->returnValue(new Filter())); $container = new Container(); $container->set('filter1', $filterLoader1); $container->set('filter2', $filterLoader2); $loader = new ChainFilterLoader($container); $result = $loader->load(array('filters' => array('filter1' => array(), 'filter2' => array()))); $this->assertInstanceOf('Avalanche\\Bundle\\ImagineBundle\\Imagine\\Filter\\ChainFilter', $result); }
protected function setUp() { $this->migrator = $this->prophesize(Migrator::class); $this->migrator->getNotes()->willReturn([]); $this->migrator->paths()->willReturn([]); $this->migrator->setConnection(Argument::any())->willReturn(); $this->container = new Container(); $this->container->setParameter('kernel.environment', 'dev'); $this->container->setParameter('wouterj_eloquent.migration_path', __DIR__ . '/migrations'); $this->container->set('wouterj_eloquent.migrator', $this->migrator->reveal()); $this->command = new MigrateRollbackCommand(); $this->command->setContainer($this->container); }
public function testDataGridExtensionWithString() { $dataGridMock = $this->getMock('Neutron\\DataGridBundle\\DataGrid\\DataGridInterface'); $providerMock = $this->getMock('Neutron\\DataGridBundle\\DataGrid\\Provider\\DataGridProviderInterface'); $providerMock->expects($this->once())->method('get')->with('myDataGrid')->will($this->returnValue($dataGridMock)); $templatingMock = $this->getMockBuilder('Symfony\\Bundle\\TwigBundle\\TwigEngine')->disableOriginalConstructor()->getMock(); $templatingMock->expects($this->once())->method('render')->with('NeutronDataGridBundle:DataGrid:index.html.twig', array('dataGrid' => $dataGridMock, 'translationDomain' => 'messages'))->will($this->returnValue('<table>test</table>')); $container = new Container(); $container->setParameter('neutron_data_grid.translation_domain', 'messages'); $container->set('templating', $templatingMock); $container->set('neutron_data_grid.provider', $providerMock); $this->assertEquals('<table>test</table>', $this->getTemplate("{{ neutron_datagrid('myDataGrid') }}", $container)->render(array())); }
public function testWarmup() { $container = new Container(); $container->set('ezpublish.config.resolver.core', new stdClass()); $container->set('ezpublish.config.resolver.chain', new stdClass()); self::assertTrue($container->initialized('ezpublish.config.resolver.core')); self::assertTrue($container->initialized('ezpublish.config.resolver.chain')); $warmer = new ConfigResolverCleanup(); $warmer->setContainer($container); $warmer->warmUp('my_cache_dir'); self::assertFalse($container->initialized('ezpublish.config.resolver.core')); self::assertFalse($container->initialized('ezpublish.config.resolver.chain')); }
/** * Create the default container containing all basic services. * * @param array $services Array of services to provide. * * @return Container */ protected function createDefaultContainer($services = []) { $container = new Container(); foreach ($services as $name => $service) { $container->set($name, $service); } if (!$container->has('event_dispatcher')) { $container->set('event_dispatcher', new EventDispatcher()); } if (!$container->has('tenside.home')) { $home = $this->getMock(HomePathDeterminator::class, ['homeDir']); $home->method('homeDir')->willReturn($this->getTempDir()); $container->set('tenside.home', $home); } if (!$container->has('tenside.config')) { $container->set('tenside.config', TensideJsonConfigFactory::create($container->get('tenside.home'))); } if (!$container->has('tenside.taskfactory')) { $container->set('tenside.taskfactory', new ComposerTaskFactory($container->get('tenside.home'))); } if (!$container->has('tenside.tasks')) { $container->set('tenside.tasks', TaskListFactory::create($container->get('tenside.home'), $container->get('tenside.taskfactory'))); } if (!$container->has('tenside.composer_json')) { $container->set('tenside.composer_json', ComposerJsonFactory::create($container->get('tenside.home'))); } if (!$container->has('tenside.status')) { $tenside = new InstallationStatusDeterminator($container->get('tenside.home')); $container->set('tenside.status', $tenside); } return $container; }
public function setUp() { $application = new Application(); $application->add(new ProvideCommand()); $command = $application->find('elasticsearch:provide'); $this->commandTester = new CommandTester($command); $this->handler = $this->getMockBuilder(Handler::class)->disableOriginalConstructor()->getMock(); $container = new Container(); $container->set('gbprod.elasticsearch_dataprovider.handler', $this->handler); $container->set('event_dispatcher', $this->getMock(EventDispatcherInterface::class)); $this->client = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock(); $container->set('m6web_elasticsearch.client.default', $this->client); $command->setContainer($container); }
public function setUp() { $application = new Application(); $application->add(new ProvideCommand()); $command = $application->find('elasticsearch:provide'); $this->commandTester = new CommandTester($command); $this->handler = $this->prophesize(Handler::class); $container = new Container(); $container->set('gbprod.elastica_provider.handler', $this->handler->reveal()); $container->set('event_dispatcher', $this->getMock(EventDispatcherInterface::class)); $this->client = $this->prophesize(Client::class); $container->set('gbprod.elastica_provider.default_client', $this->client->reveal()); $command->setContainer($container); }
/** * @test */ public function shouldExecuteAuthorizeRequest() { $request = Request::create('/'); $request->query->set('foo', 'fooVal'); $token = new Token; $token->setPaymentName('thePayment'); $token->setAfterUrl('http://example.com/theAfterUrl'); $tokenVerifierMock = $this->getMock('Payum\Core\Security\HttpRequestVerifierInterface'); $tokenVerifierMock ->expects($this->once()) ->method('verify') ->with($this->identicalTo($request)) ->will($this->returnValue($token)) ; $tokenVerifierMock ->expects($this->once()) ->method('invalidate') ->with($this->identicalTo($token)) ; $paymentMock = $this->getMock('Payum\Core\PaymentInterface'); $paymentMock ->expects($this->once()) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\Authorize')) ; $registryMock = $this->getMock('Payum\Core\Registry\RegistryInterface'); $registryMock ->expects($this->once()) ->method('getPayment') ->with('thePayment') ->will($this->returnValue($paymentMock)) ; $container = new Container; $container->set('payum', $registryMock); $container->set('payum.security.http_request_verifier', $tokenVerifierMock); $controller = new AuthorizeController; $controller->setContainer($container); $response = $controller->doAction($request); $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertEquals('http://example.com/theAfterUrl', $response->getTargetUrl()); }