The controller code I'm looking to test includes functions where queries like
$this->Model->find('all', [
'joins' => [
'table' => database.table,
'type' => 'inner',
'conditions' => ['table.id' => 'Model.table_id']
],
]);
are used extensively.
The problem is that testAction correctly finds the Model's table in the test datasource, but does not modify the explicit join, which joins it to the actual database.table, rather than test.table.
My intuition tells me that re-writing these queries to use CakePHP's contain rather than join should allow CakePHP's ControllerTestCase to replace the joined model's datasource with the test datasource, fixing the issue. However, I'd prefer not to rewrite all the query code.
Does anyone know a way to work around this? If not, am I correct in thinking that the contain method would fix solve the problem?
Aucun commentaire:
Enregistrer un commentaire