summaryrefslogtreecommitdiff
path: root/extensions/TimedMediaHandler/tests/phpunit/TestTimedMediaHandler.php
blob: 2ca350a0303ebbc7a0c561127aa4f17f94120dd7 (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
<?php
class TestTimedMediaHandler extends MediaWikiTestCase {

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

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

	/**
	 * @dataProvider providerParseParamString
	 * @param $str String a thumbnail parameter string
	 * @param $expected Array Expected thumbnailing parameters
	 */
	function testParseParamString( $str, $expected ) {
		$result = $this->handler->parseParamString( $str );
		$this->assertEquals( $result, $expected );
	}

	function providerParseParamString() {
		return array(
			array(
				'mid',
				array(),
			),
			array(
				'220px-',
				array( 'width' => 220 ),
			),
			array(
				'seek=30',
				array( 'thumbtime' => 30.0 ),
			),
			array(
				'seek=15.72',
				array( 'thumbtime' => 15.72 ),
			),
			array(
				'180px-seek=15',
				array( 'thumbtime' => 15, 'width' => 180 ),
			),
		);

	}
}