Phalcon\Test\Mvc\Model\Behavior\NestedSetTest::testShouldAddChildNodes PHP Method

testShouldAddChildNodes() public method

Add nodes to the tree
Since: 2016-02-28
Author: Serghei Iakovlev ([email protected])
    public function testShouldAddChildNodes()
    {
        $this->specify('Unable to add nodes to the tree correctly', function () {
            $cars = new CategoriesManyRoots();
            $cars->name = 'Cars';
            $cars->saveNode();
            $ford = new CategoriesManyRoots();
            $ford->name = 'Ford';
            $mercedes = new CategoriesManyRoots();
            $mercedes->name = 'Mercedes';
            $audi = new CategoriesManyRoots();
            $audi->name = 'Audi';
            $ford->appendTo($cars);
            $mercedes->insertAfter($ford);
            $audi->insertBefore($ford);
            $phones = new CategoriesManyRoots();
            $phones->name = 'Mobile Phones';
            $phones->saveNode();
            $expected = ['Cars', '     Audi', '     Ford', '     Mercedes', 'Mobile Phones'];
            expect($this->prettifyRoots())->equals($expected);
            $this->checkIntegrity($cars->root);
            $this->checkIntegrity($phones->root);
        });
    }