summaryrefslogtreecommitdiff
path: root/extensions/TimedMediaHandler/tests/phpunit/TestOggHandler.php
blob: 3c05897497f095ae378d2603045779d88627f262 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
class TestOggHandler extends MediaWikiMediaTestCase {

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

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

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

	/**
	 * @dataProvider providerGetCommonMetaArray
	 * @param $filename String name of file
	 * @param $expected Array
	 */
	function testGetCommonMetaArray( $filename, $expected ) {
		$testFile = $this->dataFile( $filename, 'application/ogg' );
		$this->assertEquals( $expected, $this->handler->getCommonMetaArray( $testFile ) );
	}

	function providerGetCommonMetaArray() {
		return array(
			array( 'test5seconds.electricsheep.300x400.ogv',
				array(
					'Software' => array( 'Lavf53.21.1' ),
					'ObjectName' => array( 'Electric Sheep' ),
					'UserComment' => array( '🐑' )
				)
			),
			array( 'doubleTag.oga',
				array(
					'Artist' => array( 'Brian', 'Bawolff' ),
					'Software' => array( 'Lavf55.10.2' )
				)
			),
			array( 'broken-file.ogg',
				array()
			),
		);
	}

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

	function providerGetWebType() {
		return array(
			array( 'test5seconds.electricsheep.300x400.ogv', 'video/ogg; codecs="theora"' ),
			array( 'doubleTag.oga', 'audio/ogg; codecs="vorbis"' ),
			// XXX: This behaviour is somewhat questionable. It perhaps should be
			// application/ogg in this case.
			array( 'broken-file.ogg', 'audio/ogg' ),
		);
	}

}