Exemple #1
0
 public function testExecute()
 {
     $name = uniqid();
     $income = 100;
     $p = Person::fromArray(compact('name', 'income'));
     $p->insert();
     $this->connection->execute("UPDATE person SET income = income + 1");
     $p2 = Person::get($p->id);
     $this->assertEquals(101, $p2->income);
 }
Exemple #2
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage [Phormium\Tests\Models\Person] record with primary key [12345678] does not exist.
  */
 public function testGetErrorModelDoesNotExist()
 {
     Person::get(12345678);
 }
 public function testPreparedExecuteTransaction()
 {
     $person = new Person();
     $person->name = 'Janick Gers';
     $person->income = 100;
     $person->insert();
     $id = $person->id;
     $conn = DB::getConnection('testdb');
     DB::begin();
     $conn->preparedExecute("UPDATE person SET income = ?", array(200));
     DB::rollback();
     $this->assertEquals(100, Person::get($id)->income);
     DB::begin();
     $conn->preparedExecute("UPDATE person SET income = ?", array(200));
     DB::commit();
     $this->assertEquals(200, Person::get($id)->income);
 }