|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainAltapayBundle\Tests\Synchronizer; |
|
4
|
|
|
|
|
5
|
|
|
use Loevgaard\AltaPay\Client\Client; |
|
6
|
|
|
use Loevgaard\AltaPay\Response\GetTerminals; |
|
7
|
|
|
use Loevgaard\DandomainAltapayBundle\Entity\TerminalRepository; |
|
8
|
|
|
use Loevgaard\DandomainAltapayBundle\Synchronizer\TerminalSynchronizer; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
11
|
|
|
|
|
12
|
|
|
class TerminalSynchronizerTest extends TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
public function testSyncAll() |
|
15
|
|
|
{ |
|
16
|
|
|
$xml = <<<XML |
|
17
|
|
|
<?xml version="1.0"?> |
|
18
|
|
|
<APIResponse version="20170228"> |
|
19
|
|
|
<Header> |
|
20
|
|
|
<Date>2016-01-07T23:43:20+01:00</Date> |
|
21
|
|
|
<Path>API/getTerminals</Path> |
|
22
|
|
|
<ErrorCode>0</ErrorCode> |
|
23
|
|
|
<ErrorMessage></ErrorMessage> |
|
24
|
|
|
</Header> |
|
25
|
|
|
<Body> |
|
26
|
|
|
<Result>Success</Result> |
|
27
|
|
|
<Terminals> |
|
28
|
|
|
<Terminal> |
|
29
|
|
|
<Title>AltaPay Multi-Nature Terminal</Title> |
|
30
|
|
|
<Country>DK</Country> |
|
31
|
|
|
<Natures> |
|
32
|
|
|
<Nature>CreditCard</Nature> |
|
33
|
|
|
<Nature>EPayment</Nature> |
|
34
|
|
|
<Nature>IdealPayment</Nature> |
|
35
|
|
|
<Nature>Invoice</Nature> |
|
36
|
|
|
</Natures> |
|
37
|
|
|
<Currencies> |
|
38
|
|
|
<Currency>DKK</Currency> |
|
39
|
|
|
<Currency>EUR</Currency> |
|
40
|
|
|
</Currencies> |
|
41
|
|
|
</Terminal> |
|
42
|
|
|
<Terminal> |
|
43
|
|
|
<Title>AltaPay BankPayment Terminal</Title> |
|
44
|
|
|
<Country></Country> |
|
45
|
|
|
<Natures> |
|
46
|
|
|
<Nature>BankPayment</Nature> |
|
47
|
|
|
</Natures> |
|
48
|
|
|
<Currencies> |
|
49
|
|
|
<Currency>EUR</Currency> |
|
50
|
|
|
</Currencies> |
|
51
|
|
|
</Terminal> |
|
52
|
|
|
</Terminals> |
|
53
|
|
|
</Body> |
|
54
|
|
|
</APIResponse> |
|
55
|
|
|
XML; |
|
56
|
|
|
|
|
57
|
|
|
$psrResponse = $this->createMock(ResponseInterface::class); |
|
58
|
|
|
$psrResponse |
|
59
|
|
|
->expects($this->any()) |
|
60
|
|
|
->method('getBody') |
|
61
|
|
|
->willReturn($xml) |
|
62
|
|
|
; |
|
63
|
|
|
$getTerminalsResponse = new GetTerminals($psrResponse); |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
/** @var TerminalRepository|\PHPUnit_Framework_MockObject_MockObject $terminalRepository */ |
|
66
|
|
|
$terminalRepository = $this->getMockBuilder(TerminalRepository::class) |
|
67
|
|
|
->disableOriginalConstructor() |
|
68
|
|
|
->setMethods(['save', 'findTerminalByTitle']) |
|
69
|
|
|
->getMock() |
|
70
|
|
|
; |
|
71
|
|
|
|
|
72
|
|
|
$terminalRepository |
|
|
|
|
|
|
73
|
|
|
->expects($this->any()) |
|
74
|
|
|
->method('save') |
|
75
|
|
|
->willReturn(null) |
|
76
|
|
|
; |
|
77
|
|
|
|
|
78
|
|
|
$terminalRepository |
|
79
|
|
|
->expects($this->any()) |
|
80
|
|
|
->method('findTerminalByTitle') |
|
81
|
|
|
->willReturn(null) |
|
82
|
|
|
; |
|
83
|
|
|
|
|
84
|
|
|
$altapayClient = $this->createMock(Client::class); |
|
85
|
|
|
$altapayClient |
|
86
|
|
|
->expects($this->any()) |
|
87
|
|
|
->method('getTerminals') |
|
88
|
|
|
->willReturn($getTerminalsResponse) |
|
89
|
|
|
; |
|
90
|
|
|
|
|
91
|
|
|
$terminalSynchronizer = new TerminalSynchronizer($terminalRepository, $altapayClient); |
|
|
|
|
|
|
92
|
|
|
$terminalSynchronizer->syncAll(); |
|
93
|
|
|
|
|
94
|
|
|
$this->assertTrue(true); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: