Browse Source

Add unit tests

tags/v1.0.1 v1.0.1
PaulZi 9 years ago
parent
commit
1d50bd6b45
  1. 3
      .scrutinizer.yml
  2. 32
      .travis.yml
  3. 5
      README.md
  4. 4
      composer.json
  5. 13
      phpunit.xml.dist
  6. 1
      tests/.gitignore
  7. 35
      tests/ArrayDataSet.php
  8. 70
      tests/BaseTestCase.php
  9. 750
      tests/NestedSetsBehaviorTestCase.php
  10. 24
      tests/NestedSetsQueryTraitTestCase.php
  11. 37
      tests/README.md
  12. 19
      tests/bootstrap.php
  13. 28
      tests/data/config.php
  14. 72
      tests/data/data.php
  15. 5
      tests/data/empty.php
  16. 75
      tests/data/test-append-to-insert-in-empty.php
  17. 76
      tests/data/test-append-to-insert-in-no-empty.php
  18. 72
      tests/data/test-append-to-update-another-tree.php
  19. 73
      tests/data/test-append-to-update-deep.php
  20. 72
      tests/data/test-append-to-update-out.php
  21. 72
      tests/data/test-append-to-update-same-node.php
  22. 33
      tests/data/test-delete-with-children-root.php
  23. 67
      tests/data/test-delete-with-children.php
  24. 70
      tests/data/test-delete.php
  25. 76
      tests/data/test-insert-after-insert-end.php
  26. 76
      tests/data/test-insert-after-insert-middle.php
  27. 72
      tests/data/test-insert-after-update-another-tree.php
  28. 74
      tests/data/test-insert-after-update-other-node.php
  29. 72
      tests/data/test-insert-after-update-same-node.php
  30. 76
      tests/data/test-insert-before-insert-begin.php
  31. 76
      tests/data/test-insert-before-insert-middle.php
  32. 72
      tests/data/test-insert-before-update-another-tree.php
  33. 72
      tests/data/test-insert-before-update-other-node.php
  34. 72
      tests/data/test-insert-before-update-same-node.php
  35. 10
      tests/data/test-make-root-insert.php
  36. 72
      tests/data/test-make-root-update.php
  37. 77
      tests/data/test-prepend-to-insert-in-empty.php
  38. 77
      tests/data/test-prepend-to-insert-in-no-empty.php
  39. 72
      tests/data/test-prepend-to-update-another-tree.php
  40. 73
      tests/data/test-prepend-to-update-deep.php
  41. 72
      tests/data/test-prepend-to-update-out.php
  42. 72
      tests/data/test-prepend-to-update-same-node.php
  43. 61
      tests/migrations/TestMigration.php
  44. 74
      tests/models/MultipleTreeNode.php
  45. 72
      tests/models/Node.php
  46. 18
      tests/models/NodeQuery.php
  47. 20
      tests/mysql/NestedSetsBehaviorTest.php
  48. 20
      tests/mysql/NestedSetsQueryTraitTest.php
  49. 20
      tests/pgsql/NestedSetsBehaviorTest.php
  50. 20
      tests/pgsql/NestedSetsQueryTraitTest.php
  51. 20
      tests/sqlite/NestedSetsBehaviorTest.php
  52. 20
      tests/sqlite/NestedSetsQueryTraitTest.php

3
.scrutinizer.yml

@ -0,0 +1,3 @@
tools:
external_code_coverage:
timeout: 2100

32
.travis.yml

@ -0,0 +1,32 @@
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
matrix:
allow_failures:
- php: 7.0
sudo: false
install:
- composer self-update
- composer global require fxp/composer-asset-plugin:~1.0
- composer install
before_script:
- mysql --version
- psql --version
- mysql -e 'create database test;'
- psql -U postgres -c 'CREATE DATABASE test;';
script:
- vendor/bin/phpunit --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

5
README.md

@ -2,6 +2,11 @@
Implementation of nested sets algorithm for storing the trees in DB tables. Implementation of nested sets algorithm for storing the trees in DB tables.
[![Packagist Version](https://img.shields.io/packagist/v/paulzi/yii2-nested-sets.svg)](https://packagist.org/packages/paulzi/yii2-nested-sets)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/paulzi/yii2-nested-sets/master.svg)](https://scrutinizer-ci.com/g/paulzi/yii2-nested-sets/?branch=master)
[![Build Status](https://img.shields.io/travis/paulzi/yii2-nested-sets/master.svg)](https://travis-ci.org/paulzi/yii2-nested-sets)
[![Total Downloads](https://img.shields.io/packagist/dt/paulzi/yii2-nested-sets.svg)](https://packagist.org/packages/paulzi/yii2-nested-sets)
## Install ## Install
Install via Composer: Install via Composer:

4
composer.json

@ -23,6 +23,10 @@
"php": ">=5.4.0", "php": ">=5.4.0",
"yiisoft/yii2": "~2.0.0" "yiisoft/yii2": "~2.0.0"
}, },
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpunit/dbunit": "~1.0"
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"paulzi\\nestedsets\\": "" "paulzi\\nestedsets\\": ""

13
phpunit.xml.dist

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Yii2 Nested Sets Behavior Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>

1
tests/.gitignore vendored

@ -0,0 +1 @@
/data/config.local.php

35
tests/ArrayDataSet.php

@ -0,0 +1,35 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests;
/**
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class ArrayDataSet extends \PHPUnit_Extensions_Database_DataSet_ArrayDataSet
{
public function __construct(array $data)
{
foreach ($data as $tableName => $rows) {
$columns = array();
if (isset($rows['columns'])) {
$columns = $rows['columns'];
unset($rows['columns']);
} elseif (isset($rows[0])) {
$columns = array_keys($rows[0]);
}
$metaData = new \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
$table = new \PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
foreach ($rows AS $row) {
$table->addRow($row);
}
$this->tables[$tableName] = $table;
}
}
}

70
tests/BaseTestCase.php

@ -0,0 +1,70 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests;
use paulzi\nestedsets\tests\migrations\TestMigration;
use Yii;
use yii\db\Connection;
/**
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class BaseTestCase extends \PHPUnit_Extensions_Database_TestCase
{
protected static $driverName = 'sqlite';
/**
* @inheritdoc
*/
public function getConnection()
{
return $this->createDefaultDBConnection(Yii::$app->getDb()->pdo);
}
/**
* @inheritdoc
*/
public function getDataSet()
{
return new \PHPUnit_Extensions_Database_DataSet_ArrayDataSet(require(__DIR__ . '/data/data.php'));
}
/**
* @inheritdoc
*/
protected function setUp()
{
if (Yii::$app->get('db', false) === null) {
$this->markTestSkipped();
} else {
(new TestMigration())->up();
if (Yii::$app->db->driverName === 'pgsql') {
Yii::$app->db->createCommand("SELECT setval(pg_get_serial_sequence('tree', 'id'), 25)")->execute();
Yii::$app->db->createCommand("SELECT setval(pg_get_serial_sequence('multiple_tree', 'id'), 39)")->execute();
}
parent::setUp();
}
}
/**
* @inheritdoc
*/
public static function setUpBeforeClass()
{
$config = require(__DIR__ . '/data/config.php');
$config = $config[static::$driverName];
$config['class'] = Connection::className();
try {
Yii::$app->set('db', $config);
Yii::$app->getDb()->open();
} catch (\Exception $e) {
Yii::$app->clear('db');
}
}
}

750
tests/NestedSetsBehaviorTestCase.php

@ -0,0 +1,750 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests;
use paulzi\nestedsets\tests\migrations\TestMigration;
use paulzi\nestedsets\tests\models\MultipleTreeNode;
use paulzi\nestedsets\tests\models\Node;
use Yii;
/**
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NestedSetsBehaviorTestCase extends BaseTestCase
{
public function testGetParents()
{
$data = [1, 4, 9];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(21)->parents));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(21)->parents));
$data = [];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(1)->parents));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(1)->parents));
$data = [2, 7];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(17)->getParents(2)->all()));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(17)->getParents(2)->all()));
$data = [26, 30];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(38)->parents));
}
public function testGetParent()
{
$this->assertEquals(5, Node::findOne(12)->parent->id);
$this->assertEquals(5, MultipleTreeNode::findOne(12)->parent->id);
$this->assertEquals(1, Node::findOne(4)->getParent()->one()->getAttribute('id'));
$this->assertEquals(26, MultipleTreeNode::findOne(29)->getParent()->one()->getAttribute('id'));
$this->assertEquals(null, Node::findOne(1)->parent);
$this->assertEquals(null, MultipleTreeNode::findOne(1)->parent);
}
public function testGetRoot()
{
$this->assertEquals(1, Node::findOne(16)->root->id);
$this->assertEquals(26, MultipleTreeNode::findOne(28)->root->id);
$this->assertEquals(1, Node::findOne(1)->getRoot()->one()->getAttribute('id'));
$this->assertEquals(26, MultipleTreeNode::findOne(26)->getRoot()->one()->getAttribute('id'));
}
public function testGetDescendants()
{
$data = [8, 9, 20, 21, 22, 10, 23, 24, 25];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(4)->descendants));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(4)->descendants));
$data = [2, 5, 6, 7];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(2)->getDescendants(1, true)->all()));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(2)->getDescendants(1, true)->all()));
$data = [10, 25, 24, 23, 9, 22, 21, 20, 8];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(4)->getDescendants(3, false, true)->all()));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(4)->getDescendants(3, false, true)->all()));
$data = [];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(8)->descendants));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(8)->descendants));
}
public function testGetChildren()
{
$data = [8, 9, 10];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(4)->children));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(4)->children));
$data = [];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(3)->getChildren()->all()));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(28)->getChildren()->all()));
}
public function testGetLeaves()
{
$data = [8, 20, 21, 22, 23, 24, 25];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(4)->leaves));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(4)->leaves));
$data = [3, 8];
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, Node::findOne(1)->getLeaves(2)->all()));
$this->assertEquals($data, array_map(function ($value) { return $value->id; }, MultipleTreeNode::findOne(1)->getLeaves(2)->all()));
}
public function testGetPrev()
{
$this->assertEquals(11, Node::findOne(12)->prev->id);
$this->assertEquals(11, MultipleTreeNode::findOne(12)->prev->id);
$this->assertEquals(null, Node::findOne(20)->getPrev()->one());
$this->assertEquals(null, MultipleTreeNode::findOne(20)->getPrev()->one());
}
public function testGetNext()
{
$this->assertEquals(13, Node::findOne(12)->next->id);
$this->assertEquals(13, MultipleTreeNode::findOne(12)->next->id);
$this->assertEquals(null, Node::findOne(19)->getNext()->one());
$this->assertEquals(null, MultipleTreeNode::findOne(19)->getNext()->one());
}
public function testIsRoot()
{
$this->assertTrue(Node::findOne(1)->isRoot());
$this->assertTrue(MultipleTreeNode::findOne(1)->isRoot());
$this->assertTrue(MultipleTreeNode::findOne(26)->isRoot());
$this->assertFalse(Node::findOne(3)->isRoot());
$this->assertFalse(MultipleTreeNode::findOne(3)->isRoot());
$this->assertFalse(MultipleTreeNode::findOne(37)->isRoot());
}
public function testIsChildOf()
{
$this->assertTrue(Node::findOne(10)->isChildOf(Node::findOne(1)));
$this->assertTrue(MultipleTreeNode::findOne(10)->isChildOf(MultipleTreeNode::findOne(1)));
$this->assertTrue(Node::findOne(9)->isChildOf(Node::findOne(4)));
$this->assertTrue(MultipleTreeNode::findOne(9)->isChildOf(MultipleTreeNode::findOne(4)));
$this->assertFalse(Node::findOne(12)->isChildOf(Node::findOne(15)));
$this->assertFalse(MultipleTreeNode::findOne(12)->isChildOf(MultipleTreeNode::findOne(15)));
$this->assertFalse(Node::findOne(21)->isChildOf(Node::findOne(22)));
$this->assertFalse(MultipleTreeNode::findOne(21)->isChildOf(MultipleTreeNode::findOne(22)));
$this->assertFalse(Node::findOne(8)->isChildOf(Node::findOne(8)));
$this->assertFalse(MultipleTreeNode::findOne(8)->isChildOf(MultipleTreeNode::findOne(8)));
$this->assertFalse(MultipleTreeNode::findOne(6)->isChildOf(MultipleTreeNode::findOne(27)));
}
public function testIsLeaf()
{
$this->assertTrue(Node::findOne(3)->isLeaf());
$this->assertTrue(MultipleTreeNode::findOne(3)->isLeaf());
$this->assertFalse(Node::findOne(4)->isLeaf());
$this->assertFalse(MultipleTreeNode::findOne(4)->isLeaf());
}
public function testMakeRootInsert()
{
(new TestMigration())->up();
$dataSet = new ArrayDataSet(require(__DIR__ . '/data/empty.php'));
$this->getDatabaseTester()->setDataSet($dataSet);
$this->getDatabaseTester()->onSetUp();
$node = new Node(['slug' => 'r']);
$this->assertTrue($node->makeRoot()->save());
$node = new MultipleTreeNode(['slug' => 'r1']);
$this->assertTrue($node->makeRoot()->save());
$node = new MultipleTreeNode([
'slug' => 'r2',
'tree' => 100,
]);
$this->assertTrue($node->makeRoot()->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-make-root-insert.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testMakeRootUpdate()
{
$node = MultipleTreeNode::findOne(9);
$this->assertTrue($node->makeRoot()->save());
$node = MultipleTreeNode::findOne(27);
$node->setAttribute('tree', 100);
$this->assertTrue($node->makeRoot()->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-make-root-update.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
/**
* @expectedException \yii\base\Exception
*/
public function testMakeRootNewExceptionIsRaisedWhenTreeAttributeIsFalseAndRootIsExists()
{
$node = new Node(['slug' => 'r']);
$node->makeRoot()->save();
}
public function testPrependToInsertInNoEmpty()
{
$node = new Node(['slug' => 'new']);
$this->assertTrue($node->prependTo(Node::findOne(1))->save());
$node = new MultipleTreeNode(['slug' => 'new']);
$this->assertTrue($node->prependTo(MultipleTreeNode::findOne(1))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-prepend-to-insert-in-no-empty.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testPrependToInsertInEmpty()
{
$node = new Node(['slug' => 'new']);
$this->assertTrue($node->prependTo(Node::findOne(15))->save());
$node = new MultipleTreeNode(['slug' => 'new']);
$this->assertTrue($node->prependTo(MultipleTreeNode::findOne(15))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-prepend-to-insert-in-empty.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testPrependToUpdateSameNode()
{
$node = Node::findOne(4);
$this->assertTrue($node->prependTo(Node::findOne(1))->save());
$node = MultipleTreeNode::findOne(4);
$this->assertTrue($node->prependTo(MultipleTreeNode::findOne(1))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-prepend-to-update-same-node.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testPrependToUpdateDeep()
{
$node = Node::findOne(10);
$this->assertTrue($node->prependTo(Node::findOne(18))->save());
$node = MultipleTreeNode::findOne(10);
$this->assertTrue($node->prependTo(MultipleTreeNode::findOne(18))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-prepend-to-update-deep.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testPrependToUpdateOut()
{
$node = Node::findOne(6);
$this->assertTrue($node->prependTo(Node::findOne(1))->save());
$node = MultipleTreeNode::findOne(6);
$this->assertTrue($node->prependTo(MultipleTreeNode::findOne(1))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-prepend-to-update-out.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testPrependToUpdateAnotherTree()
{
$node = MultipleTreeNode::findOne(30);
$this->assertTrue($node->prependTo(MultipleTreeNode::findOne(4))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-prepend-to-update-another-tree.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testPrependToUpdateSelf()
{
$node = Node::findOne(2);
$this->assertTrue($node->prependTo(Node::findOne(1))->save());
$node = MultipleTreeNode::findOne(2);
$this->assertTrue($node->prependTo(MultipleTreeNode::findOne(1))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/data.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
/**
* @expectedException \yii\base\Exception
*/
public function testPrependToInsertExceptionIsRaisedWhenTargetIsNewRecord()
{
$node = new Node(['slug' => 'new']);
$node->prependTo(new Node())->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testPrependToUpdateExceptionIsRaisedWhenTargetIsNewRecord()
{
$node = Node::findOne(2);
$node->prependTo(new Node())->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testPrependToUpdateExceptionIsRaisedWhenTargetIsSame()
{
$node = Node::findOne(3);
$node->prependTo(Node::findOne(3))->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testPrependToUpdateExceptionIsRaisedWhenTargetIsChild()
{
$node = Node::findOne(5);
$node->prependTo(Node::findOne(11))->save();
}
public function testAppendToInsertInNoEmpty()
{
$node = new Node(['slug' => 'new']);
$this->assertTrue($node->appendTo(Node::findOne(1))->save());
$node = new MultipleTreeNode(['slug' => 'new']);
$this->assertTrue($node->appendTo(MultipleTreeNode::findOne(1))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-append-to-insert-in-no-empty.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testAppendToInsertInEmpty()
{
$node = new Node(['slug' => 'new']);
$this->assertTrue($node->appendTo(Node::findOne(15))->save());
$node = new MultipleTreeNode(['slug' => 'new']);
$this->assertTrue($node->appendTo(MultipleTreeNode::findOne(15))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-append-to-insert-in-empty.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testAppendToUpdateSameNode()
{
$node = Node::findOne(2);
$this->assertTrue($node->appendTo(Node::findOne(1))->save());
$node = MultipleTreeNode::findOne(2);
$this->assertTrue($node->appendTo(MultipleTreeNode::findOne(1))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-append-to-update-same-node.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testAppendToUpdateDeep()
{
$node = Node::findOne(10);
$this->assertTrue($node->appendTo(Node::findOne(18))->save());
$node = MultipleTreeNode::findOne(10);
$this->assertTrue($node->appendTo(MultipleTreeNode::findOne(18))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-append-to-update-deep.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testAppendToUpdateOut()
{
$node = Node::findOne(6);
$this->assertTrue($node->appendTo(Node::findOne(1))->save());
$node = MultipleTreeNode::findOne(6);
$this->assertTrue($node->appendTo(MultipleTreeNode::findOne(1))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-append-to-update-out.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testAppendToUpdateAnotherTree()
{
$node = MultipleTreeNode::findOne(30);
$this->assertTrue($node->appendTo(MultipleTreeNode::findOne(4))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-append-to-update-another-tree.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testAppendToUpdateSelf()
{
$node = Node::findOne(4);
$this->assertTrue($node->appendTo(Node::findOne(1))->save());
$node = MultipleTreeNode::findOne(4);
$this->assertTrue($node->appendTo(MultipleTreeNode::findOne(1))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/data.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
/**
* @expectedException \yii\base\Exception
*/
public function testAppendToInsertExceptionIsRaisedWhenTargetIsNewRecord()
{
$node = new Node(['slug' => 'new']);
$node->appendTo(new Node())->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testAppendToUpdateExceptionIsRaisedWhenTargetIsNewRecord()
{
$node = Node::findOne(2);
$node->appendTo(new Node())->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testAppendToUpdateExceptionIsRaisedWhenTargetIsSame()
{
$node = Node::findOne(3);
$node->appendTo(Node::findOne(3))->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testAppendToUpdateExceptionIsRaisedWhenTargetIsChild()
{
$node = Node::findOne(5);
$node->appendTo(Node::findOne(11))->save();
}
public function testInsertBeforeMiddle()
{
$node = new Node(['slug' => 'new']);
$this->assertTrue($node->insertBefore(Node::findOne(16))->save());
$node = new MultipleTreeNode(['slug' => 'new']);
$this->assertTrue($node->insertBefore(MultipleTreeNode::findOne(33))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-before-insert-middle.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertBeforeInsertBegin()
{
$node = new Node(['slug' => 'new']);
$this->assertTrue($node->insertBefore(Node::findOne(20))->save());
$node = new MultipleTreeNode(['slug' => 'new']);
$this->assertTrue($node->insertBefore(MultipleTreeNode::findOne(31))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-before-insert-begin.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertBeforeUpdateSameNode()
{
$node = Node::findOne(4);
$this->assertTrue($node->insertBefore(Node::findOne(2))->save());
$node = MultipleTreeNode::findOne(38);
$this->assertTrue($node->insertBefore(MultipleTreeNode::findOne(37))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-before-update-same-node.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertBeforeUpdateOtherNode()
{
$node = Node::findOne(9);
$this->assertTrue($node->insertBefore(Node::findOne(16))->save());
$node = MultipleTreeNode::findOne(35);
$this->assertTrue($node->insertBefore(MultipleTreeNode::findOne(28))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-before-update-other-node.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertBeforeUpdateNext()
{
$node = Node::findOne(12);
$this->assertTrue($node->insertBefore(Node::findOne(13))->save());
$node = MultipleTreeNode::findOne(33);
$this->assertTrue($node->insertBefore(MultipleTreeNode::findOne(34))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/data.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertBeforeUpdateAnotherTree()
{
$node = MultipleTreeNode::findOne(26);
$this->assertTrue($node->insertBefore(MultipleTreeNode::findOne(15))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-before-update-another-tree.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
/**
* @expectedException \yii\base\Exception
*/
public function testInsertBeforeInsertExceptionIsRaisedWhenTargetIsNewRecord()
{
$node = new Node(['slug' => 'new']);
$node->insertBefore(new Node())->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testInsertBeforeInsertExceptionIsRaisedWhenTargetIsRoot()
{
$node = new Node(['name' => 'new']);
$node->insertBefore(Node::findOne(1))->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testInsertBeforeUpdateExceptionIsRaisedWhenTargetIsSame()
{
$node = Node::findOne(3);
$node->insertBefore(Node::findOne(3))->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testInsertBeforeUpdateExceptionIsRaisedWhenTargetIsChild()
{
$node = Node::findOne(10);
$node->insertBefore(Node::findOne(23))->save();
}
public function testInsertAfterInsertMiddle()
{
$node = new Node(['slug' => 'new']);
$this->assertTrue($node->insertAfter(Node::findOne(21))->save());
$node = new MultipleTreeNode(['slug' => 'new']);
$this->assertTrue($node->insertAfter(MultipleTreeNode::findOne(37))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-after-insert-middle.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertAfterInsertEnd()
{
$node = new Node(['slug' => 'new']);
$this->assertTrue($node->insertAfter(Node::findOne(19))->save());
$node = new MultipleTreeNode(['slug' => 'new']);
$this->assertTrue($node->insertAfter(MultipleTreeNode::findOne(33))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-after-insert-end.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertAfterUpdateSameNode()
{
$node = Node::findOne(2);
$this->assertTrue($node->insertAfter(Node::findOne(4))->save());
$node = MultipleTreeNode::findOne(36);
$this->assertTrue($node->insertAfter(MultipleTreeNode::findOne(37))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-after-update-same-node.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertAfterUpdateOtherNode()
{
$node = Node::findOne(6);
$this->assertTrue($node->insertAfter(Node::findOne(21))->save());
$node = MultipleTreeNode::findOne(32);
$this->assertTrue($node->insertAfter(MultipleTreeNode::findOne(30))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-after-update-other-node.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertAfterUpdatePrev()
{
$node = Node::findOne(16);
$this->assertTrue($node->insertAfter(Node::findOne(15))->save());
$node = MultipleTreeNode::findOne(38);
$this->assertTrue($node->insertAfter(MultipleTreeNode::findOne(37))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/data.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testInsertAfterUpdateAnotherTree()
{
$node = MultipleTreeNode::findOne(26);
$this->assertTrue($node->insertAfter(MultipleTreeNode::findOne(21))->save());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-insert-after-update-another-tree.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
/**
* @expectedException \yii\base\Exception
*/
public function testInsertAfterInsertExceptionIsRaisedWhenTargetIsNewRecord()
{
$node = new Node(['slug' => 'new']);
$node->insertAfter(new Node())->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testInsertAfterInsertExceptionIsRaisedWhenTargetIsRoot()
{
$node = new Node(['slug' => 'new']);
$node->insertAfter(Node::findOne(1))->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testInsertAfterUpdateExceptionIsRaisedWhenTargetIsSame()
{
$node = Node::findOne(3);
$node->insertAfter(Node::findOne(3))->save();
}
/**
* @expectedException \yii\base\Exception
*/
public function testInsertAfterUpdateExceptionIsRaisedWhenTargetIsChild()
{
$node = Node::findOne(10);
$node->insertAfter(Node::findOne(23))->save();
}
public function testDelete()
{
$this->assertEquals(1, Node::findOne(2)->delete());
$this->assertEquals(1, MultipleTreeNode::findOne(30)->delete());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-delete.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
/**
* @expectedException \yii\base\Exception
*/
public function testDeleteRoot()
{
Node::findOne(1)->delete();
}
/**
* @expectedException \yii\base\Exception
*/
public function testDeleteExceptionIsRaisedWhenNodeIsNewRecord()
{
$node = new Node(['slug' => 'new']);
$node->delete();
}
public function testDeleteWithChildren()
{
$this->assertEquals(4, Node::findOne(6)->deleteWithChildren());
$this->assertEquals(1, MultipleTreeNode::findOne(28)->deleteWithChildren());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-delete-with-children.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
public function testDeleteWithChildrenRoot()
{
$this->assertEquals(25, Node::findOne(1)->deleteWithChildren());
$this->assertEquals(14, MultipleTreeNode::findOne(26)->deleteWithChildren());
$dataSet = $this->getConnection()->createDataSet(['tree', 'multiple_tree']);
$expectedDataSet = new ArrayDataSet(require(__DIR__ . '/data/test-delete-with-children-root.php'));
$this->assertDataSetsEqual($expectedDataSet, $dataSet);
}
/**
* @expectedException \yii\base\Exception
*/
public function testDeleteWithChildrenExceptionIsRaisedWhenNodeIsNewRecord()
{
$node = new Node(['slug' => 'new']);
$node->deleteWithChildren();
}
/**
* @expectedException \yii\base\NotSupportedException
*/
public function testExceptionIsRaisedWhenInsertIsCalled()
{
$node = new Node(['slug' => 'new']);
$node->insert();
}
public function testUpdate()
{
$node = Node::findOne(3);
$node->slug = 'update';
$this->assertEquals(1, $node->update());
}
}

24
tests/NestedSetsQueryTraitTestCase.php

@ -0,0 +1,24 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests;
use paulzi\nestedsets\tests\models\Node;
use paulzi\nestedsets\tests\models\MultipleTreeNode;
use Yii;
/**
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NestedSetsQueryTraitTestCase extends BaseTestCase
{
public function testRoots()
{
$this->assertEquals([1], array_map(function ($value) { return $value->id; }, Node::find()->roots()->all()));
$this->assertEquals([1, 26], array_map(function ($value) { return $value->id; }, MultipleTreeNode::find()->roots()->all()));
}
}

37
tests/README.md

@ -0,0 +1,37 @@
# Yii2 Materialized Path Behavior unit tests
## How to run the test
Make sure you have PHPUnit installed and that you installed all composer dependencies (run `composer update` in the repo base directory).
Run PHPUnit in the yii repo base directory.
```
phpunit
```
You can run tests for specific groups only:
```
phpunit --group=sqlite,mysql
```
You can get a list of available groups via `phpunit --list-groups`.
## test configurations
PHPUnit configuration is in `phpunit.xml.dist` in repository root folder.
You can create your own phpunit.xml to override dist config.
Database and other backend system configuration can be found in `tests/data/config.php`
adjust them to your needs to allow testing databases and caching in your environment.
You can override configuration values by creating a `config.local.php` file
and manipulate the `$config` variable.
For example to change MySQL username and password your `config.local.php` should
contain the following:
```php
<?php
$config['mysql']['username'] = 'username';
$config['mysql']['password'] = 'password';
```

19
tests/bootstrap.php

@ -0,0 +1,19 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
Yii::setAlias('@tests', __DIR__);
new \yii\console\Application([
'id' => 'unit',
'basePath' => __DIR__,
]);

28
tests/data/config.php

@ -0,0 +1,28 @@
<?php
$config = [
'sqlite' => [
'dsn' => 'sqlite::memory:',
],
'mysql' => [
'dsn' => 'mysql:host=localhost;dbname=test',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
'mssql' => [
'dsn' => 'sqlsrv:Server=localhost;Database=test',
'username' => '',
'password' => '',
],
'pgsql' => [
'dsn' => 'pgsql:host=localhost;dbname=test;port=5432;',
'username' => 'postgres',
'password' => 'postgres',
],
];
if (is_file(__DIR__ . '/config.local.php')) {
include(__DIR__ . '/config.local.php');
}
return $config;

72
tests/data/data.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

5
tests/data/empty.php

@ -0,0 +1,5 @@
<?php
return array(
'tree' => array(),
'multiple_tree' => array()
);

75
tests/data/test-append-to-insert-in-empty.php

@ -0,0 +1,75 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '29','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '30','rgt' => '31','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '32','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '20','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '21','rgt' => '28','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '33','rgt' => '34','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '35','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '17','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','lft' => '15','rgt' => '16','depth' => '4','slug' => 'new'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '29','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '30','rgt' => '31','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '32','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '20','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '21','rgt' => '28','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '33','rgt' => '34','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '35','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '17','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
array('id' => '40','tree' => '1','lft' => '15','rgt' => '16','depth' => '4','slug' => 'new'),
)
);

76
tests/data/test-append-to-insert-in-no-empty.php

@ -0,0 +1,76 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','lft' => '50','rgt' => '51','depth' => '1','slug' => 'new'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
array('id' => '40','tree' => '1','lft' => '50','rgt' => '51','depth' => '1','slug' => 'new'),
)
);

72
tests/data/test-append-to-update-another-tree.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '60','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '59','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '18','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '1','lft' => '49','rgt' => '58','depth' => '2','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '1','lft' => '50','rgt' => '51','depth' => '3','slug' => 'n41'),
array('id' => '37','tree' => '1','lft' => '52','rgt' => '53','depth' => '3','slug' => 'n42'),
array('id' => '38','tree' => '1','lft' => '54','rgt' => '55','depth' => '3','slug' => 'n43'),
array('id' => '39','tree' => '1','lft' => '56','rgt' => '57','depth' => '3','slug' => 'n44'),
)
);

73
tests/data/test-append-to-update-deep.php

@ -0,0 +1,73 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '35','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '36','rgt' => '37','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '38','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '34','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '39','rgt' => '40','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '23','rgt' => '30','depth' => '4','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '31','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '24','rgt' => '25','depth' => '5','slug' => 'n331'),
array('id' => '24','lft' => '26','rgt' => '27','depth' => '5','slug' => 'n332'),
array('id' => '25','lft' => '28','rgt' => '29','depth' => '5','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '35','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '36','rgt' => '37','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '38','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '34','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '39','rgt' => '40','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '23','rgt' => '30','depth' => '4','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '31','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '24','rgt' => '25','depth' => '5','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '26','rgt' => '27','depth' => '5','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '28','rgt' => '29','depth' => '5','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

72
tests/data/test-append-to-update-out.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '19','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '20','rgt' => '21','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '22','rgt' => '41','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '42','rgt' => '49','depth' => '1','slug' => 'n12'),
array('id' => '7','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '25','rgt' => '32','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '43','rgt' => '44','depth' => '2','slug' => 'n121'),
array('id' => '15','lft' => '45','rgt' => '46','depth' => '2','slug' => 'n122'),
array('id' => '16','lft' => '47','rgt' => '48','depth' => '2','slug' => 'n123'),
array('id' => '17','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '30','rgt' => '31','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '19','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '20','rgt' => '21','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '22','rgt' => '41','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '42','rgt' => '49','depth' => '1','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '25','rgt' => '32','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '43','rgt' => '44','depth' => '2','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '45','rgt' => '46','depth' => '2','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '47','rgt' => '48','depth' => '2','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '30','rgt' => '31','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

72
tests/data/test-append-to-update-same-node.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '24','rgt' => '49','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '2','rgt' => '3','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '4','rgt' => '23','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '25','rgt' => '32','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '7','rgt' => '14','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '15','rgt' => '22','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '30','rgt' => '31','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '10','rgt' => '11','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '24','rgt' => '49','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '2','rgt' => '3','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '4','rgt' => '23','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '25','rgt' => '32','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '7','rgt' => '14','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '15','rgt' => '22','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '30','rgt' => '31','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '10','rgt' => '11','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

33
tests/data/test-delete-with-children-root.php

@ -0,0 +1,33 @@
<?php
return array(
'tree' => array(
'columns' => array('id','lft','rgt','depth','slug'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
)
);

67
tests/data/test-delete-with-children.php

@ -0,0 +1,67 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '42','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '19','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '20','rgt' => '21','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '22','rgt' => '41','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '7','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '25','rgt' => '32','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '17','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '30','rgt' => '31','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '26','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '29','tree' => '26','lft' => '12','rgt' => '15','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '16','rgt' => '25','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '13','rgt' => '14','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '17','rgt' => '18','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n44'),
)
);

70
tests/data/test-delete.php

@ -0,0 +1,70 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '48','depth' => '0','slug' => 'r1'),
array('id' => '3','lft' => '26','rgt' => '27','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '28','rgt' => '47','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '2','rgt' => '9','depth' => '1','slug' => 'n11'),
array('id' => '6','lft' => '10','rgt' => '17','depth' => '1','slug' => 'n12'),
array('id' => '7','lft' => '18','rgt' => '25','depth' => '1','slug' => 'n13'),
array('id' => '8','lft' => '29','rgt' => '30','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '31','rgt' => '38','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '39','rgt' => '46','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n111'),
array('id' => '12','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n112'),
array('id' => '13','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n113'),
array('id' => '14','lft' => '11','rgt' => '12','depth' => '2','slug' => 'n121'),
array('id' => '15','lft' => '13','rgt' => '14','depth' => '2','slug' => 'n122'),
array('id' => '16','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n123'),
array('id' => '17','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n131'),
array('id' => '18','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n132'),
array('id' => '19','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n133'),
array('id' => '20','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '26','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '18','rgt' => '19','depth' => '1','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '20','rgt' => '21','depth' => '1','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '22','rgt' => '23','depth' => '1','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '24','rgt' => '25','depth' => '1','slug' => 'n44'),
)
);

76
tests/data/test-insert-after-insert-end.php

@ -0,0 +1,76 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '29','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '30','rgt' => '31','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '32','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '28','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '33','rgt' => '34','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '35','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','lft' => '26','rgt' => '27','depth' => '3','slug' => 'new'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '30','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '13','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '14','rgt' => '15','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '16','rgt' => '19','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '20','rgt' => '29','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '11','rgt' => '12','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '17','rgt' => '18','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '27','rgt' => '28','depth' => '2','slug' => 'n44'),
array('id' => '40','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'new'),
)
);

76
tests/data/test-insert-after-insert-middle.php

@ -0,0 +1,76 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','lft' => '38','rgt' => '39','depth' => '3','slug' => 'new'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '30','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '29','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '27','rgt' => '28','depth' => '2','slug' => 'n44'),
array('id' => '40','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'new'),
)
);

72
tests/data/test-insert-after-update-another-tree.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '78','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '77','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '68','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '69','rgt' => '76','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '66','rgt' => '67','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '70','rgt' => '71','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '72','rgt' => '73','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '74','rgt' => '75','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '1','lft' => '38','rgt' => '65','depth' => '3','slug' => 'r2'),
array('id' => '27','tree' => '1','lft' => '39','rgt' => '48','depth' => '4','slug' => 'n1'),
array('id' => '28','tree' => '1','lft' => '49','rgt' => '50','depth' => '4','slug' => 'n2'),
array('id' => '29','tree' => '1','lft' => '51','rgt' => '54','depth' => '4','slug' => 'n3'),
array('id' => '30','tree' => '1','lft' => '55','rgt' => '64','depth' => '4','slug' => 'n4'),
array('id' => '31','tree' => '1','lft' => '40','rgt' => '41','depth' => '5','slug' => 'n11'),
array('id' => '32','tree' => '1','lft' => '42','rgt' => '43','depth' => '5','slug' => 'n12'),
array('id' => '33','tree' => '1','lft' => '44','rgt' => '45','depth' => '5','slug' => 'n13'),
array('id' => '34','tree' => '1','lft' => '46','rgt' => '47','depth' => '5','slug' => 'n14'),
array('id' => '35','tree' => '1','lft' => '52','rgt' => '53','depth' => '5','slug' => 'n31'),
array('id' => '36','tree' => '1','lft' => '56','rgt' => '57','depth' => '5','slug' => 'n41'),
array('id' => '37','tree' => '1','lft' => '58','rgt' => '59','depth' => '5','slug' => 'n42'),
array('id' => '38','tree' => '1','lft' => '60','rgt' => '61','depth' => '5','slug' => 'n43'),
array('id' => '39','tree' => '1','lft' => '62','rgt' => '63','depth' => '5','slug' => 'n44'),
)
);

74
tests/data/test-insert-after-update-other-node.php

@ -0,0 +1,74 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '19','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '20','rgt' => '21','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '22','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '30','rgt' => '37','depth' => '3','slug' => 'n12'),
array('id' => '7','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '25','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '31','rgt' => '32','depth' => '4','slug' => 'n121'),
array('id' => '15','lft' => '33','rgt' => '34','depth' => '4','slug' => 'n122'),
array('id' => '16','lft' => '35','rgt' => '36','depth' => '4','slug' => 'n123'),
array('id' => '17','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '9','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '10','rgt' => '11','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '12','rgt' => '15','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '16','rgt' => '25','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '26','rgt' => '27','depth' => '1','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '13','rgt' => '14','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '17','rgt' => '18','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n44'),
)
);

72
tests/data/test-insert-after-update-same-node.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '24','rgt' => '49','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '2','rgt' => '3','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '4','rgt' => '23','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '25','rgt' => '32','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '7','rgt' => '14','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '15','rgt' => '22','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '30','rgt' => '31','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '10','rgt' => '11','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

76
tests/data/test-insert-before-insert-begin.php

@ -0,0 +1,76 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','lft' => '34','rgt' => '35','depth' => '3','slug' => 'new'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '30','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '13','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '14','rgt' => '15','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '16','rgt' => '19','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '20','rgt' => '29','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '11','rgt' => '12','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '17','rgt' => '18','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '27','rgt' => '28','depth' => '2','slug' => 'n44'),
array('id' => '40','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'new'),
)
);

76
tests/data/test-insert-before-insert-middle.php

@ -0,0 +1,76 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '29','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '30','rgt' => '31','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '32','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '20','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '21','rgt' => '28','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '33','rgt' => '34','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '35','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','lft' => '16','rgt' => '17','depth' => '3','slug' => 'new'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '30','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '13','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '14','rgt' => '15','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '16','rgt' => '19','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '20','rgt' => '29','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '11','rgt' => '12','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '17','rgt' => '18','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '27','rgt' => '28','depth' => '2','slug' => 'n44'),
array('id' => '40','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'new'),
)
);

72
tests/data/test-insert-before-update-another-tree.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '78','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '55','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '56','rgt' => '57','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '58','rgt' => '77','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '46','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '47','rgt' => '54','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '59','rgt' => '60','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '61','rgt' => '68','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '69','rgt' => '76','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '50','rgt' => '51','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '52','rgt' => '53','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '62','rgt' => '63','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '64','rgt' => '65','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '66','rgt' => '67','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '70','rgt' => '71','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '72','rgt' => '73','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '74','rgt' => '75','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '1','lft' => '14','rgt' => '41','depth' => '3','slug' => 'r2'),
array('id' => '27','tree' => '1','lft' => '15','rgt' => '24','depth' => '4','slug' => 'n1'),
array('id' => '28','tree' => '1','lft' => '25','rgt' => '26','depth' => '4','slug' => 'n2'),
array('id' => '29','tree' => '1','lft' => '27','rgt' => '30','depth' => '4','slug' => 'n3'),
array('id' => '30','tree' => '1','lft' => '31','rgt' => '40','depth' => '4','slug' => 'n4'),
array('id' => '31','tree' => '1','lft' => '16','rgt' => '17','depth' => '5','slug' => 'n11'),
array('id' => '32','tree' => '1','lft' => '18','rgt' => '19','depth' => '5','slug' => 'n12'),
array('id' => '33','tree' => '1','lft' => '20','rgt' => '21','depth' => '5','slug' => 'n13'),
array('id' => '34','tree' => '1','lft' => '22','rgt' => '23','depth' => '5','slug' => 'n14'),
array('id' => '35','tree' => '1','lft' => '28','rgt' => '29','depth' => '5','slug' => 'n31'),
array('id' => '36','tree' => '1','lft' => '32','rgt' => '33','depth' => '5','slug' => 'n41'),
array('id' => '37','tree' => '1','lft' => '34','rgt' => '35','depth' => '5','slug' => 'n42'),
array('id' => '38','tree' => '1','lft' => '36','rgt' => '37','depth' => '5','slug' => 'n43'),
array('id' => '39','tree' => '1','lft' => '38','rgt' => '39','depth' => '5','slug' => 'n44'),
)
);

72
tests/data/test-insert-before-update-other-node.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '35','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '36','rgt' => '37','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '38','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '26','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '27','rgt' => '34','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '39','rgt' => '40','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '16','rgt' => '23','depth' => '3','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '30','rgt' => '31','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '17','rgt' => '18','depth' => '4','slug' => 'n321'),
array('id' => '21','lft' => '19','rgt' => '20','depth' => '4','slug' => 'n322'),
array('id' => '22','lft' => '21','rgt' => '22','depth' => '4','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '14','rgt' => '15','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '16','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

72
tests/data/test-insert-before-update-same-node.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '22','rgt' => '47','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '48','rgt' => '49','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '2','rgt' => '21','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '23','rgt' => '30','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '31','rgt' => '38','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '39','rgt' => '46','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '5','rgt' => '12','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '13','rgt' => '20','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '10','rgt' => '11','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

10
tests/data/test-make-root-insert.php

@ -0,0 +1,10 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '2','depth' => '0','slug' => 'r'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '2','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '100','lft' => '1','rgt' => '2','depth' => '0','slug' => 'r2'),
)
);

72
tests/data/test-make-root-update.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '42','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '41','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '9','lft' => '1','rgt' => '8','depth' => '0','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '9','lft' => '2','rgt' => '3','depth' => '1','slug' => 'n321'),
array('id' => '21','tree' => '9','lft' => '4','rgt' => '5','depth' => '1','slug' => 'n322'),
array('id' => '22','tree' => '9','lft' => '6','rgt' => '7','depth' => '1','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '18','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '100','lft' => '1','rgt' => '10','depth' => '0','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '2','rgt' => '3','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '4','rgt' => '7','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '8','rgt' => '17','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '100','lft' => '2','rgt' => '3','depth' => '1','slug' => 'n11'),
array('id' => '32','tree' => '100','lft' => '4','rgt' => '5','depth' => '1','slug' => 'n12'),
array('id' => '33','tree' => '100','lft' => '6','rgt' => '7','depth' => '1','slug' => 'n13'),
array('id' => '34','tree' => '100','lft' => '8','rgt' => '9','depth' => '1','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '11','rgt' => '12','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '13','rgt' => '14','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n44'),
)
);

77
tests/data/test-prepend-to-insert-in-empty.php

@ -0,0 +1,77 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '29','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '30','rgt' => '31','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '32','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '20','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '21','rgt' => '28','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '33','rgt' => '34','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '35','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '17','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','lft' => '15','rgt' => '16','depth' => '4','slug' => 'new'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '29','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '30','rgt' => '31','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '32','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '20','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '21','rgt' => '28','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '33','rgt' => '34','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '35','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '17','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
array('id' => '40','tree' => '1','lft' => '15','rgt' => '16','depth' => '4','slug' => 'new'),
)
);

77
tests/data/test-prepend-to-insert-in-no-empty.php

@ -0,0 +1,77 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '4','rgt' => '29','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '30','rgt' => '31','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '32','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '5','rgt' => '12','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '13','rgt' => '20','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '21','rgt' => '28','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '33','rgt' => '34','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '35','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '10','rgt' => '11','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','lft' => '2','rgt' => '3','depth' => '1','slug' => 'new'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '52','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '4','rgt' => '29','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '30','rgt' => '31','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '32','rgt' => '51','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '5','rgt' => '12','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '13','rgt' => '20','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '21','rgt' => '28','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '33','rgt' => '34','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '35','rgt' => '42','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '10','rgt' => '11','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
array('id' => '40','tree' => 1,'lft' => '2','rgt' => '3','depth' => '1','slug' => 'new'),
)
);

72
tests/data/test-prepend-to-update-another-tree.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '60','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '59','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '41','rgt' => '42','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '43','rgt' => '50','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '51','rgt' => '58','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '48','rgt' => '49','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '52','rgt' => '53','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '54','rgt' => '55','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '56','rgt' => '57','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '18','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '1','lft' => '31','rgt' => '40','depth' => '2','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '1','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n41'),
array('id' => '37','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n42'),
array('id' => '38','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n43'),
array('id' => '39','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n44'),
)
);

73
tests/data/test-prepend-to-update-deep.php

@ -0,0 +1,73 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '2','rgt' => '35','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '36','rgt' => '37','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '38','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '34','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '39','rgt' => '40','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '23','rgt' => '30','depth' => '4','slug' => 'n33'),
array('id' => '11','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '31','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '24','rgt' => '25','depth' => '5','slug' => 'n331'),
array('id' => '24','lft' => '26','rgt' => '27','depth' => '5','slug' => 'n332'),
array('id' => '25','lft' => '28','rgt' => '29','depth' => '5','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '2','rgt' => '35','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '36','rgt' => '37','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '38','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '3','rgt' => '10','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '34','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '39','rgt' => '40','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '23','rgt' => '30','depth' => '4','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '4','rgt' => '5','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '31','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '24','rgt' => '25','depth' => '5','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '26','rgt' => '27','depth' => '5','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '28','rgt' => '29','depth' => '5','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

72
tests/data/test-prepend-to-update-out.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '10','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '2','rgt' => '9','depth' => '1','slug' => 'n12'),
array('id' => '7','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n121'),
array('id' => '15','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n122'),
array('id' => '16','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n123'),
array('id' => '17','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '10','rgt' => '27','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '28','rgt' => '29','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '30','rgt' => '49','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '11','rgt' => '18','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '2','rgt' => '9','depth' => '1','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '19','rgt' => '26','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '31','rgt' => '32','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '33','rgt' => '40','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '41','rgt' => '48','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '12','rgt' => '13','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '20','rgt' => '21','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '22','rgt' => '23','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '38','rgt' => '39','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '46','rgt' => '47','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

72
tests/data/test-prepend-to-update-same-node.php

@ -0,0 +1,72 @@
<?php
return array(
'tree' => array(
array('id' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','lft' => '22','rgt' => '47','depth' => '1','slug' => 'n1'),
array('id' => '3','lft' => '48','rgt' => '49','depth' => '1','slug' => 'n2'),
array('id' => '4','lft' => '2','rgt' => '21','depth' => '1','slug' => 'n3'),
array('id' => '5','lft' => '23','rgt' => '30','depth' => '2','slug' => 'n11'),
array('id' => '6','lft' => '31','rgt' => '38','depth' => '2','slug' => 'n12'),
array('id' => '7','lft' => '39','rgt' => '46','depth' => '2','slug' => 'n13'),
array('id' => '8','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n31'),
array('id' => '9','lft' => '5','rgt' => '12','depth' => '2','slug' => 'n32'),
array('id' => '10','lft' => '13','rgt' => '20','depth' => '2','slug' => 'n33'),
array('id' => '11','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n111'),
array('id' => '12','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n112'),
array('id' => '13','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n113'),
array('id' => '14','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n121'),
array('id' => '15','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n122'),
array('id' => '16','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n123'),
array('id' => '17','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n131'),
array('id' => '18','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n132'),
array('id' => '19','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n133'),
array('id' => '20','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n321'),
array('id' => '21','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n322'),
array('id' => '22','lft' => '10','rgt' => '11','depth' => '3','slug' => 'n323'),
array('id' => '23','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n331'),
array('id' => '24','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n332'),
array('id' => '25','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n333'),
),
'multiple_tree' => array(
array('id' => '1','tree' => '1','lft' => '1','rgt' => '50','depth' => '0','slug' => 'r1'),
array('id' => '2','tree' => '1','lft' => '22','rgt' => '47','depth' => '1','slug' => 'n1'),
array('id' => '3','tree' => '1','lft' => '48','rgt' => '49','depth' => '1','slug' => 'n2'),
array('id' => '4','tree' => '1','lft' => '2','rgt' => '21','depth' => '1','slug' => 'n3'),
array('id' => '5','tree' => '1','lft' => '23','rgt' => '30','depth' => '2','slug' => 'n11'),
array('id' => '6','tree' => '1','lft' => '31','rgt' => '38','depth' => '2','slug' => 'n12'),
array('id' => '7','tree' => '1','lft' => '39','rgt' => '46','depth' => '2','slug' => 'n13'),
array('id' => '8','tree' => '1','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n31'),
array('id' => '9','tree' => '1','lft' => '5','rgt' => '12','depth' => '2','slug' => 'n32'),
array('id' => '10','tree' => '1','lft' => '13','rgt' => '20','depth' => '2','slug' => 'n33'),
array('id' => '11','tree' => '1','lft' => '24','rgt' => '25','depth' => '3','slug' => 'n111'),
array('id' => '12','tree' => '1','lft' => '26','rgt' => '27','depth' => '3','slug' => 'n112'),
array('id' => '13','tree' => '1','lft' => '28','rgt' => '29','depth' => '3','slug' => 'n113'),
array('id' => '14','tree' => '1','lft' => '32','rgt' => '33','depth' => '3','slug' => 'n121'),
array('id' => '15','tree' => '1','lft' => '34','rgt' => '35','depth' => '3','slug' => 'n122'),
array('id' => '16','tree' => '1','lft' => '36','rgt' => '37','depth' => '3','slug' => 'n123'),
array('id' => '17','tree' => '1','lft' => '40','rgt' => '41','depth' => '3','slug' => 'n131'),
array('id' => '18','tree' => '1','lft' => '42','rgt' => '43','depth' => '3','slug' => 'n132'),
array('id' => '19','tree' => '1','lft' => '44','rgt' => '45','depth' => '3','slug' => 'n133'),
array('id' => '20','tree' => '1','lft' => '6','rgt' => '7','depth' => '3','slug' => 'n321'),
array('id' => '21','tree' => '1','lft' => '8','rgt' => '9','depth' => '3','slug' => 'n322'),
array('id' => '22','tree' => '1','lft' => '10','rgt' => '11','depth' => '3','slug' => 'n323'),
array('id' => '23','tree' => '1','lft' => '14','rgt' => '15','depth' => '3','slug' => 'n331'),
array('id' => '24','tree' => '1','lft' => '16','rgt' => '17','depth' => '3','slug' => 'n332'),
array('id' => '25','tree' => '1','lft' => '18','rgt' => '19','depth' => '3','slug' => 'n333'),
array('id' => '26','tree' => '26','lft' => '1','rgt' => '28','depth' => '0','slug' => 'r2'),
array('id' => '27','tree' => '26','lft' => '2','rgt' => '11','depth' => '1','slug' => 'n1'),
array('id' => '28','tree' => '26','lft' => '12','rgt' => '13','depth' => '1','slug' => 'n2'),
array('id' => '29','tree' => '26','lft' => '14','rgt' => '17','depth' => '1','slug' => 'n3'),
array('id' => '30','tree' => '26','lft' => '18','rgt' => '27','depth' => '1','slug' => 'n4'),
array('id' => '31','tree' => '26','lft' => '3','rgt' => '4','depth' => '2','slug' => 'n11'),
array('id' => '32','tree' => '26','lft' => '5','rgt' => '6','depth' => '2','slug' => 'n12'),
array('id' => '33','tree' => '26','lft' => '7','rgt' => '8','depth' => '2','slug' => 'n13'),
array('id' => '34','tree' => '26','lft' => '9','rgt' => '10','depth' => '2','slug' => 'n14'),
array('id' => '35','tree' => '26','lft' => '15','rgt' => '16','depth' => '2','slug' => 'n31'),
array('id' => '36','tree' => '26','lft' => '19','rgt' => '20','depth' => '2','slug' => 'n41'),
array('id' => '37','tree' => '26','lft' => '21','rgt' => '22','depth' => '2','slug' => 'n42'),
array('id' => '38','tree' => '26','lft' => '23','rgt' => '24','depth' => '2','slug' => 'n43'),
array('id' => '39','tree' => '26','lft' => '25','rgt' => '26','depth' => '2','slug' => 'n44'),
)
);

61
tests/migrations/TestMigration.php

@ -0,0 +1,61 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\migrations;
use yii\db\Schema;
use yii\db\Migration;
/**
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class TestMigration extends Migration
{
public function up()
{
ob_start();
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
// tree
if ($this->db->getTableSchema('{{%tree}}', true) !== null) {
$this->dropTable('{{%tree}}');
}
$this->createTable('{{%tree}}', [
'id' => Schema::TYPE_PK,
'lft' => Schema::TYPE_INTEGER . ' NOT NULL',
'rgt' => Schema::TYPE_INTEGER . ' NOT NULL',
'depth' => Schema::TYPE_INTEGER . ' NOT NULL',
'slug' => Schema::TYPE_STRING . ' NOT NULL',
], $tableOptions);
$this->createIndex('lft1', '{{%tree}}', ['lft', 'rgt']);
$this->createIndex('rgt1', '{{%tree}}', ['rgt']);
// multiple tree
if ($this->db->getTableSchema('{{%multiple_tree}}', true) !== null) {
$this->dropTable('{{%multiple_tree}}');
}
$this->createTable('{{%multiple_tree}}', [
'id' => Schema::TYPE_PK,
'tree' => Schema::TYPE_INTEGER . ' NULL',
'lft' => Schema::TYPE_INTEGER . ' NOT NULL',
'rgt' => Schema::TYPE_INTEGER . ' NOT NULL',
'depth' => Schema::TYPE_INTEGER . ' NOT NULL',
'slug' => Schema::TYPE_STRING . ' NOT NULL',
], $tableOptions);
$this->createIndex('lft2', '{{%multiple_tree}}', ['tree', 'lft', 'rgt']);
$this->createIndex('rgt2', '{{%multiple_tree}}', ['tree', 'rgt']);
// update cache (sqlite bug)
$this->db->getSchema()->getTableSchema('{{%tree}}', true);
$this->db->getSchema()->getTableSchema('{{%multiple_tree}}', true);
ob_end_clean();
}
}

74
tests/models/MultipleTreeNode.php

@ -0,0 +1,74 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\models;
use paulzi\nestedsets\NestedSetsBehavior;
/**
* @author PaulZi <pavel.zimakoff@gmail.com>
*
* @property integer $id
* @property integer $tree
* @property integer $lft
* @property integer $rgt
* @property integer $depth
* @property string $slug
*
* @property Node[] $parents
* @property Node $parent
* @property Node $root
* @property Node[] $descendants
* @property Node[] $children
* @property Node[] $leaves
* @property Node $prev
* @property Node $next
*
* @method static MultipleTreeNode|null findOne() findOne($condition)
*
* @mixin NestedSetsBehavior
*/
class MultipleTreeNode extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%multiple_tree}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => NestedSetsBehavior::className(),
'treeAttribute' => 'tree',
],
];
}
/**
* @inheritdoc
*/
public function transactions()
{
return [
self::SCENARIO_DEFAULT => self::OP_ALL,
];
}
/**
* @return NodeQuery
*/
public static function find()
{
return new NodeQuery(get_called_class());
}
}

72
tests/models/Node.php

@ -0,0 +1,72 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\models;
use paulzi\nestedsets\NestedSetsBehavior;
/**
* @author PaulZi <pavel.zimakoff@gmail.com>
*
* @property integer $id
* @property integer $lft
* @property integer $rgt
* @property integer $depth
* @property string $slug
*
* @property Node[] $parents
* @property Node $parent
* @property Node $root
* @property Node[] $descendants
* @property Node[] $children
* @property Node[] $leaves
* @property Node $prev
* @property Node $next
*
* @method static Node|null findOne() findOne($condition)
*
* @mixin NestedSetsBehavior
*/
class Node extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%tree}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => NestedSetsBehavior::className(),
],
];
}
/**
* @inheritdoc
*/
public function transactions()
{
return [
self::SCENARIO_DEFAULT => self::OP_ALL,
];
}
/**
* @return NodeQuery
*/
public static function find()
{
return new NodeQuery(get_called_class());
}
}

18
tests/models/NodeQuery.php

@ -0,0 +1,18 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\models;
use paulzi\nestedsets\NestedSetsQueryTrait;
/**
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NodeQuery extends \yii\db\ActiveQuery
{
use NestedSetsQueryTrait;
}

20
tests/mysql/NestedSetsBehaviorTest.php

@ -0,0 +1,20 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\mysql;
use paulzi\nestedsets\tests\NestedSetsBehaviorTestCase;
/**
* @group mysql
*
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NestedSetsBehaviorTest extends NestedSetsBehaviorTestCase
{
protected static $driverName = 'mysql';
}

20
tests/mysql/NestedSetsQueryTraitTest.php

@ -0,0 +1,20 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\mysql;
use paulzi\nestedsets\tests\NestedSetsQueryTraitTestCase;
/**
* @group mysql
*
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NestedSetsQueryTraitTest extends NestedSetsQueryTraitTestCase
{
protected static $driverName = 'mysql';
}

20
tests/pgsql/NestedSetsBehaviorTest.php

@ -0,0 +1,20 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\pgsql;
use paulzi\nestedsets\tests\NestedSetsBehaviorTestCase;
/**
* @group pgsql
*
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NestedSetsBehaviorTest extends NestedSetsBehaviorTestCase
{
protected static $driverName = 'pgsql';
}

20
tests/pgsql/NestedSetsQueryTraitTest.php

@ -0,0 +1,20 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\pgsql;
use paulzi\nestedsets\tests\NestedSetsQueryTraitTestCase;
/**
* @group pgsql
*
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NestedSetsQueryTraitTest extends NestedSetsQueryTraitTestCase
{
protected static $driverName = 'pgsql';
}

20
tests/sqlite/NestedSetsBehaviorTest.php

@ -0,0 +1,20 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\sqlite;
use paulzi\nestedsets\tests\NestedSetsBehaviorTestCase;
/**
* @group sqlite
*
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NestedSetsBehaviorTest extends NestedSetsBehaviorTestCase
{
protected static $driverName = 'sqlite';
}

20
tests/sqlite/NestedSetsQueryTraitTest.php

@ -0,0 +1,20 @@
<?php
/**
* @link https://github.com/paulzi/yii2-nested-sets
* @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
* @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
*/
namespace paulzi\nestedsets\tests\sqlite;
use paulzi\nestedsets\tests\NestedSetsQueryTraitTestCase;
/**
* @group sqlite
*
* @author PaulZi <pavel.zimakoff@gmail.com>
*/
class NestedSetsQueryTraitTest extends NestedSetsQueryTraitTestCase
{
protected static $driverName = 'sqlite';
}
Loading…
Cancel
Save