tmf / wordpress-extension
WordPress extension for Behat 3
Requires
- behat/behat: ~3.0,>=3.0.4
- behat/mink-extension: ~2.0@dev
- phpunit/phpunit: ~4.0
- symfony/filesystem: ~2.3
- symfony/finder: ~2.3
This package is not auto-updated.
Last update: 2024-12-21 17:47:44 UTC
README
This is a Behat 3.0 Extension for WordPress plugin and theme development. You can use it to test your WordPress installation, or just test your plugin/theme without installing them in a normal WordPress installation (i.e. stand-alone). The Extension allows you to use WordPress functions in your context class (if you extend it from Tmf\WordPressExtension\Context\WordPressContext).
Installation
-
Add a composer development requirement for your WordPress theme or plugin:
{ "require-dev" : { "tmf/wordpress-extension": "~0.1", "johnpbloch/wordpress": "~4.0.0" } }
-
Add the following Behat configuration file:
default: suites: default: contexts: - Tmf\WordPressExtension\Context\WordPressContext extensions: Tmf\WordPressExtension: path: '%paths.base/vendor/wordpress' Behat\MinkExtension: base_url: 'http://localhost:8000' sessions: default: goutte: ~
-
Install the vendors and initialize behat test suites
composer update vendor/bin/behat --init
-
Start your development web server and point its document root to the wordpress directory in vendors (without mail function)
php -S localhost:8000 -t vendor/wordpress -d disable_functions=mail
-
Write some Behat features and test them
Feature: Manage plugins In order to manage plugins As an admin I need to enable and disable plugins Background: Given I have a vanilla wordpress installation | name | email | username | password | | BDD WordPress | your@email.com | admin | test | And I am logged in as "admin" with password "test" Scenario: Enable the dolly plugin Given there are plugins | plugin | status | | hello.php | enabled | When I go to "/wp-admin/" Then I should see a "#dolly" element Scenario: Disable the dolly plugin Given there are plugins | plugin | status | | hello.php | disabled | When I go to "/wp-admin/" Then I should not see a "#dolly" element
-
Run the tests
vendor/bin/behat