diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-07 08:23:22 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-07 08:23:22 +0000 |
commit | 055aa044977fdb608547bca2f39b79abe31beabe (patch) | |
tree | be62c491226b3c8e0617b082310ab9834b16392d | |
parent | d086f31ea4f877b9497f8d4933edd9352ba04b1a (diff) |
Rename moveTo to move_to and extend the test a bit.
-rw-r--r-- | core/libraries/ORM_MPTT.php | 6 | ||||
-rw-r--r-- | core/models/item.php | 4 | ||||
-rw-r--r-- | core/tests/ORM_MPTT_Test.php | 12 | ||||
-rw-r--r-- | modules/rearrange/controllers/rearrange.php | 2 |
4 files changed, 16 insertions, 8 deletions
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php index f30b6cc5..b6353cec 100644 --- a/core/libraries/ORM_MPTT.php +++ b/core/libraries/ORM_MPTT.php @@ -233,7 +233,7 @@ class ORM_MPTT_Core extends ORM { * @param boolean $locked The called is already holding the lock * @return ORM_MTPP */ - function moveTo($target, $locked=false) { + function move_to($target, $locked=false) { if ($target->type != "album") { throw new Exception("@todo '{$target->type}' IS NOT A VALID MOVE TARGET"); } @@ -242,8 +242,8 @@ class ORM_MPTT_Core extends ORM { throw new Exception("@todo '{$this->title}' IS NOT A VALID SOURCE"); } - $numberToMove = (int)(($this->right - $this->left) / 2 + 1); - $size_of_hole = $numberToMove * 2; + $number_to_move = (int)(($this->right - $this->left) / 2 + 1); + $size_of_hole = $number_to_move * 2; $original_parent = $this->parent; $original_left = $this->left; $original_right = $this->right; diff --git a/core/models/item.php b/core/models/item.php index f1a979ee..bb0adc5a 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -59,14 +59,14 @@ class Item_Model extends ORM_MPTT { * @param Item_Model $target Target item (must be an album * @return ORM_MTPP */ - function moveTo($target) { + function move_to($target) { $this->lock(); try { $original_path = $this->file_path(); $original_resize_path = $this->resize_path(); $original_thumbnail_path = $this->thumbnail_path(); - parent::moveTo($target, true); + parent::move_to($target, true); rename($original_path, $this->file_path()); if (file_exists($original_resize_path)) { diff --git a/core/tests/ORM_MPTT_Test.php b/core/tests/ORM_MPTT_Test.php index cd6b38eb..03230ad9 100644 --- a/core/tests/ORM_MPTT_Test.php +++ b/core/tests/ORM_MPTT_Test.php @@ -65,13 +65,21 @@ class ORM_MPTT_Test extends Unit_Test_Case { $album1_2->reload(); $album1_1_1->reload(); - $album1_1_1->moveTo($album1_2); + $album1_1_1->move_to($album1_2); $album1_1->reload(); $album1_2->reload(); $this->assert_equal(3, $album1_1->right - $album1_1->left); - $this->assert_equal(3, $album1_2->right - $album1_2 ->left); + $this->assert_equal(3, $album1_2->right - $album1_2->left); + + $this->assert_equal( + array($album1_1_2->id => "move_to_test_1_1_2"), + $album1_1->children()->select_list()); + + $this->assert_equal( + array($album1_1_1->id => "move_to_test_1_1_1"), + $album1_2->children()->select_list()); } public function parent_test() { diff --git a/modules/rearrange/controllers/rearrange.php b/modules/rearrange/controllers/rearrange.php index 6118e07e..291315e4 100644 --- a/modules/rearrange/controllers/rearrange.php +++ b/modules/rearrange/controllers/rearrange.php @@ -35,7 +35,7 @@ class Rearrange_Controller extends Controller { $target = ORM_MPTT::factory("item", $target_id); try { - $source->moveTo($target); + $source->move_to($target); print "success"; } catch (Exception $e) { Kohana::log("error", $e->getMessage() . "\n" + $e->getTraceAsString()); |