I know that this question is closely related to:
Laravel testing - Problems with created routes
and
Mocking Laravel's Request::segment method
and is very likely related to Laravel's order of operations.
In a nutshell, I have some code that parses the URI inside the view and uses the first parameter of the URI to target directories and create links. Everything works fine in the browser, but when testing, I try dumping the URI from within the view with var_dump($_SERVER['REQUEST_URI']); and I get the error "Undefined index: REQUEST_URI." I tried using the solution from the first link; however, I am on Laravel 5 extending my TestCase.php from Illuminate\Foundation\Testing\TestCase and the method:
$this->createClient();
doesn't exist. I also saw the second link's solution to create a SiteLayoutComposer class
class SiteLayoutComposer extends BaseComposer...
However, I don't know what is included in the BaseComposer, or how exactly I should implement that SiteLayoutComposer...if I should just include it in the controller and create an instance....etc.
Is there a way to retrieve the URI from the view within in Laravel 5 during testing?
Aucun commentaire:
Enregistrer un commentaire