seed(); $user = User::create(['name' => '作者', 'email' => 'view@test.com', 'password' => bcrypt('x')]); $category = Category::create(['name' => '技术', 'slug' => 'tech-view']); $this->post = Post::create([ 'user_id' => $user->id, 'category_id' => $category->id, 'title' => '浏览模式测试文', 'slug' => 'view-mode-test', 'excerpt' => '列表摘要文字', 'content' => '这是完整正文内容 FULL_BODY_ONLY_TOKEN', 'content_format' => 'markdown', 'status' => 'published', 'published_at' => now(), ]); } public function test_list_mode_shows_excerpt_not_full_body(): void { $this->get('/?view=list') ->assertOk() ->assertSee('浏览模式', false) ->assertSee('列表摘要文字', false) ->assertDontSee('FULL_BODY_ONLY_TOKEN', false); } public function test_full_mode_shows_article_body(): void { $this->get('/?view=full') ->assertOk() ->assertSee('浏览模式', false) ->assertSee('FULL_BODY_ONLY_TOKEN', false); } public function test_compact_pagination_shows_page_info(): void { $userId = $this->post->user_id; $categoryId = $this->post->category_id; for ($index = 1; $index <= 12; $index++) { Post::create([ 'user_id' => $userId, 'category_id' => $categoryId, 'title' => '分页文章 '.$index, 'slug' => 'pager-'.$index, 'content' => '正文 '.$index, 'content_format' => 'markdown', 'status' => 'published', 'published_at' => now()->subMinutes($index), ]); } $this->get('/') ->assertOk() ->assertSee('第 1 /', false) ->assertSee('页', false); } }