mailgun-php/tests/Api/TestCase.php
Tobias Nyholm 738e6e32e2 POC - Better api (#192)
* Added base for the new API

* code style

* Added response classes

* Added support for serializer

* The abstract API should not know of Mailgun

* Minor

* minor

* Using a client configrator

* code style

* Put HTTPClient in the configurator

* Do not use the api() function

* Use stable version of Assert

* style

* Fixed tests

* make the httpClient private

* Renamed ResponseSerializer to ResponseDeserializer

* Disabled tests that are testing error messages with Assert

* style fixes

* Refactoring fix
2016-10-24 12:01:32 -05:00

36 lines
1.1 KiB
PHP

<?php
namespace Mailgun\Tests\Api;
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
* @author Contributors of https://github.com/KnpLabs/php-github-api
*/
abstract class TestCase extends \PHPUnit_Framework_TestCase
{
abstract protected function getApiClass();
protected function getApiMock()
{
$httpClient = $this->getMockBuilder('Http\Client\HttpClient')
->setMethods(['sendRequest'])
->getMock();
$httpClient
->expects($this->any())
->method('sendRequest');
$requestClient = $this->getMockBuilder('Http\Message\MessageFactory')
->setMethods(['createRequest', 'createResponse'])
->getMock();
$serializer = $this->getMockBuilder('Mailgun\Serializer\ResponseDeserializer')
->setMethods(['deserialize'])
->getMock();
return $this->getMockBuilder($this->getApiClass())
->setMethods(['get', 'post', 'postRaw', 'delete', 'put'])
->setConstructorArgs([$httpClient, $requestClient, $serializer])
->getMock();
}
}