From a5f917bbc55e295896b8084f6657eb8b6abaf8a8 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Fri, 15 Jul 2016 15:33:36 -0300 Subject: Add TimedMediaHandler extension that allows display audio and video files in wiki pages, using the same syntax as for image files --- .../tests/phpunit/TestVideoThumbnail.php | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 extensions/TimedMediaHandler/tests/phpunit/TestVideoThumbnail.php (limited to 'extensions/TimedMediaHandler/tests/phpunit/TestVideoThumbnail.php') diff --git a/extensions/TimedMediaHandler/tests/phpunit/TestVideoThumbnail.php b/extensions/TimedMediaHandler/tests/phpunit/TestVideoThumbnail.php new file mode 100644 index 00000000..b3c9ef87 --- /dev/null +++ b/extensions/TimedMediaHandler/tests/phpunit/TestVideoThumbnail.php @@ -0,0 +1,80 @@ +uploadFile( $file); + + // Do a API request and check for valid thumbnails: + $fileName = basename( $file['filePath'] ); + $params = array( + 'action' => 'query', + 'titles' => 'File:' . $fileName, + 'prop' => 'imageinfo', + 'iiprop' => "url|size|thumbmime", + ); + + // Do a request for a small ( 200px ) thumbnail + list($result,,) = $this->doApiRequest( + array_merge( $params, array( + 'iiurlwidth' => '200' + ) + ) + ); + + // Check The thumbnail output: + $this->assertTrue( isset( $result['query'] ) ); + + $page = current( $result['query']['pages'] ); + $this->assertTrue( isset( $page['imageinfo'] ) ); + + $imageInfo = current( $page['imageinfo'] ); + + // Make sure we got a 200 wide pixel image: + $this->assertEquals( 200, ( int )$imageInfo['thumbwidth'] ); + + // Thumbnails should be image/jpeg: + $this->assertEquals( 'image/jpeg', $imageInfo['thumbmime'] ); + + // Make sure the thumbnail url is valid and the correct size ( assuming php has getimagesize function) + if( function_exists( 'getimagesize' ) ){ + list($width ,,,) = getimagesize ( $imageInfo[ 'thumburl'] ); + $this->assertEquals( 200, $width ); + } + + /** + * We combine tests because fixtures don't play well with dataProvider + * see README for more info + */ + + // Test a larger thumbnail with 1 second time offset + list( $result,, ) = $this->doApiRequest( + array_merge( $params, array( + 'iiurlwidth' => '600', + 'iiurlparam' => '1' + ) + ) + ); + $page = current( $result['query']['pages'] ); + $imageInfo = current( $page['imageinfo'] ); + // Thumb should max out at source size ( no upscale ) + $targetWidth = ( ( int )$file['width'] < 600 ) ? ( int )$file['width'] : 600; + $this->assertEquals( $targetWidth, ( int )$imageInfo['thumbwidth'] ); + if( function_exists( 'getimagesize' ) ){ + list( $srcImageWidth ,,,) = getimagesize ( $imageInfo[ 'thumburl'] ); + $this->assertEquals( $targetWidth, $srcImageWidth ); + } + } +} -- cgit v1.2.3-54-g00ecf