Exemple #1
0
 /**
  * @covers Paradox\pod\Document::onEvent
  */
 public function testOnEventNeverCalled()
 {
     $model = $this->getMock('Paradox\\AModel');
     $model->expects($this->never())->method('afterDispense');
     $model->expects($this->never())->method('afterOpen');
     $model->expects($this->never())->method('beforeStore');
     $model->expects($this->never())->method('afterStore');
     $model->expects($this->never())->method('beforeDelete');
     $model->expects($this->never())->method('afterDelete');
     $this->document->loadModel($model);
     $anotherDocument = $this->getClient()->dispense('mycollection');
     $events = array('after_dispense', 'after_open', 'before_store', 'after_store', 'before_delete', 'after_delete');
     foreach ($events as $event) {
         $this->document->onEvent(new Event($event, $anotherDocument->getPod()));
     }
 }
Exemple #2
0
 /**
  * Instantiates the pod.
  * @param Toolbox $toolbox A reference to the toolbox that owns this pod.
  * @param array   $data    Any data that we wish to instantiate this pod with.
  * @param string  $new     Whether this pod should be marked as new (never been saved to the server).
  */
 public function __construct(Toolbox $toolbox, array $data = array(), $new = true)
 {
     parent::__construct($toolbox, "vertex", $data, $new);
 }
Exemple #3
0
 /**
  * Instantiates the pod.
  * @param Toolbox $toolbox      A reference to the toolbox that owns this pod.
  * @param array   $data         Any data that we wish to instantiate this pod with.
  * @param string  $new          Whether this pod should be marked as new (never been saved to the server).
  * @param string  $internalFrom The id (document handle) of the "from" vertex.
  * @param string  $internalTo   The id (document handle) of the "to" vertex.
  */
 public function __construct(Toolbox $toolbox, array $data = array(), $new = true, $internalFrom = null, $internalTo = null)
 {
     parent::__construct($toolbox, "edge", $data, $new);
     $this->setInternalFrom($internalFrom);
     $this->setInternalTo($internalTo);
 }
Exemple #4
0
 /**
  * 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.');
     }
 }