SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 132 | Next

Hasin Hayder

"Object-Oriented Programming with PHP5"

Let's revise our renderFeedbackForm() method and correct it.
class FeedBackManager
{
public function renderFeedbackForm()
{
$form = <<< END

Name:



Email:



Subject:



Message:



following output:
PHPUnit 3.0.5 by Sebastian Bergmann.
IIII.ISSSIII
Time: 00:00
OK, but incomplete or skipped tests!
Tests: 12, Incomplete: 8, Skipped: 3.
Great! Our test has passed. That means our rendered form is potentially error free.
This is the style of Test Driven Development. You have to foresee your application
code before it is actually written. Using TDD helps you to design good API
and good code.
Writing Multiple Assertions
Don't write multiple assertions under one test. Split it as shown in the example
above. To clarify, the following example is a bad example of a unit test.
public function testFormRenderer(){
$testResult = true;
$message = "";
$Fm = new FeedBackManager();
ob_start();
$Fm->renderFeedbackForm();
$output = ob_get_clean();
$testResult = strpos($output, "name='email'");
$this->assertEquals(true, $testResult,
"Email field is not present");
$testResult = strpos($output, "name='username'");
$this->assertEquals(true, $testResult,
"Username field is not present");
$testResult = strpos($output, "name='subject'");
$this->assertEquals(true, $testResult,
"Subject field is not present");
$testResult = strpos($output, "name='message'");
$this->assertEquals(true, $testResult,
"Message field is not present");
}
This code will run, but multiple assertions in a single routine are prohibited and are
against good application design.


Pages:
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6