Created
November 1, 2012 14:19
-
-
Save everzet/3993894 to your computer and use it in GitHub Desktop.
Per-specification custom matchers support in phpspec2 alpha3
This file contains hidden or 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\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