public function testGetEtagHeader() { $response = new Response($this->headers, '', ''); $this->assertEquals('"125703609"', $response->getHeader('etag')); $this->assertEquals('"125703609"', $response->getHeader('ETAG')); $this->assertEquals('"125703609"', $response->getHeader('EtaG')); }
/** * {@inheritDoc} */ public function send($dry_run = false) { switch (count($this->messages)) { case 0: throw new \RuntimeException("No messages to send."); case 1: return $this->sendOne($dry_run); } // create xml document $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="utf-8" ?><push></push>'); $xml->addChild('user', $this->config['user']); $xml->addChild('password', $this->config['password']); $xml->addChild('serviceid', $this->config['serviceid']); $ts = date('d-m-Y H:i:00'); // attach messages foreach ($this->messages as $message) { $batch = $xml->addChild('smsbatch'); $batch->addChild('sendtime', $ts); if ($message->options['from']) { $batch->addChild('sender', $message->options['from']); } else { $batch->addChild('sender', $this->config['from']); } $batch->addChild('price', $this->config['price']); $cdata = $batch->addChild('message'); $cdata->addCData($message->message); $recipient = $batch->addChild('recipients'); $recipient->addChild('msisdn', $message->to); } $adapter = $this->getAdapter(); $adapter->setEndpoint(self::BATCH_ENDPOINT); $adapter->setBody($xml->asXML()); if ($dry_run) { return $adapter->dryRun(); } else { $response = $adapter->post(); } /** * inmobile returns 2 kinds of response * * 1: integer 2 to -18 error results * 2: xml containing the result of your success request * * we have asked inmobile to change this in new versions to always send back xml */ if (strlen($response->getBody()) <= 3) { $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="utf-8" ?><response></response>'); $error = $xml->addChild('error'); $error->addChild('code', $response->getBody()); $error->addChild('message', $this->error_codes[$response->getBody()]); $response = new Response($response->getHeaders(), $xml->asXML(), $response->getRequest()); } return $response; }