security update for uuid xmlsitemap file_field_path
This commit is contained in:
@@ -5,10 +5,30 @@
|
||||
* Unit tests for the xmlsitemap_node module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Node Functional Test.
|
||||
*/
|
||||
class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
|
||||
/**
|
||||
* Normal User.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
protected $normal_user;
|
||||
|
||||
/**
|
||||
* Nodes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $nodes = array();
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'XML sitemap node',
|
||||
@@ -17,21 +37,44 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
);
|
||||
}
|
||||
|
||||
function setUp($modules = array()) {
|
||||
/**
|
||||
* Setup.
|
||||
*/
|
||||
public function setUp($modules = array()) {
|
||||
$modules[] = 'xmlsitemap_node';
|
||||
$modules[] = 'comment';
|
||||
parent::setUp($modules);
|
||||
|
||||
$this->admin_user = $this->drupalCreateUser(array('administer nodes', 'bypass node access', 'administer content types', 'administer xmlsitemap'));
|
||||
$this->normal_user = $this->drupalCreateUser(array('create page content', 'edit any page content', 'access content', 'view own unpublished content'));
|
||||
$this->admin_user = $this->drupalCreateUser(array(
|
||||
'administer nodes',
|
||||
'bypass node access',
|
||||
'administer content types',
|
||||
'administer xmlsitemap',
|
||||
));
|
||||
$this->normal_user = $this->drupalCreateUser(array(
|
||||
'create page content',
|
||||
'edit any page content',
|
||||
'access content',
|
||||
'view own unpublished content',
|
||||
));
|
||||
xmlsitemap_link_bundle_settings_save('node', 'page', array('status' => 1, 'priority' => 0.5));
|
||||
}
|
||||
|
||||
function testNodeSettings() {
|
||||
/**
|
||||
* Node Settings.
|
||||
*/
|
||||
public function testNodeSettings() {
|
||||
$body_field = 'body[' . LANGUAGE_NONE . '][0][value]';
|
||||
|
||||
$node = $this->drupalCreateNode(array('status' => FALSE, 'uid' => $this->normal_user->uid));
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 0, 'status' => 1, 'priority' => 0.5, 'status_override' => 0, 'priority_override' => 0));
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 0,
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
'status_override' => 0,
|
||||
'priority_override' => 0,
|
||||
));
|
||||
|
||||
$this->drupalLogin($this->normal_user);
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
@@ -44,7 +87,14 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertText('Basic page Test node title has been updated.');
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 0, 'status' => 1, 'priority' => 0.5, 'status_override' => 0, 'priority_override' => 0));
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 0,
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
'status_override' => 0,
|
||||
'priority_override' => 0,
|
||||
));
|
||||
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
@@ -58,7 +108,14 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertText('Basic page Test node title has been updated.');
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 1, 'status' => 0, 'priority' => 0.9, 'status_override' => 1, 'priority_override' => 1));
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 1,
|
||||
'status' => 0,
|
||||
'priority' => 0.9,
|
||||
'status_override' => 1,
|
||||
'priority_override' => 1,
|
||||
));
|
||||
|
||||
$edit = array(
|
||||
'xmlsitemap[status]' => 'default',
|
||||
@@ -67,16 +124,24 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertText('Basic page Test node title has been updated.');
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 0, 'status' => 1, 'priority' => 0.5, 'status_override' => 0, 'priority_override' => 0));
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 0,
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
'status_override' => 0,
|
||||
'priority_override' => 0,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the content type settings.
|
||||
*/
|
||||
function testTypeSettings() {
|
||||
public function testTypeSettings() {
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
||||
$node_old = $this->drupalCreateNode();
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node_old->nid, array('status' => 1, 'priority' => 0.5));
|
||||
|
||||
$edit = array(
|
||||
@@ -87,6 +152,7 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
$this->assertText('The content type Basic page has been updated.');
|
||||
|
||||
$node = $this->drupalCreateNode();
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('status' => 0, 'priority' => 0.0));
|
||||
$this->assertSitemapLinkValues('node', $node_old->nid, array('status' => 0, 'priority' => 0.0));
|
||||
|
||||
@@ -98,9 +164,18 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
$this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
|
||||
$this->assertText('Changed the content type of 2 posts from page to page2.');
|
||||
$this->assertText('The content type Basic page has been updated.');
|
||||
$this->cronRun();
|
||||
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('subtype' => 'page2', 'status' => 1, 'priority' => 0.5));
|
||||
$this->assertSitemapLinkValues('node', $node_old->nid, array('subtype' => 'page2', 'status' => 1, 'priority' => 0.5));
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'subtype' => 'page2',
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
));
|
||||
$this->assertSitemapLinkValues('node', $node_old->nid, array(
|
||||
'subtype' => 'page2',
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
));
|
||||
$this->assertEqual(count(xmlsitemap_link_load_multiple(array('type' => 'node', 'subtype' => 'page'))), 0);
|
||||
$this->assertEqual(count(xmlsitemap_link_load_multiple(array('type' => 'node', 'subtype' => 'page2'))), 2);
|
||||
|
||||
@@ -112,7 +187,7 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
/**
|
||||
* Test the import of old nodes via cron.
|
||||
*/
|
||||
function testCron() {
|
||||
public function testCron() {
|
||||
$limit = 5;
|
||||
variable_set('xmlsitemap_batch_limit', $limit);
|
||||
|
||||
@@ -127,17 +202,21 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
|
||||
// Clear all the node link data so we can emulate 'old' nodes.
|
||||
db_delete('xmlsitemap')
|
||||
->condition('type', 'node')
|
||||
->execute();
|
||||
->condition('type', 'node')
|
||||
->execute();
|
||||
|
||||
// Run cron to import old nodes.
|
||||
xmlsitemap_node_cron();
|
||||
|
||||
for ($i = 1; $i <= ($limit + 1); $i++) {
|
||||
$node = array_pop($nodes);
|
||||
$node = array_shift($nodes);
|
||||
if ($i <= $limit) {
|
||||
// The first $limit nodes should be inserted.
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 1, 'status' => 1, 'lastmod' => $node->changed));
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 1,
|
||||
'status' => 1,
|
||||
'lastmod' => $node->changed,
|
||||
));
|
||||
}
|
||||
else {
|
||||
// Any beyond $limit should not be in the sitemap.
|
||||
@@ -145,4 +224,5 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user