Permalink
Browse files

added helperSet to console event objects

  • Loading branch information...
1 parent f224102 commit 4edf29d04a06e08dcc174c7c1ebaf36c847cea4e @bamarni bamarni committed with fabpot Feb 6, 2013
@@ -38,13 +38,16 @@
public function run(InputInterface $input, OutputInterface $output)
{
$dispatcher = $this->getContainer()->get('event_dispatcher');
+ $helperSet = $this->getHelperSet();
$initEvent = new ConsoleEvent($input, $output);
+ $initEvent->setHelperSet($helperSet);
$dispatcher->dispatch(ConsoleEvents::INIT, $initEvent);
$exitCode = parent::run($input, $output);
$terminateEvent = new ConsoleTerminateEvent($input, $output, $exitCode);
+ $terminateEvent->setHelperSet($helperSet);
$dispatcher->dispatch(ConsoleEvents::TERMINATE, $terminateEvent);
return $exitCode;
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Event;
+use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\Event;
@@ -26,13 +27,35 @@ class ConsoleEvent extends Event
private $output;
+ private $helperSet;
+
public function __construct(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
}
/**
+ * Sets the helper set.
+ *
+ * @param HelperSet $helperSet A HelperSet instance
+ */
+ public function setHelperSet(HelperSet $helperSet)
+ {
+ $this->helperSet = $helperSet;
+ }
+
+ /**
+ * Gets the helper set.
+ *
+ * @return HelperSet A HelperSet instance
+ */
+ public function getHelperSet()
+ {
+ return $this->helperSet;
+ }
+
+ /**
* Returns the input object
*
* @return InputInterface
@@ -13,8 +13,8 @@
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\Tests\Console\Fixtures\FooCommand;
-use Symfony\Bundle\FrameworkBundle\Tests\Console\Fixtures\SilentCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
+use Symfony\Bundle\FrameworkBundle\Console\ConsoleEvents;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
@@ -51,16 +51,6 @@ public function testCommandDispatchEvents()
$application->doRun(new ArrayInput(array('foo')), new NullOutput());
}
- public function testSilentCommand()
- {
- $kernel = $this->getKernel(array(), $this->never());
-
- $application = new Application($kernel);
- $application->add(new SilentCommand('chut'));
-
- $application->doRun(new ArrayInput(array('chut')), new NullOutput());
- }
-
private function getKernel(array $bundles, $dispatcherExpected = null)
{
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");
@@ -80,8 +70,19 @@ private function getKernel(array $bundles, $dispatcherExpected = null)
} else {
$eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$eventDispatcher
- ->expects($this->atLeastOnce())
- ->method('dispatch');
+ ->expects($this->at(0))
+ ->method('dispatch')
+ ->with(
+ $this->equalTo(ConsoleEvents::INIT),
+ $this->isInstanceOf('Symfony\Bundle\FrameworkBundle\Event\ConsoleEvent')
+ );
+ $eventDispatcher
+ ->expects($this->at(1))
+ ->method('dispatch')
+ ->with(
+ $this->equalTo(ConsoleEvents::TERMINATE),
+ $this->isInstanceOf('Symfony\Bundle\FrameworkBundle\Event\ConsoleTerminateEvent')
+ );
$container
->expects($dispatcherExpected)
->method('get')
@@ -1,25 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Fixtures;
-
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-
-class SilentCommand extends Command
-{
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- return 0;
- }
-}

0 comments on commit 4edf29d

Please sign in to comment.