Skip to content

Demonstration or sample how WP plugin unit test work.

License

Notifications You must be signed in to change notification settings

Rundiz-WP/demo-plugin-test

Repository files navigation

Demonstration of WordPress plugin unit test.

Run unit testing.

Install

  • Install WP-CLI
  • Install PHPUnit
  • Install WordPress PHPUnit or Download for Windows
  • Download this plugin and extract in your stand alone folder OR in the installed WordPress /wp-content/plugins/demo-plugin-test folder.

Run

  • Run the command phpunit (Recommend PHPUnit 10 and PHP 8.2).
  • The result should be:

OK (1 test, 2 assertions)

Run PHP CodeSniffer.

Install

  • Install PHP_CodeSniffer (recommended to install via Composer and set Windows environment PATH to vendor/bin).
  • Install PHPCompatibilityWP (via Composer).
  • Install WordPress Coding Standard (as standalone but DO NOT follow Add its path to the PHP_CodeSniffer configuration step).
    • Manually edit vendor/squizlabs/php_codesniffer/CodeSniffer.conf file to prepend ../../../wpcs, value.

Run

  • Run the command phpcs.
  • The result should be:

E 1 / 1 (100%)

And follow with more details.

About

Demonstration or sample how WP plugin unit test work.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published