コード例 #1
0
ファイル: MediaTest.php プロジェクト: seppi91/koel
 public function testSync()
 {
     $this->expectsEvents(LibraryChanged::class);
     $media = new Media();
     $media->sync($this->mediaPath);
     // Standard mp3 files under root path should be recognized
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/full.mp3']);
     // Ogg files and audio files in subdirectories should be recognized
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/subdir/back-in-black.ogg']);
     // File search shouldn't be case-sensitive.
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/subdir/no-name.MP3']);
     // Non-audio files shouldn't be recognized
     $this->notSeeInDatabase('songs', ['path' => $this->mediaPath . '/rubbish.log']);
     // Broken/corrupted audio files shouldn't be recognized
     $this->notSeeInDatabase('songs', ['path' => $this->mediaPath . '/fake.mp3']);
     // Artists should be created
     $this->seeInDatabase('artists', ['name' => 'Cuckoo']);
     $this->seeInDatabase('artists', ['name' => 'Koel']);
     // Albums should be created
     $this->seeInDatabase('albums', ['name' => 'Koel Testing Vol. 1']);
     // Albums and artists should be correctly linked
     $album = Album::whereName('Koel Testing Vol. 1')->first();
     $this->assertEquals('Koel', $album->artist->name);
     $currentCover = $album->cover;
     $song = Song::orderBy('id', 'desc')->first();
     // Modified file should be recognized
     touch($song->path, $time = time());
     $media->sync($this->mediaPath);
     $song = Song::find($song->id);
     $this->assertEquals($time, $song->mtime);
     // Albums with a non-default cover should have their covers overwritten
     $this->assertEquals($currentCover, Album::find($album->id)->cover);
 }
コード例 #2
0
ファイル: SongTest.php プロジェクト: Hebilicious/koel
 public function testSingleUpdateAllInfoNoCompilation()
 {
     $this->expectsEvents(LibraryChanged::class);
     $song = Song::orderBy('id', 'desc')->first();
     $this->actingAs(factory(User::class, 'admin')->create())->put('/api/songs', ['songs' => [$song->id], 'data' => ['title' => 'Foo Bar', 'artistName' => 'John Cena', 'albumName' => 'One by One', 'lyrics' => 'Lorem ipsum dolor sic amet.', 'track' => 1, 'compilationState' => 0]])->seeStatusCode(200);
     $artist = Artist::whereName('John Cena')->first();
     $this->assertNotNull($artist);
     $album = Album::whereName('One by One')->first();
     $this->assertNotNull($album);
     $this->seeInDatabase('songs', ['id' => $song->id, 'album_id' => $album->id, 'lyrics' => 'Lorem ipsum dolor sic amet.', 'track' => 1]);
 }
コード例 #3
0
ファイル: MediaTest.php プロジェクト: phanan/koel
 public function testSync()
 {
     $this->expectsEvents(LibraryChanged::class);
     $media = new Media();
     $media->sync($this->mediaPath);
     // Standard mp3 files under root path should be recognized
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/full.mp3', 'track' => 5]);
     // Ogg files and audio files in subdirectories should be recognized
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/subdir/back-in-black.ogg']);
     // GitHub issue #380. folder.png should be copied and used as the cover for files
     // under subdir/
     $song = Song::wherePath($this->mediaPath . '/subdir/back-in-black.ogg')->first();
     $this->assertNotNull($song->album->cover);
     // File search shouldn't be case-sensitive.
     $this->seeInDatabase('songs', ['path' => $this->mediaPath . '/subdir/no-name.MP3']);
     // Non-audio files shouldn't be recognized
     $this->notSeeInDatabase('songs', ['path' => $this->mediaPath . '/rubbish.log']);
     // Broken/corrupted audio files shouldn't be recognized
     $this->notSeeInDatabase('songs', ['path' => $this->mediaPath . '/fake.mp3']);
     // Artists should be created
     $this->seeInDatabase('artists', ['name' => 'Cuckoo']);
     $this->seeInDatabase('artists', ['name' => 'Koel']);
     // Albums should be created
     $this->seeInDatabase('albums', ['name' => 'Koel Testing Vol. 1']);
     // Albums and artists should be correctly linked
     $album = Album::whereName('Koel Testing Vol. 1')->first();
     $this->assertEquals('Koel', $album->artist->name);
     // Compilation albums, artists and songs must be recognized
     $song = Song::whereTitle('This song belongs to a compilation')->first();
     $this->assertNotNull($song->contributing_artist_id);
     $this->assertTrue($song->album->is_compilation);
     $this->assertEquals(Artist::VARIOUS_ID, $song->album->artist_id);
     $currentCover = $album->cover;
     $song = Song::orderBy('id', 'desc')->first();
     // Modified file should be recognized
     touch($song->path, $time = time());
     $media->sync($this->mediaPath);
     $song = Song::find($song->id);
     $this->assertEquals($time, $song->mtime);
     // Albums with a non-default cover should have their covers overwritten
     $this->assertEquals($currentCover, Album::find($album->id)->cover);
 }