/** * Creates and fills valid data in an object of class moMessageEntity. * Then passes the object based on dependency based injection to * moService's object method setMoMessage. Afterwards, Gets the set * moMessage from moService object and confirms its equal to what was passed in the * first place. * * @throws Exception */ public function testSetMOMessage() { $moService = new moService(); $message = new moMessageEntity(); $message->setMSISDN("923146153385"); $message->setOperatorID(6521600); $message->setShortCodeID(6); $message->setText("bada bing bada boom"); $moService->setMOMessage($message); $this->assertEquals($moService->getMOMessage(), $message); }
/** * Tests an expected exception when passing an invalid argument to the method * * @throws Exception */ public function testInvalidTextInput() { $moMessage = new moMessageEntity(); $this->setExpectedException('Exception'); $moMessage->setText(array()); }
<?php require_once 'config/config.php'; use Web\Services\moService; use Web\Entities\moMessageEntity; try { if (isset($_REQUEST['msisdn'])) { $message = new moMessageEntity(); $message->setMSISDN($_REQUEST['msisdn']); $message->setOperatorID((int) $_REQUEST['operatorid']); $message->setShortCodeID((int) $_REQUEST['shortcodeid']); $message->setText($_REQUEST['text']); $moService = new moService(); $moService->setMOMessage($message); $moService->saveMOMessageToSQL(); echo '{"status": "ok"}' . "\n"; } else { throw new Exception("Please pass values first."); } } catch (PDOException $pdoError) { echo $pdoError->getMessage(); } catch (Exception $error) { echo $error->getMessage(); } /* $message= new moMessageEntity(); $message->setMSISDN("923146153385"); $message->setOperatorID(6521600); $message->setShortCodeID(6); $message->setText("badabing.");