【发布时间】:2017-01-12 10:10:22
【问题描述】:
抱歉,这个问题可能很愚蠢,但我无法通过谷歌搜索找到答案。
我的问题是: 我在 backend\acceptance 下创建了文件 TaskCest.php,在该文件中有以下声明
use yii\test\FixtureTrait;
public function fixtures() {
return ['tasks' => TasksFixture::className()];
}
我在数据目录中有带有数据的夹具类。
但是当我运行脚本时出现以下错误:
[yii\base\ErrorException] ltrim() expects parameter 1 to be string, object given
错误很明显,但我无法理解,在 yii2\test\FixtureTrait.php:145 文件中,我有一个函数,它期望 name 参数是字符串但对象自动传递[我不调用 getFixture]。 什么问题。有人遇到过同样的情况吗?
-vvv 输出
测试测试/验收/TaskCest.php:getFixture
[yii\base\ErrorException] ltrim() expects parameter 1 to be string, object given
/home/nginx/www/planning-back/vendor/codeception/codeception/src/Codeception/Lib/Di.php:123
/home/nginx/www/planning-back/vendor/codeception/codeception/src/Codeception/Lib/Di.php:123
/home/nginx/www/planning-back/vendor/codeception/codeception/src/Codeception/Test/Cest.php:136
/home/nginx/www/planning-back/vendor/codeception/codeception/src/Codeception/Test/Cest.php:148
/home/nginx/www/planning-back/vendor/codeception/codeception/src/Codeception/Test/Cest.php:82
/home/nginx/www/planning-back/vendor/codeception/codeception/src/Codeception/Test/Test.php:90
/home/nginx/www/planning-back/vendor/phpunit/phpunit/src/Framework/TestSuite.php:728
/home/nginx/www/planning-back/vendor/codeception/codeception/src/Codeception/PHPUnit/Runner.php:98
/home/nginx/www/planning-back/vendor/codeception/codeception/src/Codeception/SuiteManager.php:154
/home/velaro/.config/composer/vendor/codeception/codeception/src/Codeception/Codecept.php:183
/home/velaro/.config/composer/vendor/codeception/codeception/src/Codeception/Codecept.php:152
/home/velaro/.config/composer/vendor/codeception/codeception/src/Codeception/Command/Run.php:282
/home/velaro/.config/composer/vendor/symfony/console/Command/Command.php:255
/home/velaro/.config/composer/vendor/symfony/console/Application.php:829
/home/velaro/.config/composer/vendor/symfony/console/Application.php:191
/home/velaro/.config/composer/vendor/symfony/console/Application.php:122
/home/velaro/.config/composer/vendor/codeception/codeception/src/Codeception/Application.php:103
/home/velaro/.config/composer/vendor/codeception/codeception/codecept:34
【问题讨论】:
-
可以检查或粘贴错误堆栈吗?我找不到你从哪里得到这个。
-
使用
--debug为堆栈运行代码接收。 -
就像我用红色打印一样,没有堆栈,即使我使用调试选项运行
-
嗯...也许检查
-vvv标志。
标签: php yii2-advanced-app codeception acceptance-testing