/** * @covers Centurion_Db_Table_Abstract::__call */ public function testWrongCall() { $simpleTable = new Asset_Model_DbTable_Simple(); $this->setExpectedException('Centurion_Db_Table_Exception'); //The function findOneBy (called by __call) except at least 1 parameter $simpleTable->findOneById(); }
/** * @covers Centurion_Form_Model_Validator_AlreadyTaken */ public function testValidWithParam() { $simpleTable = new Asset_Model_DbTable_Simple(); $simpleTable->all()->delete(); $row = $simpleTable->createRow(array('id' => 1, 'title' => 'test')); $row->save(); //This time we have a current record in DB, but we have filter by id > 1. So no conflict should be detected $validator = new Centurion_Form_Model_Validator_AlreadyTaken($simpleTable, 'title', array('id > 1')); $this->assertTrue($validator->isValid('test')); $simpleTable->insert(array('title' => 'test')); $this->assertFalse($validator->isValid('test')); $simpleTable->delete('title = \'test\''); $this->assertTrue($validator->isValid('test')); }
/** * @covers Centurion_Controller_Router_Route_Object::assemble * * The function assemble of Centurion_Controller_Router_Route_Object should get unknow parameter in the data array * from the object that is pass to the function. */ public function testAssemble() { $simpleTable = new Asset_Model_DbTable_Simple(); $row = $simpleTable->createRow(); $row->id = 1; $row->title = 'test'; $pattern = '/:id/:title'; $route = new Centurion_Controller_Router_Route_Object($pattern); $this->assertEquals('1/test', $route->assemble(array('object' => $row))); try { $route->assemble(array()); $this->fail('It should send an exception when no object given'); } catch (Zend_Controller_Router_Exception $e) { } }
public function testFunctionFilterWithArray() { $simpleTable = new Asset_Model_DbTable_Simple(); $simpleTable->filter(array(array('id', 1))); try { $simpleTable->fetchAll(); } catch (Exception $e) { $this->fail('No exception should be raised when using array as value of filter function'); } }
public function testFunctionGetModifiedFields() { $table = new Asset_Model_DbTable_Simple(); $row = $table->createRow(); $this->assertEmpty($row->getModifiedFields()); $row->title = "test"; $this->assertEquals(array('title' => true), $row->getModifiedFields()); $row->reset(); $this->assertEmpty($row->getModifiedFields()); }