Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output is not cleared after specify #10

Open
ddziaduch opened this issue Dec 18, 2014 · 2 comments
Open

Output is not cleared after specify #10

ddziaduch opened this issue Dec 18, 2014 · 2 comments

Comments

@ddziaduch
Copy link

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".

@ghost
Copy link

ghost commented Aug 18, 2020

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.

@ddziaduch
Copy link
Author

@TavoNiievez wow, this is quiet old issue 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant