I use Laravel 5.8 and have test method like this this
public function test_store()
{
$attribute= ['lead_name'=>'test_name','lead_family'=>'test_family'];
$this->post('/leads', $attribute);
$this->assertDatabaseHas('leads', $attribute);
}
and controller like this:
class LeadController extends Controller
{
public function store(Request $request)
{
Lead::create($request->all());
}
}
and route :
Route::resource('/leads', 'App\Http\Controller\LeadController');
When I run phpunit show me this error:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: POST http://localhost/myproject/public/leads
C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling.php:118 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:326 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:120 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php:375 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php:197 C:\wamp64\www\myproject\tests\Feature\Customer\LeadTest.php:38 I test
leads
URL with Postman and it work correctly.
I see and read this post https://stackguides.com/questions/23593892/symfony-component-httpkernel-exception-notfoundhttpexception-laravel
php artisan route:list
and see you have got the intended route – alithedeveloper