public function testSendMultipleSMS() { $initCredit = $this->client->getCredit()->getSmsPageCount(); $messages = []; for ($i = 0; $i < 10; $i++) { $messages[] = new OutgoingSMS(getenv('PANEL_LINE'), getenv('DESTINATION'), 'V2::testSendMultipleSMS' . "({$i})", uniqid('test_app:', true), new \DateTime("+{$i} Minutes")); } $response = $this->client->sendSMS($messages); $this->assertCount(10, $response); $ids = []; foreach ($response as $id) { $this->assertInstanceOf(SMSId::class, $id); $ids[] = $id->getId(); } $status = $this->client->checkStatus($ids); $this->assertInstanceOf(CheckStatusResponse::class, $status); $status = $status->getStatusArray(); $this->assertCount(10, $status); foreach ($status as $stat) { $this->assertInstanceOf(Status::class, $stat); } $finalCredit = $this->client->getCredit()->getSmsPageCount(); $this->assertLessThanOrEqual(10, $initCredit - $finalCredit); }
/** * @group 403 */ public function test403() { $this->setExpectedException(CommunicationException::class, 'Forbidden [Web-service is disabled]', CommunicationException::FORBIDDEN); $client = new HttpClient(new ConnectionConfig(getenv('OPILO_URL')), new Account(getenv('OPILO_USERNAME_WS_DISABLED'), getenv('OPILO_PASSWORD_WS_DISABLED'))); $client->getCredit(); }
/** * @expectedException \OpiloClient\Response\CommunicationException */ public function testGetCreditWithError() { // Mock a Guzzle client to be used $responseArray = ['error' => 8]; $responses = [new Response(401, [], json_encode($responseArray))]; $client = $this->mockGuzzleClient($responses); // Make HttpClient to use mocked Guzzle client $httpClient = new HttpClient('no-need-for-username', 'no-need-for-password', $client); // Call getCredit $httpClient->getCredit(); }