public function XMLSitemapCustomFunctionalTest::testCustomFileLinks in XML sitemap 7.2
Same name and namespace in other branches
- 6.2 xmlsitemap_custom/xmlsitemap_custom.test \XMLSitemapCustomFunctionalTest::testCustomFileLinks()
Test adding files as custom links.
File
- xmlsitemap_custom/
xmlsitemap_custom.test, line 103 - Unit tests for the xmlsitemap_custom.
Class
- XMLSitemapCustomFunctionalTest
- Class with Functional Test for XML Sitemap Custom.
Code
public function testCustomFileLinks() {
// Test an invalid file.
$edit['loc'] = $this
->randomName();
$this
->drupalPost('admin/config/search/xmlsitemap/custom/add', $edit, t('Save'));
$this
->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array(
'@link' => $edit['loc'],
)));
$this
->assertNoSitemapLink(array(
'type' => 'custom',
'loc' => $edit['loc'],
));
// Test an unaccessible file .
// @codingStandardsIgnoreStart
// $edit['loc'] = '.htaccess';
// $this->drupalPost('admin/config/search/xmlsitemap/custom/add', $edit, t('Save'));
// $this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc'])));
// $this->assertNoSitemapLink(array('type' => 'custom', 'loc' => $edit['loc']));
// @codingStandardsIgnoreEnd
// Test a valid file.
$edit['loc'] = 'misc/drupal.js';
$this
->drupalPost('admin/config/search/xmlsitemap/custom/add', $edit, t('Save'));
$this
->assertText('The custom link for ' . $edit['loc'] . ' was saved');
$links = xmlsitemap_link_load_multiple(array(
'type' => 'custom',
'loc' => $edit['loc'],
));
$this
->assertEqual(count($links), 1, t('Custom link saved in the database.'));
// Test a valid folder.
$edit['loc'] = 'misc';
$this
->drupalPost('admin/config/search/xmlsitemap/custom/add', $edit, t('Save'));
$this
->assertText('The custom link for ' . $edit['loc'] . ' was saved');
$links = xmlsitemap_link_load_multiple(array(
'type' => 'custom',
'loc' => $edit['loc'],
));
$this
->assertEqual(count($links), 1, t('Custom link saved in the database.'));
}