1

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 ?

Wassup
  • 42
  • 9
handkock
  • 1,067
  • 2
  • 11
  • 23
  • The default database is working probably refers to a web request, right? The CLI PHP might be configured differently, it doesn't neccesarily use the same `php.ini` as the webserver PHP. Also for more details, catch the exception and use its `getAttributes()` method to retrieve the original `PDOException` message. – ndm Apr 27 '17 at 15:43

1 Answers1

0

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.

handkock
  • 1,067
  • 2
  • 11
  • 23