public function testParseResponse() { $results = json_decode('{ "multicast_id": 216, "success": 3, "failure": 3, "canonical_ids": 1, "results": [ { "message_id": "1:0408" }, { "error": "Unavailable" }, { "error": "InvalidRegistration" }, { "message_id": "1:1516" }, { "message_id": "1:2342", "registration_id": "32" }, { "error": "NotRegistered"} ] }', true); $response = new Response($results, new Notification(array(new Device(1), new Device(2), new Device(3), new Device(4), new Device(5), new Device(6)))); $this->assertEquals(216, $response->getMulticastId()); $this->assertEquals(3, $response->getNumSuccessful()); $this->assertEquals(3, $response->getNumFailures()); $this->assertEquals(1, $response->getNumCanonicalIds()); $results = $response->getResults(); $this->assertEquals('1:0408', $results[0]->getMessageId()); $this->assertEquals(1, $results[0]->getDevice()->getRegistrationId()); $this->assertTrue($results[0]->isSuccess()); $this->assertEquals('Unavailable', $results[1]->getError()); $this->assertEquals(2, $results[1]->getDevice()->getRegistrationId()); $this->assertTrue($results[1]->hasError()); $this->assertFalse($results[1]->isSuccess()); $this->assertTrue($results[1]->isResendable()); $this->assertEquals('InvalidRegistration', $results[2]->getError()); $this->assertEquals(3, $results[2]->getDevice()->getRegistrationId()); $this->assertTrue($results[2]->hasError()); $this->assertFalse($results[2]->isSuccess()); $this->assertFalse($results[2]->isResendable()); $this->assertEquals('1:1516', $results[3]->getMessageId()); $this->assertEquals(4, $results[3]->getDevice()->getRegistrationId()); $this->assertTrue($results[3]->isSuccess()); $this->assertEquals('1:2342', $results[4]->getMessageId()); $this->assertEquals(32, $results[4]->getCanonicalId()); $this->assertEquals(5, $results[4]->getDevice()->getRegistrationId()); $this->assertTrue($results[4]->isSuccess()); $this->assertEquals('NotRegistered', $results[5]->getError()); $this->assertEquals(6, $results[5]->getDevice()->getRegistrationId()); $this->assertTrue($results[5]->hasError()); $this->assertFalse($results[5]->isSuccess()); $this->assertFalse($results[5]->isResendable()); }
/** * Gets all results from the Setopt request. * @return an associative array containing all results */ public function getResults() { return array_merge(parent::getResults(), array("Campaign id" => $this->campaign_id, "Campaign status code" => $this->campaign_status_code, "Campaign status" => $this->campaign_status, "Number" => $this->number)); }
/** * Gets all results from the Uncache request. * @return an associative array containing all results */ public function getResults() { return array_merge(parent::getResults(), array("Number" => $this->number)); }
/** * Gets all results from the Transactions request. * @return an associative array containing all results */ public function getResults() { return array_merge(parent::getResults(), array("Campaigns" => $this->campaigns)); }
/** * Gets all results from the Lookup request. * @return an associative array containing all results */ public function getResults() { return array_merge(parent::getResults(), array("Campaign id" => $this->campaign_id, "From number" => $this->from_number, "From name" => $this->from_name, "To number" => $this->to_number, "To name" => $this->to_name, "Content id" => $this->content_id, "Status" => $this->status, "History" => $this->history)); }
/** * Gets all results from the Info request. * @return an associative array containing all results */ public function getResults() { return array_merge(parent::getResults(), array("Number" => $this->number, "Carrier id" => $this->carrier_id, "Carrier" => $this->carrier, "Handset id" => $this->handset_id, "Handset" => $this->handset)); }
/** * Gets all results from the Lookup request. * @return an associative array containing all results */ public function getResults() { return array_merge(parent::getResults(), array("Message id" => $this->message_id, "Hash" => $this->hash)); }