public function testNoRulesAreAddedWhenProfilerToolbarAreDisabled() { $definition = $this->getMock(Definition::class, ['addMethod']); $container = $this->getMockBuilder(ContainerBuilder::class)->setMethods(['hasDefinition', 'getDefinition', 'hasParameter', 'getParameter'])->getMock(); $container->expects($this->exactly(3))->method('hasDefinition')->will($this->returnValue(true)); $container->expects($this->exactly(1))->method('hasParameter')->with('web_profiler.debug_toolbar.mode')->will($this->returnValue(false)); $container->expects($this->once())->method('getParameter')->with('fos_rest.format_listener.rules')->will($this->returnValue([['host' => null, 'methods' => null, 'path' => '^/', 'priorities' => ['html', 'json'], 'fallback_format' => 'html', 'exception_fallback_format' => 'html', 'prefer_extension' => true]])); $container->expects($this->exactly(2))->method('getDefinition')->with($this->logicalOr($this->equalTo('fos_rest.format_negotiator'), $this->equalTo('fos_rest.exception_format_negotiator')))->will($this->returnValue($definition)); $compiler = new FormatListenerRulesPass(); $compiler->process($container); }
public function testNoRulesAreAddedWhenProfilerToolbarAreDisabled() { $definition = $this->getMock('Symfony\\Component\\DependencyInjection\\Definition', array('addMethod')); $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder'); $container->expects($this->exactly(2))->method('hasDefinition')->will($this->returnValue(true)); $container->expects($this->exactly(1))->method('hasParameter')->with('web_profiler.debug_toolbar.mode')->will($this->returnValue(false)); $container->expects($this->once())->method('getParameter')->with('fos_rest.format_listener.rules')->will($this->returnValue(array(array('host' => null, 'methods' => null, 'path' => '^/', 'priorities' => array('html', 'json'), 'fallback_format' => 'html', 'prefer_extension' => true)))); $container->expects($this->exactly(1))->method('getDefinition')->with('fos_rest.format_negotiator')->will($this->returnValue($definition)); $compiler = new FormatListenerRulesPass(); $compiler->process($container); }