Im trying to create Tests for models on Cakephp 2.10 and i encountered this situation:
I load my fixtures like this:
public $fixtures = [
'app.test_model_one',
'app.test_model_two',
'app.test_model_three',
'app.test_model_four'
]
public $autoFixtures = false;
and the i do the setUp
public function setUp() {
parent::setUp();
$this->ModelOne = ClassRegistry::init('ModelOne');
$this->ModelOne->useTable = 'test_model_one';
$this->ModelTwo = ClassRegistry::init('ModelTwo');
$this->ModelTwo->useTable = 'test_model_two';
...
}
ModelOne has a belongsTo relation with all the other models, so i can bring the desired data using the containable behavior.
The things is, the first time my test runs it works as it should. But when i run it a second time it doesnt work.
After searching why this was happening i encoutered that my $this->ModelOne->find()
method it was not using the test_model_two
table on the query, and it was using the model_two table. Any idea why this is happening ?