Skip to content

Commit

Permalink
Do not attempt sitemap test if Sitemap is huge
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgraham committed May 15, 2019
1 parent bf8f15f commit a4680de
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions _tests/tests/unit_tests/sitemap.php
Expand Up @@ -23,6 +23,11 @@ class sitemap_test_set extends cms_test_case

public function setUp()
{
if ($GLOBALS['SITE_DB']->query_select_value('sitemap_cache', 'COUNT(*)') > 3000) {
$this->assertTrue(false, 'Test will not work on databases with a huge sitemap');
return;
}

$this->establish_admin_session();

require_code('sitemap');
Expand Down Expand Up @@ -71,6 +76,10 @@ public function flatten_sitemap($sitemap)

public function testIsConclusive()
{
if ($this->sitemap === null) {
return;
}

// Test we have an arbitrary entry-point, just to ensure things are still generating deeply
$this->assertTrue(isset($this->flattened['adminzone:admin_config:base']));

Expand All @@ -80,6 +89,10 @@ public function testIsConclusive()

public function testPageGroupingHelpDocsDefined()
{
if ($this->sitemap === null) {
return;
}

$applicable_page_groupings = array(
'audit',
'security',
Expand Down Expand Up @@ -127,6 +140,10 @@ public function testPageGroupingHelpDocsDefined()

public function testHasIcons()
{
if ($this->sitemap === null) {
return;
}

foreach ($this->flattened as $k => $c) {
if (preg_match('#^\w*:(\w*(:\w*)?)?$#', $k) != 0) {
if (in_array($k, array( // Exceptions
Expand Down Expand Up @@ -158,13 +175,21 @@ public function testHasIcons()

public function testNoOrphans()
{
if ($this->sitemap === null) {
return;
}

foreach ($this->flattened as $c) {
$this->assertTrue(!isset($c['is_unexpected_orphan']), 'Not tied in via page grouping ' . $c['title']->evaluate());
}
}

public function testNoIncompleteNodes()
{
if ($this->sitemap === null) {
return;
}

$props = array(
'title',
'content_type',
Expand Down

0 comments on commit a4680de

Please sign in to comment.