Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Console Contents Assertion Error #37

@wandersonwhcr

Description

@wandersonwhcr

Hi,

If I use "console write" in objects of Zend\Mvc\Console\Controller\AbstractConsoleController, when testing, it outputs the content and assertConsoleOutputContents don't recognize the output.

Example:

namespace Foo\Bar\Console;

use Zend\Mvc\Console\Controller\AbstractConsoleController;

class Baz extends AbstractConsoleController
{
    public function quxAction()
    {
        $this->getConsole()->writeLine('Hello');
    }
}
<?php

namespace FooTest\Bar\Console;

use Zend\Test\PHPUnit\Controller\AbstractConsoleControllerTestCase as TestCase;

class BazTest extends TestCase
{
    protected function setUp()
    {
        $this->setApplicationConfig(include './config/autoload.php');
        parent::setUp();
    }

    public function testQuxAction()
    {
        $this->dispatch('foo-bar baz-qux');

        $this->assertConsoleOutputContains('Hello');
    }
}

It outputs:

$ php vendor/bin/phpunit --filter FooTest\\Bar\\Console\\BazTest::testQuxAction
PHPUnit 5.5.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.0.10-1~dotdeb+8.1 with Xdebug 2.4.1
Configuration: /vagrant/phpunit.xml

F                                                                   1 / 1 (100%)Hello

Time: 2.46 seconds, Memory: 8.00MB

There was 1 failure:

1) FooTest\Bar\Console\BazTest::testQuxAction
Failed asserting output CONTAINS content "Hello", actual content is ""

/vagrant/vendor/zendframework/zend-test/src/PHPUnit/Controller/AbstractConsoleControllerTestCase.php:32
/vagrant/test/FooTest/Bar/Console/BazTest.php:19

FAILURES!
Tests: 1, Assertions: 0, Failures: 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions