I have a controller that gets list of images from folders and passes them to the view:
public function create()
{
$marker_images = scandir("./img/markers");
$background_images = scandir("./img/backgrounds");
$type = new Type();
return view('admin.types.create',compact('type','marker_images','background_images'));
}
This works fine until i run my unit test, which then fails on the scandir step with
failed to open dir: No such file or directory
if I add
exec('pwd',$return);
print_r($return);
I see that the path is changing, when i manually vist the page the path is
/Users/<my username>/Sites/core-site/public
but when the unit test is executed
/Users/<my username>/Sites/core-site
how do I get it to pick the correct base path for the unit test?
my unit test looks like this:
public function testTypesCreate()
{
$controller = $this->app->make('App\Http\Controllers\Admin\TypeController');
$response = $controller->create();
$this->assertEquals($response->name(), 'admin.types.create');
}