summaryrefslogtreecommitdiff
path: root/extensions/TimedMediaHandler/tests/phpunit/TestWebMHandler.php
blob: 2d73f46d47e3be1a6bd225d80b2d52e483ac21ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
class TestOggHandler extends MediaWikiMediaTestCase {

	/** @var OggHandlerTMH */
	private $handler;

	function getFilePath() {
		return __DIR__ . '/media';
	}

	function setUp() {
		parent::setUp();
		$this->handler = new WebMHandler;
	}

	/**
	 * @dataProvider providerGetStreamTypes
	 * @param $filename String name of file
	 * @param $expected array List of codecs in file
	 */
	function testGetStreamTypes( $filename, $expected ) {
		$testFile = $this->dataFile( $filename, 'video/webm' );
		$this->assertEquals( $expected, $this->handler->getStreamTypes( $testFile ) );
	}

	function providerGetStreamTypes() {
		return array(
			array( 'shuttle10seconds.1080x608.webm', array( 'VP8' ) ),
			array( 'VP9-tractor.webm', array( 'VP9' ) ),
			array( 'bear-vp9-opus.webm', array( 'Opus', 'VP9' ) )
		);
	}


	/**
	 * @dataProvider providerGetWebType
	 * @param $filename String name of file
	 * @param $expected String Mime type
	 */
	function testGetWebType( $filename, $expected ) {
		$testFile = $this->dataFile( $filename, 'video/webm' );
		$this->assertEquals( $expected, $this->handler->getWebType( $testFile ) );
	}

	function providerGetWebType() {
		return array(
			array( 'shuttle10seconds.1080x608.webm', 'video/webm; codecs="vp8"' ),
			array( 'VP9-tractor.webm', 'video/webm; codecs="vp9"' ),
			array( 'bear-vp9-opus.webm', 'video/webm; codecs="opus, vp9"' )
		);
	}
}