eddiejaoude/phpunit-wrapper

This package is abandoned and no longer maintained. No replacement package was suggested.

PHPUnit wrapper - wraps the functionality of phpunit with easy to use plain English

0.2.1 2014-03-09 06:25 UTC

This package is not auto-updated.

Last update: 2020-02-21 16:02:56 UTC


README

Build Status Coverage Status Total Downloads

PHPUnitWrapper / phpunit-wrapper

PHPUnit wrapper - wraps the functionality of phpunit with easy to use plain & simple English

Note: Your existing standard PHPUnit tests will not fail, they will continue to work fine

Installation via Composer

    "require" : {
        "EddieJaoude\PHPUnitWrapper" : "0.*"
    }

Usage

Instead of extending \PHPUnit_Framework_TestCase, extend \EddieJaoude\PHPUnitWrapper\Assert.

The Assert class extends PHPUnit, therefore you get all the previous functionality & your previous unit tests will not fail.

Assert Equals

Standard PHPUnit

    $this->assertEquals($expected, $actual);

    // or with custom message

    $this->assertEquals($expected, $actual, $message);

PHPUnit Wrapper

    $this->expectedValue('abc')
                ->equals('abc');

    // or with custom message

    $this->expectedValue('abc')
            ->setMessage('Failure, these are not equal!') // optional
            ->equals('abc');

Assert NOT Equals

Standard PHPUnit

    $this->assertNotEquals($expected, $actual, $message);

PHPUnit Wrapper

    $this->expectedValue('abc')
            ->notEquals('abcd');

Contains

Standard PHPUnit

    $this->assertContains($needle, $haystack);

    // or with custom message

    $this->assertContains($needle, $haystack, $message);

PHPUnit Wrapper

    $this->expectedValue($needle)
            ->existsIn($haystack);

    $this->expectedValue('b')
            ->existsIn(
                array('a', 'b', 'c')
            );

    // or with custom message

    $this->expectedValue('b')
            ->setMessage('Failure, does not exist!') // optional
            ->existsIn(
                array('a', 'b', 'c')
            );

NOT Contains

Standard PHPUnit

    $this->assertNotContains($needle, $haystack);

    // or with custom message

    $this->assertNotContains($needle, $haystack, $message);

PHPUnit Wrapper

    $this->expectedValue($needle)
            ->notExistsIn($haystack);

    $this->expectedValue('b')
            ->notExistsIn(
                array('a', 'c')
            );

    // or with custom message

    $this->expectedValue('b')
            ->setMessage('Failure, does exist!') // optional
            ->notExistsIn(
                array('a', 'c')
            );

Complete usage simple Example

<?php
namespace EddieJaoude\PHPUnitWrapperTest;

use EddieJaoude\PHPUnitWrapper\Assert;

/**
 * Class ExampleTest
 *
 * @package EddieJaoude\PHPUnitWrapperTest
 */
class ExampleTest extends Assert
{

    /*
     * Example of 'assert' & 'equals'
     */
    public function testAssertEquals()
    {
        $this->expectedValue('abc')
            ->equals('abc');
    }

    /*
     * Example of 'assert' & 'equals'
     */
    public function testAssertNotEquals()
    {
        $this->expectedValue('abc')
            ->notEquals('abcd');
    }
}

Contribution

Fork, Pull Request - with Tests & Updated README with examples please

Suggestions / Ideas

Please create an Issue