Kevin Steen Hansen
Kevin Steen Hansen

Reputation: 555

PHPUnit - Test class not found

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?

Upvotes: 1

Views: 866

Answers (1)

Rene Korss
Rene Korss

Reputation: 5484

You haven't included your class.

Add on top of your FacebookRestTest file:

include_once __DIR__.'/../classes/FacebookRest.php'; 

Upvotes: 1

Related Questions