phpunit Risky Test code or tested code did not (only) close its own output buffers

When I execute a phpunit test that has

@expectedException \Phalcon\Mvc\Dispatcher\Exception

thrown by \Phalcon\Mvc\Application::handle I get this message:

There was 1 risky test:

1) LicomTest\Api1\AppTest::testLicomApiAppRunMissedIndexController
Test code or tested code did not (only) close its own output buffers


OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 1, Risky: 1.

I have ext-phalcon 1.3.4 and I can not upgrade now.

Any workarround to fix it?

thanks in advance

edited May '15

Can you share the code snippit? I test expected exceptions this way. Basically, just a try/catch with a $this->fail() call if no exception is caught.

    public function testNonHttpsThrowsException()
        $dispatcher = DI::getDefault()->get("dispatcher");
        $stub = $this->getStub();

        try {
        } catch(\Exception $e) {
            $this->assertEquals($e->getCode(), 403);
            $this->assertEquals($e->getMessage(), "Unauthorized");

        $this->fail("HTTPS exception was not raised");

Not sure of your exact situation, but I got a message like that once before, where perhaps the method was echo'ing data and I needed to do some ob_start() ob_get_clean() calls.

edited May '15

Well, I do it in this way:

 * @small
 * @expectedException \Phalcon\Mvc\Dispatcher\Exception
public function testLicomApiAppRunMissedIndexController()
    $api = new \Licom\Api1\App();

Licom\Api1\App extends \Phalcon\Mvc\Application

method run() executes:


method load() set inside DI a Router, Response, Request, Dispatcher and a View

method handle() is not overrided.