inputConverter = new InputMessagesConverter(); } /** * Cleans up the environment after running a test. */ protected function tearDown() { $this->inputConverter = null; parent::tearDown(); } public function testConvertAtom() { $xml = ' example.org:AD38B3886625AAF example.org:997638BAA6F25AD You have an invitation from Joe {msgid} Click <a href="http://app.example.org/invites/{msgid}">here</a> to review your invitation. '; $message = $this->inputConverter->convertAtom($xml); $this->assertEquals('{msgid}', $message['id']); $this->assertEquals('You have an invitation from Joe', $message['title']); $this->assertEquals('Click here to review your invitation.', $message['body']); $this->assertEquals('example.org:AD38B3886625AAF', $message['recipients'][0]); $this->assertEquals('example.org:997638BAA6F25AD', $message['recipients'][1]); } public function testConvertJson() { $json = '{ "id" : "msgid", "title" : "You have an invitation from Joe", "body" : "Click here to review your invitation" }'; $message = $this->inputConverter->convertJson($json); file_put_contents(sys_get_temp_dir() . '/message.txt', print_r($json, true)); $this->assertEquals('msgid', $message['id']); $this->assertEquals('You have an invitation from Joe', $message['title']); $this->assertEquals('Click here to review your invitation', $message['body']); } public function testConvertXml() { $xml = ' example.org:AD38B3886625AAF example.org:997638BAA6F25AD You have an invitation from Joe {msgid} Click <a href="http://app.example.org/invites/{msgid}">here</a> to review your invitation. '; $message = $this->inputConverter->convertXml($xml); $this->assertEquals('{msgid}', $message['id']); $this->assertEquals('You have an invitation from Joe', $message['title']); $this->assertEquals('Click here to review your invitation.', $message['body']); $this->assertEquals('example.org:AD38B3886625AAF', $message['recipients'][0]); $this->assertEquals('example.org:997638BAA6F25AD', $message['recipients'][1]); } }