public function testInvalidCreatorRobotDataCreate() { $validRobotName = "TARS"; $invalidCreators = array("-2"); $validStatus = "in-development"; $s1 = new RobotData(array("robot_name" => $validRobotName, "creators" => $invalidCreators, "status" => $validStatus)); $this->assertTrue(!empty($s1->getError('creator')) && strcmp(Messages::getError('ROBOT_CREATOR_INVALID'), $s1->getError('creator')) == 0, 'It should have a creator error if the creator id is invalid'); }
<?php $invalidCreatorNameTest = array("creator" => ""); $s4 = new RobotData($invalidCreatorNameTest); $test4 = empty($s4->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>'; echo $test4; echo "The error for creator is: " . $s4->getError('creator') . "<br>"; echo "The object is: {$s4}<br>"; ?> <h2>It should have an error when the status is empty</h2> <?php $invalidStatusTest = array("status" => ""); $s5 = new RobotData($invalidStatusTest); $test5 = empty($s5->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>'; echo $test5; echo "The error for status is: " . $s5->getError('status') . "<br>"; echo "The object is: {$s5}<br>"; ?> <h2>It should have an error when the status is invalid</h2> <?php $invalidStatusTest = array("status" => "invalid-status"); $s6 = new RobotData($invalidStatusTest); $test6 = empty($s6->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>'; echo $test6; echo "The error for status is: " . $s6->getError('status') . "<br>"; echo "The object is: {$s6}<br>"; ?> </body> </html>