{"id":13715750,"url":"https://github.com/wp-cli/wp-cli-tests","last_synced_at":"2026-02-15T19:16:54.987Z","repository":{"id":43901874,"uuid":"134428237","full_name":"wp-cli/wp-cli-tests","owner":"wp-cli","description":"WP-CLI testing framework","archived":false,"fork":false,"pushed_at":"2026-02-02T01:50:57.000Z","size":11187,"stargazers_count":42,"open_issues_count":8,"forks_count":26,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-02-02T01:58:54.827Z","etag":null,"topics":["behat","cli","functional","hacktoberfest","linter","phpcs","phpunit","sniffer","testing","unit","wp-cli"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wp-cli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2018-05-22T14:32:40.000Z","updated_at":"2026-02-02T01:51:01.000Z","dependencies_parsed_at":"2024-01-09T19:01:23.122Z","dependency_job_id":"4f0b6907-1d82-433b-bc40-c82c9dcda750","html_url":"https://github.com/wp-cli/wp-cli-tests","commit_stats":{"total_commits":925,"total_committers":65,"mean_commits":14.23076923076923,"dds":0.7816216216216216,"last_synced_commit":"a8de3f02e16d1133c3b9f3b865e4821250bb9f37"},"previous_names":[],"tags_count":116,"template":false,"template_full_name":null,"purl":"pkg:github/wp-cli/wp-cli-tests","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fwp-cli-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fwp-cli-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fwp-cli-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fwp-cli-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wp-cli","download_url":"https://codeload.github.com/wp-cli/wp-cli-tests/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fwp-cli-tests/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29137753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T23:02:30.544Z","status":"ssl_error","status_checked_at":"2026-02-05T23:02:24.945Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["behat","cli","functional","hacktoberfest","linter","phpcs","phpunit","sniffer","testing","unit","wp-cli"],"created_at":"2024-08-03T00:01:03.025Z","updated_at":"2026-02-05T23:02:54.325Z","avatar_url":"https://github.com/wp-cli.png","language":"PHP","readme":"wp-cli/wp-cli-tests\n===================\n\nWP-CLI testing framework\n\n[![Testing](https://github.com/wp-cli/wp-cli-tests/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/wp-cli-tests/actions/workflows/testing.yml)\n\nQuick links: [Using](#using) | [Contributing](#contributing) | [Support](#support)\n\n## Using\n\nTo make use of the WP-CLI testing framework, you need to complete the following steps from within the package you want to add them to:\n\n1. Add the testing framework as a development requirement:\n    ```bash\n    composer require --dev wp-cli/wp-cli-tests\n    ```\n\n2. Add the required test scripts to the `composer.json` file:\n    ```json\n    \"scripts\": {\n        \"behat\": \"run-behat-tests\",\n        \"behat-rerun\": \"rerun-behat-tests\",\n        \"lint\": \"run-linter-tests\",\n        \"phpcs\": \"run-phpcs-tests\",\n        \"phpcbf\": \"run-phpcbf-cleanup\",\n        \"phpunit\": \"run-php-unit-tests\",\n        \"prepare-tests\": \"install-package-tests\",\n        \"test\": [\n            \"@lint\",\n            \"@phpcs\",\n            \"@phpunit\",\n            \"@behat\"\n        ]\n    }\n    ```\n    You can of course remove the ones you don't need.\n\n3. Optionally add a modified process timeout to the `composer.json` file to make sure scripts can run until their work is completed:\n    ```json\n    \"config\": {\n        \"process-timeout\": 1800\n    },\n    ```\n    The timeout is expressed in seconds.\n\n4. Optionally add a `behat.yml` file to the package root with the following content:\n    ```yaml\n    default:\n      suites:\n        default:\n          contexts:\n            - WP_CLI\\Tests\\Context\\FeatureContext\n          paths:\n            - features\n    ```\n    This will make sure that the automated Behat system works across all platforms. This is needed on Windows.\n\n5. Optionally add a `phpcs.xml.dist` file to the package root to enable code style and best practice checks using PHP_CodeSniffer.\n\n    Example of a minimal custom ruleset based on the defaults set in the WP-CLI testing framework:\n    ```xml\n    \u003c?xml version=\"1.0\"?\u003e\n    \u003cruleset name=\"WP-CLI-PROJECT-NAME\"\u003e\n    \u003cdescription\u003eCustom ruleset for WP-CLI PROJECT NAME\u003c/description\u003e\n\n        \u003c!-- What to scan. --\u003e\n        \u003cfile\u003e.\u003c/file\u003e\n\n        \u003c!-- Show progress. --\u003e\n        \u003carg value=\"p\"/\u003e\n\n        \u003c!-- Strip the filepaths down to the relevant bit. --\u003e\n        \u003carg name=\"basepath\" value=\"./\"/\u003e\n\n        \u003c!-- Check up to 8 files simultaneously. --\u003e\n        \u003carg name=\"parallel\" value=\"8\"/\u003e\n\n        \u003c!-- For help understanding the `testVersion` configuration setting:\n             https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions --\u003e\n        \u003cconfig name=\"testVersion\" value=\"5.4-\"/\u003e\n\n        \u003c!-- Rules: Include the base ruleset for WP-CLI projects. --\u003e\n        \u003crule ref=\"WP_CLI_CS\"/\u003e\n\n    \u003c/ruleset\u003e\n    ```\n\n    All other [PHPCS configuration options](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset) are, of course, available.\n6. Update your composer dependencies and regenerate your autoloader and binary folders:\n    ```bash\n    composer update\n    ```\n\nYou are now ready to use the testing framework from within your package.\n\n### Launching the tests\n\nYou can use the following commands to control the tests:\n\n* `composer prepare-tests` - Set up the database that is needed for running the functional tests. This is only needed once.\n* `composer test` - Run all test suites.\n* `composer lint` - Run only the linting test suite.\n* `composer phpcs` - Run only the code sniffer test suite.\n* `composer phpcbf` - Run only the code sniffer cleanup.\n* `composer phpunit` - Run only the unit test suite.\n* `composer behat` - Run only the functional test suite.\n\n### Controlling what to test\n\nTo send one or more arguments to one of the test tools, prepend the argument(s) with a double dash. As an example, here's how to run the functional tests for a specific feature file only:\n```bash\ncomposer behat -- features/cli-info.feature\n```\n\nPrepending with the double dash is needed because the arguments would otherwise be sent to Composer itself, not the tool that Composer executes.\n\n### Controlling the test environment\n\n#### WordPress Version\n\nYou can run the tests against a specific version of WordPress by setting the `WP_VERSION` environment variable.\n\nThis variable understands any numeric version, as well as the special terms `latest` and `trunk`.\n\nNote: This only applies to the Behat functional tests. All other tests never load WordPress.\n\nHere's how to run your tests against the latest trunk version of WordPress:\n```bash\nWP_VERSION=trunk composer behat\n```\n\n#### WP-CLI Binary\n\nYou can run the tests against a specific WP-CLI binary, instead of using the one that has been built in your project's `vendor/bin` folder.\n\nThis can be useful to run your tests against a specific Phar version of WP_CLI.\n\nTo do this, you can set the `WP_CLI_BIN_DIR` environment variable to point to a folder that contains an executable `wp` binary. Note: the binary has to be named `wp` to be properly recognized.\n\nAs an example, here's how to run your tests against a specific Phar version you've downloaded.\n```bash\n# Prepare the binary you've downloaded into the ~/wp-cli folder first.\nmv ~/wp-cli/wp-cli-1.2.0.phar ~/wp-cli/wp\nchmod +x ~/wp-cli/wp\n\nWP_CLI_BIN_DIR=~/wp-cli composer behat\n```\n\n### Setting up the tests in Travis CI\n\nBasic rules for setting up the test framework with Travis CI:\n\n* `composer prepare-tests` needs to be called once per environment.\n* `linting and sniffing` is a static analysis, so it shouldn't depend on any specific environment. You should do this only once, as a separate stage, instead of per environment.\n* `composer behat || composer behat-rerun` causes the Behat tests to run in their entirety first, and in case their were failed scenarios, a second run is done with only the failed scenarios. This usually gets around intermittent issues like timeouts or similar.\n\nHere's a basic setup of how you can configure Travis CI to work with the test framework (extract):\n```yml\ninstall:\n  - composer install\n  - composer prepare-tests\n\nscript:\n  - composer phpunit\n  - composer behat || composer behat-rerun\n\njobs:\n  include:\n    - stage: sniff\n      script:\n        - composer lint\n        - composer phpcs\n      env: BUILD=sniff\n    - stage: test\n      php: 7.2\n      env: WP_VERSION=latest\n    - stage: test\n      php: 7.2\n      env: WP_VERSION=3.7.11\n    - stage: test\n      php: 7.2\n      env: WP_VERSION=trunk\n```\n\n#### WP-CLI version\n\nYou can point the tests to a specific version of WP-CLI through the `WP_CLI_BIN_DIR` constant:\n```bash\nWP_CLI_BIN_DIR=~/my-custom-wp-cli/bin composer behat\n```\n\n#### WordPress version\n\nIf you want to run the feature tests against a specific WordPress version, you can use the `WP_VERSION` constant:\n```bash\nWP_VERSION=4.2 composer behat\n```\n\nThe `WP_VERSION` constant also understands the `latest` and `trunk` as valid version targets.\n\n#### The database credentials\n\nBy default, the tests are run in a database named `wp_cli_test` with the user also named `wp_cli_test` with password `password1`.\nThis should be set up via the `composer prepare-tests` command.\n\nThe following environment variables can be set to override the default database credentials.\n\n  - `WP_CLI_TEST_DBHOST` is the host to use and can include a port, i.e \"127.0.0.1:33060\" (defaults to \"localhost\")\n  - `WP_CLI_TEST_DBROOTUSER` is the user that has permission to administer databases and users (defaults to \"root\").\n  - `WP_CLI_TEST_DBROOTPASS` is the password to use for the above user (defaults to an empty password).\n  - `WP_CLI_TEST_DBNAME` is the database that the tests run under (defaults to \"wp_cli_test\").\n  - `WP_CLI_TEST_DBUSER` is the user that the tests run under (defaults to \"wp_cli_test\").\n  - `WP_CLI_TEST_DBPASS` is the password to use for the above user (defaults to \"password1\").\n  - `WP_CLI_TEST_DBTYPE` is the database engine type to use, i.e. \"sqlite\" for running tests on SQLite instead of MySQL (defaults to \"mysql\").\n\nEnvironment variables can be set for the whole session via the following syntax: `export WP_CLI_TEST_DBNAME=custom_db`.\n\nThey can also be set for a single execution by prepending them before the Behat command: `WP_CLI_TEST_DBNAME=custom_db composer behat`.\n\n## Contributing\n\nWe appreciate you taking the initiative to contribute to this project.\n\nContributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.\n\nFor a more thorough introduction, [check out WP-CLI's guide to contributing](https://make.wordpress.org/cli/handbook/contributing/). This package follows those policy and guidelines.\n\n### Reporting a bug\n\nThink you’ve found a bug? We’d love for you to help us get it fixed.\n\nBefore you create a new issue, you should [search existing issues](https://github.com/wp-cli/wp-cli-tests/issues?q=label%3Abug%20) to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.\n\nOnce you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/wp-cli/wp-cli-tests/issues/new). Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, [review our bug report documentation](https://make.wordpress.org/cli/handbook/bug-reports/).\n\n### Creating a pull request\n\nWant to contribute a new feature? Please first [open a new issue](https://github.com/wp-cli/wp-cli-tests/issues/new) to discuss whether the feature is a good fit for the project.\n\nOnce you've decided to commit the time to seeing your pull request through, [please follow our guidelines for creating a pull request](https://make.wordpress.org/cli/handbook/pull-requests/) to make sure it's a pleasant experience. See \"[Setting up](https://make.wordpress.org/cli/handbook/pull-requests/#setting-up)\" for details specific to working on this package locally.\n\n## Support\n\nGitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support\n\n\n","funding_links":[],"categories":["Official links"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-cli%2Fwp-cli-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwp-cli%2Fwp-cli-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-cli%2Fwp-cli-tests/lists"}