Giter Club home page Giter Club logo

wordpressbehatextension's Introduction

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 | [email protected]          | 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

wordpressbehatextension's People

Contributors

tmf avatar wdalmut avatar johnbillion avatar

Stargazers

Reilly Lowery avatar Mattias avatar Christian Johansson avatar Sven Wagener avatar Russell Vea avatar Mitra Mejia avatar Matt Vanderpol avatar Otto Rask avatar George Mamadashvili avatar Drew Jaynes avatar Edwin Siebel avatar Stephen Edgar avatar Charles Fulton avatar Mason James avatar John P. Bloch avatar Dave Smith avatar Jonathan Bardo avatar Richie avatar Luís Rodrigues avatar

Watchers

Otto Rask avatar Charles Fulton avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.