66 lines
2.0 KiB
PHP
66 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Apoloz\VideoExtractor\Tests\Unit;
|
|
|
|
use Apoloz\VideoExtractor\Platform\Platform;
|
|
use Apoloz\VideoExtractor\Parsing\RutubeUrlParser;
|
|
use Apoloz\VideoExtractor\Tests\TestCase;
|
|
|
|
class RutubeUrlParserTest extends TestCase
|
|
{
|
|
private RutubeUrlParser $parser;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->parser = new RutubeUrlParser();
|
|
}
|
|
|
|
public function test_parses_canonical_url(): void
|
|
{
|
|
$ref = $this->parser->parse('https://rutube.ru/video/373ba417757981facf06c55ea5c46cb4/');
|
|
|
|
self::assertSame(Platform::RUTUBE, $ref->platform);
|
|
self::assertSame('373ba417757981facf06c55ea5c46cb4', $ref->id);
|
|
}
|
|
|
|
public function test_normalises_uppercase_hex(): void
|
|
{
|
|
$ref = $this->parser->parse('https://rutube.ru/video/373BA417757981FACF06C55EA5C46CB4/');
|
|
|
|
self::assertSame('373ba417757981facf06c55ea5c46cb4', $ref->id);
|
|
}
|
|
|
|
public function test_parses_live_url(): void
|
|
{
|
|
$ref = $this->parser->parse('https://rutube.ru/live/video/c58f502c7bb34a8fcdd976b221fca292/');
|
|
|
|
self::assertSame('c58f502c7bb34a8fcdd976b221fca292', $ref->id);
|
|
}
|
|
|
|
public function test_parses_embed_url(): void
|
|
{
|
|
$ref = $this->parser->parse('https://rutube.ru/play/embed/03a9cb54bac3376af4c5cb0f18444e01');
|
|
|
|
self::assertSame('03a9cb54bac3376af4c5cb0f18444e01', $ref->id);
|
|
}
|
|
|
|
public function test_captures_private_token(): void
|
|
{
|
|
$ref = $this->parser->parse('https://rutube.ru/video/private/884fb55f07a97ab673c7d654553e0f48/?p=x2QojCumHTS3rsKHWXN8Lg');
|
|
|
|
self::assertSame('884fb55f07a97ab673c7d654553e0f48', $ref->id);
|
|
self::assertSame(['p' => 'x2QojCumHTS3rsKHWXN8Lg'], $ref->query);
|
|
}
|
|
|
|
public function test_parses_numeric_embed_id(): void
|
|
{
|
|
$ref = $this->parser->parse('https://rutube.ru/video/embed/6722881');
|
|
|
|
self::assertSame('6722881', $ref->id);
|
|
self::assertSame('embed_numeric', $ref->type);
|
|
}
|
|
}
|