Esempio n. 1
0
 public function testCreate()
 {
     $message = new Message();
     $message->setId(1);
     $message->setSubject('Un message');
     $message->setContent('Bonjour.');
     $message->setDatePost('2012-12-14 19:45:45');
     $message->setIdSender(1);
     $message->setIdReceiver(3);
     $messageMapper = new MessageMapper();
     $messageMapper->insertMessage($message);
     $messageMapper->setId(1);
     $this->assertEquals($message, $messageMapper->selectMessage());
 }
                    $options = array('indent' => '     ', 'addDecl' => false, XML_SERIALIZER_OPTION_RETURN_RESULT => true, "defaultTagName" => "message");
                    $serializer = new XML_Serializer($options);
                    Rest::sendResponse(200, $serializer->serialize($messagesArray), 'application/xml');
                }
            }
        } else {
            Rest::sendResponse(204);
        }
        break;
    case 'post':
        try {
            $message = new Message();
            $data_message = $http->getRequestVars();
            $messageObject = initObject($data_message, $message, true);
            if (!emptyObject($messageObject)) {
                $messageMapper = new MessageMapper();
                if ($messageMapper->insertMessage($messageObject)) {
                    Rest::sendResponse(200);
                }
            } else {
                throw new InvalidArgumentException('Need arguments to POST data !');
            }
        } catch (InvalidArgumentException $e) {
            $e->getMessage();
            exit;
        }
        break;
    default:
        Rest::sendResponse(501);
        break;
}