Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Article;
|
|
use App\Models\Category;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class ApiV1Test extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_api_meta_and_articles(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
$category = Category::query()->create(['name' => 'API', 'display_order' => 0]);
|
|
$article = Article::query()->create([
|
|
'category_id' => $category->id,
|
|
'user_id' => $user->id,
|
|
'title' => 'API Post',
|
|
'content' => '## hi',
|
|
'content_format' => 'markdown',
|
|
'published_at' => now()->subMinute(),
|
|
'visible' => true,
|
|
]);
|
|
|
|
$this->getJson('/api/v1/meta')->assertOk()->assertJsonPath('api.version', 'v1');
|
|
$this->getJson('/api/v1/articles')->assertOk()->assertJsonPath('data.0.title', 'API Post');
|
|
$this->getJson('/api/v1/articles/'.$article->id)->assertOk()->assertJsonPath('data.id', $article->id);
|
|
$this->getJson('/api/v1/categories')->assertOk();
|
|
}
|
|
}
|