admin = $this->createAdminUser(['sirsoft-board.dashboard.view']); } /** * @scenario case=dashboard_recent_visibility * * @effects dashboard_summary_excludes_hidden_posts */ #[Test] public function recent_posts_shows_secret_but_excludes_blinded_and_inactive_board_posts(): void { $activeBoard = Board::factory()->create(['is_active' => true]); $inactiveBoard = Board::factory()->create(['is_active' => false]); $this->insertPost($activeBoard->id, '공개 발행글', ['is_secret' => false, 'status' => PostStatus::Published->value]); $this->insertPost($activeBoard->id, '비밀글', ['is_secret' => true, 'status' => PostStatus::Published->value]); $this->insertPost($activeBoard->id, '블라인드글', ['is_secret' => false, 'status' => PostStatus::Blinded->value]); $this->insertPost($inactiveBoard->id, '비활성게시판글', ['is_secret' => false, 'status' => PostStatus::Published->value]); $response = $this->actingAs($this->admin)->getJson(self::ENDPOINT.'?limit=20'); $response->assertStatus(200); $titles = array_column($response->json('data'), 'title'); $this->assertContains('공개 발행글', $titles, '공개 발행글은 최신글에 노출되어야 한다.'); $this->assertContains('비밀글', $titles, '비밀글은 제목 공개 정책에 따라 관리자 대시보드에 노출되어야 한다.'); $this->assertNotContains('블라인드글', $titles, '블라인드글은 최신글에서 제외되어야 한다.'); $this->assertNotContains('비활성게시판글', $titles, '비활성 게시판 글은 최신글에서 제외되어야 한다.'); } /** * 게시글을 직접 삽입합니다. * * @param int $boardId 게시판 ID * @param string $title 제목 * @param array $attributes 추가 속성 */ private function insertPost(int $boardId, string $title, array $attributes = []): void { DB::table('board_posts')->insert(array_merge([ 'board_id' => $boardId, 'title' => $title, 'content' => '내용', 'author_name' => '작성자', 'ip_address' => '127.0.0.1', 'created_at' => now(), 'updated_at' => now(), ], $attributes)); } }