Show no date for a story without one.

Such a story showed the date of the story before it, or caused a warning when it came first.
This commit is contained in:
tim
2026-09-26 15:27:51 +02:00
parent 71f768bff2
commit 8d6282348c
2 changed files with 17 additions and 2 deletions
+13
View File
@@ -46,6 +46,19 @@ class DisplayStoriesTest extends TestCase {
$this->assertStringContainsString('<time datetime="' . $datetime . '">2020-01-02 03:04</time>', $page);
}
// A story without a date shows no date, not the date of the story before it
public function testAStoryWithoutADateShowsNone(): void {
SiteData::install(array('xxx' => array(
array('id' => 1, 'title' => 'Dated', 'date' => '2020-01-02 03:04:05'),
array('id' => 2, 'title' => 'Undated', 'date' => NULL),
)));
$GLOBALS['num_stories'] = 5;
$page = display_stories();
$this->assertSame(1, substr_count($page, '<time '));
$this->assertStringContainsString('<dd class="date"></dd>', $page);
$this->assertStringContainsString('<dd class="date"></dd>', display_stories('2'));
}
public function testHiddenStoriesAreLeftOutForVisitors(): void {
$this->assertStringNotContainsString('Picture', display_stories());
}