<?php
namespace CLIFramework\Testing;
use PHPUnit_Framework_TestCase;

abstract class CommandTestCase extends PHPUnit_Framework_TestCase
{
    public $app;

    abstract public function setupApplication();

    public function getApplication()
    {
        return $this->app;
    }

    public function setUp()
    {
        $this->app = $this->setupApplication();
    }

    public function tearDown()
    {
        $this->app = NULL;
    }

    public function runCommand($args) {
        if (is_string($args)) {
            $args = preg_split('/\s+/',$args);
        }
        return $this->app->run($args);
    }
}

<?php
namespace CLIFramework\Testing;
use PHPUnit_Framework_TestCase;

abstract class CommandTestCase extends PHPUnit_Framework_TestCase
{
    public $app;

    public $outputBufferingActive = true;

    abstract public function setupApplication();

    public function getApplication()
    {
        return $this->app;
    }

    public function setUp()
    {
        if ($this->outputBufferingActive) {
            ob_start();
        }
        $this->app = $this->setupApplication();
    }

    public function tearDown()
    {
        $this->app = NULL;
        if ($this->outputBufferingActive) {
            ob_end_clean();
        }
    }

    public function runCommand($args) {
        if (is_string($args)) {
            $args = preg_split('/\s+/',$args);
        }
        return $this->app->run($args);
    }
}

Add outputBufferingActive property to clean up output buffer automatically
Add outputBufferingActive property to clean up output buffer automatically
