|
From: Jason S. <jsw...@ya...> - 2003-12-12 19:19:20
|
in simpletest_1.0beta2
$this->AssertError(new
WantedPatternExpectation('/No.*plant.*'.TEST_PLANT_BAD.'.*/i'));
produces:
Fail: testbadgetlovparms->Expected [Object] in PHP error [No Cost Card List of
Value Keys for plant 'FOOBAR'] severity [E_USER_NOTICE] in
[/home/sweatje/public_html/pftanal/models/PlantConfig.php] line [263]
Can Assertions be modified to accept Expectations? or is there a simpler way
to look for patterns in errors?
I have temporarily added the following assertion:
/**
* Confirms that an error has occurred and
* optionally that the error text matches.
* @param $expected Expected error text regex
* @param $message Message to display.
* @public
*/
function assertErrorPattern($expected = false, $message = "%s") {
$queue = &SimpleErrorQueue::instance();
if ($queue->isEmpty()) {
$this->fail(sprintf($message, "Expected error not found"));
return;
}
list($severity, $content, $file, $line, $globals) = $queue->extract();
$severity = SimpleErrorQueue::getSeverityAsString($severity);
$this->assertTrue(
!$expected || (preg_match($expected, $content)),
"Expected pattern [$expected] does not match PHP error [$content] severity
[$severity] in [$file] line [$line]");
}
But this seems like something I would want all the time in a variety of test
cases. Any guidance on a permanent fix?
Thanks,
Jason
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
|