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

testShouldMoveNodeAsFirst() public method

Move node as first
Since: 2016-02-28
Author: Serghei Iakovlev ([email protected])
    public function testShouldMoveNodeAsFirst()
    {
        $this->specify('Unable to move nodes correctly by using moveAsFirst', function () {
            $this->createTree();
            $mercedes = CategoriesManyRoots::findFirst(3);
            $samsung = CategoriesManyRoots::findFirst(6);
            $x100 = new CategoriesManyRoots();
            $x100->name = 'X100';
            $x100->appendTo($mercedes);
            $c200 = new CategoriesManyRoots();
            $c200->name = 'C200';
            $c200->prependTo($mercedes);
            $expected = ['Cars', '     Audi', '     Ford', '     Mercedes', '          C200', '          X100', 'Mobile Phones', '     iPhone', '     Samsung', '     Motorola'];
            expect($this->prettifyRoots())->equals($expected);
            $c200->moveAsFirst($samsung);
            $x100->moveAsFirst($samsung);
            $expected = ['Cars', '     Audi', '     Ford', '     Mercedes', 'Mobile Phones', '     iPhone', '     Samsung', '          X100', '          C200', '     Motorola'];
            expect($this->prettifyRoots())->equals($expected);
            $this->checkIntegrity(CategoriesManyRoots::findFirst(1)->root);
            // cars
            $this->checkIntegrity(CategoriesManyRoots::findFirst(5)->root);
            // phones
        });
    }