Beispiel #1
0
 /**
  * @param \Rawebone\Ormish\Table $tbl
  * @param \Rawebone\Ormish\SqlGeneratorInterface $gen
  * @param \Rawebone\Ormish\Executor $ex
  */
 function it_should_include_additional_params($tbl, $gen, $ex)
 {
     $tbl->table()->willReturn("table");
     $gen->findWhere("table", "a = ?")->willReturn("query");
     $ex->query("query", array(1))->willThrow(new ExecutionException("", "", "", array()));
     $this->run("a = ?", 1)->shouldReturn(array());
 }
Beispiel #2
0
 function it_should_fail(Executor $executor)
 {
     $executor->beginTransaction()->shouldBeCalled();
     $executor->rollback()->shouldBeCalled();
     $this->beConstructedWith($executor, function () {
         throw new \Exception();
     });
     $this->shouldThrow('Exception')->during('run');
 }
Beispiel #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);
 }
Beispiel #4
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);
 }