mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
Added tests for Route
This commit is contained in:
parent
42503f72ce
commit
15bd5ae156
@ -10,12 +10,38 @@
|
|||||||
namespace Mailgun\Tests\Api;
|
namespace Mailgun\Tests\Api;
|
||||||
|
|
||||||
use GuzzleHttp\Psr7\Response;
|
use GuzzleHttp\Psr7\Response;
|
||||||
|
use Mailgun\Api\Route;
|
||||||
|
use Mailgun\Model\Route\Response\DeleteResponse;
|
||||||
|
use Mailgun\Model\Route\Response\IndexResponse;
|
||||||
|
use Mailgun\Model\Route\Response\ShowResponse;
|
||||||
|
use Mailgun\Model\Route\Response\UpdateResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author David Garcia <me@davidgarcia.cat>
|
* @author David Garcia <me@davidgarcia.cat>
|
||||||
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||||
*/
|
*/
|
||||||
class RouteTest extends TestCase
|
class RouteTest extends TestCase
|
||||||
{
|
{
|
||||||
|
public function testIndex()
|
||||||
|
{
|
||||||
|
$this->setRequestMethod('GET');
|
||||||
|
$this->setRequestUri('/v3/routes?limit=100&skip=0');
|
||||||
|
$this->setHydrateClass(IndexResponse::class);
|
||||||
|
|
||||||
|
$api = $this->getApiInstance();
|
||||||
|
$api->index();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testShow()
|
||||||
|
{
|
||||||
|
$this->setRequestMethod('GET');
|
||||||
|
$this->setRequestUri('/v3/routes/4711');
|
||||||
|
$this->setHydrateClass(ShowResponse::class);
|
||||||
|
|
||||||
|
$api = $this->getApiInstance();
|
||||||
|
$api->show('4711');
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreate()
|
public function testCreate()
|
||||||
{
|
{
|
||||||
$api = $this->getApiMock();
|
$api = $this->getApiMock();
|
||||||
@ -26,11 +52,38 @@ class RouteTest extends TestCase
|
|||||||
$api->create('catch_all()', ['forward("mailbox@myapp.com")'], 'example', 100);
|
$api->create('catch_all()', ['forward("mailbox@myapp.com")'], 'example', 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testUpdate()
|
||||||
|
{
|
||||||
|
$this->setRequestMethod('PUT');
|
||||||
|
$this->setRequestUri('/v3/routes/4711');
|
||||||
|
$this->setHydrateClass(UpdateResponse::class);
|
||||||
|
$this->setRequestBody([
|
||||||
|
'expression' => 'catch_all()',
|
||||||
|
'action' => 'forward("mailbox@myapp.com")',
|
||||||
|
'description' => 'example',
|
||||||
|
'priority' => 100,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$api = $this->getApiInstance();
|
||||||
|
$api->update('4711', 'catch_all()', ['forward("mailbox@myapp.com")'], 'example', 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDelete()
|
||||||
|
{
|
||||||
|
$this->setRequestMethod('DELETE');
|
||||||
|
$this->setRequestUri('/v3/routes/4711');
|
||||||
|
$this->setHydrateClass(DeleteResponse::class);
|
||||||
|
|
||||||
|
$api = $this->getApiInstance();
|
||||||
|
$api->delete('4711');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getApiClass()
|
protected function getApiClass()
|
||||||
{
|
{
|
||||||
return 'Mailgun\Api\Route';
|
return Route::class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user