Skip to content
This repository has been archived by the owner on Feb 3, 2019. It is now read-only.

johnbillion/WordPressBehatExtension

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
This branch is 11 commits ahead, 5 commits behind tmf:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 

WordPress Extension for Behat 3

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 Johnbillion\WordPressExtension\Context\WordPressContext).

Installation

  1. Add a composer development requirement for your WordPress theme or plugin:

    {
        "require-dev" : {
            "johnbillion/wordpress-behat-extension": "~0.1",
            "johnpbloch/wordpress": "~4.0.0"
        }
    }
  2. Add the following Behat configuration file:

    default:
      suites:
        default:
          contexts:
            - Johnbillion\WordPressExtension\Context\WordPressContext
      extensions:
        Johnbillion\WordPressExtension:
          path: '%paths.base/vendor/wordpress'
    
        Behat\MinkExtension:
          base_url:    'http://localhost:8000'
          sessions:
            default:
              goutte: ~
    
  3. Install the vendors and initialize behat test suites

    composer update
    vendor/bin/behat --init
  4. 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
  5. 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
    
    
  6. Run the tests

    vendor/bin/behat

About

This package is no longer maintained. Use WordHat instead.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • PHP 74.1%
  • Gherkin 25.9%