mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-09-30 12:02:05 +02:00
- Replace legacy in-project M3U parser with vendored Gemorroj/M3uParser - Initialize parser via bootstrap with proper namespacing - Remove obsolete src/domain/Stream/M3UEntry.php implementation - Update stream import/review mapping: - use logo as fallback when tvg-logo is missing - Add third-party compliance files for vendored parser: - ATTRIBUTION.md - LGPL LICENSE - Add full M3uParser unit test suite: - tag parsing - parser behavior - fixtures - Add StreamService integration tests for M3U parsing/import flow - Update test bootstrap: - add igbinary_serialize / igbinary_unserialize polyfills - explicitly load M3uParser bootstrap and custom test tag class
105 lines
3.1 KiB
PHP
105 lines
3.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace M3uParser\Tests;
|
|
|
|
use M3uParser\Exception as M3uParserException;
|
|
use M3uParser\M3uEntry;
|
|
use M3uParser\M3uParser;
|
|
use M3uParser\Tag\ExtTagInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class M3uParserTest extends TestCase
|
|
{
|
|
public function testParseFileFail(): void
|
|
{
|
|
$this->expectException(M3uParserException::class);
|
|
|
|
$m3uParser = new M3uParser();
|
|
$m3uParser->addDefaultTags();
|
|
$m3uParser->parseFile('fake_file');
|
|
}
|
|
|
|
public function testParseFileExtM3u(): void
|
|
{
|
|
$m3uParser = new M3uParser();
|
|
$m3uParser->addDefaultTags();
|
|
$data = $m3uParser->parseFile(__DIR__.'/fixtures/extm3u.m3u');
|
|
|
|
self::assertEquals([
|
|
'url-tvg' => 'http://www.teleguide.info/download/new3/jtv.zip',
|
|
'm3uautoload' => '1',
|
|
'deinterlace' => '8',
|
|
'cache' => '500',
|
|
], $data->getAttributes());
|
|
self::assertEquals('http://www.teleguide.info/download/new3/jtv.zip', $data->getAttribute('url-tvg'));
|
|
}
|
|
|
|
public function testParseFileComment(): void
|
|
{
|
|
$m3uParser = new M3uParser();
|
|
$m3uParser->addDefaultTags();
|
|
$data = $m3uParser->parseFile(__DIR__.'/fixtures/comment.m3u');
|
|
|
|
/** @var M3uEntry $entry */
|
|
$entry = $data[0];
|
|
|
|
self::assertEquals('http://nullwave.barricade.lan:8000/club', $entry->getPath());
|
|
self::assertEmpty($entry->getExtTags());
|
|
}
|
|
|
|
public function testParseFileNoTags(): void
|
|
{
|
|
$m3uParser = new M3uParser();
|
|
$m3uParser->addDefaultTags();
|
|
$data = $m3uParser->parseFile(__DIR__.'/fixtures/notags.m3u');
|
|
|
|
/** @var M3uEntry $entry */
|
|
$entry = $data[0];
|
|
|
|
self::assertEquals('http://scfire-ntc-aa07.stream.aol.com:80/stream/1048', $entry->getPath());
|
|
self::assertEmpty($entry->getExtTags());
|
|
}
|
|
|
|
public function testParseFileCombinedExtTags(): void
|
|
{
|
|
$m3uParser = new M3uParser();
|
|
$m3uParser->addDefaultTags();
|
|
$data = $m3uParser->parseFile(__DIR__.'/fixtures/combined.m3u');
|
|
|
|
/** @var M3uEntry $entry */
|
|
$entry = $data[0];
|
|
|
|
self::assertEquals('rtp://@232.2.201.53:5003', $entry->getPath());
|
|
|
|
/** @var ExtTagInterface[] $extTags */
|
|
$extTags = $entry->getExtTags();
|
|
self::assertCount(2, $extTags);
|
|
|
|
self::assertContainsOnlyInstancesOf(ExtTagInterface::class, $extTags);
|
|
}
|
|
|
|
public function testParseFileExtCustomTag(): void
|
|
{
|
|
$m3uParser = new M3uParser();
|
|
$m3uParser->addTag(ExtCustomTag::class);
|
|
$data = $m3uParser->parseFile(__DIR__.'/fixtures/customtag.m3u');
|
|
|
|
/** @var M3uEntry $entry */
|
|
$entry = $data[0];
|
|
|
|
self::assertEquals('http://nullwave.barricade.lan:8000/club', $entry->getPath());
|
|
|
|
/** @var ExtTagInterface[] $extTags */
|
|
$extTags = $entry->getExtTags();
|
|
self::assertCount(1, $extTags);
|
|
|
|
/** @var ExtCustomTag $extCustomTag */
|
|
$extCustomTag = $extTags[0];
|
|
self::assertInstanceOf(ExtCustomTag::class, $extCustomTag);
|
|
|
|
self::assertEquals('123', $extCustomTag->getData());
|
|
}
|
|
}
|