parsaaghayi-backend/tests/Feature/Blog/HomeTest.php

30 lines
665 B
PHP

<?php
namespace Tests\Feature\Blog;
use App\Models\Blog\Category;
use App\Models\Blog\Post;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class HomeTest extends TestCase
{
use RefreshDatabase;
public function test_can_get_homepage()
{
Post::factory()->count(5)->create();
Category::factory()->count(3)->create();
$response = $this->getJson('/api/blog/homepage');
$response->assertStatus(200)
->assertJsonStructure([
'latest_posts',
'latest_categories',
'most_viewed_posts',
'random_posts',
]);
}
}