Suppose I have a blade template:
// resources/views/fragments/foo.blade.php
<p></p>
(This is obviously a very stripped-down version of my question. I can't see why I'd ever need to test a blade template that simple.) In my controller, I would normally populate that template like this:
// app/Http/Controllers/FooController.php
$parameters = ['foo' => ''];
return view('fragments.foo', $parameters);
The problem is I'd like to write a phpunit test to ensure that template renders successfully when I pass it a specific value for $foo, but I can't figure out how to send data to the view when running the unit test. I tried this:
// tests/TestFooController.php
$this->withSession(['foo' => 'bar'])->visit('/foo')->assertViewHas('foo', 'bar');
but that test failed. How can I pass my own data to the view from within my test?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1saEawc
via IFTTT
Aucun commentaire:
Enregistrer un commentaire