/[drupal]/contributions/modules/xmlsitemap/xmlsitemap_custom/xmlsitemap_custom.test
ViewVC logotype

Diff of /contributions/modules/xmlsitemap/xmlsitemap_custom/xmlsitemap_custom.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.3, Tue Jun 2 18:24:52 2009 UTC revision 1.1.2.4, Wed Oct 28 04:05:09 2009 UTC
# Line 1  Line 1 
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
# Line 30  class XMLSitemapCustomFunctionalTest ext Line 30  class XMLSitemapCustomFunctionalTest ext
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  }  }

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

  ViewVC Help
Powered by ViewVC 1.1.2