2017 © Pedro Peláez
 

library php-stub

Small stubbing library for making dumb colaborators.

image

nulpunkt/php-stub

Small stubbing library for making dumb colaborators.

  • Monday, November 10, 2014
  • by nulpunkt
  • Repository
  • 2 Watchers
  • 2 Stars
  • 2,569 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

php-stub Build Status

A library for making colaborators, meant for testing., (*1)

Installation

Use composer to require:, (*2)

"nulpunkt/php-stub": "dev-master"

Examples

use Nulpunkt\PhpStub\Stub;

// A standard Stub
$stub = new Stub([
    'answer' => 42,
    'callMe' => function($a) { return $a; } # Anything which is a callable
]);
$stub->foo = 'bar';
$stub->myMethod = function() { return 50; };
echo $stub->answer(); # => 42
echo $stub->answer; # => 42
echo $stub->callMe('maybe'); # => 'maybe'
echo $stub->foo; # => 'bar'
echo $stub->myMethod(); # => 50
echo $stub->lol()->hey(); # => $stub

// Different configurations
$stub = new Stub([], ['chainable' => false]);
echo $stub->lol(); # => null

// We can throw exceptions on missing functions
$stub = new Stub([], ['throw' => true]);
echo $stub->lol(); # throws a RuntimeException

$stub = new Stub(
    [], 
    ['throw' => true, 'exceptionclass' => 'InvalidArgumentException', 'exceptionmessage' => 'Bad function call']
);
echo $stub->lol(); # throws an InvalidArgumentException with message "Bad function call"

The Versions

10/11 2014

dev-master

9999999-dev http://github.com/nulpunkt/php-stub

Small stubbing library for making dumb colaborators.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

stubs

10/11 2014

0.3.0

0.3.0.0 http://github.com/nulpunkt/php-stub

Small stubbing library for making dumb colaborators.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

stubs

12/09 2014

0.2.1

0.2.1.0 http://github.com/nulpunkt/php-stub

Small stubbing library for making dumb colaborators.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

stubs

19/12 2013

0.2.0

0.2.0.0 http://github.com/nulpunkt/php-stub

Small stubbing library for making dumb colaborators.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

stubs

04/10 2013

v0.1.0

0.1.0.0 http://github.com/nulpunkt/php-stub

Small stubbing library for making dumb colaborators.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

stubs