[MediaWiki-commits] [Gerrit] mediawiki/core[master]: MimeAnalyzer: Add testcases for mp3 detection

2017-08-09 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/354456 )

Change subject: MimeAnalyzer: Add testcases for mp3 detection
..


MimeAnalyzer: Add testcases for mp3 detection

This is a follow-up to change Ie1a63aa

Bug: T115170
Change-Id: Iab5e19e1dd26b0d88c72ad7253cd11e865c5e008
---
M .gitattributes
A tests/phpunit/data/media/say-test-mpeg1.mp3
A tests/phpunit/data/media/say-test-mpeg2.5.mp3
A tests/phpunit/data/media/say-test-mpeg2.mp3
A tests/phpunit/data/media/say-test-with-id3.mp3
M tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
6 files changed, 57 insertions(+), 0 deletions(-)

Approvals:
  Brion VIBBER: Looks good to me, approved
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/.gitattributes b/.gitattributes
index 09f86a3..f230c60 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,4 @@
 *.sh eol=lf
 *.icc binary
 *.webp binary
+*.mp3 binary
\ No newline at end of file
diff --git a/tests/phpunit/data/media/say-test-mpeg1.mp3 
b/tests/phpunit/data/media/say-test-mpeg1.mp3
new file mode 100644
index 000..b3a6318
--- /dev/null
+++ b/tests/phpunit/data/media/say-test-mpeg1.mp3
Binary files differ
diff --git a/tests/phpunit/data/media/say-test-mpeg2.5.mp3 
b/tests/phpunit/data/media/say-test-mpeg2.5.mp3
new file mode 100644
index 000..e6743a8
--- /dev/null
+++ b/tests/phpunit/data/media/say-test-mpeg2.5.mp3
Binary files differ
diff --git a/tests/phpunit/data/media/say-test-mpeg2.mp3 
b/tests/phpunit/data/media/say-test-mpeg2.mp3
new file mode 100644
index 000..8b2aaa2
--- /dev/null
+++ b/tests/phpunit/data/media/say-test-mpeg2.mp3
Binary files differ
diff --git a/tests/phpunit/data/media/say-test-with-id3.mp3 
b/tests/phpunit/data/media/say-test-with-id3.mp3
new file mode 100644
index 000..04205d5
--- /dev/null
+++ b/tests/phpunit/data/media/say-test-with-id3.mp3
Binary files differ
diff --git a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php 
b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
index 787d9a8..bf2a3f6 100644
--- a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
+++ b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
@@ -1,4 +1,8 @@
 mimeAnalyzer ) 
);
+   $method = $class->getMethod( 'doGuessMimeType' );
+   $method->setAccessible( true );
+   return $method->invokeArgs( $this->mimeAnalyzer, $parameters );
}
 
/**
@@ -69,4 +80,49 @@
$actualType = $this->mimeAnalyzer->getMediaType( $oggFile, 
'application/ogg' );
$this->assertEquals( $actualType, MEDIATYPE_AUDIO );
}
+
+   /**
+* Test to make sure that mp3 files are detected as audio type
+*/
+   function testMP3AsAudio() {
+   $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3';
+   $actualType = $this->mimeAnalyzer->getMediaType( $file );
+   $this->assertEquals( MEDIATYPE_AUDIO, $actualType );
+   }
+
+   /**
+* Test to make sure that MP3 with id3 tag is recognized
+*/
+   function testMP3WithID3Recognize() {
+   $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3';
+   $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] );
+   $this->assertEquals( 'audio/mpeg', $actualType );
+   }
+
+   /**
+* Test to make sure that MP3 without id3 tag is recognized (MPEG-1 
sample rates)
+*/
+   function testMP3NoID3RecognizeMPEG1() {
+   $file = __DIR__ . '/../../../data/media/say-test-mpeg1.mp3';
+   $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] );
+   $this->assertEquals( 'audio/mpeg', $actualType );
+   }
+
+   /**
+* Test to make sure that MP3 without id3 tag is recognized (MPEG-2 
sample rates)
+*/
+   function testMP3NoID3RecognizeMPEG2() {
+   $file = __DIR__ . '/../../../data/media/say-test-mpeg2.mp3';
+   $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] );
+   $this->assertEquals( 'audio/mpeg', $actualType );
+   }
+
+   /**
+* Test to make sure that MP3 without id3 tag is recognized (MPEG-2.5 
sample rates)
+*/
+   function testMP3NoID3RecognizeMPEG2_5() {
+   $file = __DIR__ . '/../../../data/media/say-test-mpeg2.5.mp3';
+   $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] );
+   $this->assertEquals( 'audio/mpeg', $actualType );
+   }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/354456
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iab5e19e1dd26b0d88c72ad7253cd11e865c5e008
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: TheDJ 
Gerrit-Reviewer: Brion VIBBER 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: MimeAnalyzer: Add testcases for mp3 detection

2017-05-19 Thread TheDJ (Code Review)
TheDJ has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/354456 )

Change subject: MimeAnalyzer: Add testcases for mp3 detection
..

MimeAnalyzer: Add testcases for mp3 detection

This is a follow-up to change Ie1a63aa

Bug: T115170
Change-Id: Iab5e19e1dd26b0d88c72ad7253cd11e865c5e008
---
A tests/phpunit/data/media/say-test-mpeg1.mp3
A tests/phpunit/data/media/say-test-mpeg2.5.mp3
A tests/phpunit/data/media/say-test-mpeg2.mp3
A tests/phpunit/data/media/say-test-with-id3.mp3
M tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
5 files changed, 56 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/56/354456/1

diff --git a/tests/phpunit/data/media/say-test-mpeg1.mp3 
b/tests/phpunit/data/media/say-test-mpeg1.mp3
new file mode 100644
index 000..b3a6318
--- /dev/null
+++ b/tests/phpunit/data/media/say-test-mpeg1.mp3
Binary files differ
diff --git a/tests/phpunit/data/media/say-test-mpeg2.5.mp3 
b/tests/phpunit/data/media/say-test-mpeg2.5.mp3
new file mode 100644
index 000..e6743a8
--- /dev/null
+++ b/tests/phpunit/data/media/say-test-mpeg2.5.mp3
Binary files differ
diff --git a/tests/phpunit/data/media/say-test-mpeg2.mp3 
b/tests/phpunit/data/media/say-test-mpeg2.mp3
new file mode 100644
index 000..8b2aaa2
--- /dev/null
+++ b/tests/phpunit/data/media/say-test-mpeg2.mp3
Binary files differ
diff --git a/tests/phpunit/data/media/say-test-with-id3.mp3 
b/tests/phpunit/data/media/say-test-with-id3.mp3
new file mode 100644
index 000..04205d5
--- /dev/null
+++ b/tests/phpunit/data/media/say-test-with-id3.mp3
Binary files differ
diff --git a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php 
b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
index 787d9a8..a5cbeb5 100644
--- a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
+++ b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
@@ -1,4 +1,8 @@
 mimeAnalyzer) );
+   $method = $class->getMethod( 'doGuessMimeType' );
+   $method->setAccessible( true );
+   return $method->invokeArgs( $this->mimeAnalyzer, $parameters );
}
 
/**
@@ -69,4 +80,49 @@
$actualType = $this->mimeAnalyzer->getMediaType( $oggFile, 
'application/ogg' );
$this->assertEquals( $actualType, MEDIATYPE_AUDIO );
}
+
+   /**
+* Test to make sure that mp3 files are detected as audio type
+*/
+   function testMP3AsAudio() {
+   $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3';
+   $actualType = $this->mimeAnalyzer->getMediaType( $file );
+   $this->assertEquals( MEDIATYPE_AUDIO, $actualType );
+   }
+
+   /**
+* Test to make sure that MP3 with id3 tag is recognized
+*/
+   function testMP3WithID3Recognize() {
+   $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3';
+   $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] );
+   $this->assertEquals( 'audio/mpeg', $actualType );
+   }
+
+   /**
+* Test to make sure that MP3 without id3 tag is recognized (MPEG-1 
sample rates)
+*/
+   function testMP3NoID3RecognizeMPEG1() {
+   $file = __DIR__ . '/../../../data/media/say-test-mpeg1.mp3';
+   $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] );
+   $this->assertEquals( 'audio/mpeg', $actualType );
+   }
+
+   /**
+* Test to make sure that MP3 without id3 tag is recognized (MPEG-2 
sample rates)
+*/
+   function testMP3NoID3RecognizeMPEG2() {
+   $file = __DIR__ . '/../../../data/media/say-test-mpeg2.mp3';
+   $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] );
+   $this->assertEquals( 'audio/mpeg', $actualType );
+   }
+
+   /**
+* Test to make sure that MP3 without id3 tag is recognized (MPEG-2.5 
sample rates)
+*/
+   function testMP3NoID3RecognizeMPEG2_5() {
+   $file = __DIR__ . '/../../../data/media/say-test-mpeg2.5.mp3';
+   $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] );
+   $this->assertEquals( 'audio/mpeg', $actualType );
+   }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/354456
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab5e19e1dd26b0d88c72ad7253cd11e865c5e008
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: TheDJ 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits