I have a deliverypoint
resource in my laravel project. The controller code associated to the route deliverypoints.index
is straightforward:
public function index()
{
return view('deliverypoints.index', [
'deliverypoints' => DeliveryPoint::all(),
]);
}
With the view deliverypoints.index
:
@extends('layouts.app')
@section('content')
<div class="container">
<ul class="row">
@foreach ($deliverypoints as $deliverypoint)
<li class="col-12"></li>
@endforeach
</ul>
</div>
@endsection
Here you can see a typo in the li
tag: deliveryPoint->id
instead of deliverypoint->id
. This causes an "undefined variable" error when I manually test the route in my browser: so far, so good.
My problem is that when testing the route with PHPUnit, the test passes instead of reporting the error. Here is the code of the feature test:
public function testIndex()
{
$response = $this->get(
route('deliverypoints.index')
);
$response->assertSuccessful()->assertViewIs(
'deliverypoints.index'
)->assertViewHasAll(
['deliverypoints']
);
}
Since the test passes, I guess the view is successfully returned by the server, but I would expect the typo to be detected.
How can I enforce the test to make it see such errors?
Aucun commentaire:
Enregistrer un commentaire