yeasir_arafat
6 months ago
1302
11
Laravel

Error: Call to undefined method Illuminate\Container\Container::resourcePath()

Posted 6 months ago by yeasir_arafat

I am following the last episode of How to read code series. I have latest version of laravel and composer. When running the below test:

    public function it_returns_the_documentation_page()
    {
        File::shouldReceive('get')
            ->with(resource_path("docs/0.1/auth"))
            ->once()
            ->andReturn("auth doc");
        $contents = Documentation::get("0.1","auth");
        $this->$this->assertEquals("auth doc", $contents);
    }

I am receiving the error:

Error: Call to undefined method Illuminate\Container\Container::resourcePath()

My Documentation class:

namespace App;
use Illuminate\Support\Facades\File;

class Documentation {
    public static function get($version, $page) {
        $path = resource_path("docs/${version}/${page}");
        // dd(app('path.storage'));
        // $path = ("docs/${version}/${page}");
        return File::get($path);
    }
}

Spent about the whole day trying to figure out what is wrong. This happens when running tests. No issue if i visit the route from browser. Any idea, please?

Please sign in or create an account to participate in this conversation.