Created
September 22, 2012 15:15
-
-
Save everzet/3766488 to your computer and use it in GitHub Desktop.
How BasicRepresenter object specification looks inside PHPSpec2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace spec\PHPSpec2\Formatter\Representer; | |
use PHPSpec2\ObjectBehavior; | |
use PHPSpec2\MethodBehavior; | |
class BasicRepresenter extends ObjectBehavior | |
{ | |
function it_should_represent_any_value() | |
{ | |
$this->representValue(42.30)->shouldReturn('double(42.3)'); | |
} | |
} | |
class BasicRepresenter_representValue extends MethodBehavior | |
{ | |
function it_should_represent_short_string_by_showing_it() | |
{ | |
$this('some_string')->shouldReturn('"some_string"'); | |
} | |
function it_should_represent_long_string_by_showing_its_type() | |
{ | |
$this('some_string_longer_than_thirty_characters')->shouldReturn('[string]'); | |
} | |
function it_should_represent_integer_by_showing_it() | |
{ | |
$this(42)->shouldReturn('integer(42)'); | |
} | |
function it_should_represent_object_as_classname() | |
{ | |
$this(new \stdClass)->shouldReturn('object(stdClass)'); | |
} | |
function it_should_represent_array_as_elements_count() | |
{ | |
$this(array(1, 2, 3))->shouldReturn('array(3)'); | |
} | |
function it_should_represent_boolean_as_string() | |
{ | |
$this(true)->shouldReturn('true'); | |
} | |
function it_should_represent_closure_as_type() | |
{ | |
$this(function(){})->shouldReturn('[closure]'); | |
} | |
} |
Author
everzet
commented
Sep 22, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment