protected function setUp() { if (!class_exists('Assetic\\AssetManager')) { $this->markTestSkipped('Assetic is not available.'); } if (!class_exists('Symfony\\Component\\Console\\Application')) { $this->markTestSkipped('Symfony Console is not available.'); } $this->writeTo = sys_get_temp_dir() . '/assetic_dump'; $this->application = $this->getMockBuilder('Symfony\\Bundle\\FrameworkBundle\\Console\\Application')->disableOriginalConstructor()->getMock(); $this->definition = $this->getMockBuilder('Symfony\\Component\\Console\\Input\\InputDefinition')->disableOriginalConstructor()->getMock(); $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface'); $this->helperSet = $this->getMock('Symfony\\Component\\Console\\Helper\\HelperSet'); $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $this->am = $this->getMockBuilder('Assetic\\Factory\\LazyAssetManager')->disableOriginalConstructor()->getMock(); $this->application->expects($this->any())->method('getDefinition')->will($this->returnValue($this->definition)); $this->definition->expects($this->any())->method('getArguments')->will($this->returnValue(array())); $this->definition->expects($this->any())->method('getOptions')->will($this->returnValue(array(new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages.'), new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev'), new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.')))); $this->application->expects($this->any())->method('getKernel')->will($this->returnValue($this->kernel)); $this->application->expects($this->once())->method('getHelperSet')->will($this->returnValue($this->helperSet)); $this->kernel->expects($this->any())->method('getContainer')->will($this->returnValue($this->container)); $writeTo = $this->writeTo; $this->container->expects($this->any())->method('getParameter')->will($this->returnCallback(function ($p) use($writeTo) { if ('assetic.write_to' === $p) { return $writeTo; } elseif ('assetic.variables' === $p) { return array(); } throw new \RuntimeException(sprintf('Unknown parameter "%s".', $p)); })); $this->container->expects($this->once())->method('get')->with('assetic.asset_manager')->will($this->returnValue($this->am)); $this->command = new DumpCommand(); $this->command->setApplication($this->application); }