diff --git a/code/GoogleSitemap.php b/code/GoogleSitemap.php index 9fe456f..8217dfa 100644 --- a/code/GoogleSitemap.php +++ b/code/GoogleSitemap.php @@ -182,6 +182,15 @@ class GoogleSitemap { * @return ArrayList */ public static function get_items($class, $page = 1) { + //normalise the class name + try { + $reflectionClass = new ReflectionClass($class); + $class = $reflectionClass->getName(); + } catch (ReflectionException $e) { + // this can happen when $class is GoogleSitemapRoute + //we should try to carry on + } + $output = new ArrayList(); $count = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap'); $filter = Config::inst()->get('GoogleSitemap', 'use_show_in_search'); diff --git a/tests/GoogleSitemapTest.php b/tests/GoogleSitemapTest.php index ff2b313..808c7e9 100644 --- a/tests/GoogleSitemapTest.php +++ b/tests/GoogleSitemapTest.php @@ -89,7 +89,7 @@ class GoogleSitemapTest extends FunctionalTest { $expected = "". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_UnviewableDataObject/2") .""; $this->assertEquals(0, substr_count($body, $expected) , 'A link to a GoogleSitemapTest_UnviewableDataObject does not exist'); - } + } public function testLastModifiedDateOnRootXML() { Config::inst()->update('GoogleSitemap', 'enabled', true); @@ -161,6 +161,19 @@ class GoogleSitemapTest extends FunctionalTest { Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original); } + public function testAccessingNestedSiteMapCaseInsensitive() { + $original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap'); + Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1); + GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject"); + + $response = $this->get('sitemap.xml/sitemap/googlesitemaptest_dataobject/1'); + $body = $response->getBody(); + + $this->assertEquals(200, $response->getStatusCode(), 'successful loaded nested sitemap'); + + Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original); + } + public function testGetItemsWithPages() { if(!class_exists('Page')) { $this->markTestIncomplete('No cms module installed, page related test skipped');