コード例 #1
0
ファイル: Review_tests.php プロジェクト: bennilyn/examples
?>

<h2>It should create a valid Review object when all input is provided</h2>
<?php 
$validTest = array("firstName" => "Kay", "lastName" => "Robbins", "submissionID" => "R3023", "score" => "5", "review" => "This was a great presentation");
$s1 = new Review($validTest);
echo "The object is: {$s1}<br>";
$test1 = is_object($s1) ? '' : 'Failed:It should create a valid object when valid input is provided<br>';
echo $test1;
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It not have errors when valid input is provided<br>';
echo $test2;
?>

<h2>It should extract the parameters that went in</h2>
<?php 
$props = $s1->getParameters();
print_r($props);
?>

<h2>It should have an error when the first name contains invalid characters</h2>
<?php 
$invalidTest = array("firstName" => "krobbins\$");
$s1 = new Review($invalidTest);
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test2;
echo "The error for firstName is: " . $s1->getError('firstName') . "<br>";
echo "The object is: {$s1}<br>";
?>
</body>
</html>
コード例 #2
0
ファイル: Review_tests.php プロジェクト: bennilyn/examples
?>

<h2>It should create a valid Review object when all input is provided</h2>
<?php 
$validTest = array("reviewerName" => "Kay", "submissionId" => "R3023", "score" => "5", "review" => "This was a great presentation");
$s1 = new Review($validTest);
echo "The object is: {$s1}<br>";
$test1 = is_object($s1) ? '' : 'Failed:It should create a valid object when valid input is provided<br>';
echo $test1;
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It not have errors when valid input is provided<br>';
echo $test2;
?>

<h2>It should extract the parameters that went in</h2>
<?php 
$props = $s1->getParameters();
print_r($props);
?>

<h2>It should have an error when the first name contains invalid characters</h2>
<?php 
$invalidTest = array("reviewerName" => "krobbins\$");
$s1 = new Review($invalidTest);
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test2;
echo "The error for reviewerName is: " . $s1->getError('reviewerName') . "<br>";
echo "The object is: {$s1}<br>";
?>
</body>
</html>