\donbidon\Lib\PHPUnitTestCase

PHPUnit functionality extension.

Implements debug functionality (self::_e() and etc).
Allows to mark groups of tests as skipped.

class MyClass
{
     public function foo()
     {
     }

     public function bar()
     {
     }
}

class MyClassTest extends \donbidon\Lib\PHPUnit\TestCase
{
    public function testFoo()
    {
        $expected = 1;
        $actual   = 2;
        if ($expected !== $actual) {
            // Mark group of tests as skipped
            self::skipGroup('someGroup');
        }
        // Failed assertion
        self::assertEquals($expected, $actual);
    }

    public function testBar()
    {
        // Skip test
        self::checkGroupIfSkipped('someGroup');
        // Following code won't run
        self::assertEquals(1, 1);
    }
}

outputs

FAILURES!
Tests: 2, Assertions: 1, Failures: 1, Skipped: 1.

Summary

Methods
Properties
Constants
No public methods found
No public properties found
No constants found
skipGroup()
checkGroupIfSkipped()
skipByOS()
_e()
_pr()
_vd()
_ve()
No protected properties found
N/A
No private methods found
$groupsToSkip
N/A

Properties

$groupsToSkip

$groupsToSkip : array

Groups of tests to skip

Type

array

Methods

skipGroup()

skipGroup(string  $group, boolean  $isolate = TRUE) : void

Sets up group to skip.

Parameters

string $group
boolean $isolate

Flag specifying to isolate groups by current class name

checkGroupIfSkipped()

checkGroupIfSkipped(string  $group, boolean  $isolate = TRUE) : void

Marks test skipped if group of tests has to be skipped.

Parameters

string $group
boolean $isolate

Flag specifying to isolate groups by current class name

skipByOS()

skipByOS(string  $regExp, string  $message = "", string  $group = "", boolean  $isolate = TRUE) : void

Skips test by OS.

Parameters

string $regExp

Regexp for PHP_OS constant value

string $message

Message

string $group
boolean $isolate

_e()

_e(string  $string) : void

Outputs string.

Parameters

string $string

_pr()

_pr(mixed  $expression) : void

Prints human-readable information about a variable.

Parameters

mixed $expression

_vd()

_vd(mixed  $expression) : void

Dumps information about a variable.

Parameters

mixed $expression

_ve()

_ve(mixed  $expression) : void

Outputs a parsable string representation of a variable.

Parameters

mixed $expression