Make sure we dont use any risky tests

This commit is contained in:
Nyholm 2019-01-12 10:05:55 +01:00 committed by David Garcia
parent 0f54332d0e
commit 3fbd33f640

View File

@ -26,7 +26,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
private $requestUri; private $requestUri;
private $requestHeaders; private $requestHeaders = [];
private $requestBody; private $requestBody;
@ -89,7 +89,15 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
$requestClient = $this->getMockBuilder('Mailgun\HttpClient\RequestBuilder') $requestClient = $this->getMockBuilder('Mailgun\HttpClient\RequestBuilder')
->setMethods(['create']) ->setMethods(['create'])
->getMock(); ->getMock();
$requestClient->method('create')
if (null !== $this->requestMethod
|| null !== $this->requestUri
|| !empty($this->requestHeaders)
|| !empty($this->requestBody)
) {
$requestClient
->expects($this->once())
->method('create')
->with( ->with(
$this->callback([$this, 'validateRequestMethod']), $this->callback([$this, 'validateRequestMethod']),
$this->callback([$this, 'validateRequestUri']), $this->callback([$this, 'validateRequestUri']),
@ -97,6 +105,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
$this->callback([$this, 'validateRequestBody']) $this->callback([$this, 'validateRequestBody'])
) )
->willReturn(new Request('GET', '/')); ->willReturn(new Request('GET', '/'));
}
$hydrator = new ModelHydrator(); $hydrator = new ModelHydrator();
if (null === $this->httpResponse) { if (null === $this->httpResponse) {
@ -198,18 +207,13 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
/** /**
* Set request http method. * Set request http method.
*
* @param string $httpMethod
*/ */
public function setRequestMethod($httpMethod) public function setRequestMethod(string $httpMethod)
{ {
$this->requestMethod = $httpMethod; $this->requestMethod = $httpMethod;
} }
/** public function setRequestUri(string $requestUri)
* @param string $requestUri
*/
public function setRequestUri($requestUri)
{ {
$this->requestUri = $requestUri; $this->requestUri = $requestUri;
} }