https://github.com/bauhausphp/dbasserture
Tool for setting up and asserting database in feature and integration tests
https://github.com/bauhausphp/dbasserture
Last synced: 4 months ago
JSON representation
Tool for setting up and asserting database in feature and integration tests
- Host: GitHub
- URL: https://github.com/bauhausphp/dbasserture
- Owner: bauhausphp
- License: mit
- Created: 2019-01-22T23:10:55.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2022-06-20T19:03:06.000Z (about 4 years ago)
- Last Synced: 2025-11-27T14:40:19.453Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 118 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/bauhausphp/dbasserture/actions?query=workflow%3ABuild)
[](https://codecov.io/gh/bauhausphp/dbasserture)
[](https://packagist.org/packages/bauhaus/dbasserture)
[](https://packagist.org/packages/bauhaus/dbasserture)
[](composer.json)
[](LICENSE)
# DB Asserture
This tool aims to help the DB setup and assertion in a integration tests
context.
```php
use Bauhaus\DbAsserture\DbAssertureFactory;
$factory = new DbAssertureFactory();
$dbAsserture = $factory->fromDsn('mysql://user:pass@host:port/dbname');
// Clean tables
$dbAsserture->clean('table_name', 'another_table_name');
// Insert registers
$dbAsserture->insert('table_name', ['id' => 1, 'name' => 'Name']);
$dbAsserture->insert('table_name',
['id' => 1, 'name' => 'Name'],
['id' => 2, 'name' => 'Another name'],
);
// Select registers
$dbAsserture->select('table_name', ['name' => 'John']); // return many registers with all fields matching provided filter
$dbAsserture->selectOne('table_name', ['id' => 1]); // return one register with all fields matching provided filters
// Assert if is registered in database
$dbAsserture->assertOneIsRegistered('table_name', ['id' => 1, 'name' => 'Name']); // return true or throw exception
```