$newchar->saveCharacter(); $newchar->printCharInfo(); echo '<br /><br />Get a copy of the character from the DB'; $charcopy = new Character($uidtotest, '', 0); $charcopy->getCharacter($newchar->getCharID(), $uidtotest); echo '<br /><br />Comparing the copy to the original: '; //$newchar->printCharInfo(); $newchar_str = $newchar->strRepresentation(); //$charcopy->printCharInfo(); $charcopy_str = $charcopy->strRepresentation(); if ($newchar_str == $charcopy_str) { //Then the original and copy are the same. print "<br />The two character objects <font color='green'>match</font> as expected - <br />"; $newchar->printCharInfo(); $goodtests++; } else { print "<br />The original object <font color='red'>does not</font> match the copy of the object as expected.<br />"; $newchar->printCharInfo(); print "<br /><br />"; $charcopy->printCharInfo(); $badtests++; } echo '<br /><br />Deleting the character from the DB'; $newchar->delCharacter(); echo '<br />'; $totaltests = $goodtests + $badtests; echo "<font color='green'>{$goodtests}/{$totaltests} succeeded</font><br />"; echo "While <font color='red'>{$badtests}/{$totaltests} failed</font>."; ?> </body> </html>
} else { $char->saveCharacter(); $_SESSION['char'] = serialize($char); } break; case 'del_character': if (!isset($_POST['charid'])) { echo json_encode("failure"); } else { $charid = intval($_POST['charid']); $delchar = new Character($userid, '', 0); $delchar->getCharacter($charid, $userid); if ($delchar->getCharID() == $char->getCharID()) { $_SESSION['char'] = serialize(new Character($userid, '', 0)); } $delchar->delCharacter(); } break; case 'get_charid': if (!$char) { echo json_encode("failure"); } else { echo json_encode("" . $char->getCharID()); } break; case 'set_charname': if (!$char) { echo json_encode("failure"); } else { if (isset($_POST['newval'])) { $char->setCharName($_POST['newval']);