kinda stumped on how to test this. I'm working on building a command line tool that allows for the artisan make commands to be used outside of a laravel application. The idea being that this would allow artisan make commands to be used for package development anywhere on a dev system. I've got a working prototype, so I wanted to start adding in tests. However I'm a bit stumped on how to get the artisan command to execute inside of a mock filesystem (using mikey179/vfsStream). This is my current code:
namespace Tests\Feature;
use Tests\TestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamWrapper;
use Illuminate\Support\Facades\Artisan;
class ChannelCommandTest extends TestCase
{
protected function setUp(): void {
parent::setUp();
$structure = [
'src' => [],
'tests' => []
];
$this->root = vfsStream::setup('newPackage', null, $structure);
vfsStreamWrapper::register();
}
public function testChannelCommand(): void {
Artisan::call('make:channel', ['name' => 'newChannel']);
$this->assertFileExists('src/Channels/Broadcasting/newChannel.php');
}
}
Aucun commentaire:
Enregistrer un commentaire