Files
XC_VM/tests/Unit/StreamSorterTest.php
T
9252836b05 fix(player-api): a channel without an icon took down the whole listing
The cs-fix pass (758a9cab) typed ImageUtils::validateURL()'s URL and
StreamSorter::formatTitle()'s title as non-nullable strings, but both
come from nullable columns (streams.stream_icon / stream_display_name,
streams_series.title / cover, …). get_live_streams passed a channel's
NULL stream_icon straight in, so one channel without an icon turned the
line's entire live list into a TypeError page — and the same for any of
the ~100 validateURL() callers (series covers, backdrops, episode
images, admin and reseller views) and a title-less stream or series.

Both now take null as '' (unit-tested). player_api also no longer hands
filterLoaded() a null when the categories cache file is missing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y4P9p5BXijMoGXd31tN6Zp
2026-09-18 09:57:17 +00:00

27 lines
763 B
PHP

<?php
use PHPUnit\Framework\TestCase;
use XcVm\Core\Config\SettingsManager;
use XcVm\Domain\Stream\StreamSorter;
/**
* @covers StreamSorter
*/
final class StreamSorterTest extends TestCase {
protected function setUp(): void {
SettingsManager::set(['movie_year_append' => 0]);
}
public function testFormatTitleAppendsAValidYear() {
$this->assertSame('Film (2020)', StreamSorter::formatTitle('Film', 2020));
$this->assertSame('Film', StreamSorter::formatTitle('Film', 1800));
}
public function testFormatTitleTakesAMissingTitle() {
// streams.stream_display_name and streams_series.title are nullable; a
// null title raised a TypeError that took down a whole player_api listing.
$this->assertSame('', StreamSorter::formatTitle(null));
}
}