Skip to content

Instantly share code, notes, and snippets.

@gnugat
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save gnugat/400729d3f97fd2ed7fc9 to your computer and use it in GitHub Desktop.

Select an option

Save gnugat/400729d3f97fd2ed7fc9 to your computer and use it in GitHub Desktop.

Revisions

  1. Loïc Chardonnet revised this gist Oct 6, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CommandTestApplication.php
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ public function __construct()
    $this->container = $this->kernel->getContainer();

    $this->application = new Application($this->kernel);
    $this->application->setAutoExit(true);
    $this->application->setAutoExit(false);
    }

    /**
  2. Loïc Chardonnet revised this gist Oct 6, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion CommandTestApplication.php
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    namespace Gnugat\Ripozi\Test;

    use Symfony\Component\Console\Application;
    use Symfony\Bundle\FrameworkBundle\Console\Application;
    use Symfony\Component\Console\Input\ArrayInput;
    use Symfony\Component\Console\Output\NullOutput;

    @@ -36,6 +36,7 @@ public function __construct()
    $this->container = $this->kernel->getContainer();

    $this->application = new Application($this->kernel);
    $this->application->setAutoExit(true);
    }

    /**
  3. Loïc Chardonnet revised this gist Oct 6, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CommandTestApplication.php
    Original file line number Diff line number Diff line change
    @@ -45,7 +45,7 @@ public function __construct()
    */
    public function run(array $rawInput)
    {
    $input = new ArrayInput($input);
    $input = new ArrayInput($rawInput);
    $output = new NullOutput();

    return $this->application->run($input, $output);
  4. Loïc Chardonnet revised this gist Oct 6, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions CommandTestApplication.php
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,8 @@
    */
    class CommandTestApplication
    {
    const EXIT_SUCCESS = 0;

    /**
    * @var Application
    */
  5. Loïc Chardonnet created this gist Oct 6, 2014.
    51 changes: 51 additions & 0 deletions CommandTestApplication.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    <?php

    namespace Gnugat\Ripozi\Test;

    use Symfony\Component\Console\Application;
    use Symfony\Component\Console\Input\ArrayInput;
    use Symfony\Component\Console\Output\NullOutput;

    /**
    * Assumes that the application kernel is named AppKernel and has been loaded
    */
    class CommandTestApplication
    {
    /**
    * @var Application
    */
    private $application;

    /**
    * @var \Symfony\Component\DependencyInjection\ContainerInterface
    */
    private $container;

    /**
    * @var \Symfony\Component\HttpKernel\KernelInterface
    */
    private $kernel;

    public function __construct()
    {
    $this->kernel = new \AppKernel('test', true);
    $this->kernel->boot();

    $this->container = $this->kernel->getContainer();

    $this->application = new Application($this->kernel);
    }

    /**
    * @param array $rawInput
    *
    * @return int
    */
    public function run(array $rawInput)
    {
    $input = new ArrayInput($input);
    $output = new NullOutput();

    return $this->application->run($input, $output);
    }
    }