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

testShouldDetectRoots() public method

Getting all roots
Since: 2016-02-28
Author: Serghei Iakovlev ([email protected])
    public function testShouldDetectRoots()
    {
        $this->specify("Model can't determine roots correctly", function () {
            expect((new CategoriesManyRoots())->roots())->count(0);
            $category1 = new CategoriesManyRoots();
            $category1->name = 'Mobile Phones';
            $category1->saveNode();
            expect($category1->roots())->count(1);
            $category2 = new CategoriesManyRoots();
            $category2->name = 'Cars';
            $category2->saveNode();
            expect($category2->roots())->count(2);
            expect($category2->roots())->isInstanceOf('Phalcon\\Mvc\\Model\\Resultset\\Simple');
            $this->checkIntegrity($category1->root);
            $this->checkIntegrity($category2->root);
        });
    }