public function movie_thumbnails_are_jpgs_test()
 {
     $movie = test::random_movie();
     $name = legal_file::change_extension($movie->name, "jpg");
     $_SERVER["REQUEST_URI"] = url::file("var/thumbs/{$name}");
     $controller = new File_Proxy_Controller();
     $this->assert_same($movie->thumb_path(), $controller->__call("", array()));
 }
Ejemplo n.º 2
0
 public function get_file_metadata_test()
 {
     $movie = test::random_movie();
     $this->assert_equal(array(360, 288, "video/x-flv", "flv", 6.0), movie::get_file_metadata($movie->file_path()));
 }
Ejemplo n.º 3
0
 public function find_by_path_with_album_test()
 {
     $parent = test::random_album();
     $album = test::random_movie($parent);
     $album_path = "{$parent->name}/{$album->name}";
     $thumb_path = "{$album_path}/.album.jpg";
     // Check normal operation.
     $this->assert_equal($album->id, item::find_by_path($album_path, "albums")->id);
     $this->assert_equal($album->id, item::find_by_path($thumb_path, "thumbs")->id);
     $this->assert_equal($album->id, item::find_by_path($album_path)->id);
     // Check that we don't get false positives.
     $this->assert_equal(null, item::find_by_path($thumb_path, "albums")->id);
     $this->assert_equal(null, item::find_by_path($album_path, "thumbs")->id);
     $this->assert_equal(null, item::find_by_path($thumb_path)->id);
     // Check normal operation without relative path cache.
     self::_remove_relative_path_caches();
     $this->assert_equal($album->id, item::find_by_path($album_path, "albums")->id);
     self::_remove_relative_path_caches();
     $this->assert_equal($album->id, item::find_by_path($thumb_path, "thumbs")->id);
     self::_remove_relative_path_caches();
     $this->assert_equal($album->id, item::find_by_path($album_path)->id);
     // Check that we don't get false positives without relative path cache.
     self::_remove_relative_path_caches();
     $this->assert_equal(null, item::find_by_path($thumb_path, "albums")->id);
     $this->assert_equal(null, item::find_by_path($album_path, "thumbs")->id);
     $this->assert_equal(null, item::find_by_path($thumb_path)->id);
 }
Ejemplo n.º 4
0
 public function generate_bad_movie_test()
 {
     // Unlike photos, its ok to have missing movies - no thrown exceptions, thumb_dirty can be reset.
     $movie = test::random_movie();
     // At this point, the movie is valid and has a valid thumb.  Make it garble.
     file_put_contents($movie->file_path(), test::lorem_ipsum(200));
     // Regenerate
     $movie->thumb_dirty = 1;
     graphics::generate($movie);
     // Check that the image got replaced with a missing image placeholder
     $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_movie.jpg"), file_get_contents($movie->thumb_path()));
     // Check that the items table got updated with new metadata
     $this->assert_equal(array(200, 200), array($movie->thumb_width, $movie->thumb_height));
     // Check that the image is *not* marked as dirty
     $this->assert_equal(0, $movie->thumb_dirty);
 }
Ejemplo n.º 5
0
 public function fix_conflict_when_base_names_identical_between_jpg_png_flv_test()
 {
     $parent = test::random_album();
     $item1 = test::random_photo($parent);
     $item2 = test::random_photo($parent);
     $item3 = test::random_movie($parent);
     $item1_orig_base = pathinfo($item1->name, PATHINFO_FILENAME);
     $item2_orig_slug = $item2->slug;
     $item3_orig_slug = $item3->slug;
     $item2->set_data_file(MODPATH . "gallery/images/graphicsmagick.png");
     $item2->name = "{$item1_orig_base}.png";
     $item2->save();
     $item3->name = "{$item1_orig_base}.flv";
     $item3->save();
     // item2 and item3 have same base name as item1 - conflict resolved by renaming with -01 and -02.
     $this->assert_same("{$item1_orig_base}-01.png", $item2->name);
     $this->assert_same("{$item2_orig_slug}-01", $item2->slug);
     $this->assert_same("{$item1_orig_base}-02.flv", $item3->name);
     $this->assert_same("{$item3_orig_slug}-02", $item3->slug);
 }