File: Mp3Test.php

package info (click to toggle)
php-getid3 2.0.0~beta6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 3,108 kB
  • sloc: php: 34,627; makefile: 12
file content (36 lines) | stat: -rw-r--r-- 961 bytes parent folder | download
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
<?php

namespace JamesHeinrich\GetID3\Tests;

use JamesHeinrich\GetID3\GetID3;
use JamesHeinrich\GetID3\WriteTags;

class Mp3Test extends \PHPUnit\Framework\TestCase
{

    public function testRead()
    {
        $filename = __DIR__ . "/files/silence.mp3";
        $band = "Protest The Hero";
        $year = 2010;

        $writer = new WriteTags;
        $writer->filename = $filename;
        $writer->tagformats = ["id3v2.4"];
        $writer->tag_encoding = "UTF-8";
        $writer->overwrite_tags = true;

        $writer->tag_data = [
            "band"              =>  [$band],
            "recording_time"    =>  [$year],
        ];

        $writer->WriteTags();

        $getID3 = new GetID3;
        $tags = $getID3->analyze($filename)["tags"]["id3v2"];
        $this->assertSame($band, $tags["band"][0]);
        $this->assertSame((string) $year, $tags["year"][0]);
        $this->assertSame((string) $year, $tags["recording_time"][0]);
    }
}