Exemple #1
0
 public function testInsert()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $foo['name'] = 'Foo';
     $foo->save();
     $this->assertSame('Foo', $foo['name']);
 }
Exemple #2
0
 public function testInflateUsingPrimaryKey()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $foo->save();
     $properties = $foo->getData();
     $foo = new \Sandbox\Model\String($this->db, $foo['id']);
     $this->assertSame($properties, $foo->getData());
 }
Exemple #3
0
 public function testGetAllPropertiesOfExistingObject()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $foo->save();
     $data = ['id' => null, 'name' => ''];
     $data['id'] = $foo['id'];
     $properties = $foo->getData();
     $this->assertSame($data, $properties);
 }
Exemple #4
0
 public function testDeleteExistingObject()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $foo['name'] = 'foo';
     $foo->save();
     $this->assertArrayHasKey('id', $foo);
     $foo->delete();
     $this->assertArrayNotHasKey('id', $foo);
 }
Exemple #5
0
 public function testDoNotUpdateIfValueHasNotChanged()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $foo['name'] = 'foo';
     $foo->save();
     $synchronisation_count = $foo->getSynchronisationCount();
     $foo->save();
     $this->assertSame($synchronisation_count, $foo->getSynchronisationCount());
 }
Exemple #6
0
 /**
  * @todo Check if object's state is recovered.
  * 
  * @expectedException Gajus\MOA\Exception\LogicException
  * @expectedExceptionMessage Transaction was commited before the time.
  */
 public function testAfterDeleteCannotCommitTransaction()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $foo['name'] = 'delete_commit_transaction';
     $foo->save();
     $foo->delete();
 }
Exemple #7
0
 public function testGetDatabaseHandle()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $this->assertSame($this->db, $foo->getDatabaseHandle());
 }
Exemple #8
0
 /**
  * @expectedException Gajus\MOA\Exception\ValidationException
  * @expectedExceptionMessage save_does_not_pass
  */
 public function testSaveValidationDoesNotPass()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $foo['name'] = 'save_do_not_pass';
     $foo->save();
 }
Exemple #9
0
 /**
  * @expectedException Gajus\MOA\Exception\InvalidArgumentException
  * @expectedExceptionMessage Name is not a string.
  */
 public function testSetNameNotString()
 {
     $foo = new \Sandbox\Model\String($this->db);
     $foo->set([], 'bar');
 }