Testing the Electorate Libraries

ID(2) != 2) { print "

Setting ID value failed (1)\n"; exit(); } if ($item->pollNumber(2) != 2) { print "

Setting pollNumber faield (2)\n"; exit(); } $array = $item->name('Mr.', 'Warren', 'Layton'); if ($array[0] != 'Mr.' || $array[1] != 'Warren' || $array[2] != 'Layton') { print "

Name value failed (3)\n"; exit(); } $array = $item->address('314', null, 'Riverdale Ave', null, 'Ottawa', 'ON', 'K1S1R5'); if ($array[0] != '314' || $array[1] != null || $array[2] != 'Riverdale Ave' || $array[3] != null || $array[4] != 'Ottawa' || $array[5] != 'ON' || $array[6] != 'K1S1R5') { print "

Address value failed (4)\n"; exit(); } if ($item->phoneNumber('6137307229') != '6137307229') { print "

Phone number failed (5)\n"; exit(); } if ($item->votingAttention(1) != 1) { print "

Setting votingAttention failed (6)\n"; exit(); } if ($item->votingAttention() != 1) { print "

Getting vottingAttention failed (7)\n"; exit(); } if ($item->votingAttention(0) != $item->votingAttention()) { print "

Voting attention does not match itself (8)\n"; exit(); } if ($item->canvassed(0) != 0) { print "

canvassed failed (9)\n"; exit(); } if ($item->phoned(1) != 1) { print "

phoned failed (10)\n"; exit(); } if ($item->phonedLookUp(1) != 1) { print "

phoneLookUp failed (11)\n"; exit(); } if ($item->voted(0) != 0) { print "

voted failed (12)\n"; exit(); } print "

Row Items Set in Object

\n"; /* Update the record */ if (!$item->update()) { print "

Failed to update the row
\n"; print "Error: " . $item->errorMessage . "
\n"; print "Line: " . $item->errorLine . "
\n"; } else { print "

Row Item Updated in database

\n"; } /* Insert a new record. Just for debugging. */ if (!$item->insert()) { print "

Failed to insert the row
\n"; print "Error: " . $item->errorMessage . "
\n"; print "Line: " . $item->errorLine . "
\n"; print "

";
		print_r($item) ;
		print"
\n"; print "

\n"; } /* Query system for information that was added */ $electorate = new Electorate(); $array = $electorate->fetchRecordsByPhone('6137307229'); print "

Getting the array or results

\n"; foreach($array as $item) { print "

Item: " . $item->id() . "
\n" . "phone: " . $item->phoneNumber() . "

\n"; } ?>