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

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?

  • 写回答

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'; 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?