diff options
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r-- | modules/gallery/tests/Access_Helper_Test.php | 4 | ||||
-rw-r--r-- | modules/gallery/tests/Albums_Controller_Test.php | 20 | ||||
-rw-r--r-- | modules/gallery/tests/Photos_Controller_Test.php | 21 | ||||
-rw-r--r-- | modules/gallery/tests/xss_data.txt | 12 |
4 files changed, 35 insertions, 22 deletions
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php index 7012a487..d71bf971 100644 --- a/modules/gallery/tests/Access_Helper_Test.php +++ b/modules/gallery/tests/Access_Helper_Test.php @@ -38,6 +38,10 @@ class Access_Helper_Test extends Unit_Test_Case { $user->delete(); } } catch (Exception $e) { } + + // Reset some permissions that we mangle below + $root = ORM::factory("item", 1); + access::allow(group::everybody(), "view", $root); } public function setup() { diff --git a/modules/gallery/tests/Albums_Controller_Test.php b/modules/gallery/tests/Albums_Controller_Test.php index ef1fac77..7674e85f 100644 --- a/modules/gallery/tests/Albums_Controller_Test.php +++ b/modules/gallery/tests/Albums_Controller_Test.php @@ -20,17 +20,21 @@ class Albums_Controller_Test extends Unit_Test_Case { public function setup() { $this->_post = $_POST; + $this->_album = null; } public function teardown() { $_POST = $this->_post; + if ($this->_album) { + $this->_album->delete(); + } } public function change_album_test() { $controller = new Albums_Controller(); $root = ORM::factory("item", 1); - $album = album::create($root, "test", "test", "test"); - $orig_name = $album->name; + $this->_album = album::create($root, "test", "test", "test"); + $orig_name = $this->_album->name; $_POST["dirname"] = "test"; $_POST["name"] = "new name"; @@ -43,31 +47,31 @@ class Albums_Controller_Test extends Unit_Test_Case { access::allow(group::everybody(), "edit", $root); ob_start(); - $controller->_update($album); + $controller->_update($this->_album); $results = ob_get_contents(); ob_end_clean(); $this->assert_equal( json_encode(array("result" => "success", "location" => "http://./index.php/test")), $results); - $this->assert_equal("new title", $album->title); - $this->assert_equal("new description", $album->description); + $this->assert_equal("new title", $this->_album->title); + $this->assert_equal("new description", $this->_album->description); // We don't change the name, yet. - $this->assert_equal($orig_name, $album->name); + $this->assert_equal($orig_name, $this->_album->name); } public function change_album_no_csrf_fails_test() { $controller = new Albums_Controller(); $root = ORM::factory("item", 1); - $album = album::create($root, "test", "test", "test"); + $this->_album = album::create($root, "test", "test", "test"); $_POST["name"] = "new name"; $_POST["title"] = "new title"; $_POST["description"] = "new description"; access::allow(group::everybody(), "edit", $root); try { - $controller->_update($album); + $controller->_update($this->_album); $this->assert_true(false, "This should fail"); } catch (Exception $e) { // pass diff --git a/modules/gallery/tests/Photos_Controller_Test.php b/modules/gallery/tests/Photos_Controller_Test.php index 771cc90d..f7d3f72f 100644 --- a/modules/gallery/tests/Photos_Controller_Test.php +++ b/modules/gallery/tests/Photos_Controller_Test.php @@ -20,17 +20,22 @@ class Photos_Controller_Test extends Unit_Test_Case { public function setup() { $this->_post = $_POST; + $this->_photo = null; } public function teardown() { $_POST = $this->_post; + if ($this->_photo) { + $this->_photo->delete(); + } } 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"); - $orig_name = $photo->name; + $this->_photo = photo::create($root, MODPATH . "gallery/tests/test.jpg", "test.jpeg", "test", + "test"); + $orig_name = $this->_photo->name; $_POST["filename"] = "test.jpeg"; $_POST["name"] = "new name"; @@ -40,7 +45,7 @@ class Photos_Controller_Test extends Unit_Test_Case { access::allow(group::everybody(), "edit", $root); ob_start(); - $controller->_update($photo); + $controller->_update($this->_photo); $results = ob_get_contents(); ob_end_clean(); @@ -48,24 +53,24 @@ class Photos_Controller_Test extends Unit_Test_Case { json_encode(array("result" => "success", "location" => "http://./index.php/test.jpeg")), $results); - $this->assert_equal("new title", $photo->title); - $this->assert_equal("new description", $photo->description); + $this->assert_equal("new title", $this->_photo->title); + $this->assert_equal("new description", $this->_photo->description); // We don't change the name, yet. - $this->assert_equal($orig_name, $photo->name); + $this->assert_equal($orig_name, $this->_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", "test", "test"); + $this->_photo = photo::create($root, MODPATH . "gallery/tests/test.jpg", "test", "test", "test"); $_POST["name"] = "new name"; $_POST["title"] = "new title"; $_POST["description"] = "new description"; access::allow(group::everybody(), "edit", $root); try { - $controller->_update($photo); + $controller->_update($this->_photo); $this->assert_true(false, "This should fail"); } catch (Exception $e) { // pass diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 4aaa520d..67f293dd 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -195,14 +195,14 @@ modules/gallery/views/l10n_client.html.php 29 DIRTY $string_l modules/gallery/views/move_browse.html.php 4 DIRTY $source->id modules/gallery/views/move_browse.html.php 39 DIRTY $tree modules/gallery/views/move_browse.html.php 42 DIRTY $source->id -modules/gallery/views/move_tree.html.php 2 DIRTY $parent->thumb_tag(array(), 25) +modules/gallery/views/move_tree.html.php 2 DIRTY $parent->thumb_img(array(), 25) modules/gallery/views/move_tree.html.php 4 DIRTY $parent->id modules/gallery/views/move_tree.html.php 4 CLEAN $parent->title modules/gallery/views/move_tree.html.php 6 DIRTY $parent->id modules/gallery/views/move_tree.html.php 6 CLEAN $parent->title modules/gallery/views/move_tree.html.php 8 DIRTY $parent->id modules/gallery/views/move_tree.html.php 10 DIRTY $child->id -modules/gallery/views/move_tree.html.php 11 DIRTY $child->thumb_tag(array(), 25) +modules/gallery/views/move_tree.html.php 11 DIRTY $child->thumb_img(array(), 25) modules/gallery/views/move_tree.html.php 13 DIRTY $child->id modules/gallery/views/move_tree.html.php 13 CLEAN $child->title modules/gallery/views/move_tree.html.php 15 DIRTY $child->id @@ -335,7 +335,7 @@ modules/organize/views/organize_thumb_grid.html.php 7 DIRTY $child->i modules/organize/views/organize_thumb_grid.html.php 7 DIRTY $child->id modules/organize/views/organize_thumb_grid.html.php 8 DIRTY $child->id modules/organize/views/organize_thumb_grid.html.php 8 DIRTY $item_class -modules/organize/views/organize_thumb_grid.html.php 9 DIRTY $child->thumb_tag(array("class" => "gThumbnail"), $thumbsize, true) +modules/organize/views/organize_thumb_grid.html.php 9 DIRTY $child->thumb_img(array("class" => "gThumbnail"), $thumbsize, true) modules/recaptcha/views/admin_recaptcha.html.php 5 DIRTY $form->get_key_url modules/recaptcha/views/admin_recaptcha.html.php 8 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 21 DIRTY $public_key @@ -406,7 +406,7 @@ modules/rss/views/rss_block.html.php 8 DIRTY $title modules/search/views/search.html.php 11 CLEAN $q modules/search/views/search.html.php 30 DIRTY $item_class modules/search/views/search.html.php 31 DIRTY $item->id -modules/search/views/search.html.php 32 DIRTY $item->thumb_tag() +modules/search/views/search.html.php 32 DIRTY $item->thumb_img() modules/search/views/search.html.php 34 CLEAN $item->title modules/search/views/search.html.php 37 CLEAN $item->description modules/search/views/search.html.php 43 DIRTY $theme->pager() @@ -518,7 +518,7 @@ themes/default/views/album.html.php 15 DIRTY $child->i themes/default/views/album.html.php 15 DIRTY $item_class themes/default/views/album.html.php 16 DIRTY $theme->thumb_top($child) themes/default/views/album.html.php 17 DIRTY $child->url() -themes/default/views/album.html.php 18 DIRTY $child->thumb_tag(array("class" => "gThumbnail")) +themes/default/views/album.html.php 18 DIRTY $child->thumb_img(array("class" => "gThumbnail")) themes/default/views/album.html.php 20 DIRTY $theme->thumb_bottom($child) themes/default/views/album.html.php 21 DIRTY $child->url() themes/default/views/album.html.php 21 CLEAN $child->title @@ -607,7 +607,7 @@ themes/default/views/photo.html.php 15 DIRTY $position themes/default/views/photo.html.php 15 DIRTY $sibling_count themes/default/views/photo.html.php 18 DIRTY $next_item->url() themes/default/views/photo.html.php 28 DIRTY $theme->resize_top($item) -themes/default/views/photo.html.php 32 DIRTY $item->resize_tag(array("id" => "gPhotoId-{$item->id}", "class" => "gResize")) +themes/default/views/photo.html.php 32 DIRTY $item->resize_img(array("id" => "gPhotoId-{$item->id}", "class" => "gResize")) themes/default/views/photo.html.php 36 DIRTY $theme->resize_bottom($item) themes/default/views/photo.html.php 40 CLEAN $item->title themes/default/views/photo.html.php 41 CLEAN $item->description |