If one is going to build an ORM in PHP by himself, how would one properly test it against multiple database systems?
I know, this question requires a long answer... I ask that because my team will need to implement one by itself and I am very curious.
So I am thinking of an ORM that provides multiple database drivers (like Doctrine
):
- MySQL
- PostgreSQL
- Informix
- ...
Each driver should provide a querybuilder who generates Queries that are parsable by its underlying database system.
As that is, i think an ORM should always test all capabilities (associations, inheritance, what else, ..) with all possible (or currently implemented) drivers.
I already took a look how Doctrine
does that with PHPUnit
, but it seems they don't test their ORM like that... see here: phpunit.xml.dist on github
Well, of course they test their ORM against multiple database systems, but apparently not automatically..!?
So how would such an automatic "testsuite" look like, that tests against multiple database systems?
One Example
Using PHPUnit
(and DBUnit
indeed) I can currently only think of something like this...
phpunit.xml
would look this:
<phpunit bootstrap="buildUpDBConnections.php">
....
</phpunit>
So the phpunit.xml
does not provide any db settings, but executes a script (buildUpDBConnections.php)
, that sets up all database connections.
I think this connections then must somehow be publicly available as a collection, which is injected in all tests that should execute queries.
And before running the tests, this script prepares the fixtures for each database.
And then each test runs its queries against all connections. so a test is only successful, if the queries were executed correctly for all database systems.
Is this "concept" actually correct? are there more practical ways?
Aucun commentaire:
Enregistrer un commentaire