finish cached data reading

This commit is contained in:
John Bintz 2009-06-10 13:32:06 -04:00
parent a06b70e6ed
commit 19c8a6ba57
2 changed files with 6 additions and 4 deletions

View File

@ -171,8 +171,12 @@ class DailyImageWidget {
list($timestamp, $cached_data) = $data;
if (($timestamp + $this->_cache_time) > time()) {
$is_valid = (count(array_intersect()) == count($this->_valid_column_names));
$is_valid = true;
foreach ($this->_valid_column_names as $field) {
if (!isset($cached_data[$field])) { $is_valid = false; break; }
}
return ($is_valid) ? $cached_data : false;
}
}
}

View File

@ -187,7 +187,7 @@ class DailyImageWidgetTest extends PHPUnit_Framework_TestCase {
function testGetCachedData() {
$test_time = time() + 86500;
update_option('hubblesite-daily-image-cache', serialize(array($test_time, $this->sample_data)));
$this->assertEquals(array($test_time, $this->sample_data), $this->diw->_get_cached_data());
$this->assertEquals($this->sample_data, $this->diw->_get_cached_data());
$test_time = time() - 86500;
update_option('hubblesite-daily-image-cache', serialize(array($test_time, $this->sample_data)));
@ -195,8 +195,6 @@ class DailyImageWidgetTest extends PHPUnit_Framework_TestCase {
update_option('hubblesite-daily-image-cache', null);
$this->assertEquals(false, $this->diw->_get_cached_data());
$this->markTestIncomplete();
}
}