0

If I'm running the code via url it is working (eg: http://localhost:8080/projects/emailNewProject/2008098)

But if I'm trying to access it via http://localhost:8080/test.php?show=cases&app=true it is throwing the error : Missing database table for the model Customer

I tried to change the datasource in controller using :

Configure::write('currentDataSource', 'testdb');
$dataSource = Configure::read('currentDataSource');
$this->setDataSource($dataSource);

still it doesn't affect!!

class ProjectsControllerTest extends CakeTestCase{
    function testEmailNewProject()
        {
            $id     = 2008098;
            $result = $this->testAction('/projects/emailNewProject', array('fixturize' => true, 'data' => $id, 'method' => 'post'));
            debug($result);
        }
    }
  • Example given in this link [enter link description here](https://stackoverflow.com/questions/42784824/cakephp-3-multiple-databases) – Chintan Feb 19 '19 at 04:01
  • @Chintan I'm working on a legacy project which is based on Cakephp 1.3 and I'm not trying to connect any remote db. All data sources are in localhost. – Suborno Samanta Feb 20 '19 at 11:01

1 Answers1

0

It's probably because your Project model is associated (hasOne, belongsTo, etc.) with the Customer model, and you don't have a fixture for Customer. This is what tells the testing engine what database tables to create for the test database.

You can read more about this here: https://book.cakephp.org/1.3/en/The-Manual/Common-Tasks-With-CakePHP/Testing.html#preparing-test-data.

If you're still having trouble, let me know.

Erebus
  • 1,998
  • 2
  • 19
  • 32