Example #1
0
 /**
  * @param \Rawebone\Ormish\Entity $ent
  * @param \Rawebone\Ormish\Table $tbl
  * @param \Rawebone\Ormish\SqlGeneratorInterface $gen
  * @param \Rawebone\Ormish\Executor $ex
  * @param \Rawebone\Ormish\Utilities\Populater $pop
  * @param \Rawebone\Ormish\Utilities\EntityManager $em
  * @param \Rawebone\Ormish\Database $db
  * @param \Rawebone\Ormish\GatewayInterface $gw
  */
 function it_should_find_records($ent, $tbl, $gen, $ex, $pop, $em, $db, $gw, \PDOStatement $stmt)
 {
     $tbl->table()->willReturn("table");
     $tbl->readOnly()->willReturn(true);
     $tbl->model()->willReturn("Entity");
     $gen->findWhere("table", "a = 1")->willReturn("query");
     $ex->query("query", array())->willReturn($stmt);
     $pop->populate($stmt, "Entity")->willReturn(array($ent));
     $em->prepare($ent, $gw, $db, true)->shouldBeCalled();
     $this->run("a = 1")->shouldReturn(array($ent));
 }
Example #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);
 }
Example #3
0
 /**
  * @param \Rawebone\Ormish\Table $tbl
  * @param \Rawebone\Ormish\SqlGeneratorInterface $gen
  * @param \Rawebone\Ormish\Executor $ex
  * @param \Rawebone\Ormish\Utilities\Populater $pop
  */
 function it_should_return_null_if_no_records_returned($tbl, $gen, $ex, $pop, \PDOStatement $stmt)
 {
     $tbl->table()->willReturn("table");
     $tbl->id()->willReturn("id");
     $tbl->model()->willReturn("Entity");
     $tbl->readOnly()->willReturn(true);
     $gen->find("table", "id")->willReturn("query");
     $ex->query("query", array(1))->willReturn($stmt);
     $pop->populate($stmt, "Entity")->willReturn(array());
     $this->run(1)->shouldReturn(null);
 }
Example #4
0
 /**
  * @param \Rawebone\Ormish\Utilities\EntityManager $em
  * @param \Rawebone\Ormish\Entity $ent
  * @param \Rawebone\Ormish\Table $tbl
  * @param \Rawebone\Ormish\Database $db
  */
 function it_should_return_a_new_entity_instance($em, $ent, $tbl, $db)
 {
     $entity = 'Rawebone\\Ormish\\Entity';
     $id = "id";
     $readOnly = false;
     $tbl->model()->willReturn($entity);
     $tbl->id()->willReturn($id);
     $tbl->readOnly()->willReturn($readOnly);
     $em->create($entity, $id, array())->willReturn($ent);
     $em->prepare($ent, Argument::type('Rawebone\\Ormish\\GatewayInterface'), $db, $readOnly)->shouldBeCalled();
     $this->run(array())->shouldReturn($ent);
 }