drfif48428
2015-10-01 06:49
浏览 334
已采纳

PHPUnit - 找不到测试类

When I am trying to test a class, it can't find the class to be tested.

Under the following line you see the test:

    <?php

class FacebookRestTest extends \PHPUnit_Framework_TestCase
{
    public function testFacebookFirstTest()
    {
        $pageid = 634336563297055;
        $since = 1438387200;
        $until = 1443052800;

        $facebook = new FacebookRest(new DataReader(new Report($pageid, $since, $until)));
        $page = $facebook->getPage();
        $this->assertTrue(!empty($page));
    }
}

But when I run the test in the terminal, it throws an error that it can't find the FacebookRest class.

Here is the error:

Fatal error: Class 'FacebookRest' not found in /Applications/MAMP/htdocs/faceboo1/tests/FacebookRestTest.php on line 11

Anyone know how to solve this?

图片转代码服务由CSDN问答提供 功能建议

当我尝试测试一个类时,它找不到要测试的类。

在以下行中您会看到测试:

 &lt;?php 
 
class FacebookRestTest extends \ PHPUnit_Framework_TestCase 
 {\  n public function testFacebookFirstTest()
 {
 $ pageid = 634336563297055; 
 $ since = 1438387200; 
 $ until = 1443052800; 
 
 $ facebook = new FacebookRest(new DataReader(new Report($ pageid,$ 因为,$ until))); 
 $ page = $ facebook-&gt; getPage(); 
 $ this-&gt; assertTrue(!empty($ page)); 
} 
} 
   
 
 

但是当我在终端中运行测试时,它会抛出一个无法找到FacebookRest类的错误。

这是 错误:

 致命错误:在第11行的/Applications/MAMP/htdocs/faceboo1/tests/FacebookRestTest.php中找不到类'FacebookRest'
  <  / pre> 
 
 

任何人都知道如何解决这个问题?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpleylxzx47207117 2015-10-01 07:15
    已采纳

    You haven't included your class.

    Add on top of your FacebookRestTest file:

    include_once __DIR__.'/../classes/FacebookRest.php'; 
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题