Esempio n. 1
0
<?php

include dirname(__FILE__) . '/../bootstrap/doctrine.php';
// Initialize the test object
$t = new lime_test(24, new lime_output_color());
$valid_test_song = array('artist_name' => 'Gorillaz', 'album_name' => 'Gorillaz Compilation', 'genre_name' => 'Electronic', 'song_name' => 'Clint Eastwood', 'song_length' => '2:05', 'accurate_length' => '125000', 'filesize' => 3000024, 'bitrate' => 128, 'yearpublished' => 2010, 'tracknumber' => 7, 'label' => 'EMI', 'mtime' => 1293300000, 'atime' => 1293300011, 'filename' => 'file://localhost/home/notroot/music/test.mp3');
$utf8_test_song = array('artist_name' => 'Sigur Rós', 'album_name' => 'með suð í eyrum við spilum endalaust', 'genre_name' => 'Русский', 'song_name' => 'dót widget', 'song_length' => '3:05', 'accurate_length' => 185000, 'filesize' => 3002332, 'bitrate' => 128, 'yearpublished' => 2005, 'tracknumber' => 1, 'label' => 'ンスの映像を世界に先がけて', 'mtime' => 1293300023, 'atime' => 1293300011, 'filename' => 'file://localhost/home/notroot/music/Fließgewässer.mp3');
$media_scan = new MediaScan();
$t->comment('->construct()');
$t->like($media_scan->get_last_scan_id(), '/\\d+/', 'Entered a new scan id successfully.');
$t->comment('->is_scanned()');
$t->is($media_scan->is_scanned('file://localhost/home/notroot/music/test.mp3', '1293300000'), false, 'Song should not exist yet');
$first_insert_id = $media_scan->add_song($valid_test_song);
$t->like($first_insert_id, '/\\d+/', 'Successfully added a song to the database');
$t->comment('->add_song()');
$media_scan = new MediaScan();
$second_insert_id = $media_scan->add_song($utf8_test_song);
$t->like($second_insert_id, '/\\d+/', 'Successfully added a UTF-8 Song entry.');
$t->is($media_scan->is_scanned('file://localhost/home/notroot/music/test.mp3', '1293300000'), true, 'Updated old record to new scan id number');
$media_scan = new MediaScan();
$second_insert_id = $media_scan->add_song($utf8_test_song);
//Test Data Integrity after add
$song_integrity_test = Doctrine_Core::getTable('Song')->find(2);
$artist_integrity_test = Doctrine_Core::getTable('Artist')->find(2);
$album_integrity_test = Doctrine_Core::getTable('Album')->find(2);
$genre_integrity_test = Doctrine_Core::getTable('Genre')->find(127);
$t->is($song_integrity_test->id, 2, 'integrity: primary id');
$t->is($song_integrity_test->scan_id, 2, 'integrity: last_scan_id id');
$t->is($song_integrity_test->artist_id, 2, 'integrity: artist_id');
$t->is($artist_integrity_test->name, 'Sigur Rós', 'integrity: artist_name');
$t->is($song_integrity_test->album_id, 2, 'integrity: album_id');