I have config for test database
'test' => [
'host' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'url' => env('DATABASE_TEST_URL', 'sqlite://127.0.0.1/tmp/tests.sqlite'),
],
How to create - tests.sqlite
database?
If exported schema from phpmyadmin and store to /tests/schema.sql and uncomment code from /tests/bootstrap.php
use Cake\TestSuite\Fixture\SchemaLoader;
(new SchemaLoader())->loadSqlFiles('./tests/schema.sql', 'test');
schema.sql
DROP TABLE IF EXISTS `albums`;
CREATE TABLE IF NOT EXISTS `albums` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`albums_type_id` int(11) NOT NULL,
`file` varchar(250) NOT NULL,
`name` varchar(150) NOT NULL,
`description` text DEFAULT NULL,
`created` datetime NOT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `albums___fk1` (`albums_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Doesnt work, i get error eg.
Error in bootstrap script: PDOException:
SQLSTATE[HY000]: General error: 1 near "KEY": syntax error
#0 E:\projects\www\vendor\cakephp\cakephp\src\Database\Driver.php(257): PDO->exec('DROP TABLE IF E...')
#1 E:\projects\www\vendor\cakephp\cakephp\src\TestSuite\Fixture\SchemaLoader.php(91): Cake\Database\Driver->exec('DROP TABLE IF E...')
#2 E:\projects\www\tests\bootstrap.php(64): Cake\TestSuite\Fixture\SchemaLoader->loadSqlFiles('./tests/schema....', 'test')
#3 E:\projects\www\vendor\phpunit\phpunit\src\TextUI\Application.php(299): include_once('E:\\projects\\www...')
#4 E:\projects\www\vendor\phpunit\phpunit\src\TextUI\Application.php(98): PHPUnit\TextUI\Application->loadBootstrapScript('E:\\projects\\www...')
#5 E:\projects\www\vendor\phpunit\phpunit\phpunit(99): PHPUnit\TextUI\Application->run(Array)
#6 {main}
Please help.