Using annotations in PHPUnit is a non-obtrusive way to control input for test cases. E.g., a custom annotation @httpMockWillRejectWith404
can be added which will instruct a mocked HTTP server to return a 404 code for all requests.
Created
March 4, 2015 09:04
-
-
Save StanAngeloff/60356fca93d3de6e1cb1 to your computer and use it in GitHub Desktop.
Using annotations to control input for PHPUnit test cases
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 | |
final class ClassTest extends \PHPUnit_Framework_TestCase | |
{ | |
# [..] | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function runTest() | |
{ | |
$annotations = $this->getAnnotations(); | |
if (isset ($annotations['method']['myAnnotation'])) { | |
# Set up mock objects accordingly... | |
} | |
return parent::runTest(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment