예제 #1
0
 /**
  * @covers Centurion_Db_Table_Abstract::__call
  */
 public function testMagicFunctionFindby()
 {
     $simpleTable = new Asset_Model_DbTable_Simple();
     $simpleTable->delete(array(new Zend_Db_Expr('1')));
     $test1Row = $simpleTable->insert(array('title' => 'test', 'retrieve' => true));
     $simpleTable->insert(array('title' => 'test'));
     $resultRowSet = $simpleTable->findByTitle('test');
     $this->assertCount(2, $resultRowSet);
     $resultRow = $simpleTable->findOneById($test1Row->id);
     $this->assertEquals($test1Row->pk, $resultRow->pk);
     $resultRow = $simpleTable->findOneByIdAndTitle($test1Row->id, 'test');
     $this->assertEquals($test1Row->pk, $resultRow->pk);
 }
예제 #2
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'));
 }
예제 #3
0
 /**
  * @covers Centurion_Db_Table_Select::not
  */
 public function testNotFunctionWithSimpleTable()
 {
     $simpleTable = new Asset_Model_DbTable_Simple();
     $simpleTable->delete(array(new Zend_Db_Expr('1')));
     $test1Row = $simpleTable->insert(array('title' => 'test1', 'retrieve' => true));
     $test2Row = $simpleTable->insert(array('title' => 'test2', 'retrieve' => true));
     $test3Row = $simpleTable->insert(array('title' => 'test3', 'retrieve' => true));
     $resultRowSet = $simpleTable->select(true)->not($test2Row)->order('id asc')->fetchAll();
     $this->assertCount(2, $resultRowSet);
     $this->assertEquals($test1Row->pk, $resultRowSet[0]->pk);
     $this->assertEquals($test3Row->pk, $resultRowSet[1]->pk);
 }