| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: xmlsitemap_engines.test,v 1.1.2.9 2010/04/19 05:35:38 davereid Exp $ 3 4 /** 5 * @file 6 * Tests for the xmlsitemap_engines module. 7 */ 8 9 class XMLSitemapEnginesFunctionalTest extends XMLSitemapTestHelper { 10 protected $submit_url; 11 12 public static function getInfo() { 13 return array( 14 'name' => 'XML sitemap engines functional tests', 15 'description' => 'Functional tests for the XML sitemap engines module.', 16 'group' => 'XML sitemap', 17 ); 18 } 19 20 function setUp() { 21 parent::setUp('xmlsitemap_engines', 'xmlsitemap_engines_test'); 22 $this->admin_user = $this->drupalCreateUser(array('access content', 'administer xmlsitemap')); 23 $this->drupalLogin($this->admin_user); 24 $this->submit_url = url('ping', array('absolute' => TRUE, 'query' => array('sitemap' => ''))) . '[sitemap]'; 25 } 26 27 function submitEngines() { 28 variable_set('xmlsitemap_engines_submit_last', REQUEST_TIME - 10000); 29 variable_set('xmlsitemap_generated_last', REQUEST_TIME - 100); 30 variable_set('xmlsitemap_engines_minimum_lifetime', 0); 31 xmlsitemap_engines_cron(); 32 $this->assertTrue(variable_get('xmlsitemap_engines_submit_last', 0) > (REQUEST_TIME - 100), 'Submitted the sitemaps to search engines.'); 33 } 34 35 function testPrepareURL() { 36 $sitemap = 'http://example.com/sitemap.xml'; 37 $input = 'http://example.com/ping?sitemap=[sitemap]&foo=bar'; 38 $output = 'http://example.com/ping?sitemap=http://example.com/sitemap.xml&foo=bar'; 39 $this->assertEqual(xmlsitemap_engines_prepare_url($input, $sitemap), $output); 40 } 41 42 function testSubmitSitemaps() { 43 $sitemaps = array( 44 array( 45 'uri' => array( 46 'path' => 'http://example.com/sitemap.xml', 47 'options' => array(), 48 ), 49 ), 50 array( 51 'uri' => array( 52 'path' => 'http://example.com/sitemap-2.xml', 53 'options' => array(), 54 ), 55 ), 56 ); 57 xmlsitemap_engines_submit_sitemaps($this->submit_url, $sitemaps); 58 59 $this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Recieved ping for @sitemap.', 'variables' => array('@sitemap' => 'http://example.com/sitemap.xml'))); 60 $this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Recieved ping for @sitemap.', 'variables' => array('@sitemap' => 'http://example.com/sitemap-2.xml'))); 61 } 62 63 function testPing() { 64 $edit = array('xmlsitemap_engines_engines[simpletest]' => TRUE); 65 $this->drupalPost('admin/settings/xmlsitemap/engines', $edit, t('Save configuration')); 66 $this->assertText(t('The configuration options have been saved.')); 67 68 $this->submitEngines(); 69 $this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Submitted the sitemap to %url and received response @code.')); 70 $this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Recieved ping for @sitemap.')); 71 } 72 73 function testCustomURL() { 74 $edit = array('xmlsitemap_engines_custom_urls' => 'an-invalid-url'); 75 $this->drupalPost('admin/settings/xmlsitemap/engines', $edit, t('Save configuration')); 76 $this->assertText('Invalid URL an-invalid-url.'); 77 $this->assertNoText('The configuration options have been saved.'); 78 79 $url = url('ping', array('absolute' => TRUE)); 80 $edit = array('xmlsitemap_engines_custom_urls' => $url); 81 $this->drupalPost('admin/settings/xmlsitemap/engines', $edit, t('Save configuration')); 82 $this->assertText(t('The configuration options have been saved.')); 83 84 $this->submitEngines(); 85 $this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Submitted the sitemap to %url and received response @code.', 'variables' => array('%url' => $url, '@code' => '404'))); 86 $this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'No valid sitemap parameter provided.')); 87 $this->assertWatchdogMessage(array('type' => 'page not found', 'message' => 'ping')); 88 89 $edit = array('xmlsitemap_engines_custom_urls' => $this->submit_url); 90 $this->drupalPost('admin/settings/xmlsitemap/engines', $edit, t('Save configuration')); 91 $this->assertText(t('The configuration options have been saved.')); 92 93 $this->submitEngines(); 94 $url = xmlsitemap_engines_prepare_url($this->submit_url, url('sitemap.xml', array('absolute' => TRUE))); 95 $this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Submitted the sitemap to %url and received response @code.', 'variables' => array('%url' => $url, '@code' => '200'))); 96 $this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Recieved ping for @sitemap.', 'variables' => array('@sitemap' => url('sitemap.xml', array('absolute' => TRUE))))); 97 } 98 }
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 |