Merge pull request #85 from dhensby/pulls/case-class

Allow URLs to be case insensitive
This commit is contained in:
Will Rossiter 2015-07-27 15:21:04 +12:00
commit 82778473a8
2 changed files with 23 additions and 1 deletions

View File

@ -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');

View File

@ -89,7 +89,7 @@ class GoogleSitemapTest extends FunctionalTest {
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_UnviewableDataObject/2") ."</loc>";
$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');