【问题标题】:PhpUnit Artisan:call explode expects parameter 2 to be stringPhpUnit Artisan:call explode 期望参数 2 为字符串
【发布时间】:2016-01-01 15:30:02
【问题描述】:

我正在尝试使用 PhpUnit 测试 Laravel 5.1 控制器,因为我创建了一个继承自 TestCase 的类,并使用 DatabaseTransactionsWithoutMiddleware 特征。

在实现 setUpBeforeClass 方法的类中,该方法包含:

Artisan::call('migrate:refresh');

当我尝试运行测试时,出现以下错误:

1) JugadoresControllerTest::test_Index_trae_arreglo_de_jugadores
ErrorException: explode() expects parameter 2 to be string, array given

/home/vagrant/.composer/vendor/illuminate/support/helpers.php:390
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Support/Arr.php:319
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Support/Collection.php:428
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1548
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:53
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:79
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:74
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Container/Container.php:503
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Console/Command.php:150
/home/vagrant/Code/marcadores/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Console/Application.php:62
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:152
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:210
/home/vagrant/Code/marcadores/tests/unit/JugadoresControllerTest.php:34
/home/vagrant/Code/marcadores/tests/unit/JugadoresControllerTest.php:34
/home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:151
/home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:103

希望任何人都可以帮助我!

【问题讨论】:

    标签: phpunit laravel-5.1 laravel-artisan


    【解决方案1】:

    我不知道你有没有想过这个问题,但是我在尝试在 laravel 5.1 下运行 phpunit 测试时遇到了类似的问题。显然,我的全球作曲家安装中有一些过时的供应商构建(正如您的错误所崇敬:/home/vagrant/.composer/vendor/illuminate/support/helpers.php:390

    我所做的只是 cd 到我的作曲家目录: cd /home/vagrant/.composer 并运行 composer update

    这更新了我的全局作曲家,一切都按预期工作。

    【讨论】:

    • 谢谢伙计,在我的情况下,我重新启动了宅基地,一切正常。忘记发xD了
    • 谢谢!刚刚根据您的建议解决了这个错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-14
    • 1970-01-01
    • 1970-01-01
    • 2017-08-30
    • 2021-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多