Closed maxalmonte14 closed 6 years ago
Hi @maxalmonte14!
This happens because PageSpeed modifies the original content generated by the view.
See:
//Illuminate\Foundation\Testing\TestResponse.php
protected function ensureResponseHasView()
{
if (! isset($this->original) || ! $this->original instanceof View) {
return PHPUnit::fail('The response is not a view.');
}
return $this;
}
The methods:
Call ensureResponseHasView() internally...
You can disable PageSpeed in your tests:
<!-- phpunit.xml -->
<php>
<env name="LARAVEL_PAGE_SPEED_ENABLE" value="false"/>
</php>
Hope this helps! :smile:
I've been having a problem for some hours with the Laravel built-in assertViewHas test method when I pass a piece of data to a view and I concluded this package is the reason, the assertViewHas method was returning the message
The response is not a view.
so I decided make a little test in a new empty project and see the results, this is what I did.First of all I installed Laravel and the package:
HomeTest.php
web.php
example.blade.php
HomeController.php
At this point if I run the command
vendor/bin/phpunit --filter=test_data_can_be_passed_to_a_view
everything is fineBut if I add the package middlewares to the
Kernel.php
file...The output of the
vendor/bin/phpunit --filter=test_data_can_be_passed_to_a_view
is the following:I don't why this happens but it's happening!
I hope you will can reproduce the error, I will try to clone the repo and find the problem, for the moment I hope this help you. Greetings!