{"id":34977520,"url":"https://github.com/cspray/database-testing-pdo","last_synced_at":"2026-01-20T16:39:06.225Z","repository":{"id":292241290,"uuid":"978726399","full_name":"cspray/database-testing-pdo","owner":"cspray","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-25T17:42:26.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-20T12:39:57.228Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cspray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-06T12:24:04.000Z","updated_at":"2025-11-25T17:42:27.000Z","dependencies_parsed_at":"2025-05-08T21:54:41.515Z","dependency_job_id":null,"html_url":"https://github.com/cspray/database-testing-pdo","commit_stats":null,"previous_names":["cspray/database-testing-pdo"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cspray/database-testing-pdo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdatabase-testing-pdo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdatabase-testing-pdo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdatabase-testing-pdo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdatabase-testing-pdo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cspray","download_url":"https://codeload.github.com/cspray/database-testing-pdo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cspray%2Fdatabase-testing-pdo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28066214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-27T00:29:54.932Z","updated_at":"2025-12-27T00:29:55.663Z","avatar_url":"https://github.com/cspray.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cspray/database-testing-pdo\n\nA connection adapter for [`cspray/database-testing`](https://github.com/cspray/database-testing) that allows you to \nuse a PDO connection for testing database interactions.\n\n## Installation\n\nComposer is the only supported means to install this package.\n\n```shell\ncomposer require --dev cspray/database-testing-pdo\n```\n\n## Quick Start\n\nThis library works by providing an implementation of the `Cspray\\DatabaseTesting\\ConnectionAdapter\\ConnectionAdapter` interface, along with a variety of `Cspray\\DatabaseTesting\\ConnectionAdapter\\ConnectionAdapterFactory` implementations designed to work with common databases. Check out the example appropriate for your database below or check out the \"Database Connection Adapter Reference\"!\n\nAll examples below will use code from the `cspray/database-testing-phpunit` extension. If you're using a different testing framework you may need to adjust your code as appropriate.\n\n### Postgres\n\n```php\n\u003c?php declare(strict_types=1);\n\nnamespace Cspray\\DatabaseTesting\\Pdo\\Demo;\n\nuse Cspray\\DatabaseTesting\\ConnectionAdapter\\ConnectionAdapterConfig;\nuse Cspray\\DatabaseTesting\\DatabaseCleanup\\TransactionWithRollback;\nuse Cspray\\DatabaseTesting\\RequiresTestDatabase;\nuse Cspray\\DatabaseTesting\\Pdo\\Postgres\\PostgresConnectionAdapterFactory;\nuse PHPUnit\\Framework\\TestCase;\n\n#[RequiresTestDatabase(\n    new PostgresConnectionAdapterFactory(new ConnectionAdapterConfig(\n        'my_database',\n        '127.0.0.1',\n        5432,\n        'my_user',\n        'my_password'\n    )),\n    new TransactionWithRollback()\n)]\nfinal class PostgresDemoTest extends TestCase {\n\n}\n```\n\n### MySql\n\n```php\n\u003c?php declare(strict_types=1);\n\nnamespace Cspray\\DatabaseTesting\\Pdo\\Demo;\n\nuse Cspray\\DatabaseTesting\\ConnectionAdapter\\ConnectionAdapterConfig;\nuse Cspray\\DatabaseTesting\\DatabaseCleanup\\TransactionWithRollback;\nuse Cspray\\DatabaseTesting\\RequiresTestDatabase;\nuse Cspray\\DatabaseTesting\\Pdo\\Postgres\\PostgresConnectionAdapterFactory;\nuse PHPUnit\\Framework\\TestCase;\n\n#[RequiresTestDatabase(\n    new PostgresConnectionAdapterFactory(new ConnectionAdapterConfig(\n        'my_database',\n        '127.0.0.1',\n        5432,\n        'my_user',\n        'my_password'\n    )),\n    new TransactionWithRollback()\n)]\nfinal class PostgresDemoTest extends TestCase {\n\n}\n```\n\n### Sqlite\n\n```php\n\u003c?php declare(strict_types=1);\n\nnamespace Cspray\\DatabaseTesting\\Pdo\\Demo;\n\nuse Cspray\\DatabaseTesting\\ConnectionAdapter\\ConnectionAdapterConfig;\nuse Cspray\\DatabaseTesting\\DatabaseCleanup\\TransactionWithRollback;\nuse Cspray\\DatabaseTesting\\RequiresTestDatabase;\nuse Cspray\\DatabaseTesting\\Pdo\\Sqlite\\SqliteConnectionAdapterFactory;\nuse PHPUnit\\Framework\\TestCase;\n\n#[RequiresTestDatabase(\n    // The default file path for Sqlite is an in-memory database\n    // Provide the path to the SQL file that should be loaded when\n    // the database is created\n    // if you're using a persisted file, provide it as the first argument\n    // and remove the initial schema path\n    new SqliteConnectionAdapterFactory(\n        initialSchemaPath: __DIR__ . '/schemas/sqlite.sql'\n    ),\n    new TransactionWithRollback()\n)]\nfinal class SqliteDemoTest extends TestCase {\n\n}\n```\n\n## Database Connection Adapter Reference\n\n| Database | ConnectionAdapterFactory                                               | \n| --- |------------------------------------------------------------------------|\n| Postgres | `Cspray\\DatabaseTesting\\Pdo\\Postgres\\PostgresConnectionAdapterFactory` |\n| MySql | `Cspray\\DatabaseTesting\\Pdo\\Mysql\\MysqlConnectionAdapterFactory`       |\n| SQLite | `Cspray\\DatabaseTesting\\Pdo\\Sqlite\\SqliteConnectionAdapterFactory`     |\n\n## Running Tests\n\nBy the nature of this library, we need to interact with a database during our tests. This presents some challenges and concessions that otherwise wouldn't be present when writing tests. Most importantly, that means we need to have multiple running database servers. To run tests for this library you must use `docker compose run --rm tests`. This will ensure the appropriate database servers are up and running so tests have something to connect to.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcspray%2Fdatabase-testing-pdo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcspray%2Fdatabase-testing-pdo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcspray%2Fdatabase-testing-pdo/lists"}