PHP Classes

File: tests/Posts/PostIndexTest.php

Recommend this page to a friend!
  Classes of Omar Andrés Barbosa Ortiz   Easy Blog   tests/Posts/PostIndexTest.php   Download  
File: tests/Posts/PostIndexTest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Easy Blog
Provide a blog as a Laravel service
Author: By
Last change:
Date: 4 days ago
Size: 686 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use
Barbosa\EasyBlog\Models\Post;
use
Barbosa\EasyBlog\Tests\Models\User;
use
Illuminate\Database\Eloquent\Collection;

use function
Pest\Laravel\actingAs;

it('can access the posts index', function (): void {
   
$user = User::factory()->create();

   
$post = Post::factory()->create([
       
'user_id' => $user->id,
    ]);

   
$response = actingAs($user)
        ->
get(route('posts.index'));

   
$response->assertOk()
        ->
assertViewIs('easyblog::posts.index')
        ->
assertViewHas('posts', function (Collection $posts) use ($post): bool {
            return
$posts->contains($post);
        })
        ->
assertSeeText($post->title);
});