I developed my own version of a package and it has console commands that I need to test. All the tests run fine except for the ones that assert an output from artisan. For some reason, Artisan::output() returns "" when running the tests.
Could it be that I don't have an application instance in the tests like a normal Laravel app that extends Illuminate\Foundation\Testing\TestCase instead of mine that extends Orchestra\Testbench\TestCase? If so, is there any way to replicate that for a package because I would really get these last few tests to pass.
I know the output is there because I ran the command like I have in the test in an application that is using the package and it displays the expected output in the console. I just really want to get the test to pass.
Of course after asking the question I found how to solve it. I didn't realize that the console gets mocked now and you can prevent that behavior in your tests. Adding the following line in the setUp function in my base test class fixed my issue:
public function setUp()
{
parent::setUp();
// This fixed the issue
$this->withoutMockingConsoleOutput();
}
Thanks @Cronix, I did try that as well but it was the same problem with nothing being returned from the output. Turns out it was just being mocked and I had to disable that with withoutMockingConsoleOutput.