Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.