diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-18 23:49:00 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-18 23:49:00 -0800 |
commit | c059a444c77c0adc6d003b8ece38ba654e4f45f0 (patch) | |
tree | 8240eeb6d00223b145d92b9904f5bfc259ae66b8 | |
parent | 4418993db96a6d9c4444957b78588b4ce01556f4 (diff) |
Updated for model based validation. Fixed
change_photo_no_csrf_fails_test() which has been broken since we
deleted Rest_Controller.
-rw-r--r-- | modules/gallery/tests/Photos_Controller_Test.php | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/modules/gallery/tests/Photos_Controller_Test.php b/modules/gallery/tests/Photos_Controller_Test.php index b6c6df47..31e0bc21 100644 --- a/modules/gallery/tests/Photos_Controller_Test.php +++ b/modules/gallery/tests/Photos_Controller_Test.php @@ -29,19 +29,14 @@ class Photos_Controller_Test extends Unit_Test_Case { public function change_photo_test() { $controller = new Photos_Controller(); - $root = ORM::factory("item", 1); - $photo = photo::create( - $root, MODPATH . "gallery/tests/test.jpg", "test.jpeg", - "test", "test", identity::active_user()->id, "slug"); - $orig_name = $photo->name; + $photo = test::random_photo(); - $_POST["filename"] = "test.jpeg"; - $_POST["name"] = "new name"; + $_POST["filename"] = "new name.jpg"; $_POST["title"] = "new title"; $_POST["description"] = "new description"; $_POST["slug"] = "new-slug"; $_POST["csrf"] = access::csrf_token(); - access::allow(identity::everybody(), "edit", $root); + access::allow(identity::everybody(), "edit", item::root()); ob_start(); $controller->update($photo->id); @@ -53,26 +48,25 @@ class Photos_Controller_Test extends Unit_Test_Case { $this->assert_equal("new-slug", $photo->slug); $this->assert_equal("new title", $photo->title); $this->assert_equal("new description", $photo->description); - - // We don't change the name, yet. - $this->assert_equal($orig_name, $photo->name); + $this->assert_equal("new name.jpeg", $photo->name); } public function change_photo_no_csrf_fails_test() { $controller = new Photos_Controller(); - $root = ORM::factory("item", 1); - $photo = photo::create( - $root, MODPATH . "gallery/tests/test.jpg", "test.jpg", "test", "test"); - $_POST["name"] = "new name"; + $photo = test::random_photo(); + + $_POST["filename"] = "new name.jpg"; $_POST["title"] = "new title"; $_POST["description"] = "new description"; - access::allow(identity::everybody(), "edit", $root); + $_POST["slug"] = "new slug"; + access::allow(identity::everybody(), "edit", item::root()); try { - $controller->_update($photo); + $controller->update($photo); $this->assert_true(false, "This should fail"); } catch (Exception $e) { // pass + $this->assert_same("@todo FORBIDDEN", $e->getMessage()); } } } |