|
|
@@ -696,13 +696,6 @@ class TreeBehaviorTest extends TestCase
|
|
|
{
|
|
|
$table = TableRegistry::get('MenuLinkTrees');
|
|
|
$table->addBehavior('Tree', ['scope' => ['menu' => 'main-menu']]);
|
|
|
- $expected = $table->find()
|
|
|
- ->where(['menu' => 'main-menu'])
|
|
|
- ->order('lft')
|
|
|
- ->hydrate(false)
|
|
|
- ->toArray();
|
|
|
-
|
|
|
-
|
|
|
$table->updateAll(['lft' => null, 'rght' => null], ['menu' => 'main-menu']);
|
|
|
$table->recover();
|
|
|
|
|
|
@@ -736,6 +729,31 @@ class TreeBehaviorTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Test recover function with a custom order clause
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testRecoverWithCustomOrder()
|
|
|
+ {
|
|
|
+ $table = TableRegistry::get('MenuLinkTrees');
|
|
|
+ $table->addBehavior('Tree', ['scope' => ['menu' => 'main-menu'], 'recoverOrder' => ['MenuLinkTrees.title' => 'desc']]);
|
|
|
+ $table->updateAll(['lft' => null, 'rght' => null], ['menu' => 'main-menu']);
|
|
|
+ $table->recover();
|
|
|
+
|
|
|
+ $expected = [
|
|
|
+ ' 1: 2 - 8:Link 8',
|
|
|
+ ' 3: 6 - 6:Link 6',
|
|
|
+ '_ 4: 5 - 7:Link 7',
|
|
|
+ ' 7:16 - 1:Link 1',
|
|
|
+ '_ 8:13 - 3:Link 3',
|
|
|
+ '__ 9:12 - 4:Link 4',
|
|
|
+ '___10:11 - 5:Link 5',
|
|
|
+ '_14:15 - 2:Link 2'
|
|
|
+ ];
|
|
|
+ $this->assertMpttValues($expected, $table);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Tests adding a new orphan node
|
|
|
*
|
|
|
* @return void
|