I'm trying to set up Edit Post functionality in the tutorial project https://laracasts.com/series/build-a-forum-with-laravel
I am working on a clone of branch episode_51; nothing changed at all except I've added extra Post resource routes edit and update, as well as a new test file EditPost.php.
Here's my web.php route:
Route::middleware([
'auth',
config('jetstream.auth_session'),
'verified',
])->group(function () {
Route::get('/dashboard', function () {
return Inertia::render('Dashboard');
})->name('dashboard');
Route::resource('posts', PostController::class)->only(['create', 'store', 'edit', 'update', 'destroy']);
Route::resource('posts.comments', CommentController::class)->shallow()->only(['store', 'update', 'destroy']);
Route::post('/likes/{type}/{id}', [LikeController::class, 'store'])->name('likes.store');
Route::delete('/likes/{type}/{id}', [LikeController::class, 'destroy'])->name('likes.destroy');
});
And here's my EditPost.php test:
<?php
use App\Models\Post;
use function Pest\Laravel\get;
it('requires authentication', function () {
get(route('posts.edit', [Post::factory()->create()]))->assertRedirect(route('login'));
});
Why am I getting this error:
FAIL Tests\Feature\Controllers\PostController\EditTest
⨯ it requires authentication 2.67s
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
FAILED Tests\Feature\Controllers\PostController\EditTest > it requires authenticati… CommunicationException
cURL error 7: Failed to connect to 127.0.0.1 port 7700 after 2020 ms: Couldn't connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://127.0.0.1:7700/indexes/posts/documents?primaryKey=id
at vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:210
206▕ }
207▕
208▕ // Create a connection exception if it was a specific error code.
209▕ $error = isset($connectionErrors[$easy->errno])
➜ 210▕ ? new ConnectException($message, $easy->request, null, $ctx)
211▕ : new RequestException($message, $easy->request, $easy->response, null, $ctx);
212▕
213▕ return P\Create::rejectionFor($error);
214▕ }
1 vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:210
2 vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:158
Tests: 1 failed (0 assertions)
Duration: 2.80s