summaryrefslogtreecommitdiff
path: root/modules/gallery/tests
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-01-23 21:33:19 -0500
committerBharat Mediratta <bharat@menalto.com>2013-01-23 21:33:19 -0500
commitaa8fffcd8fc7d16f4bd84a9f8f7ead206d9ce45a (patch)
tree484ad936b32d0683c0ad45c898fa900ca5857546 /modules/gallery/tests
parentde78d3bfca20fec80fc87a7c5e2d18f3fdd791f1 (diff)
Extract reweighting logic out of Organize_Controller into
item::reweight_all_children as an API and write a test for it. Work in progress on #1914.
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 0c08d1af..63081884 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -235,4 +235,19 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$level3b->id,
item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
}
+
+ public function resequence_child_weights_test() {
+ $album = test::random_album();
+ $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);
+ }
}