Skip to content

Instantly share code, notes, and snippets.

@everzet
Created November 1, 2012 14:19
Show Gist options
  • Save everzet/3993894 to your computer and use it in GitHub Desktop.
Save everzet/3993894 to your computer and use it in GitHub Desktop.
Per-specification custom matchers support in phpspec2 alpha3
<?php
namespace spec\Bank\Controller;
use PHPSpec2\ObjectBehavior;
use PHPSpec2\Matcher\CustomMatchersProviderInterface;
use PHPSpec2\Matcher\InlineMatcher;
class PaymentController extends ObjectBehavior implements CustomMatchersProviderInterface
{
/**
* @param Symfony\Component\HttpFoundation\Request $request
*/
function it_should_return_proper_response($request)
{
$response = $this->indexAction($request);
$response->shouldBeOKResponse();
$response->shouldNotRedirect();
}
static public function getMatchers()
{
return [
new InlineMatcher('beOKResponse', function($subject) {
return 200 === $subject->getStatusCode();
}),
new InlineMatcher('redirect', function($subject) {
return $subject->isRedirection();
}),
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment