TXZ

570 经验值

我暂时用绝对路径的方式引用bootstrap/bootstrap.php,会报错:

/home/vagrant/Code/Packages/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:62
/home/vagrant/Code/Packages/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:166
/home/vagrant/Code/Packages/packages/cals/validator/src/AjaxValidator.php:17
/home/vagrant/Code/Packages/packages/cals/validator/tests/AjaxValidatorTest.php:26
/home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/Command.php:185
/home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/Command.php:115
PHP Fatal error:  Uncaught Error: Call to undefined method PHPUnit_Framework_TestResult::warnings() in /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php:297
Stack trace:
#0 /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(187): PHPUnit_TextUI_ResultPrinter->printWarnings(Object(PHPUnit_Framework_TestResult))
#1 /home/vagrant/Code/Packages/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(446): PHPUnit_TextUI_ResultPrinter->printResult(Object(PHPUnit_Framework_TestResult))
#2 /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/Command.php(185): PHPUnit_TextUI_TestRunner->doRun(Array, true)
#3 /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/Command.php(115): PHPUnit_TextUI_Command->run(Array, true)
#4 /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/phpunit(47): PHPUnit_TextUI_Command::main()
#5 {main}
  thrown in /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 297

Fatal error: Uncaught Error: Call to undefined method PHPUnit_Framework_TestResult::warnings() in /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php:297
Stack trace:
#0 /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(187): PHPUnit_TextUI_ResultPrinter->printWarnings(Object(PHPUnit_Framework_TestResult))
#1 /home/vagrant/Code/Packages/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(446): PHPUnit_TextUI_ResultPrinter->printResult(Object(PHPUnit_Framework_TestResult))
#2 /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/Command.php(185): PHPUnit_TextUI_TestRunner->doRun(Array, true)
#3 /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/Command.php(115): PHPUnit_TextUI_Command->run(Array, true)
#4 /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/phpunit(47): PHPUnit_TextUI_Command::main()
#5 {main}
  thrown in /home/vagrant/Code/Packages/packages/cals/validator/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 297

这里写相对路径无效啊?
其实还有几个问题,我写的package依赖有配置文件,当用户没有vendor:publish的时候,config会报错,怎么解决啊?
最大的问题还是测试,不会用phpunit,很简单的代码,肯定不会有问题,但是就是phpunit测试会失败,laravel对这方面的文档太少了。
jelly,只有靠你了。

换成这个错误变成了打不开bootstrap/autoload.php,要改文件权限吗?

不是太明白,我已经将bootstrap改成"vendor/bootstrap.php"了

我的package里面用到了Laravel提供的辅助函数,测试说未定义的方法,怎么解决啊?
还有,我貌似问了很多问题你都没回过,jelly。。。

Jelly,为什么我的state里面的数据老是上一次mutation修改的数据?所以每次第一次登陆的时候老是state为空围着undefined

之前是ModelFactory里面写错了,解决了。

>>> factory(App\Todo::class, 10)->create();
TypeError: Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in /home/vagrant/Code/TODO/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 672

这是什么原因啊?

我觉得可以结合Laravel API 讲一个Vue SPA 的视频。