Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 拉韦尔敦的移民';测试时不能正常工作_Php_Laravel_Unit Testing_Phpunit_Migration - Fatal编程技术网

Php 拉韦尔敦的移民';测试时不能正常工作

Php 拉韦尔敦的移民';测试时不能正常工作,php,laravel,unit-testing,phpunit,migration,Php,Laravel,Unit Testing,Phpunit,Migration,我在进行测试时遇到了运行迁移的问题。我在不同的地方迁移。用户迁移取决于公司迁移,但每次运行测试时都会出现一个错误,即表“companys”不存在 来自测试类的代码: protected function setUp() { parent::setUp(); $this->artisan('migrate', [ '--path' => ['Modules/Company/Database/Migrations',

我在进行测试时遇到了运行迁移的问题。我在不同的地方迁移。用户迁移取决于公司迁移,但每次运行测试时都会出现一个错误,即表“companys”不存在

来自测试类的代码:

protected function setUp()
{
    parent::setUp();

    $this->artisan('migrate', [
        '--path' => ['Modules/Company/Database/Migrations', 
                            'Modules/User/Database/Migrations'],
    ]);
}

protected function tearDown()
{
    $this->artisan('migrate:reset', [
        '--path' => ['Modules/User/Database/Migrations', 
                           'Modules/Company/Database/Migrations'],
    ]);

    parent::tearDown();

}
谁能帮帮我吗。
谢谢

问题出在两个地方:

  • 1) 选项--路径作为数组提供(但不显示任何警告)
  • 2) 命令migrate:reset(它使用提供的--path重置所有迁移,从而发生错误“Undefined index:create_company_table”)
最后版本

protected function setUp()
{
   parent::setUp();
   $this->artisan('migrate', [
         '--path' => 'Modules/Company/Database/Migrations',
   ]);
   $this->artisan('migrate', [
         '--path' => 'Modules/User/Database/Migrations',
   ]);
}

protected function tearDown()
{
    $this->artisan('migrate:rollback', [
        '--path' => 'Modules/User/Database/Migrations/',
    ]);
    $this->artisan('migrate:rollback', [
        '--path' => 'Modules/Company/Database/Migrations/',
    ]);

    parent::tearDown();

}