{"id":21484189,"url":"https://github.com/stephenharris/phpunit-require-wordpress-version","last_synced_at":"2026-05-18T08:32:46.556Z","repository":{"id":57059658,"uuid":"69680171","full_name":"stephenharris/phpunit-require-wordpress-version","owner":"stephenharris","description":"Skip WordPress PHPUnit tests based on the version of WordPress running using @ requires WordPress","archived":false,"fork":false,"pushed_at":"2016-10-01T18:18:01.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-25T03:52:35.105Z","etag":null,"topics":["phpunit-tests","wordpress"],"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/stephenharris.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":"2016-09-30T15:50:22.000Z","updated_at":"2017-05-17T14:12:48.000Z","dependencies_parsed_at":"2022-08-24T07:30:39.749Z","dependency_job_id":null,"html_url":"https://github.com/stephenharris/phpunit-require-wordpress-version","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stephenharris/phpunit-require-wordpress-version","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenharris%2Fphpunit-require-wordpress-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenharris%2Fphpunit-require-wordpress-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenharris%2Fphpunit-require-wordpress-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenharris%2Fphpunit-require-wordpress-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephenharris","download_url":"https://codeload.github.com/stephenharris/phpunit-require-wordpress-version/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenharris%2Fphpunit-require-wordpress-version/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33170846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T05:43:36.989Z","status":"ssl_error","status_checked_at":"2026-05-18T05:43:19.133Z","response_time":71,"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":["phpunit-tests","wordpress"],"created_at":"2024-11-23T12:50:27.130Z","updated_at":"2026-05-18T08:32:46.536Z","avatar_url":"https://github.com/stephenharris.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @requires WordPress\n\nThis package provides a trait (to use in your test cases) so that you can run your\nphpunit tests for specific WordPress versions:\n\n```php\nclass My_Test_Case extends WP_UnitTestCase {\n\tuse StephenHarris\\PHPUnit\\RequiresWordPressVersion;\n\n}\n```\n\nThen in your tests:\n\n```php\nclass My_Test extends My_Test_Case {\n\n\t/**\n\t * @requires WordPress 4.4.0\n\t */\n\t function testSomethingThatRequiresTermMeta() {\n\t\t \t// test will be skipped unless WordPress \u003e= 4.4.0\n\t }\n\n}-\n```\n\n\n## Getting Started\n\n### Installation\n\nTo install you need:\n\n- PHP 5.4+\n- Composer\n\nYou can install by running following command in your project folder:\n\n```\ncomposer require stephenharris/phpunit-require-wordpress-version:1.* --dev\n```\n\nAlternativevely you can directly edit your composer.json by adding:\n\n```\n{\n  \"require-dev\": {\n    \"stephenharris/phpunit-require-wordpress-version\": \"~1.0\"\n  }\n}\n```\n\n### Setting up your test cases\n\nTo use, simply add the `use` statement for the provided trait to your test case:\n\n```php\nclass My_Test_Case extends WP_UnitTestCase {\n\tuse StephenHarris\\PHPUnit\\RequiresWordPressVersion;\n\n}\n```\n\nThis trait overloads the `PHPUnit_Framework_TestCase::checkRequirements()`, if you\nalready overloading `checkRequirements()` in your test case class then you can alias\nthe method:\n\n```php\nclass My_Test_Case extends WP_UnitTestCase {\n\tuse StephenHarris\\PHPUnit\\RequiresWordPressVersion {\n\t\tcheckRequirements as checkWordPressVersionRequirements;\n\t}\n\n\tfunction checkRequirements() {\n\t\t$this-\u003echeckWordPressVersionRequirements();\n\n\t\t//... your checkRequirements() method here\n\t}\n\n}\n```\n\nIf you are using multiple traits with the `checkRequirements()` method, then you will\nneed to resolve the conflicts using aliases:\n\n```php\nclass My_Test_Case extends WP_UnitTestCase {\n\tuse StephenHarris\\PHPUnit\\RequiresWordPressVersion {\n\t\tcheckRequirements as checkWordPressVersionRequirements;\n\t}\n\tuse Some\\Other\\checkRequirementsTrait {\n\t\tcheckRequirements as checkSomeOtherRequirements;\n\t}\n\n\tfunction checkRequirements() {\n\t\t$this-\u003echeckWordPressVersionRequirements();\n\t\t$this-\u003echeckSomeOtherRequirements();\n\t}\n\n}\n```\n\n## Examples\n\n```php\nclass My_Test extends My_Test_Case {\n\n\t/**\n\t * @requires WordPress 4.4.0\n\t */\n\t function testSomethingRequiresAtLeast440() {\n\t\t \t// test will be skipped unless WordPress \u003e= 4.4.0\n\t }\n\n\t/**\n\t * @requires WordPress \u003e= 4.4.0-alpha-123\n\t */\n\t function testSomethingRequiresAtLeast440alpha123() {\n\t\t \t// test will be skipped unless WordPress \u003e= 4.4.0-alpha-123\n\t\t \t// also works if you specify 4.4-alpha-123 instead\n\t }\n\n\t/**\n\t * @requires WordPress \u003e 4.6.2-rc-1\n\t */\n\t function testSomethingRequiresGreaterThan462ReleaseCandidate() {\n\t \t // test will be skipped unless WordPress version is greater than 4.6.2-rc-1\n\t }\n\n\t/**\n\t * @requires WordPress == 4.6.0\n\t */\n\t function testOnlyRunsForWordPress460() {\n\t \t // test will only run with version 4.6.0\n\t }\n\n\t/**\n\t * @requires WordPress != 4.6\n\t */\n\tfunction testSkippedIf460() {\n\t\t// test will be skipped if WordPress version is 4.6.0\n\t}\n\n\t/**\n\t * @requires WordPress \u003c 4.2-alpha-1234\n\t */\n\tfunction testOnlyRunsForVersionsBefore42Alpha1234() {\n\t\t// test will only run for WordPress versions strictly less than4.2-alpha-1234\n\t}\n\n\t/**\n\t * @requires WordPress \u003c= 4.2.0\n\t */\n\tfunction testOnlyRunsFor420AndEarlier() {\n\t\t// test will only run for WordPress version 4.2.0 and earlier\n\t}\n\n}\n```\n\n### Alternative syntax\n\nYou use `@requires WordPress` with just a version number, and no operator:\n\n```php\n/**\n * @requires WordPress 4.2.0\n */\n```\n\nwhich means the test requires WordPress 4.2.0 or higher to run, and is otherwise\nskipped. Or you can specify an operator. E.g:\n\n```php\n/**\n * @requires WordPress \u003c 4.2.0\n */\n```\n\nwhich means the test requires a WordPress version strictly before 4.2.0.\n\nThe various operators supported are listed below. Also note, that you do not\nneed to include the patch version number if it is 0.\n\n* WordPress greater than or equal to 4.4.0\n  - WordPress 4.4\n  - WordPress 4.4.0\n  - WordPress \u003e= 4.4.0\n  - WordPress ge 4.4.0\n\n* WordPress greater than 4.4.0\n  - WordPress \u003e 4.4\n  - WordPress \u003e 4.4.0\n  - WordPress gt 4.4.0\n\n* WordPress equal to 4.4.0\n  - WordPress == 4.4\n  - WordPress == 4.4.0\n  - WordPress = 4.4.0\n  - WordPress eq 4.4.0\n\n* WordPress not equal to 4.4.0\n  - WordPress != 4.4\n  - WordPress != 4.4.0\n  - WordPress ne 4.4.0\n  - WordPress \u003c\u003e 4.4.0\n\n* WordPress less than 4.4.0\n  - WordPress \u003c 4.4\n  - WordPress \u003c 4.4.0\n  - WordPress lt 4.4.0\n\n* WordPress less than or equal to 4.4.0\n  - WordPress \u003c= 4.4\n  - WordPress \u003c= 4.4.0\n  - WordPress le 4.4.0\n\n\n## License\n\nThis package is open source and released under MIT license. See LICENSE file for more info.\n\n## Questions? Problems?\n\nPlease open an issue at \u003chttps://github.com/stephenharris/phpunit-require-wordpress-version/issues\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenharris%2Fphpunit-require-wordpress-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenharris%2Fphpunit-require-wordpress-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenharris%2Fphpunit-require-wordpress-version/lists"}