提问人:Mohammad Darweesh 提问时间:11/12/2023 最后编辑:Mohammad Darweesh 更新时间:11/12/2023 访问量:45
Php 单元测试在默认的 laravel 应用程序中出现错误
Php unit test gives error in default laravel application
问:
在默认的 laravl 应用程序中,当我运行 phpunit 时,它总是给我错误:
PHP Fatal error: Uncaught Error: Call to undefined function each() in C:\xampp\php\pear\PHPUnit\Util\Getopt.php:80
Stack trace:
#0 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(239): PHPUnit_Util_Getopt::getopt(Array, 'd:c:hv', Array)
#1 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(138): PHPUnit_TextUI_Command->handleArguments(Array)
#2 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#3 C:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
#4 {main}
thrown in C:\xampp\php\pear\PHPUnit\Util\Getopt.php on line 80
Fatal error: Uncaught Error: Call to undefined function each() in C:\xampp\php\pear\PHPUnit\Util\Getopt.php:80
Stack trace:
#0 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(239): PHPUnit_Util_Getopt::getopt(Array, 'd:c:hv', Array)
#1 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(138): PHPUnit_TextUI_Command->handleArguments(Array)
#2 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#3 C:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
#4 {main}
thrown in C:\xampp\php\pear\PHPUnit\Util\Getopt.php on line 80
这是我的phpunit phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>app</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
</phpunit>
我尝试进行作曲家更新以查看 anthing 是否会更改,但它仍然给我同样的错误
答: 暂无答案
评论
each()
Getopt.php
phpunit.xml