Skip to content

Commit

Permalink
Tests the find('treeList') method after move
Browse files Browse the repository at this point in the history
  • Loading branch information
fiblan committed Oct 4, 2014
1 parent 5acecb7 commit e4ec7d9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/TestCase/Model/Behavior/TreeBehaviorTest.php
Expand Up @@ -194,6 +194,46 @@ public function testFindTreeList() {
];
$this->assertEquals($expected, $result);
}

/**
* Tests the find('treeList') method after moveUp, moveDown
*
* @return void
*/
public function testFindTreeListAfterMove() {
$table = TableRegistry::get('MenuLinkTrees');
$table->addBehavior('Tree', ['scope' => ['menu' => 'main-menu']]);

// moveUp
$table->moveUp($table->get(3), 1);
$result = $table->find('treeList')->toArray();
$expected = [
1 => 'Link 1',
3 => '_Link 3',
4 => '__Link 4',
5 => '___Link 5',
2 => '_Link 2',
6 => 'Link 6',
7 => '_Link 7',
8 => 'Link 8'
];
$this->assertSame($expected, $result);

// moveDown
$table->moveDown($table->get(6), 1);
$result2 = $table->find('treeList')->toArray();
$expected2 = [
1 => 'Link 1',
3 => '_Link 3',
4 => '__Link 4',
5 => '___Link 5',
2 => '_Link 2',
8 => 'Link 8',
6 => 'Link 6',
7 => '_Link 7',
];
$this->assertSame($expected2, $result2);
}

/**
* Tests the find('treeList') method with custom options
Expand Down

0 comments on commit e4ec7d9

Please sign in to comment.