{"id":13810382,"url":"https://github.com/10up/wp-codeception","last_synced_at":"2025-05-14T10:33:00.522Z","repository":{"id":29495544,"uuid":"33033260","full_name":"10up/wp-codeception","owner":"10up","description":"Integrates Codeception framework into WordPress and allows run tests using WP CLI command.","archived":true,"fork":false,"pushed_at":"2021-05-25T19:18:51.000Z","size":199,"stargazers_count":103,"open_issues_count":10,"forks_count":12,"subscribers_count":135,"default_branch":"master","last_synced_at":"2025-03-10T20:42:21.663Z","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":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/10up.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-28T12:50:44.000Z","updated_at":"2024-07-23T21:06:17.000Z","dependencies_parsed_at":"2022-08-24T07:10:40.710Z","dependency_job_id":null,"html_url":"https://github.com/10up/wp-codeception","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10up%2Fwp-codeception","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10up%2Fwp-codeception/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10up%2Fwp-codeception/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10up%2Fwp-codeception/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/10up","download_url":"https://codeload.github.com/10up/wp-codeception/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254121103,"owners_count":22018103,"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-04T02:00:51.750Z","updated_at":"2025-05-14T10:32:55.503Z","avatar_url":"https://github.com/10up.png","language":"PHP","funding_links":[],"categories":["WordPress Plugins"],"sub_categories":[],"readme":"# WP Codeception\n\n\u003e This is a WordPress Plugin which integrates with the [Codeception](http://codeception.com/) PHP testing framework and allows you to write and run Codeception tests for WordPress via WP CLI.\n\n[![Support Level](https://img.shields.io/badge/support-archived-red.svg)](#support-level)\n\nWe're working towards supporting all of [Codeceptions commands](http://codeception.com/docs/reference/Commands). If you find one we haven't included yet, please submit a [Pull Request](https://github.com/10up/wp-codeception/pulls)!\n\n## Installation\n[Download the latest version](https://github.com/10up/wp-codeception/archive/master.zip) and extract, or clone the repository with Git into a new directory `wp-content/plugins/wp-codeception` in your WordPress install.\n\n#### Install required node modules and composer dependencies\n\nWe'll run our commands from within [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV) because WP CLI, Node, and Composer are already installed for us there.\n\n```Bash\n$ vagrant up\n$ vagrant ssh\n$ sudo apt-get install openjdk-7-jre-headless\n$ cd /srv/www/yoursite/htdocs/wp-content/plugins/wp-codeception\n$ composer install\n$ wp plugin activate wp-codeception\n```\n\nAfterwards you'll have a new `vendor` directory within your `plugins/wp-codeception` directory which contains all the code libraries we're dependant on.\n\n#### Install as a composer dependency\n\nThere is an alternative way to install this plugin. You can add it as a composer dependency for your project. To do it, run following command in your terminal:\n\n```Bash\n$ composer require 10up/wp-codeception\n```\n\nThis command will install the plugin and all its dependencies for your project. Please, pay attention that if you already use [composer/installers](https://github.com/composer/installers) dependency in your project, then `wp-codeception` will be installed into `\u003cPROJECT_DIR\u003e/wp-content/plugins/wp-codeception/` folder. It happens, because `wp-codeception` has `wordpress-plugin` type and will be processed by `composer/installers` accordingly (read its documentation for more details).\n\nIf you want to add it as a dependency to your plugin or theme, you will need to update your `composer.json` file and tell it where to install `wp-codeception`. You can achieve it by providing `installer-paths` instructions like in the snippet below.\n\n```Bash\n{\n    ...,\n    \"extra\": {\n        \"installer-paths\": {\n            \"vendor/{$name}/\": [\"type:wordpress-plugin\"]\n        }\n    },\n    ...\n}\n```\n\nNow `composer/installers` will know to install wordpress plugins into *vendor* folder. The final step which you need to do is to update your `autoload` section and add `wp-codeception.php` file to the autoload files list.\n\n```Bash\n{\n    ...,\n    \"autoload\": {\n        \"psr-X\": {\n            ...\n        },\n        \"files\": [\n            ...,\n            \"vendor/wp-codeception/wp-codeception.php\"\n        ]\n    },\n    ...\n}\n```\n\n#### Install the test suite\n\nSee the [Codeception bootstrapping documentation](http://codeception.com/docs/reference/Commands#Bootstrap) for further information.\n\n```Bash\n# You'll create the test suite in your own plugin or theme directory..\n$ cd /srv/www/yoursite/htdocs/wp-content/{your plugin or theme directory}\n$ wp codeception bootstrap\n```\n\nAfterwards you'll have a new `tests` directory within your plugin or theme directory. This is your new test suite, and where you'll write all your tests.\n\n## Writing Tests\nYou can write tests using any of the three [Codeception](http://codeception.com/) testing frameworks: [Acceptance](http://codeception.com/docs/03-AcceptanceTests), [Functional](http://codeception.com/docs/04-FunctionalTests) and [Unit](http://codeception.com/docs/05-UnitTests) testing. If you look within the new `tests` directory you'll see three config files; one for each test framework (acceptance.suite.yml, functional.suite.yml, unit.suite.yml). Edit these files as you wish.\n\n#### Generate your first test\n```Bash\n# You should be in the plugin or theme directory where you ran the bootstrap\n$ wp codeception generate-(cept|cest) (acceptance|functional|unit) MyTestName\n\n# Example\n$ wp codeception generate-cept acceptance LoginTest\n```\n\nAfterwards you'll have a new file in your plugin or theme directory `tests/acceptance/LoginTest.php`, where you can write your first test. Remember, any Codeception test will work here! For example, you could run any of the [acceptance test examples](http://codeception.com/docs/03-AcceptanceTests) mentioned in the Codeception documentation. Likewise, the same goes for [Functional](http://codeception.com/docs/04-FunctionalTests) and [Unit tests](http://codeception.com/docs/05-UnitTests).\n\n#### Example: Writing a Login Acceptance Test\n```PHP\n\u003c?php\n\n// Make sure you've added your site URL to acceptance.suite.yml\n// @see http://codeception.com/docs/03-AcceptanceTests#PHP-Browser\n$I = new AcceptanceTester( $scenario );\n$I-\u003ewantTo( 'Ensure WordPress Login Works' );\n\n// Let's start on the login page\n$I-\u003eamOnPage( wp_login_url() );\n\n// Populate the login form's user id field\n$I-\u003efillField( 'input#user_login', 'YourUsername' );\n\n// Popupate the login form's password field\n$I-\u003efillField( 'input#user_pass', 'YourPassword' );\n\n// Submit the login form\n$I-\u003eclick( 'Log In' );\n\n// Validate the successful loading of the Dashboard\n$I-\u003esee( 'Dashboard' );\n```\n\n## Running Your Tests\nNow you've written some tests, it's time to run them! But first..\n\n#### Selenium\nIf you've created any browser automation/acceptance tests you'll need to turn [Selenium](http://www.seleniumhq.org/) on, and likewise, you'll want to stop Selenium after you're through running tests.\n\n```Bash\n# You can run these commands from anywhere in your WordPress install\n$ wp selenium start\n\n# Stop Selenium when you're through\n$ wp selenium stop\n```\n\n#### Run\nYou'll use the `run` command to execute your tests from within your plugin or theme directory (where you ran the bootstrap). We've implemented most of the [Codeception 'run' command](http://codeception.com/docs/reference/Commands#Run) arguments, but if you find one we've missed please submit a [Pull Request](https://github.com/10up/wp-codeception/pulls)!\n\n```Bash\n# You should be in the plugin or theme directory where you ran the bootstrap\n$ wp codeception run\n```\n\n#### Example: Running our Login Test\n```Bash\n# You should be in the plugin or theme directory where you ran the bootstrap\n# Let's display verbose output\n$ wp codeception run -vvv\n\nCodeception PHP Testing Framework v2.0.11\nPowered by PHPUnit 4.5.1 by Sebastian Bergmann and contributors.\n\n  Rebuilding AcceptanceTester...\n\nAcceptance-production Tests (1) ---------------------------------\nModules: WebDriver, WordPress, AcceptanceHelper\n-----------------------------------------------------------------\nEnsure WordPress Login Works (LoginTest)\nScenario:\n* I am on page \"http://site.com/wp-login.php\"\n* I fill field \"input#user_login\",\"YourUsername\"\n* I fill field \"input#user_pass\",\"YourPassword\"\n* I click \"Login\"\n* I see \"Dashboard\"\n PASSED\n```\n\n## Support Level\n\n**Archived:** This project is no longer maintained by 10up. We are no longer responding to Issues or Pull Requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!\n\n## Like what you see?\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"http://10up.com/contact/\"\u003e\u003cimg src=\"https://10up.com/uploads/2016/10/10up-Github-Banner.png\" width=\"850\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10up%2Fwp-codeception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F10up%2Fwp-codeception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10up%2Fwp-codeception/lists"}