Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit-Testing doesn't seem to work #20

Closed
liviakuenzli opened this issue Oct 19, 2017 · 2 comments
Closed

Unit-Testing doesn't seem to work #20

liviakuenzli opened this issue Oct 19, 2017 · 2 comments

Comments

@liviakuenzli
Copy link
Contributor

Hi!

I use this plugin and a slightly altered version of the cakephp-app template and the testMissingTemplateInDebug() https://github.com/cakephp/app/blob/master/tests/TestCase/Controller/PagesControllerTest.php#L75 test fails on me.

I think it might be because a missingTemplate Exception is thrown (deliberately), which starts this database log plugin, but it's looking for a test-log datasource configuration:
Cake\Datasource\Exception\MissingDatasourceConfigException: The datasource configuration "test_database_log" was not found.
That config doesn't seem to exist.

How can we fix that, how can we ensure the test_database_log config does indeed exist?
We could add the test_database_log connection in your bootstrap.php, just like we do with database_log, but I'm not sure that is the way to go. Do you have any insight on this? Except Disabling databaselog for testing https://github.com/dereuromark/CakePHP-DatabaseLog/tree/master/docs#disabling-for-tests. :)

@dereuromark
Copy link
Owner

Thats why there is this part in the docs, for testing I recommend disabling for now.
If you find a better solution let me know!

@dereuromark
Copy link
Owner

Actually, there is a simple way.
In your /tests/bootstrap.php just add this:

ConnectionManager::config('test_database_log', [
	'className' => 'Cake\Database\Connection',
	'driver' => 'Cake\Database\Driver\Sqlite',
	'database' => LOGS . 'database_log.sqlite',
	'encoding' => 'utf8',
	'cacheMetadata' => true,
	'quoteIdentifiers' => true,
]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants