GithubHelp home page GithubHelp logo

isabella232 / plugin-tester Goto Github PK

View Code? Open in Web Editor NEW

This project forked from humanmade/plugin-tester

0.0 0.0 0.0 36 KB

Simple Docker image for running unit tests for WordPress plugins

Dockerfile 58.66% Shell 16.54% PHP 24.81%

plugin-tester's Introduction

humanmade/plugin-tester

Docker Pulls Docker Image Size (latest by date)

Simple Docker image for running unit tests for WordPress plugins.

To run the tests for your plugin, run this in your plugin directory:

docker run --rm -v "$PWD:/code" humanmade/plugin-tester

You will need phpunit/phpunit specified as a Composer dependency of your plugin. Additional arguments can be passed to PHPUnit on the CLI directly, e.g.:

docker run --rm -v "$PWD:/code" humanmade/plugin-tester --stop-on-error

Configuration

To configure PHPUnit, place a phpunit.xml.dist in the plugin root. You can alternatively use the command line arguments for PHPUnit for simpler tests.

Typically your tests directory in your plugin should include a bootstrap.php including at least the following:

<?php
require '/wp-phpunit/includes/functions.php';

tests_add_filter( 'muplugins_loaded', function () {
	require dirname( __FILE__ ) . '/../your-plugin-entry-point.php';
} );

require '/wp-phpunit/includes/bootstrap.php';

Continuous Integration with Travis

For Travis, the following minimal configuration will get your tests running:

services:
  - docker

before_script:
  - composer install

script:
  - docker run --rm -v "$PWD:/code" humanmade/plugin-tester

We recommend also caching the vendor directory:

cache:
  timeout: 1000
  directories:
    - vendor

Code Coverage

Plugin Tester includes pcov for test coverage, which is natively supported by PHPUnit 8+.

WordPress requires PHPUnit 7, so slight adjustments need to be made to PHPUnit to fix compatibility. Plugin Tester will do this automatically for you, provided you have pcov-clobber installed via Composer:

composer require --dev pcov/clobber

You can then set up coverage in your phpunit.xml.dist, or use the command-line flags:

docker run --rm -v "$PWD:/code" humanmade/plugin-tester --coverage-text --whitelist inc/

plugin-tester's People

Contributors

joehoyle avatar kadamwhite avatar rmccue 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.