/** * @covers Paradox\pod\Document::loadFromArray */ public function testLoadFromArray() { $array = array(); $array['_id'] = 'mycollection/123456'; $array['_rev'] = 'myrevision'; $array['_key'] = '123456'; $array['mykey'] = 'myvalue'; $this->document->loadFromArray($array); $this->assertEquals('mycollection/123456', $this->document->getId(), "The id does not match"); $this->assertEquals('myrevision', $this->document->getRevision(), "The revision does not match"); $this->assertEquals('myvalue', $this->document->get('mykey'), 'The value for "mykey" does not match'); }
/** * Convinence function that gets the document id (handle) from models, vertex pods and strings. * @param Document|AModel|string $model * @throws GraphManagerException */ protected function getVertexId($model) { if ($model instanceof AModel) { return $model->getPod()->getId(); } elseif ($model instanceof Document) { return $model->getId(); } elseif (is_string($model)) { return $model; } else { throw new GraphManagerException('$model can be either a model, a vertex pod or the id of the vertex.'); } }