2013-03-02 68 views
7

我有以下测试文件,这是PHPUnit网站上的一个示例。PHPUnit在PHPStorm中不工作

<?php 

require_once 'PHPUnit/Autoload.php'; 

class StackTest extends PHPUnit_Framework_TestCase 
{ 
    public function testPushAndPop() 
    { 
     $stack = array(); 
     $this->assertEquals(0, count($stack)); 

     array_push($stack, 'foo'); 
     $this->assertEquals('foo', $stack[count($stack)-1]); 
     $this->assertEquals(1, count($stack)); 

     $this->assertEquals('foo', array_pop($stack)); 
     $this->assertEquals(0, count($stack)); 
    } 
} 
?> 

我试图在PHPStorm 5.0运行它,但我得到了以下错误:

E:\wamp\bin\php\php5.3.13\php.exe C:\Users\<user>\AppData\Local\Temp\ide-phpunit.php --no-configuration StackTest E:\wamp\www\renting\tests\StackTest.php 
Testing started at 03:37 ... 

SCREAM: Error suppression ignored for 
Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in C:\Users\<user>\AppData\Local\Temp\ide-phpunit.php on line 166 

任何想法,为什么它要C:当我设置了包括路径E: ?

回答

9

解决了!

似乎有一些依赖项的问题,特别是pear.symfony.com/Yaml。

这样做解决了这个问题:

pear channel-discover pear.symfony.com 
pear install pear.symfony.com/Yaml 
pear channel-discover pear.phpunit.de 
pear install --alldeps pear.phpunit.de/PHPUnit 

的解决方案的想法来自:How do I correctly install PHPUnit with PEAR?

+0

只是想离开这里了这一点:[为PEAR安装方法终止(https://github.com/sebastianbergmann/phpunit/wiki/End-of-Life-for-PEAR-Installation -方法) – 2016-12-15 11:06:03

1

我的问题是类似的 - 但我解决了这个问题,通过指向测试引导文件。然后,一切正常。