'48']); $this->assertSame(48, $board->new_display_hours); } #[Test] public function new_display_hours_is_integer_after_create_without_refresh(): void { $board = Board::create([ 'slug' => 'cast-new-display-hours', 'name' => ['ko' => '캐스트 테스트', 'en' => 'Cast Test'], 'is_active' => true, 'new_display_hours' => '48', ]); $this->assertSame(48, $board->new_display_hours); } #[Test] public function new_display_hours_is_cast_to_integer_when_loaded_from_db(): void { DB::table('boards')->where('id', $this->board->id)->update(['new_display_hours' => 12]); $board = Board::findOrFail($this->board->id); $this->assertSame(12, $board->new_display_hours); } #[Test] public function post_is_new_does_not_crash_when_board_attribute_is_string(): void { $postId = $this->createTestPost(); $post = Post::with('board')->findOrFail($postId); // 문자열 유입 재현 (캐스트 도입 후 정수로 해석되어야 함 — 비회귀 가드) $post->board->new_display_hours = '24'; $this->assertTrue($post->isNew()); } #[Test] public function post_is_new_returns_false_for_old_post(): void { $postId = $this->createTestPost(); DB::table('board_posts')->where('id', $postId)->update(['created_at' => now()->subHours(5)]); $post = Post::with('board')->findOrFail($postId); $post->board->new_display_hours = '1'; $this->assertFalse($post->isNew()); } }