예제 #1
0
 /**
  * @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'));
 }
예제 #2
0
 /**
  * @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) {
     }
 }
예제 #3
0
 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());
 }