tests
[m6w6/pq-gateway] / tests / lib / pq / Gateway / RowsetTest.php
index c0ff003b204df80f8bd613d3946c077d1fd2b259..7ef1a0eb21721a374ba36b41c59108197b08b387 100644 (file)
@@ -70,6 +70,13 @@ class RowsetTest extends \PHPUnit_Framework_TestCase {
                $this->assertCount(1, $rowset);
                $this->assertCount(4, $this->table->find());
        }
+       
+       public function testCreateFail() {
+               $this->setExpectedException("\\pq\\Exception");
+               $rowset = new Rowset($this->table);
+               $rowset->append(new Row($this->table, array("foo" => "bar"), true));
+               $rowset->create();
+       }
 
        public function testUpdate() {
                $rowset = $this->table->find();
@@ -83,11 +90,27 @@ class RowsetTest extends \PHPUnit_Framework_TestCase {
                });
        }
 
+       public function testUpdateFail() {
+               $this->setExpectedException("pq\\Exception");
+               $rowset = $this->table->find();
+               $rowset->apply(function($row) {
+                       $row->data = new \pq\Query\Expr("die");
+               });
+               $rowset->update();
+               
+       }
+
        public function testDelete() {
                $this->table->find()->delete();
                $this->assertCount(0, $this->table->find());
        }
 
+       public function testDeleteFail() {
+               $this->setExpectedException("pq\\Exception");
+               $rowset = new Rowset($this->table);
+               $rowset->append(new Row($this->table, array("xx" => 0)))->delete();
+       }
+
        public function testJsonSerialize() {
                $json = sprintf('[{"id":"1","created":"%s","counter":"-1","number":"-1.1","data":"yesterday"}'
                        .',{"id":"2","created":"%s","counter":"0","number":"0","data":"today"}'