I am having an issue with testing a Laravel app I have inherited.
The folder that is usually labelled as "public" was renamed to "html".
The app itself works fine, but when Behat tests run it still looks for a public folder. I have been working around it by just copying the "html" file and renaming it as public, but I would like to just fix this so I can get some other co workers testing this app.
I have looked in the Behat documentation and was unable to find it. I also googled this quite a bit but did not find anything addressing it.
Anyone know how to set this path so instead of looking for a folder called "public" I can change it to look for a folder called "html."
The exact error I get is
Warning: file_get_contents(/Library/WebServer/Documents/myApp/myApp/public/build/rev-manifest.json): failed to open stream: No such file or directory in /Library/WebServer/Documents/thirdspace-app/thirdspace/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php line 668
So the public in the above path needs to be html.
That code that is being referenced in that error looks like below
if ( ! function_exists('elixir'))
{
function elixir($file)
{
static $manifest = null;
if (is_null($manifest))
{
$manifest = json_decode(file_get_contents(public_path().'/build/rev-manifest.json'), true);
}
if (isset($manifest[$file]))
{
return '/build/'.$manifest[$file];
}
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
}
}
I do not really want to change this however because I think this will affect the app itself. I just want to send the test looking for html in stead of public. I really just want to make sure the solution to ths only affects the tests, not the app itself.
This uses the Laravel helper function public_path()
which will always return a path expecting a directory called public
.
There are a few different ways to overwrite this, but this is probably the simplest. In order that this runs before Behat, define this in bootstrap/app.php
:
$app->bind('path.public', function() {
return base_path().'/html';
});