Exemplo n.º 1
0
 /**
  * Prepares an Entity for use in the application.
  * 
  * @param \Rawebone\Ormish\Entity $entity
  * @param \Rawebone\Ormish\GatewayInterface $gateway
  * @param \Rawebone\Ormish\Database $db
  * @param boolean $readOnly
  */
 public function prepare(Entity $entity, GatewayInterface $gateway, Database $db, $readOnly)
 {
     $shadow = (bool) $readOnly ? new NullShadow() : new Shadow();
     $shadow->update($entity->all());
     $entity->letDatabase($db);
     $entity->letShadow($shadow);
     $entity->letGateway($gateway);
 }
Exemplo n.º 2
0
 /**
  * @param \Rawebone\Ormish\Entity $ent
  * @param \Rawebone\Ormish\Table $tbl
  * @param \Rawebone\Ormish\SqlGeneratorInterface $gen
  * @param \Rawebone\Ormish\Executor $ex
  */
 function it_should_try_to_update_and_fail($ent, $tbl, $gen, $ex)
 {
     $tbl->readOnly()->willReturn(false);
     $tbl->id()->willReturn("id");
     $tbl->table()->willReturn("table");
     $ent->id = 1;
     $ent->changes()->willReturn(array());
     $gen->update("table", array(), "id", 1)->willReturn(array("query", array()));
     $ex->exec("query", array())->willThrow(new ExecutionException("", "", "", array()));
     $this->run($ent)->shouldReturn(false);
 }
Exemplo n.º 3
0
 function it_should_prepare_an_entity_with_a_real_shadow(Entity $ent, GatewayInterface $gate, Database $db)
 {
     $readOnly = false;
     $ent->all()->willReturn(array())->shouldBeCalled();
     $ent->letDatabase($db)->shouldBeCalled();
     $ent->letGateway($gate)->shouldBeCalled();
     $ent->letShadow(Argument::type('Rawebone\\Ormish\\Utilities\\Shadow'))->shouldBeCalled();
     $this->prepare($ent, $gate, $db, $readOnly);
 }
Exemplo n.º 4
0
 protected function tryUpdate($id, Entity $entity)
 {
     list($query, $params) = $this->generator->update($this->table->table(), $entity->changes(), $id, $entity->{$id});
     $this->executor->exec($query, $params);
 }