From: jenkins-bot Date: Tue, 14 Jun 2016 16:46:26 +0000 (+0000) Subject: Merge "Add an audio file parser test" X-Git-Tag: 1.31.0-rc.0~6618 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=ff13c3d92a3357d2cbb03c4d58dfc33999942b0a;hp=0a69565ff307462f08ef65b56bce84b1c1809eda;p=lhc%2Fweb%2Fwiklou.git Merge "Add an audio file parser test" --- diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 132743f32d..e519f59d0a 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -1137,6 +1137,19 @@ class ParserTest { 'fileExists' => true ], $this->db->timestamp( '20010115123500' ), $user ); + $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Audio.oga' ) ); + $image->recordUpload2( '', 'An awesome hitsong', 'Will it play', [ + 'size' => 12345, + 'width' => 0, + 'height' => 0, + 'bits' => 0, + 'media_type' => MEDIATYPE_AUDIO, + 'mime' => 'application/ogg', + 'metadata' => serialize( [] ), + 'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ), + 'fileExists' => true + ], $this->db->timestamp( '20010115123500' ), $user ); + # A DjVu file $image = wfLocalFile( Title::makeTitle( NS_FILE, 'LoremIpsum.djvu' ) ); $image->recordUpload2( '', 'Upload a DjVu', 'A DjVu', [ @@ -1252,6 +1265,8 @@ class ParserTest { copy( "$IP/tests/phpunit/data/parser/LoremIpsum.djvu", "$dir/5/5f/LoremIpsum.djvu" ); wfMkdirParents( $dir . '/0/00', null, __METHOD__ ); copy( "$IP/tests/phpunit/data/parser/320x240.ogv", "$dir/0/00/Video.ogv" ); + wfMkdirParents( $dir . '/4/41', null, __METHOD__ ); + copy( "$IP/tests/phpunit/data/media/say-test.ogg", "$dir/4/41/Audio.oga" ); return; } @@ -1301,6 +1316,7 @@ class ParserTest { "$dir/thumb/0/00/Video.ogv/270px--Video.ogv.jpg", "$dir/thumb/0/00/Video.ogv/320px-seek=2-Video.ogv.jpg", "$dir/thumb/0/00/Video.ogv/320px-seek=3.3666666666667-Video.ogv.jpg", + "$dir/4/41/Audio.oga", ] ); @@ -1330,6 +1346,8 @@ class ParserTest { "$dir/thumb/5/5f", "$dir/thumb/5", "$dir/thumb", + "$dir/4/41", + "$dir/4", "$dir/math/f/a/5", "$dir/math/f/a", "$dir/math/f", diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 1f1d53b393..cf7daed1e2 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -9870,7 +9870,7 @@ Magic Word: {{NUMBEROFFILES}} !! wikitext {{NUMBEROFFILES}} !! html -

6 +

7

!! end diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 354ddd4fc6..8512572a25 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -324,7 +324,21 @@ class NewParserTest extends MediaWikiTestCase { ], $this->db->timestamp( '20010115123500' ), $user ); } - # A DjVu file + $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Audio.oga' ) ); + if ( !$this->db->selectField( 'image', '1', [ 'img_name' => $image->getName() ] ) ) { + $image->recordUpload2( '', 'An awesome hitsong ', 'Will it play', [ + 'size' => 12345, + 'width' => 0, + 'height' => 0, + 'bits' => 0, + 'media_type' => MEDIATYPE_AUDIO, + 'mime' => 'application/ogg', + 'metadata' => serialize( [] ), + 'sha1' => Wikimedia\base_convert( '', 16, 36, 32 ), + 'fileExists' => true + ], $this->db->timestamp( '20010115123500' ), $user ); + } + # A DjVu file $image = wfLocalFile( Title::makeTitle( NS_FILE, 'LoremIpsum.djvu' ) ); if ( !$this->db->selectField( 'image', '1', [ 'img_name' => $image->getName() ] ) ) { diff --git a/tests/phpunit/mocks/media/MockOggHandler.php b/tests/phpunit/mocks/media/MockOggHandler.php index b110e2137f..99992fe3d8 100644 --- a/tests/phpunit/mocks/media/MockOggHandler.php +++ b/tests/phpunit/mocks/media/MockOggHandler.php @@ -76,18 +76,30 @@ class MockOggHandler extends OggHandlerTMH { } function getLength( $file ) { + if ( $this->isAudio( $file ) ) { + return 0.99875; + } return 4.3666666666667; } function getBitRate( $file ) { + if ( $this->isAudio( $file ) ) { + return 41107; + } return 590013; } function getWebType( $file ) { + if ( $this->isAudio( $file ) ) { + return "audio/ogg; codecs=\"vorbis\""; + } return "video/ogg; codecs=\"theora\""; } function getFramerate( $file ) { + if ( $this->isAudio( $file ) ) { + return 0; + } return 30; } }