Skip to content

bencates/php_as_expected

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP As Expected

PHP As Expected is a PHPUnit compatible assertion library.

Usage

Either include path/to/vendor/folder/PHPAsExpected/functions.php or add the following function to your TestCase base class:

class My_TestCase extends PHPUnit_Framework_TestCase
{
    private function expect($subject)
    {
        return new PHPAsExpected\Expectations\Expectation($subject);
    } 
}

Then in your tests you can call expect() like so:

class FooBarTest extends My_TestCase
{
    function testSomething()
    {
        // if included via functions.php
        expect(true)->toBeTrue();
    }

    function testSomethingElse()
    {
        // if included via class declaration
        $this->expect(2 + 2)->toEqual(4);
    }
}

Supported Exceptions

  • toBeTrue()
  • toBeTruthy()
  • toBeFalse()
  • toBeFalsy()
  • toBeNull()
  • toEqual($other)
  • toMatch($regex)

About

PHPUnit compatible expectations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages