1 | <?php |
||
21 | class XApiClientTest extends \PHPUnit_Framework_TestCase |
||
22 | { |
||
23 | /** |
||
24 | * @var HandlerInterface|\PHPUnit_Framework_MockObject_MockObject |
||
25 | */ |
||
26 | private $requestHandler; |
||
27 | |||
28 | /** |
||
29 | * @var SerializerRegistryInterface|\PHPUnit_Framework_MockObject_MockObject |
||
30 | */ |
||
31 | private $serializerRegistry; |
||
32 | |||
33 | /** |
||
34 | * @var XApiClient |
||
35 | */ |
||
36 | private $client; |
||
37 | |||
38 | protected function setUp() |
||
39 | { |
||
40 | $this->requestHandler = $this->createRequestHandlerMock(); |
||
41 | $this->serializerRegistry = $this->createSerializerRegistryMock(); |
||
42 | $this->client = new XApiClient($this->requestHandler, $this->serializerRegistry, '1.0.1'); |
||
43 | } |
||
44 | |||
45 | public function testGetRequestHandler() |
||
46 | { |
||
47 | $this->assertSame($this->requestHandler, $this->client->getRequestHandler()); |
||
48 | } |
||
49 | |||
50 | public function testGetSerializerRegistry() |
||
51 | { |
||
52 | $this->assertSame($this->serializerRegistry, $this->client->getSerializerRegistry()); |
||
53 | } |
||
54 | |||
55 | public function testGetStatementsApi() |
||
56 | { |
||
57 | $this->assertInstanceOf( |
||
58 | 'Xabbuh\XApi\Client\Api\StatementsApiClientInterface', |
||
59 | $this->client->getStatementsApiClient() |
||
60 | ); |
||
61 | } |
||
62 | |||
63 | public function testGetStateApi() |
||
64 | { |
||
65 | $this->assertInstanceOf( |
||
66 | 'Xabbuh\XApi\Client\Api\StateApiClientInterface', |
||
67 | $this->client->getStateApiClient() |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | public function testGetActivityProfileApi() |
||
72 | { |
||
73 | $this->assertInstanceOf( |
||
74 | 'Xabbuh\XApi\Client\Api\ActivityProfileApiClientInterface', |
||
75 | $this->client->getActivityProfileApiClient() |
||
76 | ); |
||
77 | } |
||
78 | |||
79 | public function testGetAgentProfileApi() |
||
80 | { |
||
81 | $this->assertInstanceOf( |
||
82 | 'Xabbuh\XApi\Client\Api\AgentProfileApiClientInterface', |
||
83 | $this->client->getAgentProfileApiClient() |
||
84 | ); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * @return HandlerInterface|\PHPUnit_Framework_MockObject_MockObject |
||
89 | */ |
||
90 | private function createRequestHandlerMock() |
||
91 | { |
||
92 | return $this->getMock('\Xabbuh\XApi\Client\Request\HandlerInterface'); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @return SerializerRegistryInterface|\PHPUnit_Framework_MockObject_MockObject |
||
97 | */ |
||
98 | private function createSerializerRegistryMock() |
||
99 | { |
||
100 | $serializerRegistry = $this->getMock('\Xabbuh\XApi\Serializer\SerializerRegistryInterface'); |
||
101 | |||
102 | $statementSerializer = $this->getMock('\Xabbuh\XApi\Serializer\StatementSerializerInterface'); |
||
103 | $serializerRegistry |
||
104 | ->expects($this->any()) |
||
105 | ->method('getStatementSerializer') |
||
106 | ->will($this->returnValue($statementSerializer)); |
||
107 | |||
108 | $statementResultSerializer = $this->getMock('\Xabbuh\XApi\Serializer\StatementResultSerializerInterface'); |
||
109 | $serializerRegistry |
||
110 | ->expects($this->any()) |
||
111 | ->method('getStatementResultSerializer') |
||
112 | ->will($this->returnValue($statementResultSerializer)); |
||
113 | |||
114 | $actorSerializer = $this->getMock('\Xabbuh\XApi\Serializer\ActorSerializerInterface'); |
||
115 | $serializerRegistry |
||
116 | ->expects($this->any()) |
||
117 | ->method('getActorSerializer') |
||
118 | ->will($this->returnValue($actorSerializer)); |
||
119 | |||
120 | $documentDataSerializer = $this->getMock('\Xabbuh\XApi\Serializer\DocumentDataSerializerInterface'); |
||
121 | $serializerRegistry |
||
122 | ->expects($this->any()) |
||
123 | ->method('getDocumentDataSerializer') |
||
124 | ->will($this->returnValue($documentDataSerializer)); |
||
125 | |||
126 | return $serializerRegistry; |
||
127 | } |
||
128 | } |
||
129 |