{"id":13684624,"url":"https://github.com/cakephp/codeception","last_synced_at":"2025-05-01T00:32:17.225Z","repository":{"id":27076207,"uuid":"30542735","full_name":"cakephp/codeception","owner":"cakephp","description":"CakePHP module for Codeception","archived":true,"fork":false,"pushed_at":"2023-02-20T01:56:24.000Z","size":219,"stargazers_count":46,"open_issues_count":7,"forks_count":28,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-11-01T16:47:29.253Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cakephp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2015-02-09T15:32:47.000Z","updated_at":"2023-02-20T01:56:39.000Z","dependencies_parsed_at":"2024-06-19T00:20:27.458Z","dependency_job_id":"37cef400-261b-4bca-b7d8-c0ddffcde017","html_url":"https://github.com/cakephp/codeception","commit_stats":{"total_commits":149,"total_committers":13,"mean_commits":"11.461538461538462","dds":0.5100671140939597,"last_synced_commit":"b5f5757fee5052e96fa93a1f9136eaaef757ef25"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fcodeception","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fcodeception/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fcodeception/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fcodeception/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cakephp","download_url":"https://codeload.github.com/cakephp/codeception/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224230568,"owners_count":17277372,"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":[],"created_at":"2024-08-02T14:00:35.839Z","updated_at":"2024-11-12T06:30:23.380Z","avatar_url":"https://github.com/cakephp.png","language":"PHP","readme":"CakePHP 3 Codeception Module\n============================\n\n[![Build Status](https://img.shields.io/travis/com/cakephp/codeception?style=flat-square)](https://travis-ci.com/cakephp/codeception)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n\n:warning: This repository is archived and is no longer maintained.\n\nA [codeception](http://codeception.com) module to test your CakePHP 3 powered application. Using Codeception with CakePHP opens up a whole new set of testing capabilities.\n\n##### Front-end testing\n\n_(i.e. browser-based workflow tests)_\n\n  - [[Functional Tests]](http://codeception.com/docs/05-FunctionalTests)\n    - does the App run the way we expect\n  - [[Acceptance Tests]](http://codeception.com/docs/04-AcceptanceTests)\n    - does the App do what the customer/user expects\n\n##### Back-end testing\n\n_(i.e. direct, internal method tests)_\n\n- [[API Tests]](http://codeception.com/docs/10-WebServices)\n  - does the App's API work\n- [[Unit Tests]](http://codeception.com/docs/06-UnitTests)\n  - do the App's internal functions do what we expect\n\nUsage\n-----\n\nFrom a CakePHP application, run the following from the command-line:\n\n```console\n$ composer require --dev cakephp/codeception:dev-master \u0026\u0026 composer run-script post-install-cmd\n```\n\nIf you are developing a plugin, add the post-install script to your `composer.json` first:\n\n```json\n{\n    \"scripts\": {\n        \"post-install-cmd\": \"Cake\\\\Codeception\\\\Console\\\\Installer::customizeCodeceptionBinary\"\n    }\n}\n```\n\nOnce installed, you can now run `bootstrap` which will create all the codeception required files\nin your application:\n\n```console\n$ vendor/bin/codecept bootstrap\n```\n\nThis creates the following files/folders in your `app` directory:\n\n```\n├── codeception.yml\n├── src\n│   └── TestSuite\n│       └── Codeception\n|           ├── AcceptanceTester.php\n|           ├── FunctionalTester.php\n|           ├── UnitTester.php\n|           ├── Helper\n│           │   ├── Acceptance.php\n│           │   ├── Functional.php\n│           │   └── Unit.php\n|           └── _generated\n|               └── .gitignore\n└── tests\n    ├── Acceptance.suite.yml\n    ├── Functional.suite.yml\n    ├── Unit.suite.yml\n    ├── Acceptance\n    │   └── bootstrap.php\n    ├── Fixture\n    │   └── dump.sql\n    ├── Functional\n    │   └── bootstrap.php\n    └── Unit\n        └── bootstrap.php\n```\n\nAs you might have noticed, the CakePHP implementation differs in a couple things:\n\n- uses CamelCase suite names (`Functional` vs. `functional`)\n- uses `bootstrap.php`, no underscore prefix (vs. `_bootstrap.php`)\n- uses `src/TestSuite/Codeception` for custom modules (helpers) (vs. `tests/_helpers`)\n- uses `tmp/tests` to store logs (vs. `tests/_logs`)\n- uses `tests/Fixture` to fixture data (vs. `tests/_data`)\n- uses `tests/Envs` to fixture data (vs. `tests/_envs`)\n- adds a `.gitignore` to never track auto-generated files\n- adds custom templates for various generated files using the `codecept` binary\n\nTo better understand how Codeception tests work, please check the [official documentation][codeception_docs].\n\n[codeception_docs]:http://codeception.com/docs/01-Introduction\n\n## Example Cept\n\n```php\n\u003c?php\n$I = new FunctionalTester($scenario);\n$I-\u003ewantTo('ensure that adding a bookmark works');\n$I-\u003eamOnPage('/bookmarks/add');\n$I-\u003esee('Submit');\n$I-\u003esubmitForm('#add', [\n    'title' =\u003e 'First bookmark',\n]);\n$I-\u003eseeInSession([\n    'Flash'\n]);\n```\n\n## Actions\n\n### Auth\n\n...\n\n### Config\n\n#### Assert config key(/value) with `seeInConfig($key, $value = null)`\n\n```php\n$I-\u003eseeInConfig('App.name'); // checks only that the key exists\n$I-\u003eseeInConfig('App.name', 'CakePHP');\n$I-\u003eseeInConfig(['App.name' =\u003e 'CakePHP']);\n```\n\n#### Assert no config key(/value) with `dontSeeInConfig($key, $value = null)`\n\n```php\n$I-\u003edontSeeInConfig('App.name'); // checks only that the key does not exist\n$I-\u003edontSeeInConfig('App.name', 'CakePHP');\n$I-\u003edontSeeInConfig(['App.name' =\u003e 'CakePHP']);\n```\n\n### Db\n\n\n#### Insert record with `haveRecord($model, $data = [])`\n\nThis is useful when you need a record for just one test (temporary fixture). It\ndoes not assert anything and returns the inserted record's ID.\n\n```php\n$I-\u003ehaveRecord('users', ['email' =\u003e 'jadb@cakephp.org', 'username' =\u003e 'jadb']);\n```\n\n#### Retrieve record with `grabRecord($model, $conditions = [])`\n\nThis is a wrapper around the `Cake\\ORM\\Table::find('first')` method.\n\n```php\n$I-\u003egrabRecord('users', ['id' =\u003e '1']);\n```\n\n#### Assert record exists with `seeRecord($model, $conditions = [])`\n\nThis checks that the requested record does exist in the database.\n\n```php\n$I-\u003eseeRecord('users', ['username' =\u003e 'jadb']);\n```\n\n#### Assert record does not exist with `dontSeeRecord($model, $conditions = [])`\n\nThis checks that the request record does not exist in the database.\n\n```php\n$I-\u003edontSeeRecord('users', ['email' =\u003e 'jadb@cakephp.org']);\n```\n\n### Dispatcher\n\n...\n\n### Miscellaneous\n\n#### Load fixtures\n\nIn your `Cest` test case, write `$fixutures` property:\n\n```php\nclass AwesomeCest\n{\n    public $fixtures = [\n        'app.users',\n        'app.posts',\n    ];\n\n    // ...\n}\n```\n\nYou can use `$autoFixtures`, `$dropTables` property, and `loadFixtures()` method:\n\n```php\nclass AwesomeCest\n{\n    public $autoFixtures = false;\n    public $dropTables = false;\n    public $fixtures = [\n        'app.users',\n        'app.posts',\n    ];\n\n    public function tryYourSenario($I)\n    {\n        // load fixtures manually\n        $I-\u003eloadFixtures('Users', 'Posts');\n        // or load all fixtures\n        $I-\u003eloadFixtures();\n        // ...\n    }\n}\n```\n\nIn your `Cept` test case, use `$I-\u003euseFixtures()` and `$I-\u003eloadFixtures()`:\n\n```php\n$I = new FunctionalTester($scenario);\n\n// You should call `useFixtures` before `loadFixtures`\n$I-\u003euseFixtures('app.users', 'app.posts');\n// Then load fixtures manually\n$I-\u003eloadFixtures('Users', 'Posts');\n// or load all fixtures\n$I-\u003eloadFixtures();\n```\n\n#### Assert CakePHP version with `expectedCakePHPVersion($ver, $operator = 'ge')`\n\n```php\n$I-\u003eexpectedCakePHPVersion('3.0.4');\n```\n\n### Router\n\n#### Open page by route with `amOnRoute($route, $params = [])`\n\nAll the below forms are equivalent:\n\n```php\n$I-\u003eamOnRoute(['controller' =\u003e 'Posts', 'action' =\u003e 'add']);\n$I-\u003eamOnRoute('addPost'); // assuming there is a route named `addPost`\n```\n\n#### Open page by action with `amOnAction($action, $params = [])`\n\nAll the below forms are equivalent:\n\n```php\n$I-\u003eamOnAction('Posts@add');\n$I-\u003eamOnAction('Posts.add');\n$I-\u003eamOnAction('PostsController@add');\n$I-\u003eamOnAction('PostsController.add');\n$I-\u003eamOnAction('posts@add');\n$I-\u003eamOnAction('posts.add');\n```\n\n#### Assert URL matches route with `seeCurrentRouteIs($route, $params = [])`\n\nAll the below forms are equivalent:\n\n```php\n$I-\u003eseeCurrentRouteIs(['controller' =\u003e 'Posts', 'action' =\u003e 'add']);\n$I-\u003eseeCurrentRouteIs('addPost'); // assuming there is a route named `addPost`\n```\n\n#### Assert URL matches action with `seeCurrentActionIs($action, $params = [])`\n\nAll the below forms are equivalent:\n\n```php\n$I-\u003eseeCurrentActionIs('Posts@add');\n$I-\u003eseeCurrentActionIs('Posts.add');\n$I-\u003eseeCurrentActionIs('PostsController@add');\n$I-\u003eseeCurrentActionIs('PostsController.add');\n$I-\u003eseeCurrentActionIs('posts@add');\n$I-\u003eseeCurrentActionIs('posts.add');\n```\n\n### Session\n\n#### Insert key/value(s) in session with `haveInSession($key, $value = null)`\n\n```php\n$I-\u003ehaveInSession('redirect', Router::url(['_name' =\u003e 'dashboard']));\n$I-\u003ehaveInSession(['redirect' =\u003e Router::url(['_name' =\u003e 'dashboard'])]);\n```\n\n#### Assert key(/value) in session with `seeInSession($key, $value = null)`\n\n```php\n$I-\u003eseeInSession('redirect'); // only checks the key exists.\n$I-\u003eseeInSession('redirect', Router::url(['_name' =\u003e 'dashboard']));\n$I-\u003eseeInSession(['redirect', Router::url(['_name' =\u003e 'dashboard'])]);\n```\n\n#### Assert key(/value) not in session with `dontSeeInSession($key, $value = null)`\n\n```php\n$I-\u003edontSeeInSession('redirect'); // only checks the key does not exist.\n$I-\u003edontSeeInSession('redirect', Router::url(['_name' =\u003e 'dashboard']));\n$I-\u003edontSeeInSession(['redirect', Router::url(['_name' =\u003e 'dashboard'])]);\n```\n\n\n### View\n\n...\n","funding_links":[],"categories":["Testing"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakephp%2Fcodeception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcakephp%2Fcodeception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakephp%2Fcodeception/lists"}