mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-04 04:02:30 +02:00
StreamService::process() runs the stream icon through
ImageUtils::downloadImage() when "download images" is on, and an empty icon
arrives there as null. The `string` type the cs-fix pass (758a9cab) put on
the parameter made that a TypeError, so saving a new stream with no icon
answered an empty page and created nothing. Series, movies, episodes, radios
and created channels hand it optional covers and backdrops the same way.
downloadImage() now takes null and hands back whatever it cannot download
unchanged, null included. Found by the new E2E stream test.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WDhDajBPziJwjWZcXnh6R
47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
|
|
use XcVm\Core\Util\ImageUtils;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @covers ImageUtils
|
|
*/
|
|
final class ImageUtilsTest extends TestCase {
|
|
|
|
public function testKeepAspectRatioDownscales() {
|
|
$size = ImageUtils::getImageSizeKeepAspectRatio(1000, 500, 100, 100);
|
|
$this->assertEquals(100, $size['width']);
|
|
$this->assertEquals(50, $size['height']);
|
|
}
|
|
|
|
public function testKeepAspectRatioDoesNotUpscale() {
|
|
$size = ImageUtils::getImageSizeKeepAspectRatio(50, 50, 100, 100);
|
|
$this->assertEquals(50, $size['width']);
|
|
$this->assertEquals(50, $size['height']);
|
|
}
|
|
|
|
public function testKeepAspectRatioTreatsZeroMaxAsUnbounded() {
|
|
$size = ImageUtils::getImageSizeKeepAspectRatio(200, 100, 0, 50);
|
|
$this->assertEquals(100, $size['width']);
|
|
$this->assertEquals(50, $size['height']);
|
|
}
|
|
|
|
public function testIsAbsoluteUrl() {
|
|
$this->assertTrue(ImageUtils::isAbsoluteUrl('http://example.com/a.png'));
|
|
$this->assertTrue(ImageUtils::isAbsoluteUrl('https://example.com/a.png'));
|
|
$this->assertFalse(ImageUtils::isAbsoluteUrl('/relative/a.png'));
|
|
$this->assertFalse(ImageUtils::isAbsoluteUrl('a.png'));
|
|
}
|
|
|
|
/**
|
|
* Callers hand over optional columns (a stream without an icon, a movie
|
|
* without a backdrop). What cannot be downloaded comes back unchanged —
|
|
* null included; it used to end the save with a TypeError.
|
|
*/
|
|
public function testDownloadImageReturnsWhatItCannotDownload() {
|
|
$this->assertNull(ImageUtils::downloadImage(null, 1));
|
|
$this->assertSame('', ImageUtils::downloadImage(''));
|
|
$this->assertSame('/images/local.png', ImageUtils::downloadImage('/images/local.png', 2));
|
|
}
|
|
}
|