From 8d787c486ed1ab04a97d38ecf2b10d2284874d4e Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Mon, 23 Jul 2012 15:01:33 +1200 Subject: [PATCH] BUGFIX: Clear sitemap registration at the end of each test --- code/GoogleSitemap.php | 7 +++++++ tests/GoogleSitemapTest.php | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/code/GoogleSitemap.php b/code/GoogleSitemap.php index d56e4e8..8698993 100644 --- a/code/GoogleSitemap.php +++ b/code/GoogleSitemap.php @@ -93,6 +93,13 @@ class GoogleSitemap extends Controller { return isset(self::$dataobjects[$className]); } + /** + * Clears registered dataobjects. Useful for unit tests. + */ + public static function clear_registered_dataobjects() { + self::$dataobjects = array(); + } + /** * Returns a list containing each viewable {@link DataObject} instance of * the registered class names. diff --git a/tests/GoogleSitemapTest.php b/tests/GoogleSitemapTest.php index 97d2846..697969d 100644 --- a/tests/GoogleSitemapTest.php +++ b/tests/GoogleSitemapTest.php @@ -22,6 +22,12 @@ class GoogleSitemapTest extends FunctionalTest { } } + public function tearDown() { + parent::tearDown(); + + GoogleSitemap::clear_registered_dataobjects(); + } + public function testItems() { $sitemap = new GoogleSitemap();