Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.45 KB

readme.md

File metadata and controls

39 lines (29 loc) · 1.45 KB

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.