2017 © Pedro Peláez
 

library phpunit-wrapper

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

image

eddiejaoude/phpunit-wrapper

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

  • Sunday, March 9, 2014
  • by eddiejaoude
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Build Status Coverage Status Total Downloads, (*1)

PHPUnitWrapper / phpunit-wrapper

PHPUnit wrapper - wraps the functionality of phpunit with easy to use plain & simple English, (*2)

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


Installation via Composer

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

Usage

Instead of extending \PHPUnit_Framework_TestCase, extend \EddieJaoude\PHPUnitWrapper\Assert., (*4)

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


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, (*6)


Suggestions / Ideas

Please create an Issue, (*7)

The Versions

09/03 2014

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eddie Jaoude

phpunit wrapper

09/03 2014

0.2.1

0.2.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eddie Jaoude

phpunit wrapper

09/03 2014

0.2

0.2.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eddie Jaoude

phpunit wrapper

08/03 2014

0.1

0.1.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eddie Jaoude

phpunit wrapper