Download the PHP package idct/database-comparator without Composer
On this page you can find all versions of the php package idct/database-comparator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download idct/database-comparator
More information about idct/database-comparator
Files in idct/database-comparator
Package database-comparator
Short Description Datasource sets comparing framework
License MIT
Homepage https://github.com/ideaconnect/database-comparator
Informations about the package database-comparator
database-comparator
Basic framework for database comparisons. Allows to report differences between two datasources.
Useful especially when making a major change in an application which writes data to any data source and you would like to verify if nothing got broken. One could say that it allows to write easy black box tests.
contents
Framework provides so far:
PdoSource
: for comparing databases to which PDO can be used as a connector.SourceInterface
: interface for writing new compatible data source connectors.SimpleOutput
: basic textual output for writing out differences to files.OutputInterface
: interface for building new output writing objects.
usage
- Install by composer using:
or manually by downloading contents and placing in desired folder.
-
Include all your files or the autoloader:
- Build your comparison definitions:
Assuming you have a table with schema:
id | irrelevant | value |
---|---|---|
0 | somedate | 11 |
0 | somedate | 12 |
Create new objects:
In case you compare within SAME database you can use same connector (same source)
- Special cases:
In some cases you want to omit some fields - for instance if your tables have the automatic "last updated" fields. You can do it in two ways:
- do not specify it within your queries (
QueryAll
,QuerySingle
) or in case it would be hard to do (like in SQL you would need to list all other fields) set "ignored fields":
In case your tables / data sources have complex data sources just specify them as
next array elements in setSingleKeys
, for example:
One of the most interesting features of the framework is option to alter results
just before comparison - this is very useful in situations when you know what
you have changed and want to check if you achieved it.
For instance: if you had an application which fills the sample table above and
you made a change to your app which causes writing of the value
field with data
substracted by 2 you can still verify that using getSinglePreCheckTransformation
method.
SinglePreCheckTransformation
is meant to update the data from the current data
source and should return the updated set. So in case your application substracted
2 from value of field value
of every row/entry you can add 2 back in order to
make the comparison using the code above.
contribution
In case you found any bugs, problems or would like to add some features... or write tests :) it is more than welcome! Please make the changes, add a pull request and I will merge it when it is possible. Thank you in advance!