From 19c8a6ba5701a28b90cd1467a5ea587b225a12de Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 10 Jun 2009 13:32:06 -0400 Subject: [PATCH] finish cached data reading --- classes/DailyImageWidget.php | 6 +++++- test/DailyImageWidgetTest.php | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/DailyImageWidget.php b/classes/DailyImageWidget.php index bec4c58..aaa7fd7 100644 --- a/classes/DailyImageWidget.php +++ b/classes/DailyImageWidget.php @@ -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; } } } diff --git a/test/DailyImageWidgetTest.php b/test/DailyImageWidgetTest.php index 80d9bec..6c0687c 100644 --- a/test/DailyImageWidgetTest.php +++ b/test/DailyImageWidgetTest.php @@ -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(); } }