Skip to content

Commit

Permalink
Moving testGenerateInnerJoinAssociationQuery out from DboSourceTest
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Nov 4, 2010
1 parent 605a6b1 commit f2f378c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
29 changes: 29 additions & 0 deletions cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
Expand Up @@ -1002,4 +1002,33 @@ function &_prepareAssociationQuery(&$model, &$queryData, $binding) {
$result = array_merge(array('linkModel' => &$linkModel), compact('type', 'assoc', 'assocData', 'external'));
return $result;
}
/**
* testGenerateInnerJoinAssociationQuery method
*
* @access public
* @return void
*/
function testGenerateInnerJoinAssociationQuery() {
$test = $this->getMock('DboMysql', array('connect', '_execute', 'execute'));
$this->Model = $this->getMock('TestModel9', array('getDataSource'));
$this->Model->expects($this->any())
->method('getDataSource')
->will($this->returnValue($test));
$this->Model->TestModel8 = $this->getMock('TestModel8', array('getDataSource'));
$this->Model->TestModel8->expects($this->any())
->method('getDataSource')
->will($this->returnValue($test));
$test->expects($this->at(0))->method('execute')
->with(new PHPUnit_Framework_Constraint_PCREMatch('/`TestModel9` LEFT JOIN `test_model8`/'));
$test->expects($this->at(1))->method('execute')
->with(new PHPUnit_Framework_Constraint_PCREMatch('/`TestModel9` INNER JOIN `test_model8`/'));
$test->read($this->Model, array('recursive' => 1));
$this->Model->belongsTo['TestModel8']['type'] = 'INNER';
$test->read($this->Model, array('recursive' => 1));
}
}
24 changes: 0 additions & 24 deletions cake/tests/cases/libs/model/datasources/dbo_source.test.php
Expand Up @@ -117,30 +117,6 @@ function tearDown() {
unset($this->Model);
}

/**
* testGenerateInnerJoinAssociationQuery method
*
* @access public
* @return void
*/
function testGenerateInnerJoinAssociationQuery() {
$this->Model = new TestModel9();
$test = ConnectionManager::create('test2', $this->__config);
$this->Model->setDataSource('test2');
$this->Model->TestModel8 = new TestModel8();
$this->Model->TestModel8->setDataSource('test2');

$this->testDb->read($this->Model, array('recursive' => 1));
$result = $this->testDb->getLastQuery();
$this->assertPattern('/`TestModel9` LEFT JOIN `' . $this->testDb->fullTableName('test_model8', false) . '`/', $result);

$this->Model->belongsTo['TestModel8']['type'] = 'INNER';
$this->testDb->read($this->Model, array('recursive' => 1));
$result = $this->testDb->getLastQuery();
$this->assertPattern('/`TestModel9` INNER JOIN `' . $this->testDb->fullTableName('test_model8', false) . '`/', $result);

}

/**
* testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBinding method
*
Expand Down

0 comments on commit f2f378c

Please sign in to comment.