potherca/phpunit-testcase-traits

Traits that offer helper functions to be used in PHPUnit TestCases.

v0.4.0 2017-06-23 12:01 UTC

README

project-stage-badge license-badge

Traits that offer helper functions to be used in PHPUnit TestCases.

Introduction

This projects contains various traits that offer convenience methods for tasks that occur when creating test code.

Installation

composer require 'potherca/phpunit-testcase-traits'

Usage

Add a use statement for a desired trait to a class definition. The public API of that trait can then be used in the defined class.

For full details on how to use traits, please refer to the section on traits in the PHP manual.

Available traits

  • CreateDataProviderTrait -- Create data-provider arrays.
    Creates a key/value pair from a given one-dimensional array of values, which is meant to be returned from a data-provider method in a TestCase.

  • CreateObjectFromAbstractClassTrait -- Create an object instance from an abstract class.
    Creates a concrete object whose methods can be called and, thus, be tested.

  • GetCompatibleExceptionNameTrait -- _Provide names of PHP5 compatible PHPUnit_Framework_Exception for (new) PHP7 Exceptions._

  • SetNonPublicPropertyTrait -- Change the value of a non-public class properties.

Colophon