Exemplo n.º 1
0
 public function testSaveRelationship_UpdateTransportError_ThrowsException()
 {
     $properties = array('foo' => 'bar', 'baz' => 'qux');
     $rel = new Relationship($this->client);
     $rel->useLazyLoad(false)->setId(123)->setProperties($properties);
     $this->transport->expects($this->once())->method('put')->with('/relationship/123/properties', $properties)->will($this->returnValue(array('code' => 400)));
     $this->setExpectedException('Everyman\\Neo4j\\Exception');
     $this->client->saveRelationship($rel);
 }
Exemplo n.º 2
0
 /**
  * Fill a relationship with data
  *
  * @param Relationship $rel
  * @param array $data
  * @return Relationship
  */
 public function populateRelationship(Relationship $rel, $data)
 {
     $rel->useLazyLoad(false);
     $rel->setProperties($data['data']);
     $rel->setType($data['type']);
     $rel->setStartNode($this->getNodeFromUri($data['start']));
     $rel->setEndNode($this->getNodeFromUri($data['end']));
     return $rel;
 }
Exemplo n.º 3
0
 public function testSaveRelationship_Failure_RelationshipNotInCache()
 {
     $relId = 123;
     $rel = new Relationship($this->client);
     $rel->useLazyLoad(false)->setId($relId);
     $this->transport->expects($this->once())->method('put')->with('/relationship/123/properties', array())->will($this->returnValue(array('code' => 400)));
     try {
         $this->client->saveRelationship($rel);
         $this->fail();
     } catch (Exception $e) {
         $this->assertFalse($this->cache->get("relationship-{$relId}"));
     }
 }
 public function testCommitBatch_UpdateRelationship_Success_ReturnsTrue()
 {
     $rel = new Relationship($this->client);
     $rel->useLazyLoad(false)->setId(123)->setProperties(array('foo' => 'bar', 'baz' => 'qux'));
     $request = array(array('id' => 0, 'method' => 'PUT', 'to' => '/relationship/123/properties', 'body' => array('foo' => 'bar', 'baz' => 'qux')));
     $return = array('code' => 200, 'data' => array(array('id' => 0)));
     $this->batch->save($rel);
     $this->setupTransportExpectation($request, $this->returnValue($return));
     $result = $this->client->commitBatch($this->batch);
     $this->assertTrue($result);
     $this->assertSame($rel, $this->client->getEntityCache()->getCachedEntity(123, 'relationship'));
 }