public function testCreate() { $announcement = new Announcement(); $announcement->setId('1'); $announcement->setTitle('Annonce test'); $announcement->setSubtitle('Description'); $announcement->setContent('Besoin de mécanicien contre cours de cuisine'); $announcement->setPostDate('2012-12-14 18:07:27'); $announcement->setConclued('0'); $announcementMapper = new AnnouncementMapper(); $announcementMapper->insertAnnouncement($announcement); $announcementMapper->setId(1); $announcement->setPictures(null); $this->assertEquals($announcement, $announcementMapper->selectAnnouncement()); }
$options = array('indent' => ' ', 'addDecl' => false, XML_SERIALIZER_OPTION_RETURN_RESULT => true, "defaultTagName" => "announcement"); $serializer = new XML_Serializer($options); Rest::sendResponse(200, $serializer->serialize($announcementsArray), 'application/xml'); } } } else { Rest::sendResponse(204); } break; case 'post': try { $announcement = new Announcement(); $data_announcement = $http->getRequestVars(); $announcementsObject = initObject($data_announcement, $announcement, true); if (!emptyObject($announcementsObject)) { $announcementMapper = new \AnnouncementMapper(); if ($announcementMapper->insertAnnouncement($announcementsObject)) { Rest::sendResponse(200); } } else { throw new InvalidArgumentException('Need arguments to POST data !'); } } catch (InvalidArgumentException $e) { $e->getMessage(); exit; } break; default: Rest::sendResponse(501); break; }