/** * @dataProvider eventNameProvider * @param $eventName */ public function testGetSet($eventName) { $className = 'HireVoice\\Neo4j\\Event\\' . ucfirst($eventName); $city = new City(); $city->setName('Zurich'); $event = new $className($city); $this->assertSame($event->getEntity(), $city); $movie = new Movie(); $movie->setTitle('Terminator'); $event->setEntity($movie); $this->assertSame($event->getEntity(), $movie); $this->assertSame($event->getEventName(), $eventName); }
public function testRelationRemove() { $eventManager = $this->getEventManagerWithListenerExpectations(array('prePersist' => 3, 'postPersist' => 3, 'preRelationCreate' => 1, 'postRelationCreate' => 1, 'preRelationRemove' => 1, 'postRelationRemove' => 1)); $movie = new Entity\Movie(); $movie->setTitle('Terminator'); $actor = new Entity\Person(); $actor->setFirstName('Arnold'); $movie->addActor($actor); $this->em->setEventManager($eventManager); $this->em->persist($movie); $this->em->flush(); $movie = $this->em->find(get_class($movie), $movie->getId()); $actor = $movie->getActors()->first(); $movie->removeActor($actor); $this->em->persist($movie); $this->em->flush(); }
public function testChildAttribValue() { $em = $this->getEntityManager(); $movie = new Entity\Movie(); $movie->setTitle('Army of Darkness'); $cinema = new Entity\Cinema(); $cinema->setName('Nuovo Cinema paradiso'); $cinema->addPresentedMovie($movie); $multiplex = new Entity\Multiplex(); $multiplex->setName('Multisala Portanova'); $multiplex->addPresentedMovie($movie); $multiplex->setRooms(5); $em->persist($multiplex); $em->flush(); $id = $multiplex->getId(); $mp = $em->getRepository('HireVoice\\Neo4j\\Tests\\Entity\\Multiplex')->findOneBy(array('id' => $id)); $this->assertEquals(5, $mp->getRooms()); }
function setUp() { if (!self::$root) { $aragorn = new Entity\Person(); $aragorn->setFirstName('Viggo'); $aragorn->setLastName('Mortensen'); $legolas = new Entity\Person(); $legolas->setFirstName('Orlando'); $legolas->setLastName('Bloom'); $root = new Entity\Movie(); $root->setTitle('Return of the king'); $root->addActor($aragorn); $root->addActor($legolas); self::$root = $root; self::$aragorn = $aragorn; self::$legolas = $legolas; $em = $this->getEntityManager(); $em->persist($root); $em->flush(); } }
/** * @dataProvider eventNameProvider * @param $eventName */ public function testGetSet($eventName) { $className = 'HireVoice\\Neo4j\\Event\\' . ucfirst($eventName); $movie = new Movie(); $movie->setTitle('Terminator'); $cinema = new Cinema(); $cinema->setName('Cinedome'); $cinema->addPresentedMovie($movie); $client = $this->getMockBuilder('Everyman\\Neo4j\\Client')->disableAutoload()->disableOriginalConstructor()->getMock(); $relationship = new Relationship($client); $event = new $className($cinema, $movie, 'presents', $relationship); $this->assertSame($event->getFrom(), $cinema); $this->assertSame($event->getTo(), $movie); $this->assertSame($event->getName(), 'presents'); $this->assertSame($event->getRelationship(), $relationship); $event->setFrom($movie); $event->setTo($cinema); $event->setName('presented-by'); $this->assertSame($event->getFrom(), $movie); $this->assertSame($event->getTo(), $cinema); $this->assertSame($event->getName(), 'presented-by'); $this->assertSame($event->getRelationship(), $relationship); $this->assertSame($event->getEventName(), $eventName); }
/** * Check the fix of issue #54. */ function testRemoveEntity() { $entity = new Entity\Movie(); $entity->setTitle('Jules et Jim'); $em = $this->getEntityManager(); $em->persist($entity); $em->flush(); $em->remove($entity); $em->flush(); $entity2 = new Entity\Movie(); $entity2->setTitle('Rois et reine'); $em->persist($entity2); $em->flush(); // one only checks that a second flush // after a remove does not throw an exception // if not the test is ok. $this->assertTrue(true); }
function testStoreArray() { $movie = new Entity\Movie(); $movie->setTitle(array('A', 'B')); $em = $this->getEntityManager(); $em->persist($movie); $em->flush(); $movie = $em->findAny($movie->getId()); $this->assertEquals(array('A', 'B'), $movie->getTitle()); }
public function testComplexLuceneQuery() { $em = $this->getEntityManager(); $entity = new Entity\Movie(); $entity->setTitle('Game Of Thrones'); $em->persist($entity); $em->flush(); $repository = $this->getRepository(); $movie = $repository->findOneBy(array('title' => '(+*am* Of +*hron*)')); $this->assertEquals($entity->getTitle(), $movie->getTitle()); }