Specify icon indicating copy to clipboard operation
Specify copied to clipboard

Output is not cleared after specify

Open ddziaduch opened this issue 10 years ago • 2 comments

Hi.

I've a test:

public function testSomething()
{
    $this->specify(
        'expect output',
        function () {
            $this->expectOutputString('lorem ipsum');
            (new TestedClass)->doSomething();
        }
    );
    $this->specify(
        'expect another output',
        function () {
            $this->expectOutputString('lorem ipsum');
            (new TestedClass)->doSomethingElse();
        }
    );
}

The first specification passes. Second specification is failing. It expect output to be "lorem ipsum 2", but gots "lorem ipsum 1lorem ipsum 2".

ddziaduch avatar Dec 18 '14 16:12 ddziaduch

Calling the ob_clean() function immediately after performing tasks that involve the output buffer may be a solution.

Otherwise this may serve as a workaround: How to flush output after each echo call? .

I don't know if there is a way to fix this without refactoring the code, but I think it is due to the fact that Specify lives as a trait and that assertions are made within anonymous functions that this cannot be easily controlled without calling the Output Control Functions explicitly.

ghost avatar Aug 18 '20 08:08 ghost

@TavoNiievez wow, this is quiet old issue 😆

ddziaduch avatar Aug 21 '20 10:08 ddziaduch