Skip to content

An hopefully growing assortment of PHP test tools for a smoother testing experience.

Notifications You must be signed in to change notification settings

lucatume/test-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test Tools

An hopefully growing assortment of PHP test tools for a smoother testing experience.

Code example

Ours is a fast-paced world, no time to read docs.

use function tad\TestTools\revealOrReturn;
use tad\FunctionMocker\FunctionMocker;
class ClassOneTest extends \Codeception\TestCase\Test {

    protected $a;
    protected $b;
    protected $c;
    protected $d;

    public function setUp() {
        $this->a = $this->prophesize( 'A' );
        $this->b = $this->getMockBuilder( 'B' );
        $this->c = FunctionMocker::replace( 'C' );
        $this->d = new D;
    }

    protected function makeInstance() {
        return new ClassOne(
            revealOrReturn( $this->a ),
            revealOrReturn( $this->b ),
            revealOrReturn( $this->c ),
            revealOrReturn( $this->d )
        );
    }

    public function testOne() {
        $this->a->someMethod()->willReturn( 12 );
        $sut = $this->makeInstance();

        $sut->doSomething();

        $this->assertTrue( true );
    }

    public function testTwo() {
        $this->b->expects($this->any())->method('anotherMethod')->willReturn(23);
        $sut = $this->makeInstance();

        $sut->doSomethingElse();

        $this->assertTrue( true );
    }

    public function testThree() {
        $this->c->method('yetAnotherMethod', 13);
        $sut = $this->makeInstance();

        $sut->doSomethingElse();

        $this->assertTrue( true );
    }
}

More to come.

Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

[0.1.0] - 2016-01-15

Added

  • revealOrReturn function

About

An hopefully growing assortment of PHP test tools for a smoother testing experience.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages