|
From: Marcus B. <ma...@la...> - 2003-11-13 04:12:10
|
Hi...
Jason Sweat wrote:
> Just a check to make sure I am headed in the right direction:
You certainly seem to be.
> /**
> *
> * @package DataCache
> * @subpackage tests
> */
Surprising. Do you find it useful to PHPDoc your test cases?
> function Setup() {
> $this->c =& new DataCacheDaoFile(TEST_APPLICATION);
> $id = TEST_DAOFILE_BLANK;
> if (file_exists(DATACACHE_PATH.TEST_APPLICATION."/$id.php")) {
> unlink(DATACACHE_PATH.TEST_APPLICATION."/$id.php");
> }
> }
This is certainly the right way to use setUp().
> function TestTimeStamp() {
> $id = 'time';
> $ts = mktime();
> $this->AssertTrue($this->c->SetCache($id,$ts.$ts));
> $this->AssertTrue(1 >= abs($this->c->GetCacheTime($id) - $ts));
> $this->AssertEqual($this->c->GetCache($id), $ts.$ts);
> }
You could create a separate assert method for this, such as...
function assertNow($timing, $message = '%s') {
$message = sprintf($message, 'Within one second of now');
$this->assertTrue(1 >= abs($timing - mktime()), $message);
}
function testTimeStamp() {
$id = 'time';
$this->AssertTrue($this->c->SetCache($id,$ts.$ts));
$this->AssertNow($this->c->GetCacheTime($id));
$this->AssertEqual($this->c->GetCache($id), $ts.$ts);
}
>
> //run if stand alone
> if (!isset($this)) {
> $test = &new TestDataCacheDaoFile();
> $test->run(new HtmlReporter());
> }
Sneaky :).
yours, Marcus
--
Marcus Baker, ma...@la..., no...@ap...
|