Skip to content

Instantly share code, notes, and snippets.

@cod3beat
Created October 8, 2015 05:02
Show Gist options
  • Save cod3beat/dbae8bf7d83bbdbf33d9 to your computer and use it in GitHub Desktop.
Save cod3beat/dbae8bf7d83bbdbf33d9 to your computer and use it in GitHub Desktop.
<?php
namespace spec;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RouteRegistrationSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('RouteRegistration');
}
function it_should_register_a_get_route()
{
$this->register('get', 'user', 'handler');
$this->shouldHaveRoute('get', 'user');
}
function it_should_register_a_post_route()
{
$this->register('post', 'user', 'handler');
$this->shouldHaveRoute('post', 'user');
}
function it_should_register_a_put_route()
{
$this->register('put', 'user', 'handler');
$this->shouldHaveRoute('put', 'user');
}
function it_should_register_a_delete_route()
{
$this->register('delete', 'user', 'handler');
$this->shouldHaveRoute('delete', 'user');
}
function it_should_return_the_registered_handler()
{
$this->register('delete', 'user', 'handler');
$this->getRegisteredHandler('delete', 'user')->shouldReturn('handler');
}
function it_should_return_the_registered_handler_for_a_complex_route(\RouteMatcher $routeMatcher)
{
$this->beConstructedWith($routeMatcher);
$this->register('delete', 'user/{id}/profile', 'handlerProfile');
$this->register('delete', 'user/{id}', 'handlerBasic');
$this->getRegisteredHandler('delete','user/1')
->shouldReturn('handlerBasic');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment