Neos\ContentRepository\Tests\Functional\Domain\NodesTest::renumberingTakesUnpersistedNodeOrderChangesIntoAccount PHP Метод

renumberingTakesUnpersistedNodeOrderChangesIntoAccount() публичный Метод

The error can be reproduced in the following way: - First, create some nodes, and persist. - Then, move a node after another one, filling the LAST free sorting index between the nodes. Do NOT persist after that. - After that, try to *again* move a node to this spot. In this case, we need to *renumber* the node indices, and the system needs to take the before-moved node into account as well. The bug tested by this testcase led to wrong orderings on the floworg website in the documentation part under some circumstances.
    public function renumberingTakesUnpersistedNodeOrderChangesIntoAccount()
    {
        $rootNode = $this->context->getRootNode();
        $liveParentNode = $rootNode->createNode('parent-node');
        $nodes = [];
        $nodes[1] = $liveParentNode->createNode('node001');
        $nodes[1]->setIndex(1);
        $nodes[2] = $liveParentNode->createNode('node002');
        $nodes[2]->setIndex(2);
        $nodes[3] = $liveParentNode->createNode('node003');
        $nodes[3]->setIndex(4);
        $nodes[4] = $liveParentNode->createNode('node004');
        $nodes[4]->setIndex(5);
        $this->nodeDataRepository->persistEntities();
        $nodes[1]->moveAfter($nodes[2]);
        $nodes[3]->moveAfter($nodes[2]);
        $this->nodeDataRepository->persistEntities();
        $actualChildNodes = $liveParentNode->getChildNodes();
        $newNodeOrder = [$nodes[2], $nodes[3], $nodes[1], $nodes[4]];
        $this->assertSameOrder($newNodeOrder, $actualChildNodes);
    }
NodesTest