| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: xmlsitemap_custom.test,v 1.1.2.8 2010/02/11 02:23:42 davereid Exp $ 3 4 /** 5 * @file 6 * Unit tests for the xmlsitemap_custom module. 7 */ 8 9 class XMLSitemapCustomFunctionalTest extends XMLSitemapTestHelper { 10 public static function getInfo() { 11 return array( 12 'name' => 'XML sitemap custom interface tests', 13 'description' => 'Functional tests for the XML sitemap custom module.', 14 'group' => 'XML sitemap', 15 ); 16 } 17 18 function setUp() { 19 parent::setUp('xmlsitemap_custom', 'path'); 20 21 $this->admin_user = $this->drupalCreateUser(array('access content', 'administer xmlsitemap')); 22 $this->drupalLogin($this->admin_user); 23 } 24 25 function testCustomLinks() { 26 // Set a path alias for the node page. 27 path_set_alias('system/files', 'public-files'); 28 29 $this->drupalGet('admin/settings/xmlsitemap/custom'); 30 $this->clickLink(t('Add custom link')); 31 32 // Test an invalid path. 33 $edit['loc'] = 'invalid-testing-path'; 34 $this->drupalPost(NULL, $edit, t('Save')); 35 $this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); 36 $this->assertNoSitemapLink(array('type' => 'custom', 'loc' => $edit['loc'])); 37 38 // Test a path not accessible to anonymous user. 39 $edit['loc'] = 'admin/user/user'; 40 $this->drupalPost(NULL, $edit, t('Save')); 41 $this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); 42 $this->assertNoSitemapLink(array('type' => 'custom', 'loc' => $edit['loc'])); 43 44 // Test that the current page, which should not give a false positive for 45 // $menu_item['access'] since the result has been cached already. 46 $edit['loc'] = 'admin/settings/xmlsitemap/custom/add'; 47 $this->drupalPost(NULL, $edit, t('Save')); 48 $this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); 49 $this->assertNoSitemapLink(array('type' => 'custom', 'loc' => $edit['loc'])); 50 51 // Add an aliased path with padded spaces. 52 $edit['loc'] = ' public-files '; 53 $this->drupalPost(NULL, $edit, t('Save')); 54 $this->assertText('The custom link for system/files was saved'); 55 $links = xmlsitemap_link_load_multiple(array('type' => 'custom', 'loc' => 'system/files')); 56 $this->assertEqual(count($links), 1, t('Custom link saved in the database.')); 57 $link = reset($links); 58 $this->assertSitemapLinkValues('custom', $link['id'], array('priority' => 0.5, 'changefreq' => 0, 'access' => 1, 'status' => 1)); 59 60 $this->clickLink('Edit'); 61 $edit = array( 62 'priority' => 0.1, 63 'changefreq' => XMLSITEMAP_FREQUENCY_ALWAYS, 64 ); 65 $this->drupalPost(NULL, $edit, t('Save')); 66 $this->assertText('The custom link for system/files was saved'); 67 $this->assertSitemapLinkValues('custom', $link['id'], array('priority' => 0.1, 'changefreq' => XMLSITEMAP_FREQUENCY_ALWAYS, 'access' => 1, 'status' => 1)); 68 69 $this->clickLink('Delete'); 70 $this->drupalPost(NULL, array(), t('Delete')); 71 $this->assertText('The custom link for system/files has been deleted.'); 72 $this->assertNoSitemapLink(array('type' => 'custom', 'loc' => 'system/files')); 73 } 74 75 /** 76 * Test adding files as custom links. 77 */ 78 function testCustomFileLinks() { 79 // Test an invalid file. 80 $edit['loc'] = $this->randomName(); 81 $this->drupalPost('admin/settings/xmlsitemap/custom/add', $edit, t('Save')); 82 $this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); 83 $this->assertNoSitemapLink(array('type' => 'custom', 'loc' => $edit['loc'])); 84 85 // Test an unaccessible file . 86 //$edit['loc'] = '.htaccess'; 87 //$this->drupalPost('admin/settings/xmlsitemap/custom/add', $edit, t('Save')); 88 //$this->assertText(t('The custom link @link is either invalid or it cannot be accessed by anonymous users.', array('@link' => $edit['loc']))); 89 //$this->assertNoSitemapLink(array('type' => 'custom', 'loc' => $edit['loc'])); 90 91 // Test a valid file. 92 $edit['loc'] = 'misc/drupal.js'; 93 $this->drupalPost('admin/settings/xmlsitemap/custom/add', $edit, t('Save')); 94 $this->assertText('The custom link for ' . $edit['loc'] . ' was saved'); 95 $links = xmlsitemap_link_load_multiple(array('type' => 'custom', 'loc' => $edit['loc'])); 96 $this->assertEqual(count($links), 1, t('Custom link saved in the database.')); 97 98 // Test a valid folder. 99 $edit['loc'] = 'misc'; 100 $this->drupalPost('admin/settings/xmlsitemap/custom/add', $edit, t('Save')); 101 $this->assertText('The custom link for ' . $edit['loc'] . ' was saved'); 102 $links = xmlsitemap_link_load_multiple(array('type' => 'custom', 'loc' => $edit['loc'])); 103 $this->assertEqual(count($links), 1, t('Custom link saved in the database.')); 104 } 105 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |