PHPUnit和Yii错误需要* .php文件

时间:2012-10-26 15:41:42

标签: yii phpunit

我在运行PHPUnit时遇到了问题..我遇到了很多问题,但现在我已经有了这个......

所以我在我的应用程序文件夹中受保护/测试...... 在我的控制台中,我写道:

phpunit unit/DbTest.php

回复得到(很多信件很抱歉): 附:使用Wamp和Win8

PHP Warning:  require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to o
pen stream: No such file or directory in C:\wamp\www\framework\test\CWebTestCase
.php on line 12
PHP Stack trace:
PHP   1. {main}() C:\wamp\bin\php\php5.3.13\phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3.13\phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.13\pear\PHPUnit\Te
xtUI\Command.php:129
PHP   4. PHPUnit_TextUI_Command->handleArguments() C:\wamp\bin\php\php5.3.13\pea
r\PHPUnit\TextUI\Command.php:138
PHP   5. PHPUnit_TextUI_Command->handleBootstrap() C:\wamp\bin\php\php5.3.13\pea
r\PHPUnit\TextUI\Command.php:606
PHP   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\wamp\bin\php\php5.3.13\pear\
PHPUnit\TextUI\Command.php:778
PHP   7. PHPUnit_Util_Fileloader::load() C:\wamp\bin\php\php5.3.13\pear\PHPUnit\
Util\Fileloader.php:76
PHP   8. include_once() C:\wamp\bin\php\php5.3.13\pear\PHPUnit\Util\Fileloader.p
hp:92
PHP   9. require_once() C:\wamp\www\test\protected\tests\bootstrap.php:8
PHP  10. YiiBase::autoload() C:\wamp\www\test\protected\tests\bootstrap.php:0

PHP  11. include() C:\wamp\www\framework\YiiBase.php:397

Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to open s
tream: No such file or directory in C:\wamp\www\framework\test\CWebTestCase.php
on line 12

Call Stack:
    0.0003     325320   1. {main}() C:\wamp\bin\php\php5.3.13\phpunit:0
    0.0081     684192   2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3
.13\phpunit:46
    0.0081     684608   3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.
13\pear\PHPUnit\TextUI\Command.php:129
    0.0081     684608   4. PHPUnit_TextUI_Command->handleArguments() C:\wamp\bin
\php\php5.3.13\pear\PHPUnit\TextUI\Command.php:138
    0.0152    1197056   5. PHPUnit_TextUI_Command->handleBootstrap() C:\wamp\bin
\php\php5.3.13\pear\PHPUnit\TextUI\Command.php:606
    0.0157    1209440   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\wamp\bin\p
hp\php5.3.13\pear\PHPUnit\TextUI\Command.php:778
    0.0164    1209536   7. PHPUnit_Util_Fileloader::load() C:\wamp\bin\php\php5.
3.13\pear\PHPUnit\Util\Fileloader.php:76
    0.0167    1214200   8. include_once('C:\wamp\www\test\protected\tests\boo
tstrap.php') C:\wamp\bin\php\php5.3.13\pear\PHPUnit\Util\Fileloader.php:92
    0.0212    1495872   9. require_once('C:\wamp\www\test\protected\tests\Web
TestCase.php') C:\wamp\www\test\protected\tests\bootstrap.php:8
    0.0213    1496136  10. YiiBase::autoload() C:\wamp\www\test\protected\tes
ts\bootstrap.php:0
    0.0220    1519520  11. include('C:\wamp\www\framework\test\CWebTestCase.php'
) C:\wamp\www\framework\YiiBase.php:397

PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Extensions/Se
leniumTestCase.php' (include_path='.;C:\wamp\bin\php\php5.3.13\pear') in C:\wamp
\www\framework\test\CWebTestCase.php on line 12
PHP Stack trace:
PHP   1. {main}() C:\wamp\bin\php\php5.3.13\phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3.13\phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.13\pear\PHPUnit\Te
xtUI\Command.php:129
PHP   4. PHPUnit_TextUI_Command->handleArguments() C:\wamp\bin\php\php5.3.13\pea
r\PHPUnit\TextUI\Command.php:138
PHP   5. PHPUnit_TextUI_Command->handleBootstrap() C:\wamp\bin\php\php5.3.13\pea
r\PHPUnit\TextUI\Command.php:606
PHP   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\wamp\bin\php\php5.3.13\pear\
PHPUnit\TextUI\Command.php:778
PHP   7. PHPUnit_Util_Fileloader::load() C:\wamp\bin\php\php5.3.13\pear\PHPUnit\
Util\Fileloader.php:76
PHP   8. include_once() C:\wamp\bin\php\php5.3.13\pear\PHPUnit\Util\Fileloader.p
hp:92
PHP   9. require_once() C:\wamp\www\test\protected\tests\bootstrap.php:8
PHP  10. YiiBase::autoload() C:\wamp\www\test\protected\tests\bootstrap.php:0

PHP  11. include() C:\wamp\www\framework\YiiBase.php:397

Fatal error: require_once(): Failed opening required 'PHPUnit/Extensions/Seleniu
mTestCase.php' (include_path='.;C:\wamp\bin\php\php5.3.13\pear') in C:\wamp\www\
framework\test\CWebTestCase.php on line 12

Call Stack:
    0.0003     325320   1. {main}() C:\wamp\bin\php\php5.3.13\phpunit:0
    0.0081     684192   2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3
.13\phpunit:46
    0.0081     684608   3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.
13\pear\PHPUnit\TextUI\Command.php:129
    0.0081     684608   4. PHPUnit_TextUI_Command->handleArguments() C:\wamp\bin
\php\php5.3.13\pear\PHPUnit\TextUI\Command.php:138
    0.0152    1197056   5. PHPUnit_TextUI_Command->handleBootstrap() C:\wamp\bin
\php\php5.3.13\pear\PHPUnit\TextUI\Command.php:606
    0.0157    1209440   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\wamp\bin\p
hp\php5.3.13\pear\PHPUnit\TextUI\Command.php:778
    0.0164    1209536   7. PHPUnit_Util_Fileloader::load() C:\wamp\bin\php\php5.
3.13\pear\PHPUnit\Util\Fileloader.php:76
    0.0167    1214200   8. include_once('C:\wamp\www\test\protected\tests\boo
tstrap.php') C:\wamp\bin\php\php5.3.13\pear\PHPUnit\Util\Fileloader.php:92
    0.0212    1495872   9. require_once('C:\wamp\www\test\protected\tests\Web
TestCase.php') C:\wamp\www\test\protected\tests\bootstrap.php:8
    0.0213    1496136  10. YiiBase::autoload() C:\wamp\www\test\protected\tes
ts\bootstrap.php:0
    0.0220    1519520  11. include('C:\wamp\www\framework\test\CWebTestCase.php'
) C:\wamp\www\framework\YiiBase.php:397

1 个答案:

答案 0 :(得分:3)

首先你需要安装Selenium

pear install phpunit/PHPUnit_Selenium

然后你需要改变

中的第11-14行
/framework/test/CTestCase.php

如下

require_once('PHPUnit/Runner/Version.php');
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');
if (in_array('phpunit_autoload', spl_autoload_functions())) { // PHPUnit >= 3.7    'phpunit_alutoload' was obsoleted
    spl_autoload_unregister('phpunit_autoload');
    Yii::registerAutoloader('phpunit_autoload');
}