Bug Report #4248
Unable to unit-test with in-memory PDO databases
| Status: | New | Start date: | 09/05/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | - | |||
| Target version: | Kohana v3.x - Unscheduled | |||
| Resolution: | Points: | 1 |
Description
The database fixtures part of phpunit requires a PDO object in order to do its job.
For 'real' databases this is fine because you can make a second connection, however with in-memory databases doing this creates a second database.
In order to unit test on an in-memory database access to the inner PDO object is needed.
History
Updated by Chris Bandy over 1 year ago
What would the general case for this look like? Should Database be able to wrap already open connections?
Updated by Marcus Cobden over 1 year ago
I've not really considered the wider implications of how the API would look.
For reference, here's how we worked around it:
https://github.com/leth/kohana-jelly/blob/ed41df21ca5f769b03cb42f470eaeb03962b49dc/tests/classes/database/pdo.php
https://github.com/leth/kohana-jelly/blob/ed41df21ca5f769b03cb42f470eaeb03962b49dc/tests/classes/kohana/unittest/jelly/testcase.php#L80
Updated by Chris Bandy over 1 year ago
- Project changed from Kohana v3.x to UnitTest
- Category deleted (
Modules:Database) - Assignee set to Chris Bandy
I think the right way to resolve this is to implement a PHPUnit_Extensions_Database_DB_IDatabaseConnection backed by Kohana_Database.
Updated by Chris Bandy over 1 year ago
- Target version set to v3.3.0
Updated by Jeremy Bush over 1 year ago
- Target version changed from v3.3.0 to Unscheduled