|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Mhor\PhpMp3Info\Test; |
|
4
|
|
|
|
|
5
|
|
|
use Mhor\PhpMp3Info\PhpMp3Info; |
|
6
|
|
|
use PHPUnit\Framework\TestCase; |
|
7
|
|
|
|
|
8
|
|
|
class PhpMp3InfoTest extends TestCase { |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @var string filePath |
|
12
|
|
|
*/ |
|
13
|
|
|
private $filePath = __DIR__ . '/testFiles/ZOE.LEELA_-_Pop_Up.mp3'; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @var PhpMp3Info |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $mp3info; |
|
19
|
|
|
|
|
20
|
|
|
public function testTags() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->mp3info = new PhpMp3Info(); |
|
23
|
|
|
$mp3tags = $this->mp3info->extractId3Tags($this->filePath); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertEquals('Digital Guilt', $mp3tags->getAlbum()); |
|
26
|
|
|
$this->assertEquals('1', $mp3tags->getTrack(), '1'); |
|
27
|
|
|
$this->assertEquals('Pop Up', $mp3tags->getTitle()); |
|
28
|
|
|
$this->assertEquals('ZOE LEELA', $mp3tags->getArtist()); |
|
29
|
|
|
$this->assertEquals('1:44', $mp3tags->getLength()); |
|
30
|
|
|
$this->assertEquals('Variable', $mp3tags->getBitrate()); |
|
31
|
|
|
$this->assertEquals($this->filePath, $mp3tags->getFilePath()); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @expectedException \RuntimeException |
|
36
|
|
|
*/ |
|
37
|
|
|
public function testFailCommand() |
|
38
|
|
|
{ |
|
39
|
|
|
$mp3tags = new PhpMp3Info('this-command-doesnt-exist', 'no arguments'); |
|
40
|
|
|
$mp3tags->extractId3Tags($this->filePath); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @expectedException \Exception |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testFailFile() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->mp3info = new PhpMp3Info(); |
|
49
|
|
|
$this->mp3info->extractId3Tags('thisFileDoesNotExist.mp3'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|