Laravel 5 Symfony\Component\HttpKernel\Exception\NotFoundHttpException: POST Http://localhost/myproject/public/leads
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://stackoverflow.com/questions/23593892/symfony-component-httpkernel-exception-notfoundhttpexception-laravel
Answer
I solved it. I change to config\app.php
file
'url' =>'http://localhost/myscript_addres/public',
To
'url' =>'http://localhost/',
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?