Search code examples
mysqldatabasecakephpcakephp-2.9

CakePHP: default database is working, while test doesn't


Hi after changing to Schema type of database and the CakePHP version from 2.4.4 to 2.9.7 the test database just doesn't want to work: Error: Database connection "Mysql" is missing, or could not be created. when I want to run tests: ./Console/cake test app AllModel. Here is my database.php file:

<?php class DATABASE_CONFIG {
    public function __construct() {
        $this->default = array(
            'datasource' => 'Database/Mysql',
            'driver' => 'mysql',
                'persistent' => false,
                'encoding' => 'utf8',
                'prefix' => 'prefix_',
                'host' => 'localhost',
                'database' => 'db',
                'login' => 'root', /*** replace this ***/
                'password' => 'pass', /*** replace this ***/
        );

        $this->test = $this->default;
        $this->test['database'] = $this->test['database'].'_test';
    }

Here you can see, that the test database is just a copy of default one. But the default database is working and is connected, while the test database is giving me an error. What could it be ?


Solution

  • All I needed to do is to just create a database with a name db_test, but not populate it, because later it would be populated with fixtures.