johnbillion / wp-browser

Easy acceptance, functional, integration and unit testing for WordPress plugins, themes and sites using Codeception.

Home Page:https://wpbrowser.wptestkit.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wp-browser

CI

wp-browser provides easy acceptance, functional, integration and unit testing for WordPress plugins, themes and whole sites using Codeception.

Find out more in the documentation.

Installation and setup - the really fast version

Using Composer require wp-browser as a development dependency:

cd my-wordrpess-project
composer require --dev lucatume/wp-browser
vendor/bin/codecept init wpbrowser

Answer the questions and you will be ready to test your project. Find out more about the setup in the project documentation.

Using wp-browser with Codeception 4.0

Codeception version 4.0, while still being compatible with PHP 5.6 and wp-browser, did break its structure into discrete modules.

If you want to use wp-browser with Codeception version 4.0+ you will need to make sure you've got all the required packages.
Add the following requirements in your composer.json file, in the require-dev section:

{
  "require-dev": {
    "lucatume/wp-browser": "^3.0",
    "codeception/module-asserts": "^1.0",
    "codeception/module-phpbrowser": "^1.0",
    "codeception/module-webdriver": "^1.0",
    "codeception/module-db": "^1.0",
    "codeception/module-filesystem": "^1.0",
    "codeception/module-cli": "^1.0",
    "codeception/util-universalframework": "^1.0"
  }
}

You might not need all of them depending on the modules you use in your suites, but this will cover all the modules for this project.

Read more here.

Usage

The project provides a number of modules to ease the testing of WordPress projects; you can find out more in the modules section of the documentation.
Here's a quick example acceptance test you can write:

// tests/acceptance/PrivatePostsCept.php
$I->haveManyPostsInDatabase(3, ['post_title' => 'Test post {{n}}', 'post_status' => 'private']);

$I->loginAs('subscriber', 'secret');
$I->amOnPage('/');
$I->see('Nothing found');

$I->loginAs('editor', 'secret');
$I->amOnPage('/');
$I->see('Test post 0');
$I->see('Test post 1');
$I->see('Test post 2');

This is just a bite though, find out more in the documentation.

Current Sponsors

My sincere thanks to my sponsors: you make maintaining this project easier.

About

Easy acceptance, functional, integration and unit testing for WordPress plugins, themes and sites using Codeception.

https://wpbrowser.wptestkit.dev/

License:MIT License


Languages

Language:PHP 98.1%Language:Handlebars 1.2%Language:Makefile 0.4%Language:Shell 0.1%Language:CSS 0.1%Language:Python 0.1%Language:Dockerfile 0.0%Language:Hack 0.0%Language:HTML 0.0%