-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathSmsapiClientUnitTestCase.php
More file actions
74 lines (66 loc) · 2.65 KB
/
Copy pathSmsapiClientUnitTestCase.php
File metadata and controls
74 lines (66 loc) · 2.65 KB
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
68
69
70
71
72
73
74
<?php
declare(strict_types=1);
namespace Smsapi\Client\Tests;
use Smsapi\Client\Feature\Data\DataFactoryProvider;
use Smsapi\Client\Curl\RequestFactory;
use Smsapi\Client\Curl\StreamFactory;
use Smsapi\Client\Infrastructure\RequestExecutor\LegacyRequestExecutor;
use Smsapi\Client\Infrastructure\RequestExecutor\RequestExecutorFactory;
use Smsapi\Client\Infrastructure\RequestExecutor\RestRequestExecutor;
use Smsapi\Client\Infrastructure\RequestMapper\LegacyRequestMapper;
use Smsapi\Client\Infrastructure\RequestMapper\Query\Formatter\ComplexParametersQueryFormatter;
use Smsapi\Client\Infrastructure\RequestMapper\RestRequestMapper;
use Smsapi\Client\Infrastructure\ResponseMapper\JsonDecode;
use Smsapi\Client\Infrastructure\ResponseMapper\LegacyResponseMapper;
use Smsapi\Client\Infrastructure\ResponseMapper\RestResponseMapper;
use Smsapi\Client\Service\SmsapiPlHttpService;
use Smsapi\Client\Tests\Helper\HttpClient\HttpClientMock;
class SmsapiClientUnitTestCase extends SmsapiClientTestCase
{
/** @var HttpClientMock */
private $httpClient;
/**
* @before
*/
public function prepare()
{
$this->httpClient = new HttpClientMock();
$requestFactory = new RequestFactory();
$streamFactory = new StreamFactory();
$queryFormatter = new ComplexParametersQueryFormatter();
$jsonDecode = new JsonDecode();
/** @var RequestExecutorFactory $requestExecutorFactory */
$requestExecutorFactory = $this->prophesize(RequestExecutorFactory::class);
$requestExecutorFactory
->createLegacyRequestExecutor($this->httpClient)
->willReturn(
new LegacyRequestExecutor(
new LegacyRequestMapper($queryFormatter),
$this->httpClient,
new LegacyResponseMapper($jsonDecode),
$requestFactory,
$streamFactory
)
);
$requestExecutorFactory
->createRestRequestExecutor($this->httpClient)
->willReturn(
new RestRequestExecutor(
new RestRequestMapper($queryFormatter),
$this->httpClient,
new RestResponseMapper($jsonDecode),
$requestFactory,
$streamFactory
)
);
self::$smsapiService = new SmsapiPlHttpService(
$this->httpClient,
$requestExecutorFactory->reveal(),
new DataFactoryProvider()
);
}
protected function mockResponse(int $statusCode, string $body)
{
$this->httpClient->mockResponse($statusCode, $body);
}
}