|
|
@@ -327,6 +327,36 @@ class TreeBehaviorTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Tests the testFormatTreeListCustom() method.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testFormatTreeListCustom()
|
|
|
+ {
|
|
|
+ $table = TableRegistry::get('MenuLinkTrees');
|
|
|
+ $table->addBehavior('Tree');
|
|
|
+
|
|
|
+ $query = $table
|
|
|
+ ->find('threaded')
|
|
|
+ ->where(['menu' => 'main-menu']);
|
|
|
+
|
|
|
+ $options = ['keyPath' => 'url', 'valuePath' => 'id', 'spacer' => ' '];
|
|
|
+ $result = $table->formatTreeList($query, $options)->toArray();
|
|
|
+
|
|
|
+ $expected = [
|
|
|
+ '/link1.html' => '1',
|
|
|
+ 'http://example.com' => ' 2',
|
|
|
+ '/what/even-more-links.html' => ' 3',
|
|
|
+ '/lorem/ipsum.html' => ' 4',
|
|
|
+ '/what/the.html' => ' 5',
|
|
|
+ '/yeah/another-link.html' => '6',
|
|
|
+ 'http://cakephp.org' => ' 7',
|
|
|
+ '/page/who-we-are.html' => '8'
|
|
|
+ ];
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Tests the moveUp() method
|
|
|
*
|
|
|
* @return void
|