Skip to content

Instantly share code, notes, and snippets.

@everzet
Created September 22, 2012 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save everzet/3766488 to your computer and use it in GitHub Desktop.
Save everzet/3766488 to your computer and use it in GitHub Desktop.
How BasicRepresenter object specification looks inside PHPSpec2
<?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]');
}
}
@everzet
Copy link
Author

everzet commented Sep 22, 2012

Output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment