diff options
Diffstat (limited to 'modules/gallery/tests')
| -rw-r--r-- | modules/gallery/tests/Input_Library_Test.php | 25 | ||||
| -rw-r--r-- | modules/gallery/tests/Item_Helper_Test.php | 13 | ||||
| -rw-r--r-- | modules/gallery/tests/Item_Model_Test.php | 15 | ||||
| -rw-r--r-- | modules/gallery/tests/Item_Rest_Helper_Test.php | 70 | ||||
| -rw-r--r-- | modules/gallery/tests/xss_data.txt | 47 | 
5 files changed, 115 insertions, 55 deletions
| diff --git a/modules/gallery/tests/Input_Library_Test.php b/modules/gallery/tests/Input_Library_Test.php new file mode 100644 index 00000000..06641323 --- /dev/null +++ b/modules/gallery/tests/Input_Library_Test.php @@ -0,0 +1,25 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2010 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA. + */ +class Input_Library_Test extends Gallery_Unit_Test_Case { +  function clean_input_keys_test() { +    $input = Input::instance(); +    $this->assert_same("foo_bar", $input->clean_input_keys("foo|bar")); +  } +}
\ No newline at end of file diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php index 295871a5..4771b11a 100644 --- a/modules/gallery/tests/Item_Helper_Test.php +++ b/modules/gallery/tests/Item_Helper_Test.php @@ -54,7 +54,6 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {      $this->assert_same($dst_album->id, $photo->parent_id);    } -    public function move_updates_album_covers_test() {      // 2 photos in the source album      $src_album = test::random_album(); @@ -106,4 +105,16 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {      $this->assert_not_same("{$rand}.jpg", $photo2->name);      $this->assert_not_same($rand, $photo2->slug);    } + +  public function delete_cover_photo_picks_new_album_cover() { +    $album = test::random_album(); +    $photo1 = test::random_photo($album); +    // At this point, $photo1 is the album cover.  We verify this in +    // Item_Model_Test::first_photo_becomes_album_cover +    $photo2 = test::random_photo($album); +    $photo1->delete(); +    $album->reload(); + +    $this->assert_same($photo2->id, $album->album_cover_item_id); +  }  } diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index d0676292..15aa2d8c 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -295,7 +295,6 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {      } catch (ORM_Validation_Exception $e) {        $this->assert_same(array("description" => "length",                                 "name" => "required", -                               "slug" => "required",                                 "title" => "required",                                 "album_cover_item_id" => "invalid_item",                                 "parent_id" => "invalid", @@ -324,6 +323,12 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {      $album->save();    } +  public function name_with_only_invalid_chars_is_still_valid_test() { +    $album = test::random_album_unsaved(); +    $album->name = "[]"; +    $album->save(); +  } +    public function cant_change_item_type_test() {      $photo = test::random_photo();      try { @@ -358,4 +363,12 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {      $this->assert_true(!array_key_exists("parent_id", $result));      $this->assert_true(!array_key_exists("album_cover_item_id", $result));    } + +  public function first_photo_becomes_album_cover() { +    $album = test::random_album(); +    $photo = test::random_photo($album); +    $album->reload(); + +    $this->assert_same($photo->id, $album->album_cover_item_id); +  }  } diff --git a/modules/gallery/tests/Item_Rest_Helper_Test.php b/modules/gallery/tests/Item_Rest_Helper_Test.php index bef95668..0b5e0471 100644 --- a/modules/gallery/tests/Item_Rest_Helper_Test.php +++ b/modules/gallery/tests/Item_Rest_Helper_Test.php @@ -42,13 +42,14 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $this->assert_equal_array(        array("url" => rest::url("item", $album1),              "entity" => $album1->as_restful_array(), -            "members" => array( -              rest::url("item", $photo1), -              rest::url("item", $album2)),              "relationships" => array(                "tags" => array(                  "url" => rest::url("item_tags", $album1), -                "members" => array()))), +                "members" => array())), +            "members" => array( +              rest::url("item", $photo1), +              rest::url("item", $album2)), +            ),        item_rest::get($request));      $request->url = rest::url("item", $album1); @@ -56,13 +57,14 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $this->assert_equal_array(        array("url" => rest::url("item", $album1),              "entity" => $album1->as_restful_array(), -            "members" => array( -              rest::url("item", $photo1), -              rest::url("item", $album2)),              "relationships" => array(                "tags" => array(                  "url" => rest::url("item_tags", $album1), -                "members" => array()))), +                "members" => array())), +            "members" => array( +              rest::url("item", $photo1), +              rest::url("item", $album2)), +            ),        item_rest::get($request));      $request->url = rest::url("item", $album1); @@ -70,14 +72,15 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $this->assert_equal_array(        array("url" => rest::url("item", $album1),              "entity" => $album1->as_restful_array(), +            "relationships" => array( +              "tags" => array( +                "url" => rest::url("item_tags", $album1), +                "members" => array())),              "members" => array(                rest::url("item", $photo1),                rest::url("item", $album2),                rest::url("item", $photo2)), -            "relationships" => array( -              "tags" => array( -                "url" => rest::url("item_tags", $album1), -                "members" => array()))), +            ),        item_rest::get($request));    } @@ -96,12 +99,13 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $this->assert_equal_array(        array("url" => rest::url("item", $album1),              "entity" => $album1->as_restful_array(), -            "members" => array( -              rest::url("item", $photo2)),              "relationships" => array(                "tags" => array(                  "url" => rest::url("item_tags", $album1), -                "members" => array()))), +                "members" => array())), +            "members" => array( +              rest::url("item", $photo2)), +            ),        item_rest::get($request));    } @@ -118,12 +122,13 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $this->assert_equal_array(        array("url" => rest::url("item", $album1),              "entity" => $album1->as_restful_array(), -            "members" => array( -              rest::url("item", $album2)),              "relationships" => array(                "tags" => array(                  "url" => rest::url("item_tags", $album1), -                "members" => array() ))), +                "members" => array())), +            "members" => array( +              rest::url("item", $album2)), +            ),        item_rest::get($request));    } @@ -134,7 +139,8 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $request = new stdClass();      $request->url = rest::url("item", $album1);      $request->params = new stdClass(); -    $request->params->title = "my new title"; +    $request->params->entity = new stdClass(); +    $request->params->entity->title = "my new title";      item_rest::put($request);      $this->assert_equal("my new title", $album1->reload()->title); @@ -147,8 +153,9 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $request = new stdClass();      $request->url = rest::url("item", $album1);      $request->params = new stdClass(); -    $request->params->title = "my new title"; -    $request->params->slug = "not url safe"; +    $request->params->entity = new stdClass(); +    $request->params->entity->title = "my new title"; +    $request->params->entity->slug = "not url safe";      try {        item_rest::put($request); @@ -166,9 +173,10 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $request = new stdClass();      $request->url = rest::url("item", $album1);      $request->params = new stdClass(); -    $request->params->type = "album"; -    $request->params->name = "my album"; -    $request->params->title = "my album"; +    $request->params->entity = new stdClass(); +    $request->params->entity->type = "album"; +    $request->params->entity->name = "my album"; +    $request->params->entity->title = "my album";      $response = item_rest::post($request);      $new_album = rest::resolve($response["url"]); @@ -183,10 +191,11 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $request = new stdClass();      $request->url = rest::url("item", $album1);      $request->params = new stdClass(); -    $request->params->type = "album"; -    $request->params->name = "my album"; -    $request->params->title = "my album"; -    $request->params->slug = "not url safe"; +    $request->params->entity = new stdClass(); +    $request->params->entity->type = "album"; +    $request->params->entity->name = "my album"; +    $request->params->entity->title = "my album"; +    $request->params->entity->slug = "not url safe";      try {        item_rest::post($request); @@ -205,8 +214,9 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {      $request = new stdClass();      $request->url = rest::url("item", $album1);      $request->params = new stdClass(); -    $request->params->type = "photo"; -    $request->params->name = "my photo.jpg"; +    $request->params->entity = new stdClass(); +    $request->params->entity->type = "photo"; +    $request->params->entity->name = "my photo.jpg";      $request->file = MODPATH . "gallery/tests/test.jpg";      $response = item_rest::post($request);      $new_photo = rest::resolve($response["url"]); diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index a3ca31f4..afad9e13 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -70,12 +70,12 @@ modules/gallery/views/admin_graphics_imagemagick.html.php    2   DIRTY_ATTR $is_  modules/gallery/views/admin_graphics_imagemagick.html.php    2   DIRTY_ATTR $tk->installed?"  g-installed-toolkit":" g-unavailable"  modules/gallery/views/admin_graphics_imagemagick.html.php    18  DIRTY    $tk->error  modules/gallery/views/admin_languages.html.php               43  DIRTY    access::csrf_form_field() -modules/gallery/views/admin_languages.html.php               60  DIRTY_ATTR (isset($installed_locales[$code]))?"g-available":"" -modules/gallery/views/admin_languages.html.php               60  DIRTY_ATTR ($default_locale==$code)?" g-selected":"" -modules/gallery/views/admin_languages.html.php               61  DIRTY    form::checkbox("installed_locales[]",$code,isset($installed_locales[$code])) -modules/gallery/views/admin_languages.html.php               62  DIRTY    $display_name -modules/gallery/views/admin_languages.html.php               64  DIRTY    form::radio("default_locale",$code,($default_locale==$code),((isset($installed_locales[$code]))?'':'disabled="disabled"')) -modules/gallery/views/admin_languages.html.php               109 DIRTY    $share_translations_form +modules/gallery/views/admin_languages.html.php               61  DIRTY_ATTR (isset($installed_locales[$code]))?"g-available":"" +modules/gallery/views/admin_languages.html.php               61  DIRTY_ATTR ($default_locale==$code)?" g-selected":"" +modules/gallery/views/admin_languages.html.php               62  DIRTY    form::checkbox("installed_locales[]",$code,isset($installed_locales[$code])) +modules/gallery/views/admin_languages.html.php               63  DIRTY    $display_name +modules/gallery/views/admin_languages.html.php               65  DIRTY    form::radio("default_locale",$code,($default_locale==$code),((isset($installed_locales[$code]))?'':'disabled="disabled"')) +modules/gallery/views/admin_languages.html.php               110 DIRTY    $share_translations_form  modules/gallery/views/admin_maintenance.html.php             24  DIRTY_ATTR text::alternate("g-odd","g-even")  modules/gallery/views/admin_maintenance.html.php             24  DIRTY_ATTR log::severity_class($task->severity)  modules/gallery/views/admin_maintenance.html.php             25  DIRTY_ATTR log::severity_class($task->severity) @@ -121,10 +121,10 @@ modules/gallery/views/admin_themes.html.php                  76  DIRTY    $info-  modules/gallery/views/admin_themes.html.php                  78  DIRTY    $info->description  modules/gallery/views/admin_themes_preview.html.php          7   DIRTY_ATTR $url  modules/gallery/views/error_404.html.php                     14  DIRTY    $login_form -modules/gallery/views/form_uploadify.html.php                30  DIRTY_JS url::file("lib/uploadify/uploadify.swf") -modules/gallery/views/form_uploadify.html.php                31  DIRTY_JS url::site("simple_uploader/add_photo/{$album->id}") -modules/gallery/views/form_uploadify.html.php                35  DIRTY_JS url::file("lib/uploadify/cancel.png") -modules/gallery/views/form_uploadify.html.php                36  DIRTY_JS $simultaneous_upload_limit +modules/gallery/views/form_uploadify.html.php                9   DIRTY_JS url::file("lib/uploadify/uploadify.swf") +modules/gallery/views/form_uploadify.html.php                10  DIRTY_JS url::site("simple_uploader/add_photo/{$album->id}") +modules/gallery/views/form_uploadify.html.php                14  DIRTY_JS url::file("lib/uploadify/cancel.png") +modules/gallery/views/form_uploadify.html.php                15  DIRTY_JS $simultaneous_upload_limit  modules/gallery/views/in_place_edit.html.php                 2   DIRTY    form::open($action,array("method"=>"post","id"=>"g-in-place-edit-form","class"=>"g-short-form"))  modules/gallery/views/in_place_edit.html.php                 3   DIRTY    access::csrf_form_field()  modules/gallery/views/in_place_edit.html.php                 6   DIRTY    form::input("input",$form["input"]," class=\"textbox\"") @@ -320,19 +320,20 @@ modules/user/views/admin_users_group.html.php                24  DIRTY_JS $group  modules/watermark/views/admin_watermarks.html.php            20  DIRTY_ATTR $width  modules/watermark/views/admin_watermarks.html.php            20  DIRTY_ATTR $height  modules/watermark/views/admin_watermarks.html.php            20  DIRTY_ATTR $url -themes/admin_wind/views/admin.html.php                       16  DIRTY_JS $theme->url() -themes/admin_wind/views/admin.html.php                       33  DIRTY    $theme->admin_head() -themes/admin_wind/views/admin.html.php                       37  DIRTY    $theme->admin_page_top() -themes/admin_wind/views/admin.html.php                       45  DIRTY    $theme->admin_header_top() -themes/admin_wind/views/admin.html.php                       46  DIRTY_JS item::root()->url() -themes/admin_wind/views/admin.html.php                       49  DIRTY    $theme->user_menu() -themes/admin_wind/views/admin.html.php                       51  DIRTY    $theme->admin_menu() -themes/admin_wind/views/admin.html.php                       53  DIRTY    $theme->admin_header_bottom() -themes/admin_wind/views/admin.html.php                       60  DIRTY    $content -themes/admin_wind/views/admin.html.php                       66  DIRTY    $sidebar -themes/admin_wind/views/admin.html.php                       71  DIRTY    $theme->admin_footer() -themes/admin_wind/views/admin.html.php                       73  DIRTY    $theme->admin_credits() -themes/admin_wind/views/admin.html.php                       77  DIRTY    $theme->admin_page_bottom() +themes/admin_wind/views/admin.html.php                       9   DIRTY    $page_title +themes/admin_wind/views/admin.html.php                       22  DIRTY_JS $theme->url() +themes/admin_wind/views/admin.html.php                       39  DIRTY    $theme->admin_head() +themes/admin_wind/views/admin.html.php                       43  DIRTY    $theme->admin_page_top() +themes/admin_wind/views/admin.html.php                       51  DIRTY    $theme->admin_header_top() +themes/admin_wind/views/admin.html.php                       52  DIRTY_JS item::root()->url() +themes/admin_wind/views/admin.html.php                       55  DIRTY    $theme->user_menu() +themes/admin_wind/views/admin.html.php                       57  DIRTY    $theme->admin_menu() +themes/admin_wind/views/admin.html.php                       59  DIRTY    $theme->admin_header_bottom() +themes/admin_wind/views/admin.html.php                       66  DIRTY    $content +themes/admin_wind/views/admin.html.php                       72  DIRTY    $sidebar +themes/admin_wind/views/admin.html.php                       77  DIRTY    $theme->admin_footer() +themes/admin_wind/views/admin.html.php                       79  DIRTY    $theme->admin_credits() +themes/admin_wind/views/admin.html.php                       83  DIRTY    $theme->admin_page_bottom()  themes/admin_wind/views/block.html.php                       3   DIRTY_ATTR $anchor  themes/admin_wind/views/block.html.php                       5   DIRTY    $id  themes/admin_wind/views/block.html.php                       5   DIRTY_ATTR $css_id | 
