【发布时间】:2018-12-10 05:11:01
【问题描述】:
(更新的问题表明它不像链接的问题)
我编写了一个 Laravel 命令(如下所示),它基本上是 Dusk 的包装器,因此我可以确保事先调用某些其他函数。 (否则,我不可避免地会忘记重置我的测试环境。)
当我运行 php artisan mydusk 时它完美运行。
namespace App\Console\Commands;
class DuskCommand extends BaseCommand {
protected $signature = 'mydusk {file?} {--filter=?}';
protected $description = 'refreshAndSeedTestingDb, then run Dusk suite of tests';
public function handle() {
$this->consoleOutput($this->description);
$resetTestingEnv = new ResetTestingEnv();
$resetTestingEnv->refreshAndSeedTestingDb();
$this->consoleOutput('refreshAndSeedTestingDb finished. Now will run Dusk...');
$file = $this->argument('file');//What to do with this?
return \Artisan::call('dusk', ['--filter' => $this->option('filter')]);
}
}
如您所见,我已经阅读了 these docs 并了解如何编写 $signature 以接受可选参数。
我的目标是有时能够运行 php artisan mydusk 并且还能够有选择地添加参数,例如当我可能想要调用类似 php artisan mydusk tests/Browser/MailcheckTest.php --filter testBasicValidCaseButtonClick 的东西时(这会将 tests/Browser/MailcheckTest.php --filter testBasicValidCaseButtonClick 参数传递给普通的 @ 987654330@ 命令)。
如何编辑handle() 函数的最后两行,以便将$file 传递给dusk?
【问题讨论】:
-
您阅读手册了吗?它给出了例子。 laravel.com/docs/5.6/artisan#defining-input-expectations
-
@fubar 是的,我已经阅读了那些文档。我觉得你可能没有阅读我的问题。无论如何,我现在已经对其进行了编辑以使其更清晰。谢谢你的帮助。 :-)
标签: laravel laravel-5 laravel-artisan laravel-dusk