public function test422Errors() { $failed = false; try { $client = new HttpClient(new ConnectionConfig(getenv('OPILO_URL')), new Account(getenv('OPILO_USERNAME'), getenv('OPILO_PASSWORD'))); $client->checkStatus(['string']); } catch (ValidationException $e) { $failed = true; $errors = $e->getErrors(); $this->assertCount(1, $errors); $this->assertArrayHasKey('Integer', $errors['ids.0']); } $this->assertTrue($failed); }
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); }