-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestAccessRequestTest.php
67 lines (54 loc) · 2.09 KB
/
TestAccessRequestTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare(strict_types=1);
namespace Message;
use Omnipay\Przelewy24\Message\TestAccessRequest;
use Omnipay\Przelewy24\Message\TestAccessResponse;
use Omnipay\Tests\TestCase;
use Symfony\Component\HttpFoundation\Response;
class TestAccessRequestTest extends TestCase
{
/**
* @var TestAccessRequest
*/
private $request;
public function setUp(): void
{
$this->request = new TestAccessRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize([]);
}
public function testGetData(): void
{
$data = $this->request->getData();
$this->assertSame([], $data);
}
public function testSendSuccess(): void
{
$this->setMockHttpResponse('TestAccessSuccess.txt');
$response = $this->request->send();
$this->assertInstanceOf(TestAccessResponse::class, $response);
$this->assertTrue($response->isSuccessful());
$this->assertSame(Response::HTTP_OK, $response->getCode());
$this->assertSame('', $response->getMessage());
$this->assertTrue($response->getTest());
}
public function testSendAuthFailure(): void
{
$this->setMockHttpResponse('TestAccessAuthFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(TestAccessResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode());
$this->assertSame('Incorrect authentication', $response->getMessage());
$this->assertFalse($response->getTest());
}
public function testSendInvalidDataFailure(): void
{
$this->setMockHttpResponse('TestAccessInvalidDataFailure.txt');
$response = $this->request->send();
$this->assertInstanceOf(TestAccessResponse::class, $response);
$this->assertFalse($response->isSuccessful());
$this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode());
$this->assertSame('Invalid input data', $response->getMessage());
$this->assertFalse($response->getTest());
}
}