{"id":20945101,"url":"https://github.com/vjik/codeception-db-populator","last_synced_at":"2025-05-14T01:31:30.071Z","repository":{"id":38533520,"uuid":"407770621","full_name":"vjik/codeception-db-populator","owner":"vjik","description":"Codeception DB module addon for populate database","archived":false,"fork":false,"pushed_at":"2024-07-18T10:51:02.000Z","size":35,"stargazers_count":21,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-14T21:42:31.208Z","etag":null,"topics":["codeception","codeception-module","database-testing","db-testing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vjik.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2021-09-18T05:57:50.000Z","updated_at":"2024-07-18T10:50:28.000Z","dependencies_parsed_at":"2024-11-14T21:42:21.617Z","dependency_job_id":"73e49051-25a4-499f-aa05-16c5c47bc5af","html_url":"https://github.com/vjik/codeception-db-populator","commit_stats":{"total_commits":7,"total_committers":2,"mean_commits":3.5,"dds":0.2857142857142857,"last_synced_commit":"a9dc40086013afd66f9fef279681c6d52194e128"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":"vjik/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vjik%2Fcodeception-db-populator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vjik%2Fcodeception-db-populator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vjik%2Fcodeception-db-populator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vjik%2Fcodeception-db-populator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vjik","download_url":"https://codeload.github.com/vjik/codeception-db-populator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225269316,"owners_count":17447507,"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","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":["codeception","codeception-module","database-testing","db-testing"],"created_at":"2024-11-18T23:46:39.953Z","updated_at":"2024-11-18T23:46:40.518Z","avatar_url":"https://github.com/vjik.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"codeception-logo.png\" height=\"100\"\u003e\n    \u003ch1 align=\"center\"\u003eDatabase Populator for Codeception DB Module\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/vjik/codeception-db-populator/v)](https://packagist.org/packages/vjik/codeception-db-populator)\n[![Total Downloads](https://poser.pugx.org/vjik/codeception-db-populator/downloads)](https://packagist.org/packages/vjik/codeception-db-populator)\n[![MySQL build](https://github.com/vjik/codeception-db-populator/actions/workflows/build-mysql.yml/badge.svg)](https://github.com/vjik/codeception-db-populator/actions/workflows/build-mysql.yml)\n[![PgSQL build](https://github.com/vjik/codeception-db-populator/actions/workflows/build-pgsql.yml/badge.svg)](https://github.com/vjik/codeception-db-populator/actions/workflows/build-pgsql.yml)\n[![static analysis](https://github.com/vjik/codeception-db-populator/actions/workflows/static.yml/badge.svg)](https://github.com/vjik/codeception-db-populator/actions/workflows/static.yml)\n[![License](https://poser.pugx.org/vjik/codeception-db-populator/license)](/LICENSE)\n\n[Codeception](https://codeception.com/) DB module addon that helps you to tune database populations. \nSo for a test you could load only needed tables or rows. As a result it dramatically reduces the total execution time.\n\n## Requirements\n\n- PHP 8.0 or higher.\n- Codeception 5.0 or higher.\n- Codeception Module DB 3.0 or higher.\n\n## Installation\n\nThe package could be installed with [composer](https://getcomposer.org/download/):\n\n```shell\ncomposer require vjik/codeception-db-populator --dev\n```\n## General usage\n\nEnable module `Db` and `DatabasePopulator` addon in the suite:\n\n```yml\nmodules:\n  enabled:\n    - Db:\n        dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%'\n        user: '%DB_USERNAME%'\n        password: '%DB_PASSWORD%'\n    - Vjik\\Codeception\\DatabasePopulator\\Module:\n        dumpsPath: 'tests/_data/dumps'\n        rowsPath: 'tests/_data/rows'\n```\n\nCreate SQL dumps that contains a record of the table structure and/or the data for use in tests.\nPut dumps into path, specified in options (for example, `tests/_data/dumps`).\n\nCreate row sets for populate database tables. Row sets is PHP file that return array in format `table =\u003e rows`.\nFor example:\n\n```php\n\u003c?php\nreturn [\n    'author' =\u003e [\n        [\n            'id' =\u003e 1,\n            'name' =\u003e 'Ivan',\n        ],\n        [\n            'id' =\u003e 2,\n            'name' =\u003e 'Petr',\n        ],\n    ],\n    'post' =\u003e [\n        [\n            'id' =\u003e 1,\n            'author_id' =\u003e 2,\n            'name' =\u003e 'First post',\n        ],\n        [\n            'id' =\u003e 2,\n            'author_id' =\u003e 2,\n            'name' =\u003e 'My history',\n        ],\n    ],\n];\n```\n\nYou can get structure, similar to this:\n\n```\ntests/\n  _data/\n    dumps/\n      user-management.sql\n      blog.sql\n      catalog.sql\n    rows/\n      users.php\n      authors.php\n      blog-categories.php\n      posts-with-categories.php\n```\n\nLoad dumps and row sets in your tests:\n\n```php\nfinal class BlogTest extends Unit\n{\n    public function testCreatePost(): void\n    {\n        $this-\u003etester-\u003eloadDump('blog');\n        $this-\u003etester-\u003eloadRows('authors');\n        ...\n    }\n}\n```\n\n## Actions\n\n### `loadDump()`\n\nLoad the specified dump(s) to database. Before loading the dump, the database is cleaned.\n\n```php\n$I-\u003eloadDump('blog'); // load one dump\n$I-\u003eloadDump('blog', 'catalog'); // load several dumps\n```\n\n### `loadRows()`\n\nLoad the specified row set(s) to database.\n\n```php\n$I-\u003eloadRows('posts'); // load one set\n$I-\u003eloadRows('users', 'comments'); // load several sets\n```\n\n## Configuration\n\n\n- `dumpsPath` (required) — relative path to directory with dumps (for example, `tests/_dump`).\n- `rowsPath` (required) — relative path to directory with row sets (for example, `tests/_rows`).\n- `preloadDump` — dump(s) for preload before run suite.\n- `preloadRows` — row set(s) for preload before run suite.\n\n## Testing\n\n### Unit and integration testing\n\nThe package is tested with [Codeception](https://codeception.com/). For tests need MySQL database with configuration:\n\n- host: `127.0.0.1`\n- name: `db_test`\n- user: `root`\n- password: `root`\n\nTo run tests:\n\n```shell\n./vendor/bin/codecept run\n```\n\n### Static analysis\n\nThe code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:\n\n```shell\n./vendor/bin/psalm\n```\n\n## License\n\nThe Database Populator for Codeception DB Module is free software. It is released under the terms of the BSD License. Please see [`LICENSE`](./LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvjik%2Fcodeception-db-populator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvjik%2Fcodeception-db-populator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvjik%2Fcodeception-db-populator/lists"}