Esempio n. 1
0
 function testRelationRemoval()
 {
     $usr1 = new Entity\User();
     $usr2 = new Entity\User();
     $rel = new Entity\FriendsWith();
     $usr1->setFirstName('Arnold');
     $usr1->setLastName('Schwarzenegger');
     $usr1->setTestId($this->id);
     $usr2->setFirstName('Sean');
     $usr2->setLastName('Connery');
     $usr2->setTestId($this->id);
     $rel->setTo($usr2);
     $rel->setFrom($usr1);
     $rel->setSince("1989");
     ArachnidTest::$arachnid->persist($rel);
     ArachnidTest::$arachnid->flush();
     //Get the relation with everyman
     $id = $this->id;
     $queryString = "MATCH (n {firstName:'Arnold', testId:'{$id}'})-[r {since:'1989'}]->(m {firstName:'Sean'}) RETURN r;";
     $query = new EM_QUERY(ArachnidTest::$arachnid->getClient(), $queryString);
     $d = $query->getResultSet();
     //Check the property
     $i = 0;
     foreach ($d as $row) {
         //Check the since property
         $this->assertEquals($row['x']->getProperty("since"), "1989");
         $i++;
     }
     $this->assertEquals(1, $i);
     //Get relation
     $rel = ArachnidTest::$arachnid->reload($rel);
     //Remove it
     $t = microtime(true);
     ArachnidTest::$arachnid->remove($rel);
     ArachnidTest::$arachnid->flush();
     $this->printTime(__FUNCTION__, microtime(true) - $t);
     //Query for it again
     $id = $this->id;
     $queryString = "MATCH (n {firstName:'Arnold', testId:'{$id}'})-[r {since:'1989'}]->(m {firstName:'Sean'}) RETURN r;";
     $query = new EM_QUERY(ArachnidTest::$arachnid->getClient(), $queryString);
     $d = $query->getResultSet();
     //Check the property
     foreach ($d as $row) {
         $this->fail();
     }
 }
Esempio n. 2
0
 function testRelationFindByEndNodeCriteria()
 {
     $mov1 = new Entity\User();
     $mov1->setFirstName('Simon');
     $mov1->setLastName('Cowell');
     $mov1->setTestId($this->id);
     $mov2 = new Entity\User();
     $mov2->setFirstName('Tiger');
     $mov2->setLastName('Woods');
     $mov2->setTestId($this->id);
     $rel1 = new Entity\FriendsWith();
     $rel1->setTo($mov1);
     $rel1->setFrom($mov2);
     $rel1->setSince("2058");
     $rel2 = new Entity\FriendsWith();
     $rel2->setTo($mov1);
     $rel2->setFrom($mov2);
     $rel2->setSince("2059");
     self::$arachnid->persist($rel1);
     self::$arachnid->persist($rel2);
     self::$arachnid->flush();
     //Grab simon
     $simon = self::$arachnid->reload($mov1);
     $t = microtime(true);
     //Find his sibling relation
     $rels = self::$arachnid->getRepository('LRezek\\Arachnid\\Tests\\Entity\\FriendsWith')->findBy(array('to' => $simon))->toArray();
     $this->printTime(__FUNCTION__, microtime(true) - $t);
     $this->assertEquals(count($rels), 2);
 }