$em = Project::srvc('EntityManager');
     $repo = $em->getRepository('OrderedItem\\ExampleEntities\\OrderedItemWithParentRelation');
     $f1 = $repo->find($fixtureIds[0]);
     $f2 = $repo->find($fixtureIds[1]);
     $f3 = $repo->find($fixtureIds[2]);
     $repo->addBefore($f3, $f1);
     $em->flush();
     $em->clear();
     $parent = $repo->find($f1->getParent()->getId());
     $all = $repo->findAllByParent($parent);
     expect($all[0]->getid())->should('be equals', $f3->getId());
     expect($all[1]->getid())->should('be equals', $f1->getId());
     expect($all[2]->getid())->should('be equals', $f2->getId());
 });
 it('should move to another parent', function () use(&$fixtureIds) {
     $em = Project::srvc('EntityManager');
     $repo = $em->getRepository('OrderedItem\\ExampleEntities\\OrderedItemWithParentRelation');
     $parent2 = OrderedItemWithParentRelation::build('parent2', null);
     $repo->addLast($parent2);
     $em->flush();
     $fixture2Ids = OrderedItemWithParentRelationFixtures::threeItems($em, $parent2);
     $f_1 = $repo->find($fixtureIds[1]);
     $f2_1 = $repo->find($fixture2Ids[1]);
     $em->flush();
     $em->clear();
     $parent = $repo->find($parent2->getId());
     $f_1->setParent($parent);
     // needs to clear the repo before calling add last to test the query to find the max position.
     $repo->addLast($f_1);
     $children = $repo->findAllByParent($parent);
     expect(count($children))->should('be equals', 4);
Exemplo n.º 2
0
<?php

use PSpec\PSpecSuite, Project\Project;
require_once __DIR__ . "/../../../class_loaders.php";
Project::init('test');
PSpecSuite::instance('../../../vendor_lib/pspec/')->addParameters($_GET)->addListener(Project::srvc('DoctrineSqlLogger'))->setSpec(__DIR__ . '/specs/OrderedItem.spec.php')->runAndReport();