我有一个NetBeans项目,我正在使用PHPUnit测试来学习。 我使用NetBeans 8.0.2在我的桌面PC上创建它,但工作正常,但是当我在笔记本上导入项目时,PHPUnit不会执行任何测试。
这是输出窗口:
"C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\bin\phpunit.bat" "--colors" "--log-junit" "C:\Users\MARCOA~1\AppData\Local\Temp\nb-phpunit-log.xml" "--configuration" "C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\phpunit.xml" "C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php" "--run=C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests"
Warning: array_merge(): Argument #1 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 143
Call Stack:
0.0016 130056 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
0.0385 398928 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
0.0386 402664 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
0.1218 887816 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
0.1910 1624632 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1910 1624648 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1911 1625712 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
0.1954 1626688 8. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
0.2026 1627056 9. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
0.2061 1627360 10. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
0.2229 1628168 11. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
Warning: array_merge(): Argument #1 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 143
Call Stack:
0.0016 130056 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
0.0385 398928 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
0.0386 402664 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
0.1218 887816 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
0.1910 1624632 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1910 1624648 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1911 1625712 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
0.1954 1626688 8. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
0.2026 1627056 9. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
0.2061 1627360 10. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
0.2343 1628632 11. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
Warning: array_merge(): Argument #1 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 143
Call Stack:
0.0016 130056 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
0.0385 398928 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
0.0386 402664 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
0.1218 887816 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
0.1910 1624632 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1910 1624648 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1911 1625712 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
0.1954 1626688 8. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
0.2026 1627056 9. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
0.2385 1627464 10. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP Warning: array_merge(): Argument #1 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 143
PHP Stack trace:
PHP 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
PHP 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
PHP 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
PHP 8. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
PHP 9. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP 10. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP 11. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP Warning: array_merge(): Argument #1 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 143
PHP Stack trace:
PHP 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
PHP 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
PHP 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
PHP 8. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
PHP 9. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP 10. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP 11. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP Warning: array_merge(): Argument #1 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 143
PHP Stack trace:
PHP 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
PHP 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
PHP 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
PHP 8. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
PHP 9. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP 10. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP Warni
Warning: array_merge(): Argument #1 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 143
Call Stack:
0.0016 130056 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
0.0385 398928 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
0.0386 402664 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
0.1218 887816 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
0.1910 1624632 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1910 1624648 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1911 1625712 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
0.1954 1626688 8. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
0.3064 1627160 9. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
Warning: array_merge(): Argument #2 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 115
Call Stack:
0.0016 130056 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
0.0385 398928 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
0.0386 402664 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
0.1218 887816 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
0.1910 1624632 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1910 1624648 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1911 1625712 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
0.3851 1626672 8. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
Warning: Invalid argument supplied for foreach() in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 84
Call Stack:
0.0016 130056 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
0.0385 398928 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
0.0386 402664 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
0.1218 887816 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
0.1910 1624632 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
0.1910 1624648 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHPUnit 4.5.0 by Sebastian Bergmann and contributors.
Configuration read from C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\phpunit.xml
Time: 684 ms, Memory: 2.25Mb
No tests executed!
Generating code coverage report in HTML format ... done
ng: array_merge(): Argument #1 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 143
PHP Stack trace:
PHP 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
PHP 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
PHP 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
PHP 8. NetBeansSuite::rglob() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
PHP 9. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:143
PHP Warning: array_merge(): Argument #2 is not an array in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 115
PHP Stack trace:
PHP 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
PHP 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
PHP 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 7. NetBeansSuite::toRun() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:84
PHP 8. array_merge() C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php:115
PHP Warning: Invalid argument supplied for foreach() in C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php on line 84
PHP Stack trace:
PHP 1. {main}() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\phpunit:36
PHP 3. PHPUnit_TextUI_Command->run() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:104
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\TextUI\Command.php:126
PHP 5. ReflectionMethod->invoke() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
PHP 6. NetBeansSuite::suite() C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit\src\Runner\BaseTestRunner.php:89
Concluído.
我正在使用Composer。 我已经安装了依赖项,将phpunit可执行文件指向NetBeans配置中的bin文件夹,并从我桌面上的项目完成了所有相同的配置,但是我仍然遇到此错误。
编辑:
C:\ WebServer \ Apache 2.2 \ htdocs \ DataBaseTests \ tests中的文件
C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\Marco\Test\Manager\InvoiceManagerTest.php
C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\Marco\Test\Manager\PDOMock.php
C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\Marco\Test\Model\InvoiceTest.php
答案 0 :(得分:1)
我发现shell脚本版本(bin / phpunit.sh)不适用于Netbeans。请改为选择libexec / phpunit.phar。
我遇到了2个问题。第一个具有“未找到测试”的症状,并且如果您尝试使用该命令则会输出类似的错误:
"/usr/local/bin/php" "/usr/local/Cellar/phpunit/4.3.4/bin/phpunit" "--colors" "--log-junit" "/var/folders/vc/r2k02djd5gg664g0v7ggm8l40000gn/T/nb-phpunit-log.xml" "--bootstrap" "/Users/...bootstrap.php.cache" "--configuration" "/Users/.../app/phpunit.xml.dist" "/Applications/NetBeans/NetBeans 8.0.2.app/Contents/Resources/NetBeans/php/phpunit/NetBeansSuite.php" "--run=/Users/...Tests/Controller/DefaultControllerTest.php"
这是通过使用phpunit / 4.3.4 / libexec / phpunit.phar修复的。
我遇到的第二个问题,但有一个不同的症状是使用phpunit 5.0.0。我使用了上面的phar版本,但似乎有一个错误https://github.com/sebastianbergmann/phpunit/issues/1887。它返回
Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in phar:///usr/local/Cellar/phpunit/5.0.0/libexec/phpunit-5.0.0.phar/phar/phpunit-mock-objects/Framework/MockObject/Builder/InvocationMocker.php on line 82