Framework: [6.x] Console Command Test with table() is broken

Created on 12 Feb 2020  路  9Comments  路  Source: laravel/framework

  • Laravel Version: 6.x
  • PHP Version: 7.3.14 (not relevant)
  • Database Driver & Version: (not relevant)

Description:

With https://github.com/laravel/framework/pull/31426 now any command that uses table() is breaking on tests, the reason is at testing we mock a BufferedOutput and not a ConsoleOutput, which has section() method:

https://github.com/laravel/framework/blob/6.x/src/Illuminate/Foundation/Testing/PendingCommand.php#L185-L207

I tried to mock ConsoleOutput instead but it's not that simple as the output stream at ConsoleOutput is done on private methods.

Steps To Reproduce:

Create a Command that uses table() and tests it asserting the exit code.

bug

Most helpful comment

@tbuteler @stefanullrich I鈥檓 going to take a look at this issue this evening and see if I can patch

All 9 comments

Fixed in 6.15.1.

Thanks for the quick fix, though I think this error still occurs when the test has the mockConsoleOutput property set to false.

@adam-prickett
Can confirm, as @tbuteler said, it is not working when testing commands with mockConsoleOutputis set to false within test.

Call to undefined method Symfony\Component\Console\Output\BufferedOutput::section()
in file /.../vendor/laravel/framework/src/Illuminate/Console/Concerns/InteractsWithIO.php (225)

Downgrading to 6.14.0 worked like charm.

@tbuteler @stefanullrich I鈥檓 going to take a look at this issue this evening and see if I can patch

I side with @stefanullrich. I just upgraded from v6.11.0 => v6.15.1 and Artisan::output() broke. Now some tests fail.

Error: Call to undefined method Symfony\Component\Console\Output\BufferedOutput::section()

@JosephSilber

Can you check if the tests breaking on v6.15.0 and also v6.15.1.

I'm not sure how the test would fail on your case since I can't find that the code using table(), it might be best to debug if it's related to changes to PendingCommand code in v6.15.1 (and also why it's failing in 7.4 only).

@crynobone you're right. Bouncer's failing test has nothing to do with this (nor with PendingCommand), since it now also fails on Laravel 6.0.0.

It must be a different dependency that was updated. I'll have to investigate and track that down.

Sorry for adding to the noise here.

We've reverted the entire feature for now because of all the problems popping up.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

progmars picture progmars  路  3Comments

shopblocks picture shopblocks  路  3Comments

PhiloNL picture PhiloNL  路  3Comments

klimentLambevski picture klimentLambevski  路  3Comments

YannPl picture YannPl  路  3Comments