|
9 | 9 | namespace NexmoTest\Message; |
10 | 10 |
|
11 | 11 | use Nexmo\Message\Client; |
| 12 | +use Nexmo\Message\Message; |
12 | 13 | use Nexmo\Message\Text; |
13 | 14 | use NexmoTest\Psr7AssertionTrait; |
14 | 15 | use Prophecy\Argument; |
@@ -115,6 +116,50 @@ public function testThrowServerException() |
115 | 116 | } |
116 | 117 | } |
117 | 118 |
|
| 119 | + public function testCanSearchByMessage() |
| 120 | + { |
| 121 | + $message = new Message('02000000D912945A'); |
| 122 | + $response = $this->getResponse('search-outbound'); |
| 123 | + |
| 124 | + $this->nexmoClient->send(Argument::that(function(Request $request) { |
| 125 | + $this->assertRequestQueryContains('id', '02000000D912945A', $request); |
| 126 | + return true; |
| 127 | + }))->willReturn($response); |
| 128 | + |
| 129 | + $this->messageClient->search($message); |
| 130 | + $this->assertSame($response, $message->getResponse()); |
| 131 | + } |
| 132 | + |
| 133 | + public function testCanSearchBySingleOutboundId() |
| 134 | + { |
| 135 | + $response = $this->getResponse('search-outbound'); |
| 136 | + |
| 137 | + $this->nexmoClient->send(Argument::that(function(Request $request) { |
| 138 | + $this->assertRequestQueryContains('id', '02000000D912945A', $request); |
| 139 | + return true; |
| 140 | + }))->willReturn($response); |
| 141 | + |
| 142 | + $message = $this->messageClient->search('02000000D912945A'); |
| 143 | + |
| 144 | + $this->assertInstanceOf('Nexmo\Message\Message', $message); |
| 145 | + $this->assertSame($response, $message->getResponse()); |
| 146 | + } |
| 147 | + |
| 148 | + public function testCanSearchBySingleInboundId() |
| 149 | + { |
| 150 | + $response = $this->getResponse('search-inbound'); |
| 151 | + |
| 152 | + $this->nexmoClient->send(Argument::that(function(Request $request) { |
| 153 | + $this->assertRequestQueryContains('id', '02000000DA7C52E7', $request); |
| 154 | + return true; |
| 155 | + }))->willReturn($response); |
| 156 | + |
| 157 | + $message = $this->messageClient->search('02000000DA7C52E7'); |
| 158 | + |
| 159 | + $this->assertInstanceOf('Nexmo\Message\InboundMessage', $message); |
| 160 | + $this->assertSame($response, $message->getResponse()); |
| 161 | + } |
| 162 | + |
118 | 163 | /** |
119 | 164 | * Get the API response we'd expect for a call to the API. Message API currently returns 200 all the time, so only |
120 | 165 | * change between success / fail is body of the message. |
|
0 commit comments