first commit
This commit is contained in:
55
tests/Unit/OkRuUrlParserTest.php
Normal file
55
tests/Unit/OkRuUrlParserTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\VideoExtractor\Tests\Unit;
|
||||
|
||||
use Apoloz\VideoExtractor\Platform\Platform;
|
||||
use Apoloz\VideoExtractor\Parsing\OkRuUrlParser;
|
||||
use Apoloz\VideoExtractor\Tests\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class OkRuUrlParserTest extends TestCase
|
||||
{
|
||||
private OkRuUrlParser $parser;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->parser = new OkRuUrlParser();
|
||||
}
|
||||
|
||||
#[DataProvider('urlShapes')]
|
||||
public function test_parses_canonical_and_embed_urls(string $url, string $expectedId): void
|
||||
{
|
||||
$ref = $this->parser->parse($url);
|
||||
|
||||
self::assertSame(Platform::OK, $ref->platform);
|
||||
self::assertSame($expectedId, $ref->id);
|
||||
}
|
||||
|
||||
public function test_parses_legacy_deep_link_query(): void
|
||||
{
|
||||
$ref = $this->parser->parse('https://ok.ru/dk?st.cmd=movieLayer&st.mvId=863789452017&tkn=3648');
|
||||
|
||||
self::assertSame('863789452017', $ref->id);
|
||||
}
|
||||
|
||||
public function test_parses_id_with_segment_suffix(): void
|
||||
{
|
||||
$ref = $this->parser->parse('https://ok.ru/video/63567059965189-0');
|
||||
|
||||
self::assertSame('63567059965189-0', $ref->id);
|
||||
}
|
||||
|
||||
public static function urlShapes(): array
|
||||
{
|
||||
return [
|
||||
'video' => ['https://ok.ru/video/15019292494547', '15019292494547'],
|
||||
'videoembed' => ['https://ok.ru/videoembed/2932705602075', '2932705602075'],
|
||||
'live' => ['https://ok.ru/live/484531969818', '484531969818'],
|
||||
'moviePlayer API' => ['https://ok.ru/web-api/video/moviePlayer/20079905452', '20079905452'],
|
||||
'mobile' => ['https://m.ok.ru/video/2361249957145', '2361249957145'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user