public function register(Container $container)
 {
     $container["data_collectors.swiftmailer.message_logger"] = function () {
         return new \Swift_Plugins_MessageLogger();
     };
     $container["data_collectors.swiftmailer.collector_container"] = function (Container $app) {
         $container = new SymfonyContainer();
         $container->setParameter("swiftmailer.mailers", ["default" => $app["swiftmailer.options"]]);
         $container->setParameter("swiftmailer.default_mailer", "default");
         $container->setParameter("swiftmailer.mailer.default.spool.enabled", $app["swiftmailer.use_spool"]);
         $container->set("swiftmailer.mailer.default.plugin.messagelogger", $app["data_collectors.swiftmailer.message_logger"]);
         return $container;
     };
     $container->extend('mailer', function (\Swift_Mailer $mailer, Container $container) {
         $mailer->registerPlugin($container['data_collectors.swiftmailer.message_logger']);
         return $mailer;
     });
     $container->extend('data_collectors', function (array $collectors, Container $container) {
         $collectors['swiftmailer'] = function ($container) {
             return new MessageDataCollector($container["data_collectors.swiftmailer.collector_container"]);
         };
         return $collectors;
     });
     $container->extend('data_collector.templates', function ($templates) {
         $templates[] = ['swiftmailer', '@Swiftmailer/Collector/swiftmailer.html.twig'];
         return $templates;
     });
     $container->extend('twig.loader.filesystem', function (\Twig_Loader_Filesystem $loader) {
         $loader->addPath(dirname(dirname((new \ReflectionClass(MessageDataCollector::class))->getFileName())) . '/Resources/views', 'Swiftmailer');
         return $loader;
     });
 }
 /**
  * @dataProvider getDebugModes
  */
 public function testDefaultConfig($debug)
 {
     $this->container->setParameter('kernel.debug', $debug);
     $extension = new WebProfilerExtension();
     $extension->load(array(array()), $this->container);
     $this->assertFalse($this->container->has('web_profiler.debug_toolbar'));
     $this->assertSaneContainer($this->getDumpedContainer());
 }
Esempio n. 3
0
 /**
  * @dataProvider getDebugModes
  */
 public function testToolbarConfig($debug)
 {
     $this->container->setParameter('kernel.debug', $debug);
     $extension = new WebProfilerExtension();
     $extension->load(array(array('toolbar' => $debug)), $this->container);
     $this->assertTrue($debug === $this->container->has('web_profiler.debug_toolbar'), '->load() registers web_profiler.debug_toolbar only when toolbar is true');
     $this->assertSaneContainer($this->getDumpedContainer());
 }
 /**
  * @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;
 }
 /**
  * @dataProvider menuStructureProvider
  * @param array $options
  */
 public function testBuild($options)
 {
     $this->container->setParameter('oro_menu_config', $options);
     $this->configurationBuilder->setContainer($this->container);
     $menu = new MenuItem('navbar', $this->factory);
     $this->configurationBuilder->build($menu, array(), 'navbar');
     $this->assertCount(2, $menu->getChildren());
     $this->assertEquals($options['tree']['navbar']['type'], $menu->getExtra('type'));
     $this->assertCount(count($options['tree']['navbar']['children']['user_user_show']['children']), $menu->getChild('user_user_show'));
     $this->assertEquals('user_user_show', $menu->getChild('user_user_show')->getName());
 }
 /**
  * @return void
  */
 public function setUp()
 {
     // create container
     $this->container = new Container();
     // create pid directory
     $this->pidDirectory = sys_get_temp_dir() . '/FFreitasBrCommandLockBundle/pid_directory';
     $fs = new Filesystem();
     if (!$fs->exists($this->pidDirectory)) {
         $fs->mkdir($this->pidDirectory);
     }
     // configure container
     $this->container->setParameter($this->configurationsParameterKey, array($this->pidDirectorySetting => $this->pidDirectory, $this->exceptionsListSetting => $this->exceptionsList));
 }
 protected function setUp()
 {
     /**
      * 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", $definition = array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
     $request = new Request();
     $requestStack = new RequestStack();
     $requestStack->push($request);
     $request->setSession(new Session(new MockArraySessionStorage()));
     $container->set("request", $request);
     $container->set("request_stack", $requestStack);
     $container->set("thelia.forms.validator_builder", new ValidatorBuilder());
     $container->set("event_dispatcher", new EventDispatcher());
     $this->factory = new TheliaFormFactory($requestStack, $container, $definition);
 }
 /**
  */
 public function testBuildWithOptionsAndRenderer()
 {
     $menuConfig = $this->getMenuConfigYamlArray();
     $this->helper->expects($this->once())->method('render')->with($this->containsOnlyInstancesOf('Knp\\Menu\\MenuItem'), $this->equalTo(['type' => 'some_menu']), $this->equalTo('some_renderer'))->will($this->returnValue('menu'));
     $this->container->setParameter('oro_menu_config', $menuConfig);
     $this->menuExtension->render(['navbar', 'user_user_show'], ['type' => 'some_menu'], 'some_renderer');
 }
Esempio n. 9
0
 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);
 }
 /**
  * @return SymfonyIntegration
  */
 private function getIntegration()
 {
     $container = new Container();
     $container->setParameter('plehatron_limoncello', []);
     $integration = new SymfonyIntegration();
     $integration->setContainer($container);
     return $integration;
 }
 /**
  * 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;
 }
Esempio n. 12
0
 public function testGetSetParameter()
 {
     $sc = new Container(new ParameterBag(array('foo' => 'bar')));
     $sc->setParameter('bar', 'foo');
     $this->assertEquals('foo', $sc->getParameter('bar'), '->setParameter() sets the value of a new parameter');
     $sc->setParameter('foo', 'baz');
     $this->assertEquals('baz', $sc->getParameter('foo'), '->setParameter() overrides previously set parameter');
     $sc->setParameter('Foo', 'baz1');
     $this->assertEquals('baz1', $sc->getParameter('foo'), '->setParameter() converts the key to lowercase');
     $this->assertEquals('baz1', $sc->getParameter('FOO'), '->getParameter() converts the key to lowercase');
     try {
         $sc->getParameter('baba');
         $this->fail('->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
         $this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
     }
 }
 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;
 }
Esempio n. 14
0
 /**
  * @see \Cosma\Bundle\TestingBundle\TestCase\Traits\RedisTrait::getRedisClient
  */
 public function testGetRedisClient()
 {
     $container = new Container();
     $container->setParameter('cosma_testing.redis.scheme', 'tcp');
     $container->setParameter('cosma_testing.redis.host', '127.0.0.1');
     $container->setParameter('cosma_testing.redis.port', 6379);
     $container->setParameter('cosma_testing.redis.database', 13);
     $container->setParameter('cosma_testing.redis.timeout', 5.0);
     $kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->setMethods(['getContainer'])->getMockForAbstractClass();
     $kernel->expects($this->any())->method('getContainer')->will($this->returnValue($container));
     $testCaseTrait = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\TestCase\\Traits\\RedisTrait')->disableOriginalConstructor()->setMethods(['getKernel'])->getMockForTrait();
     $testCaseTrait->expects($this->any())->method('getKernel')->will($this->returnValue($kernel));
     $reflectionClass = new \ReflectionClass($testCaseTrait);
     $reflectionMethod = $reflectionClass->getMethod('getRedisClient');
     $reflectionMethod->setAccessible(true);
     /** @type Client $redisClient */
     $redisClient = $reflectionMethod->invoke($testCaseTrait);
     $this->assertInstanceOf('\\Predis\\Client', $redisClient);
     return [$testCaseTrait, $reflectionClass, $kernel, $container];
 }
Esempio n. 15
0
 /**
  * @see \Cosma\Bundle\TestingBundle\TestCase\Traits\SolrTrait::getSolariumClient
  */
 public function testGetSolariumClient()
 {
     $container = new Container();
     $container->setParameter('cosma_testing.solarium.host', '127.0.0.1');
     $container->setParameter('cosma_testing.solarium.port', 8080);
     $container->setParameter('cosma_testing.solarium.path', '/solr');
     $container->setParameter('cosma_testing.solarium.core', 'test');
     $container->setParameter('cosma_testing.solarium.timeout', 10);
     $kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->setMethods(['getContainer'])->getMockForAbstractClass();
     $kernel->expects($this->once())->method('getContainer')->will($this->returnValue($container));
     $testCaseTrait = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\TestCase\\Traits\\SolrTrait')->disableOriginalConstructor()->setMethods(['getKernel'])->getMockForTrait();
     $testCaseTrait->expects($this->once())->method('getKernel')->will($this->returnValue($kernel));
     $reflectionClass = new \ReflectionClass($testCaseTrait);
     $reflectionMethod = $reflectionClass->getMethod('getSolariumClient');
     $reflectionMethod->setAccessible(true);
     /** @type Client $solariumClient */
     $solariumClient = $reflectionMethod->invoke($testCaseTrait);
     $this->assertInstanceOf('\\Solarium\\Core\\Client\\Client', $solariumClient);
     $this->assertEquals(['scheme' => 'http', 'host' => '127.0.0.1', 'port' => 8080, 'path' => '/solr', 'core' => 'test', 'timeout' => 10, 'key' => 'localhostTesting'], $solariumClient->getEndpoint()->getOptions());
     return [$testCaseTrait, $reflectionClass];
 }
Esempio n. 16
0
 /**
  * @see \Cosma\Bundle\TestingBundle\TestCase\Traits\ElasticTrait::getElasticClient
  */
 public function testGetElasticClient()
 {
     $container = new Container();
     $container->setParameter('cosma_testing.elastica.host', '127.0.0.1');
     $container->setParameter('cosma_testing.elastica.port', 8080);
     $container->setParameter('cosma_testing.elastica.path', '/search');
     $container->setParameter('cosma_testing.elastica.timeout', 10);
     $container->setParameter('cosma_testing.elastica.index', 'test_index');
     $kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->setMethods(['getContainer'])->getMockForAbstractClass();
     $kernel->expects($this->any())->method('getContainer')->will($this->returnValue($container));
     $testCaseTrait = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\TestCase\\Traits\\ElasticTrait')->disableOriginalConstructor()->setMethods(['getKernel'])->getMockForTrait();
     $testCaseTrait->expects($this->any())->method('getKernel')->will($this->returnValue($kernel));
     $reflectionClass = new \ReflectionClass($testCaseTrait);
     $reflectionMethod = $reflectionClass->getMethod('getElasticClient');
     $reflectionMethod->setAccessible(true);
     /** @type Client $elasticClient */
     $elasticClient = $reflectionMethod->invoke($testCaseTrait);
     $this->assertInstanceOf('\\Elastica\\Client', $elasticClient);
     $this->assertEquals(['host' => '127.0.0.1', 'port' => 8080, 'path' => '/search', 'timeout' => 10, 'url' => null, 'proxy' => null, 'transport' => null, 'persistent' => true, 'connections' => [], 'roundRobin' => false, 'log' => false, 'retryOnConflict' => 0, 'connectionStrategy' => 'Simple'], $elasticClient->getConfig());
     return [$testCaseTrait, $reflectionClass, $kernel, $container];
 }
Esempio n. 17
0
 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;
 }
 /**
  * @covers Hearsay\RequireJSBundle\Configuration\ConfigurationBuilder::__construct
  * @covers Hearsay\RequireJSBundle\Configuration\ConfigurationBuilder::getBaseUrl
  * @covers Hearsay\RequireJSBundle\Configuration\ConfigurationBuilder::setUseAlmond
  * @covers Hearsay\RequireJSBundle\Configuration\ConfigurationBuilder::getConfiguration
  */
 public function testUseAlmondProdEnvironment()
 {
     $mapping = $this->getMock('Hearsay\\RequireJSBundle\\Configuration\\NamespaceMappingInterface');
     $this->setRequestMock('/base');
     $this->container->setParameter('assetic.use_controller', true);
     $this->container->setParameter('kernel.debug', false);
     $builder = new ConfigurationBuilder($this->container, $mapping);
     $builder->setUseAlmond(true);
     $config = $builder->getConfiguration();
     $this->assertArrayHasKey('almond', $config, 'Almond key should exists');
     $this->assertTrue($config['almond'], 'Almond value should be true');
 }
 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 testShouldResolveTemplateFromContainerParameter()
 {
     $container = new Container();
     $container->setParameter('a_template_parameter', '@aTemplate');
     $factory = new ContainerAwareCoreGatewayFactory();
     $factory->setContainer($container);
     $called = false;
     $factory->create(['payum.template.foo' => '%a_template_parameter%', 'test' => function (ArrayObject $config) use(&$called) {
         $called = true;
         $this->assertEquals('@aTemplate', $config['payum.template.foo']);
     }]);
     $this->assertTrue($called);
 }
 /**
  * Execute the TgaLetsEncrypt command with specific parameters.
  *
  * @param array $parameters
  * @return CommandTester
  */
 public function execute($parameters = [])
 {
     $parameters = array_merge(['letsencrypt' => 'php ' . __DIR__ . '/../Fixtures/mockscript-ok.php', 'recovery_email' => '*****@*****.**', 'domains' => ['example.org'], 'logs_directory' => __DIR__ . '/../Fixtures/tmp', 'monitoring.email.enabled' => false, 'monitoring.email.to' => []], $parameters);
     $container = new Container();
     foreach ($parameters as $name => $value) {
         $container->setParameter('tga_lets_encrypt.' . $name, $value);
     }
     $command = new TgaLetsencryptCommand();
     $command->setContainer($container);
     $application = new Application();
     $application->add($command);
     $application->setAutoExit(false);
     $command = $application->find('tga:letsencrypt');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()]);
     return $commandTester;
 }
Esempio n. 22
0
 /**
  *
  */
 public function testExecute()
 {
     $this->container->setParameter('robots_txt', array('User-agent: *', 'Sitemap: http://test.com/sitemap.xml'));
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
     $kernel->method('getRootdir')->willReturn($this->webPath);
     $this->container->set('kernel', $kernel);
     $this->command->setContainer($this->container);
     $method = $this->reflectionClass->getMethod('execute');
     $method->setAccessible(true);
     $output = new StreamOutput(fopen('php://memory', 'w', false));
     $method->invoke($this->command, new ArrayInput(array()), $output);
     rewind($output->getStream());
     $this->assertRegExp('/Done/', stream_get_contents($output->getStream()));
     $this->assertTrue($this->filesystem->exists(array($this->webPath . '/robots.txt')));
     $data = file_get_contents($this->webPath . '/robots.txt');
     $this->assertEquals('User-agent: *' . PHP_EOL . 'Sitemap: http://test.com/sitemap.xml', $data);
 }
Esempio n. 23
0
 /**
  * Mocks a container with scopes.
  *
  * @param string|null $scope An optional scope
  *
  * @return \PHPUnit_Framework_MockObject_MockObject|Container The container object
  */
 protected function mockContainerWithContaoScopes($scope = null)
 {
     $container = new Container();
     $container->setParameter('kernel.root_dir', $this->getRootDir());
     $container->setParameter('kernel.cache_dir', $this->getCacheDir());
     $container->setParameter('kernel.debug', false);
     $container->setParameter('contao.image.bypass_cache', false);
     $container->setParameter('contao.image.target_path', 'assets/images');
     $container->set('contao.resource_finder', new ResourceFinder($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'));
     $container->set('contao.resource_locator', new FileLocator($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'));
     $request = new Request();
     $request->server->set('REMOTE_ADDR', '123.456.789.0');
     $request->server->set('SCRIPT_NAME', '/core/index.php');
     if (null !== $scope) {
         $request->attributes->set('_scope', $scope);
     }
     $requestStack = new RequestStack();
     $requestStack->push($request);
     $container->set('request_stack', $requestStack);
     $container->set('session', $this->mockSession());
     return $container;
 }
 protected function createTranslator($em, $cacheDir)
 {
     $listener = new GetDatabaseResourcesListener($this->getORMStorage($em), 'xxxxx');
     $dispatcher = new EventDispatcher();
     $dispatcher->addListener('lexik_translation.event.get_database_resources', array($listener, 'onGetDatabaseResources'));
     $container = new Container();
     $container->setParameter('kernel.default_locale', 'en');
     $container->set('event_dispatcher', $dispatcher);
     $container->compile();
     $loaderIds = array();
     $options = array('cache_dir' => $cacheDir);
     return new TranslatorMock($container, new MessageSelector(), $loaderIds, $options);
 }
 /**
  * @see \Cosma\Bundle\TestingBundle\TestCase\Traits\SeleniumTrait::openSecure
  */
 public function testOpenSecure()
 {
     $container = new Container();
     $container->setParameter('cosma_testing.selenium.remote_server_url', 'http://selenium.ro/wd/hub');
     $container->setParameter('cosma_testing.selenium.test_domain', 'google.ro');
     $kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->setMethods(['getContainer'])->getMockForAbstractClass();
     $kernel->expects($this->once())->method('getContainer')->will($this->returnValue($container));
     $testCaseTrait = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\TestCase\\Traits\\SeleniumTrait')->disableOriginalConstructor()->setMethods(['getKernel'])->getMockForTrait();
     $testCaseTrait->expects($this->once())->method('getKernel')->will($this->returnValue($kernel));
     $remoteWebDriver = $this->getMockBuilder('\\Facebook\\WebDriver\\Remote\\RemoteWebDriver')->disableOriginalConstructor()->setMethods(['get'])->getMock();
     $remoteWebDriver->expects($this->once())->method('get')->with('https://google.ro/secure_page.html')->will($this->returnSelf());
     $reflectionClass = new \ReflectionClass($testCaseTrait);
     $property = $reflectionClass->getParentClass()->getProperty('remoteWebDriver');
     $property->setAccessible(true);
     $property->setValue($testCaseTrait, $remoteWebDriver);
     $method = $reflectionClass->getMethod('openSecure');
     $method->setAccessible(true);
     $method->invoke($testCaseTrait, '/secure_page.html');
 }
 private function createContainer()
 {
     $container = new Container();
     $container->set('wouterj_eloquent.migrator', $this->migrator->reveal());
     $container->setParameter('wouterj_eloquent.migration_path', __DIR__ . '/migrations');
     $container->setParameter('kernel.environment', 'dev');
     return $container;
 }
 /**
  * Test normal updating.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 public function testUpdate()
 {
     $localFile = $_SERVER['argv'][0] = $this->createFixture('phar-file.phar', 'old-version');
     $this->provideFixture('self-update' . DIRECTORY_SEPARATOR . 'version');
     $newPhar = $this->provideFixture('self-update' . DIRECTORY_SEPARATOR . 'download' . DIRECTORY_SEPARATOR . '1.0.0' . DIRECTORY_SEPARATOR . 'tenside.phar');
     $container = new Container();
     $container->setParameter('tenside.self_update.base_url', 'file://' . $this->getTempDir() . DIRECTORY_SEPARATOR . 'self-update');
     $container->setParameter('tenside.self_update.origin_name', 'tenside.org');
     $container->setParameter('tenside.self_update.phar_name', 'tenside.phar');
     $input = new ArrayInput([]);
     $output = new BufferedOutput();
     $command = new SelfUpdateCommand();
     $command->setHelperSet(new HelperSet([]));
     $command->setContainer($container);
     $command->setIO(new ConsoleIO($input, $output, $command->getHelperSet()));
     $this->assertEquals(0, $command->run($input, $output));
     $this->assertFileEquals($newPhar, $localFile);
 }
Esempio n. 28
0
 private function getContainerInvalidFile()
 {
     $uploadedFileMock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\File\\UploadedFile')->disableOriginalConstructor()->getMock();
     $uploadedFileMock->expects($this->once())->method('guessExtension')->will($this->returnValue('txt'));
     $fileBagMock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\FileBag')->disableOriginalConstructor()->getMock();
     $fileBagMock->expects($this->once())->method('get')->with('file')->will($this->returnValue($uploadedFileMock));
     $requestMock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->disableOriginalConstructor()->getMock();
     $requestMock->expects($this->exactly(1))->method('isMethod')->with('POST')->will($this->returnValue(true));
     $requestMock->files = $fileBagMock;
     $managerMock = $this->getMock('Neutron\\FormBundle\\Manager\\FileManagerInterface');
     $sessionMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface');
     $sessionMock->expects($this->exactly(1))->method('has')->will($this->returnValue(true));
     $constraintValidationMock = $this->getMockBuilder('Symfony\\Component\\Validator\\ConstraintViolation')->disableOriginalConstructor()->getMock();
     $constraintValidationMock->expects($this->once())->method('getMessageTemplate')->will($this->returnValue('message_template'));
     $constraintValidationMock->expects($this->once())->method('getMessageParameters')->will($this->returnValue(array()));
     $validatorMock = $this->getMock('Symfony\\Component\\Validator\\ValidatorInterface');
     $validatorMock->expects($this->once())->method('validateValue')->will($this->returnValue(array($constraintValidationMock)));
     $translatorMock = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $translatorMock->expects($this->once())->method('trans')->will($this->returnValue(array('key' => 'translated_message')));
     $container = new Container();
     $container->set('request', $requestMock);
     $container->set('neutron_form.manager.file_manager', $managerMock);
     $container->set('session', $sessionMock);
     $container->set('validator', $validatorMock);
     $container->set('translator', $translatorMock);
     $container->setParameter('neutron_form.plupload.configs', array());
     return $container;
 }
Esempio n. 29
0
 /**
  * Mocks a container with scopes.
  *
  * @param string|null $scope
  *
  * @return \PHPUnit_Framework_MockObject_MockObject|Container
  */
 protected function mockContainerWithContaoScopes($scope = null)
 {
     $container = new Container();
     $container->setParameter('kernel.root_dir', $this->getRootDir());
     $container->setParameter('kernel.cache_dir', $this->getCacheDir());
     $container->setParameter('kernel.debug', false);
     $container->setParameter('contao.image.bypass_cache', false);
     $container->setParameter('contao.image.target_path', 'assets/images');
     $container->setParameter('contao.image.valid_extensions', ['jpg', 'svg', 'svgz']);
     $container->setParameter('contao.image.imagine_options', ['jpeg_quality' => 80, 'interlace' => ImageInterface::INTERLACE_PLANE]);
     $container->set('contao.resource_finder', new ResourceFinder($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'));
     $container->set('contao.resource_locator', new FileLocator($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'));
     $request = new Request();
     $request->server->set('REMOTE_ADDR', '123.456.789.0');
     $request->server->set('SCRIPT_NAME', '/core/index.php');
     if (null !== $scope) {
         $request->attributes->set('_scope', $scope);
     }
     $requestStack = new RequestStack();
     $requestStack->push($request);
     $container->set('request_stack', $requestStack);
     $container->set('session', $this->mockSession());
     $container->set('monolog.logger.contao', new NullLogger());
     return $container;
 }
 private function getContainerInvalidFile()
 {
     $uploadedFileMock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\File\\UploadedFile')->disableOriginalConstructor()->getMock();
     $uploadedFileMock->expects($this->once())->method('guessExtension')->will($this->returnValue('txt'));
     $fileBagMock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\FileBag')->disableOriginalConstructor()->getMock();
     $fileBagMock->expects($this->once())->method('get')->with('file')->will($this->returnValue($uploadedFileMock));
     $requestMock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->disableOriginalConstructor()->getMock();
     $requestMock->files = $fileBagMock;
     $managerMock = $this->getMock('Thrace\\MediaBundle\\Manager\\FileManagerInterface');
     $sessionMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface');
     $sessionMock->expects($this->exactly(1))->method('get')->will($this->returnValue(array('max_upload_size' => '4M', 'extensions' => 'jpg', 'minWidth' => 300, 'minHeight' => 100)));
     $constraintValidationMock = $this->getMockBuilder('Symfony\\Component\\Validator\\ConstraintViolation')->disableOriginalConstructor()->getMock();
     $constraintValidationMock->expects($this->once())->method('getMessageTemplate')->will($this->returnValue('message_template'));
     $constraintValidationMock->expects($this->once())->method('getMessageParameters')->will($this->returnValue(array()));
     $validatorMock = $this->getMock('Symfony\\Component\\Validator\\ValidatorInterface');
     $validatorMock->expects($this->once())->method('validateValue')->will($this->returnValue(array($constraintValidationMock)));
     $translatorMock = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $translatorMock->expects($this->once())->method('trans')->will($this->returnValue(array('key' => 'translated_message')));
     $container = new Container();
     $container->set('request', $requestMock);
     $container->set('thrace_media.imagemanager', $managerMock);
     $container->set('session', $sessionMock);
     $container->set('validator', $validatorMock);
     $container->set('translator', $translatorMock);
     $container->setParameter('thrace_media.plupload.options', array('normalize_width' => 1000, 'normalize_height' => 1000));
     return $container;
 }