Skip to content

Instantly share code, notes, and snippets.

@davidpeach
Last active October 29, 2020 13:59
Show Gist options
  • Save davidpeach/44ec36bda1f7a7dde2a2ea825b1be2b6 to your computer and use it in GitHub Desktop.
Save davidpeach/44ec36bda1f7a7dde2a2ea825b1be2b6 to your computer and use it in GitHub Desktop.
<?php
namespace Tests\Feature;
use App\Models\Post;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ViewPostsTest extends TestCase
{
use HasFactory;
use RefreshDatabase;
/** @test */
public function a_guest_can_view_the_blog_post_archive()
{
list($postA, $postB, $postC) = Post::factory()->count(3)->create();
$response = $this->get('/posts');
$response->assertViewHas('posts', new Collection([
$postA->fresh(),
$postB->fresh(),
$postC->fresh(),
]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment