Ejemplo n.º 1
0
 public function name_with_only_invalid_chars_is_still_valid_test()
 {
     $album = test::random_album_unsaved();
     $album->name = "[]";
     $album->save();
 }
Ejemplo n.º 2
0
 public function albums_can_have_two_dots_in_name_test()
 {
     $album = test::random_album_unsaved(item::root());
     $album->name = $album->name . ".foo.bar";
     $album->save();
 }
Ejemplo n.º 3
0
 public function find_by_path_test()
 {
     $level1 = test::random_album();
     $level2 = test::random_album_unsaved($level1);
     $level2->name = "plus + space";
     $level2->save()->reload();
     $level3 = test::random_photo_unsaved($level2);
     $level3->name = "same.jpg";
     $level3->save()->reload();
     $level2b = test::random_album($level1);
     $level3b = test::random_photo_unsaved($level2b);
     $level3b->name = "same.jpg";
     $level3b->save()->reload();
     // Item in album
     $this->assert_same($level3->id, item::find_by_path("/{$level1->name}/{$level2->name}/{$level3->name}")->id);
     // Album, ends with a slash
     $this->assert_same($level2->id, item::find_by_path("{$level1->name}/{$level2->name}/")->id);
     // Album, ends without a slash
     $this->assert_same($level2->id, item::find_by_path("/{$level1->name}/{$level2->name}")->id);
     // Return root if "" is passed
     $this->assert_same(item::root()->id, item::find_by_path("")->id);
     // Verify that we don't get confused by the part names, using the fallback code.
     db::build()->update("items")->set(array("relative_path_cache" => null))->where("id", "IN", array($level3->id, $level3b->id))->execute();
     $this->assert_same($level3->id, item::find_by_path("{$level1->name}/{$level2->name}/{$level3->name}")->id);
     $this->assert_same($level3b->id, item::find_by_path("{$level1->name}/{$level2b->name}/{$level3b->name}")->id);
     // Verify that we don't get false positives
     $this->assert_false(item::find_by_path("foo/bar/baz")->loaded());
     // Verify that the fallback code works
     $this->assert_same($level3b->id, item::find_by_path("{$level1->name}/{$level2b->name}/{$level3b->name}")->id);
 }
Ejemplo n.º 4
0
 static function random_album($parent = null)
 {
     return test::random_album_unsaved($parent)->save()->reload();
 }
Ejemplo n.º 5
0
 public function resequence_child_weights_test()
 {
     $album = test::random_album_unsaved();
     $album->sort_column = "id";
     $album->save();
     $photo1 = test::random_photo($album);
     $photo2 = test::random_photo($album);
     $this->assert_true($photo2->weight > $photo1->weight);
     $album->reload();
     $album->sort_order = "DESC";
     $album->save();
     item::resequence_child_weights($album);
     $this->assert_equal(2, $photo1->reload()->weight);
     $this->assert_equal(1, $photo2->reload()->weight);
 }
Ejemplo n.º 6
0
 public function slug_is_url_safe_test()
 {
     try {
         $album = test::random_album_unsaved();
         $album->slug = "illegal chars! !@#@#\$!@~";
         $album->save();
         $this->assert_true(false, "Shouldn't be able to save");
     } catch (ORM_Validation_Exception $e) {
         $this->assert_same(array("slug" => "not_url_safe"), $e->validation->errors());
     }
     // This should work
     $album->slug = "the_quick_brown_fox";
     $album->save();
 }