-
Notifications
You must be signed in to change notification settings - Fork 895
Running tests
WordPress SEO is using Travis CI to run its tests after every commit. Should you want to run the WordPress SEO in your local development area you can take the following steps.
Make sure you have Composer and PHPUnit installed.
- Set up the WordPress core test environment, following Automated Testing instructions in the Core Handbook
- Set up the development copy of the plugin, following setting up development copy instructions in the wiki
- Run
composer config-yoastcs
in the plugin's directory to set up PHP Code Sniffer settings.
The following commands should now be used in plugin's directory:
-
phpunit -c phpunit.xml
will run unit tests -
vendor/bin/phpcs
will run code style check
- Set up PHPUnit support, following instructions in documentation.
- Create new run configuration via: Run > Edit Configurations > Add New Configuration > PHPUnit
- Set Test Scope to Defined in the configuration file
- Enable Use alternative configuration file and point to
wordpress-seo/phpunit.xml
file location - Save configuration
- Run configuration via Run menu
- Follow instructions for normal PHPUnit setup
- Make sure you have Xdebug PHP extension enabled with
xdebug.coverage_enable
andxdebug.extended_info
- Run configuration via Run menu > Run [configuration name] with coverage...
- Configure Settings > Languages & Frameworks > PHP > Code Sniffer > PHP Code Sniffer (phpcs) path to point to
vendor/bin/phpcs
in the plugin. - Enable Settings > Editor > Inspections > PHP > PHP Code Sniffer validation
- Set Severity to Error
- Set Show warning as to desired level
- Set Coding standard to Yoast (make sure you had run
composer config-yoastcs
before this)
You will see results inline, together with other inspections.
- Configure Settings > Languages & Frameworks > PHP > Mess Detector > PHP Mess Detector (phpmd) path to point to
vendor/bin/phpmd
in the plugin. - Enable Settings > Editor > Inspections > PHP > PHP Mess Detector validation
- Set Severity to desired level
- Disable all Options
- Add Custom ruleset, pointing to
vendor/yoast/yoastcs/phpmd.xml
You will see results inline, together with other inspections.
- Install Laps plugin into WordPress installation, with Composer or built release download
- The Laps output in WordPress Toolbar will show performance breakdown of current page
- Laps has dedicated set of events for Yoast plugins (work in progress), events can be pull requested to
Yoast_Events
class or suggested on issue tracker
- Make sure you're on a (virtual) machine with PHP, MySQL, PEAR, PHPUnit and Git installed.
- Open a terminal and navigate to the plugin root folder,
/wp-content/plugins/wordpress-seo
- Create a file with the contents of this gist and name it
tests.sh
- Run
bash tests.sh
.
The script will then download the WordPress development suite, activate the plugin and run PHPUnit with the configuration included in the phpunit.xml
file. It will also download and install PHP_CodeSniffer to check the code against the WordPress Code Standard.
After running the tests.sh
script it will ask you for the following environment variables to test against.
WP_MULTISITE
Possible values: 0
, 1
WP_VERSION
Possible values: master
, 3.9
, 3.8
or any other valid develop.git.wordpress.org branch.