Commit 5fa07299 authored by Dave Reid's avatar Dave Reid
Browse files

by Dave Reid: Removed redundant test functions.

parent 6e35a7dc
......@@ -78,18 +78,18 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
return $link;
}
protected function assertSitemapLinkVisible(array $link, $load = FALSE) {
if ($load) {
$link = $this->assertSitemapLink($link);
protected function assertSitemapLinkVisible() {
$links = func_get_args();
foreach ($links as $link) {
$this->assertTrue($link && $link['access'] && $link['status'], 'Sitemap link is visible.');
}
$this->assertTrue($link && $link['access'] && $link['status'], 'Sitemap link is visible.');
}
protected function assertSitemapLinkNotVisible(array $link, $load = FALSE) {
if ($load) {
$link = $this->assertSitemapLink($link);
protected function assertSitemapLinkNotVisible() {
$links = func_get_args();
foreach ($links as $link) {
$this->assertTrue($link && !($link['access'] && $link['status']), 'Sitemap link is not visible.');
}
$this->assertTrue($link && !($link['access'] && $link['status']), 'Sitemap link is not visible.');
}
protected function assertSitemapLinkValues(array $link, array $conditions) {
......@@ -118,42 +118,6 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
}
}
/**
* Assert that a link is found in the sitemap.
*
* @param $conditions
* An array of values/conditions to match keyed by field name.
*/
protected function assertInSitemap($conditions) {
$link = xmlsitemap_load_link($conditions);
$this->assertTrue($link && $link['access'] && $link['status'], t('Link found in sitemap.'));
return $link;
}
/**
* Assert that a link is not found in the sitemap.
*
* @param $conditions
* An array of values/conditions to match keyed by field name.
*/
protected function assertNotInSitemap($conditions) {
$link = xmlsitemap_load_link($conditions);
$this->assertTrue(!$link || !$link['access'] || !$link['status'], t('Link not found in sitemap.'));
return $link;
}
protected function assertLinkInSitemap(&$link) {
$link = xmlsitemap_load_link(array('id' => $link['id'], 'type' => $link['type']));
$this->assertTrue($link && $link['access'] && $link['status'], t('Link found in sitemap.'));
return $link;
}
protected function assertLinkNotInSitemap(&$link) {
$link = xmlsitemap_load_link(array('id' => $link['id'], 'type' => $link['type']));
$this->assertTrue(!$link || !$link['access'] || !$link['status'], t('Link found in sitemap.'));
return $link;
}
protected function assertRawSitemapLinks() {
$links = func_get_args();
foreach ($links as $link) {
......@@ -171,7 +135,7 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
}
protected function addSitemapLink(array $link = array()) {
static $last_id = 1;
$last_id = &drupal_static(__FUNCTION__, 1);
$link += array(
'type' => 'testing',
......@@ -563,9 +527,6 @@ class XMLSitemapUnitTest extends XMLSitemapTestHelper {
$updated = xmlsitemap_update_links(array('status' => 0), array('type' => 'testing', 'subtype' => 'group1', 'status_override' => 0));
$this->assertEqual($updated, 2);
//$this->assertLinkNotInSitemap($link1);
//$this->assertLinkNotInSitemap($link2);
//$this->assertLinkInSitemap($link3);
$this->assertFlag('regenerate_needed', TRUE);
// id | type | subtype | language | status | priority
// 1 | testing | group1 | '' | 0 | 0.5
......
......@@ -27,11 +27,13 @@ class XMLSitemapNodeTestHelper extends XMLSitemapTestHelper {
//}
protected function assertNodeInSitemap($node) {
return $this->assertInSitemap(array('type' => 'node', 'id' => (is_object($node) ? $node->nid : $node)));
$link = xmlsitemap_load_link(array('type' => 'node', 'id' => (is_object($node) ? $node->nid : $node)));
return $this->assertSitemapLinkVisible($link);
}
protected function assertNodeNotInSitemap($node) {
return $this->assertNotInSitemap(array('type' => 'node', 'id' => (is_object($node) ? $node->nid : $node)));
$link = xmlsitemap_load_link(array('type' => 'node', 'id' => (is_object($node) ? $node->nid : $node)));
return $this->assertSitemapLinkNotVisible($link);
}
protected function assertNodeLinkValues($node, array $values) {
......@@ -166,13 +168,12 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapNodeTestHelper {
}
// Clear all the node link data so we can emulate 'old' nodes.
db_query("DELETE FROM {xmlsitemap} WHERE type = 'node'");
foreach ($nodes as $node) {
$this->assertNodeNotInSitemap($node);
}
db_delete('xmlsitemap')
->condition('type', 'node')
->execute();
// Run cron to import old nodes.
drupal_cron_run();
xmlsitemap_node_cron();
for ($i = 1; $i <= ($limit + 1); $i++) {
$node = array_pop($nodes);
......@@ -182,7 +183,7 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapNodeTestHelper {
}
else {
// Any beyond $limit should not be in the sitemap.
$this->assertNodeNotInSitemap($node);
$this->assertNoSitemapLink(array('type' => 'node', 'id' => $node->nid));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment