From 60524be44b6b6a7c276514643ae8430840de2ab1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 11 Dec 2008 20:11:40 +0000 Subject: - Patch #345632 by boombatower: corrected assertTitle logic and added assertNoTitle for completeness. --- modules/simpletest/drupal_web_test_case.php | 18 +++++++++++++++++- modules/simpletest/simpletest.test | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 679d51a4d..ce94a858c 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1705,7 +1705,23 @@ class DrupalWebTestCase { * TRUE on pass, FALSE on fail. */ protected function assertTitle($title, $message, $group = 'Other') { - return $this->assert($this->xpath('//title[text()="' . $title . '"]') !== FALSE, $message, $group); + return $this->assertTrue($this->xpath('//title[text()="' . $title . '"]'), $message, $group); + } + + /** + * Pass if the page title is not the given string. + * + * @param $title + * The string the title should not be. + * @param $message + * Message to display. + * @param $group + * The group this message belongs to. + * @return + * TRUE on pass, FALSE on fail. + */ + protected function assertNoTitle($title, $message, $group = 'Other') { + return $this->assertFalse($this->xpath('//title[text()="' . $title . '"]'), $message, $group); } /** diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test index 0aa830115..40d48f435 100644 --- a/modules/simpletest/simpletest.test +++ b/modules/simpletest/simpletest.test @@ -46,6 +46,7 @@ class SimpleTestTestCase extends DrupalWebTestCase { $this->drupalGet('node'); $this->assertTrue($this->drupalGetHeader('Date'), t('An HTTP header was received.')); $this->assertTitle(variable_get('site_name', 'Drupal'), t('Site title matches.')); + $this->assertNoTitle('Foo', t('Site title does not match.')); // Make sure that we are locked out of the installer when prefixing // using the user-agent header. This is an important security check. global $base_url; -- cgit v1.2.3