spiral / app

Spiral Framework Skeleton HTTP Application: Queue, Console, Cycle ORM
https://spiral.dev/
MIT License
191 stars 20 forks source link

InteractsWithConsole trait is broken #27

Closed hotrush closed 4 years ago

hotrush commented 4 years ago

Just try to create an app using this skeleton, go to TestCase class and add $this->runCommand('test'); into setUp method:

PHPUnit 8.5.4 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 230 ms, Memory: 12.00 MB

There was 1 error:

1) Tests\Unit\DemoTest::testDemo
Error: Call to undefined method Tests\TestApp::console()

/app/tests/Traits/InteractsWithConsole.php:25
/app/tests/TestCase.php:44

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
hotrush commented 4 years ago

@wolfy-j any workaround i can use to call command from test case?

wolfy-j commented 4 years ago

Hi, I haven't created these traits so it will take me some time to fix them. But you can invoke the run method of console dispatcher:

https://github.com/spiral/app/blob/master/tests/Traits/InteractsWithConsole.php#L25

I assume that all you need to do is to implement console method in TestApp which:

use Spiral\Console\Console;
// ...

public function console()
{
    return $this->get(Console::class);
}
hotrush commented 4 years ago

That works, thanks