Laravel facade class not found when mocked in a unit test Laravel facade class not found when mocked in a unit test laravel laravel

Laravel facade class not found when mocked in a unit test


I missed this in the docs:

Note: If you define your own setUp method, be sure to call parent::setUp.

Calling that cured the problem. Doh!


it's because laravel framework is not loaded before using facade OR it because you are not using laravel php unit(TestCase class)here is a sample code to test case that are in app///attention to extends from TestCase not ()

/** * TEST CASE the application. * */class TestCase extends Illuminate\Foundation\Testing\TestCase {    /**     * Creates the application.     *     * @return \Symfony\Component\HttpKernel\HttpKernelInterface     */    public function createApplication()    {        $unitTesting = true;        $testEnvironment = 'testing';        //this line boot the laravel framework so all facades are in your hand        return require __DIR__.'/../../bootstrap/start.php';   }}