finish cached data reading
This commit is contained in:
parent
a06b70e6ed
commit
19c8a6ba57
@ -171,8 +171,12 @@ class DailyImageWidget {
|
|||||||
list($timestamp, $cached_data) = $data;
|
list($timestamp, $cached_data) = $data;
|
||||||
|
|
||||||
if (($timestamp + $this->_cache_time) > time()) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ class DailyImageWidgetTest extends PHPUnit_Framework_TestCase {
|
|||||||
function testGetCachedData() {
|
function testGetCachedData() {
|
||||||
$test_time = time() + 86500;
|
$test_time = time() + 86500;
|
||||||
update_option('hubblesite-daily-image-cache', serialize(array($test_time, $this->sample_data)));
|
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;
|
$test_time = time() - 86500;
|
||||||
update_option('hubblesite-daily-image-cache', serialize(array($test_time, $this->sample_data)));
|
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);
|
update_option('hubblesite-daily-image-cache', null);
|
||||||
$this->assertEquals(false, $this->diw->_get_cached_data());
|
$this->assertEquals(false, $this->diw->_get_cached_data());
|
||||||
|
|
||||||
$this->markTestIncomplete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user