| 1 |
<?php |
<?php |
| 2 |
// $Id: xmlsitemap_custom.test,v 1.1.2.2 2009/06/02 14:48:51 davereid Exp $ |
// $Id: xmlsitemap_custom.test,v 1.1.2.3 2009/06/02 18:24:52 davereid Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 30 |
$this->drupalGet('admin/settings/xmlsitemap/custom'); |
$this->drupalGet('admin/settings/xmlsitemap/custom'); |
| 31 |
$this->clickLink(t('Add custom link')); |
$this->clickLink(t('Add custom link')); |
| 32 |
|
|
| 33 |
$edit = array(); |
// Test an invalid path. |
| 34 |
$edit['loc'] = "invalid-path"; |
$edit['loc'] = 'invalid-testing-path'; |
| 35 |
$this->drupalPost(NULL, $edit, t('Save')); |
$this->drupalPost(NULL, $edit, t('Save')); |
| 36 |
$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); |
$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); |
| 37 |
$this->assertNotInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
$this->assertNotInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
| 38 |
|
|
| 39 |
$edit['loc'] = "admin/user/user"; |
// Test a path not accessible to anonymous user. |
| 40 |
|
$edit['loc'] = 'admin/user/user'; |
| 41 |
$this->drupalPost(NULL, $edit, t('Save')); |
$this->drupalPost(NULL, $edit, t('Save')); |
| 42 |
$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); |
$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); |
| 43 |
$this->assertNotInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
$this->assertNotInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
| 44 |
|
|
| 45 |
// Test that the current page, which shouldn't give a false positive for |
// Test that the current page, which should not give a false positive for |
| 46 |
// $menu_item['access'] since the result has been cached already. |
// $menu_item['access'] since the result has been cached already. |
| 47 |
$edit['loc'] = "admin/settings/xmlsitemap/custom/add"; |
$edit['loc'] = 'admin/settings/xmlsitemap/custom/add'; |
| 48 |
$this->drupalPost(NULL, $edit, t('Save')); |
$this->drupalPost(NULL, $edit, t('Save')); |
| 49 |
$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); |
$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); |
| 50 |
$this->assertNotInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
$this->assertNotInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
| 51 |
|
|
| 52 |
$edit['loc'] = " content "; |
// Add an aliased path with padded spaces. |
| 53 |
|
$edit['loc'] = ' content '; |
| 54 |
$this->drupalPost(NULL, $edit, t('Save')); |
$this->drupalPost(NULL, $edit, t('Save')); |
| 55 |
$this->assertText(t('The sitemap system stores system paths only, but will use the URL alias in the sitemap output. The custom link @link has been stored as @normal_path.', array('@link' => 'content', '@normal_path' => 'node'))); |
$this->assertText(t('The sitemap system stores system paths only, but will use the URL alias in the sitemap output. The custom link @link has been stored as @normal_path.', array('@link' => 'content', '@normal_path' => 'node'))); |
| 56 |
$this->assertInSitemap(array('type' => 'custom', 'loc' => 'node')); |
$this->assertInSitemap(array('type' => 'custom', 'loc' => 'node')); |
| 57 |
} |
} |
| 58 |
|
|
| 59 |
|
/** |
| 60 |
|
* Test adding files as custom links. |
| 61 |
|
*/ |
| 62 |
|
function testCustomFileLinks() { |
| 63 |
|
// Test an invalid file. |
| 64 |
|
$edit['loc'] = $this->randomName(); |
| 65 |
|
$this->drupalPost('admin/settings/xmlsitemap/custom/add', $edit, t('Save')); |
| 66 |
|
$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); |
| 67 |
|
$this->assertNotInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
| 68 |
|
|
| 69 |
|
// Test an unaccessible file . |
| 70 |
|
//$edit['loc'] = '.htaccess'; |
| 71 |
|
//$this->drupalPost('admin/settings/xmlsitemap/custom/add', $edit, t('Save')); |
| 72 |
|
//$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); |
| 73 |
|
//$this->assertNotInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
| 74 |
|
|
| 75 |
|
// Test a valid file. |
| 76 |
|
//$valid_files = $this->drupalGetTestFiles('html'); |
| 77 |
|
//$edit['loc'] = current($valid_files); |
| 78 |
|
$edit['loc'] = 'misc/drupal.js'; |
| 79 |
|
$this->drupalPost('admin/settings/xmlsitemap/custom/add', $edit, t('Save')); |
| 80 |
|
$this->assertText('The custom link for ' . $edit['loc'] . ' was saved'); |
| 81 |
|
$this->assertInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
| 82 |
|
|
| 83 |
|
// Test a valid folder. |
| 84 |
|
$edit['loc'] = 'misc'; |
| 85 |
|
$this->drupalPost('admin/settings/xmlsitemap/custom/add', $edit, t('Save')); |
| 86 |
|
$this->assertText('The custom link for ' . $edit['loc'] . ' was saved'); |
| 87 |
|
$this->assertInSitemap(array('type' => 'custom', 'loc' => $edit['loc'])); |
| 88 |
|
} |
| 89 |
} |
} |