8000 [2.7] [FrameworkBundle] minor fix tests added by #17569 by HeahDude · Pull Request #17859 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.7] [FrameworkBundle] minor fix tests added by #17569 #17859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7911
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testBundleInterfaceImplementation()
{
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');

$kernel = $this->getKernel(array($bundle));
$kernel = $this->getKernel(array($bundle), true);

$application = new Application($kernel);
$application->doRun(new ArrayInput(array('list')), new NullOutput());
Expand All @@ -35,7 +35,7 @@ public function testBundleCommandsAreRegistered()
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');

$kernel = $this->getKernel(array($bundle));
$kernel = $this->getKernel(array($bundle), true);

$application = new Application($kernel);
$application->doRun(new ArrayInput(array('list')), new NullOutput());
Expand All @@ -49,12 +49,7 @@ public function testBundleCommandsAreRetrievable()
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');

$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array($bundle)))
;
$kernel = $this->getKernel(array($bundle));

$application = new Application($kernel);
$application->all();
Expand All @@ -68,12 +63,7 @@ public function testBundleSingleCommandIsRetrievable()
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');

$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array($bundle)))
;
$kernel = $this->getKernel(array($bundle));

$application = new Application($kernel);

Expand All @@ -88,12 +78,7 @@ public function testBundleCommandCanBeFound()
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');

$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array($bundle)))
;
$kernel = $this->getKernel(array($bundle));

$application = new Application($kernel);

Expand All @@ -108,12 +93,7 @@ public function testBundleCommandCanBeFoundByAlias()
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
$bundle->expects($this->once())->method('registerCommands');

$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array($bundle)))
;
$kernel = $this->getKernel(array($bundle));

$application = new Application($kernel);

Expand All @@ -130,7 +110,7 @@ public function testBundleCommandsHaveRightContainer()
$command->setCode(function () {});
$command->expects($this->exactly(2))->method('setContainer');

$application = new Application($this->getKernel(array()));
$application = new Application($this->getKernel(array(), true));
$application->setAutoExit(false);
$application->setCatchExceptions(false);
$application->add($command);
Expand All @@ -143,21 +123,23 @@ public function testBundleCommandsHaveRightContainer()
$tester->run(array('command' => 'foo'));
}

private function getKernel(array $bundles)
private function getKernel(array $bundles, $useDispatcher = false)
{
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$dispatcher
->expects($this->atLeastOnce())
->method('dispatch')
;

$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container
->expects($this->atLeastOnce())
->method('get')
->with($this->equalTo('event_dispatcher'))
->will($this->returnValue($dispatcher))
;

if ($useDispatcher) {
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$dispatcher
->expects($this->atLeastOnce())
->method('dispatch')
;
$container
->expects($this->atLeastOnce())
->method('get')
->with($this->equalTo('event_dispatcher'))
->will($this->returnValue($dispatcher));
}

$container
->expects($this->once())
->method('hasParameter')
Expand Down
0