? 371235-patched-benchmarks.txt
? 371235-unpatched-benchmarks.txt
? sites/all/modules/cvs
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.32
diff -u -p -r1.32 path.inc
--- includes/path.inc 4 Jan 2009 20:04:32 -0000 1.32
+++ includes/path.inc 25 Feb 2009 23:12:42 -0000
@@ -260,3 +260,30 @@ function drupal_match_path($path, $patte
}
return (bool)preg_match($regexps[$patterns], $path);
}
+
+/*
+ * Extract part of the current Drupal path from a certain 'argument' onward.
+ *
+ * For example, if the path is 'http://example-drupal/blah/foo/foobar/ferzle':
+ * $pos = 0, returns 'blah/foo/foobar/ferzle'
+ * $pos = 2, returns 'foobar/ferzle'
+ * $pos = 4, returns ''
+ *
+ * @param $pos
+ * The argument of the path to start at, use 0 to get the whole path.
+ * @return
+ * The extracted part of the path.
+ */
+function drupal_get_path_segment($arg = 0, $path = NULL) {
+ if (!isset($path)) {
+ $path = trim($_GET['q']);
+ }
+
+ if ($arg > 0) {
+ $path = explode('/', $path, $arg + 1);
+ $path = (count($path) > $arg ? end($path) : '');
+ }
+
+ return $path;
+}
+
Index: modules/simpletest/tests/system_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/system_test.module,v
retrieving revision 1.8
diff -u -p -r1.8 system_test.module
--- modules/simpletest/tests/system_test.module 9 Dec 2008 11:09:26 -0000 1.8
+++ modules/simpletest/tests/system_test.module 25 Feb 2009 23:12:45 -0000
@@ -158,16 +158,6 @@ function system_test_boot() {
}
/**
- * Implementation of hook_init().
- */
-function system_test_init() {
- // Used by FrontPageTestCase to get the results of drupal_is_front_page().
- if (variable_get('front_page_output', 0) && drupal_is_front_page()) {
- drupal_set_message(t('On front page.'));
- }
-}
-
-/**
* Implementation of hook_exit().
*/
function system_test_exit() {
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.39
diff -u -p -r1.39 system.test
--- modules/system/system.test 11 Feb 2009 05:33:18 -0000 1.39
+++ modules/system/system.test 25 Feb 2009 23:12:50 -0000
@@ -580,125 +580,6 @@ class DateTimeFunctionalTest extends Dru
}
}
-class PageTitleFiltering extends DrupalWebTestCase {
- protected $content_user;
- protected $saved_title;
-
- /**
- * Implementation of getInfo().
- */
- function getInfo() {
- return array(
- 'name' => t('HTML in page titles'),
- 'description' => t('Tests correct handling or conversion by drupal_set_title() and drupal_get_title().'),
- 'group' => t('System')
- );
- }
-
- /**
- * Implementation of setUp().
- */
- function setUp() {
- parent::setUp();
-
- $this->content_user = $this->drupalCreateUser(array('create page content', 'access content'));
- $this->drupalLogin($this->content_user);
- $this->saved_title = drupal_get_title();
- }
-
- /**
- * Reset page title.
- */
- function tearDown() {
- // Restore the page title.
- drupal_set_title($this->saved_title, PASS_THROUGH);
-
- parent::tearDown();
- }
-
- /**
- * Tests the handling of HTML by drupal_set_title() and drupal_get_title()
- */
- function testTitleTags() {
- $title = "string with HTML";
- // drupal_set_title's $filter is CHECK_PLAIN by default, so the title should be
- // returned with check_plain().
- drupal_set_title($title, CHECK_PLAIN);
- $this->assertTrue(strpos(drupal_get_title(), '') === FALSE, t('Tags in title converted to entities when $output is CHECK_PLAIN.'));
- // drupal_set_title's $filter is passed as PASS_THROUGH, so the title should be
- // returned with HTML.
- drupal_set_title($title, PASS_THROUGH);
- $this->assertTrue(strpos(drupal_get_title(), '') !== FALSE, t('Tags in title are not converted to entities when $output is PASS_THROUGH.'));
- // Generate node content.
- $edit = array(
- 'title' => '!SimpleTest! ' . $title . $this->randomName(20),
- 'body' => '!SimpleTest! test body' . $this->randomName(200),
- );
- // Create the node with HTML in the title.
- $this->drupalPost('node/add/page', $edit, t('Save'));
-
- $node = $this->drupalGetNodeByTitle($edit['title']);
- $this->assertNotNull($node, 'Node created and found in database');
- $this->drupalGet("node/" . $node->nid);
- $this->assertText(check_plain($edit['title']), 'Check to make sure tags in the node title are converted.');
- }
-}
-
-/**
- * Test front page functionality and administration.
- */
-class FrontPageTestCase extends DrupalWebTestCase {
-
- function getInfo() {
- return array(
- 'name' => t('Front page'),
- 'description' => t('Tests front page functionality and administration.'),
- 'group' => t('System'),
- );
- }
-
- function setUp() {
- parent::setUp('system_test');
-
- // Create admin user, log in admin user, and create one node.
- $this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration'));
- $this->drupalLogin($this->admin_user);
- $this->node_path = "node/" . $this->drupalCreateNode(array('promote' => 1))->nid;
-
- // Enable front page logging in system_test.module.
- variable_set('front_page_output', 1);
- }
-
- /**
- * Test front page functionality.
- */
- function testDrupalIsFrontPage() {
- $this->drupalGet('');
- $this->assertText(t('On front page.'), t('Path is the front page.'));
- $this->drupalGet('node');
- $this->assertText(t('On front page.'), t('Path is the front page.'));
- $this->drupalGet($this->node_path);
- $this->assertNoText(t('On front page.'), t('Path is not the front page.'));
-
- // Change the front page to an invalid path.
- $edit = array('site_frontpage' => 'kittens');
- $this->drupalPost('admin/settings/site-information', $edit, t('Save configuration'));
- $this->assertText(t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $edit['site_frontpage'])));
-
- // Change the front page to a valid path.
- $edit['site_frontpage'] = $this->node_path;
- $this->drupalPost('admin/settings/site-information', $edit, t('Save configuration'));
- $this->assertText(t('The configuration options have been saved.'), t('The front page path has been saved.'));
-
- $this->drupalGet('');
- $this->assertText(t('On front page.'), t('Path is the front page.'));
- $this->drupalGet('node');
- $this->assertNoText(t('On front page.'), t('Path is not the front page.'));
- $this->drupalGet($this->node_path);
- $this->assertText(t('On front page.'), t('Path is the front page.'));
- }
-}
-
class SystemBlockTestCase extends DrupalWebTestCase {
function getInfo() {
return array(
Index: modules/taxonomy/taxonomy.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v
retrieving revision 1.23
diff -u -p -r1.23 taxonomy.pages.inc
--- modules/taxonomy/taxonomy.pages.inc 27 Jan 2009 00:22:27 -0000 1.23
+++ modules/taxonomy/taxonomy.pages.inc 25 Feb 2009 23:12:51 -0000
@@ -116,7 +116,9 @@ function taxonomy_term_edit($term) {
/**
* Helper function for autocompletion
*/
-function taxonomy_autocomplete($vid, $string = '') {
+function taxonomy_autocomplete($vid) {
+ $string = drupal_get_path_segment(3);
+
// The user enters a comma-separated list of tags. We only autocomplete the last tag.
$array = drupal_explode_tags($string);
Index: modules/simpletest/tests/path.test
===================================================================
RCS file: modules/simpletest/tests/path.test
diff -N modules/simpletest/tests/path.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/tests/path.test 25 Feb 2009 23:12:57 -0000
@@ -0,0 +1,139 @@
+ t('HTML in page titles'),
+ 'description' => t('Tests correct handling or conversion by drupal_set_title() and drupal_get_title().'),
+ 'group' => t('Path')
+ );
+ }
+
+ function setUp() {
+ parent::setUp();
+
+ $this->content_user = $this->drupalCreateUser(array('create page content', 'access content'));
+ $this->drupalLogin($this->content_user);
+ $this->saved_title = drupal_get_title();
+ }
+
+ function tearDown() {
+ // Restore the page title.
+ drupal_set_title($this->saved_title, PASS_THROUGH);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Tests the handling of HTML by drupal_set_title() and drupal_get_title()
+ */
+ function testTitleTags() {
+ $title = "string with HTML";
+ // drupal_set_title's $filter is CHECK_PLAIN by default, so the title should be
+ // returned with check_plain().
+ drupal_set_title($title, CHECK_PLAIN);
+ $this->assertTrue(strpos(drupal_get_title(), '') === FALSE, t('Tags in title converted to entities when $output is CHECK_PLAIN.'));
+ // drupal_set_title's $filter is passed as PASS_THROUGH, so the title should be
+ // returned with HTML.
+ drupal_set_title($title, PASS_THROUGH);
+ $this->assertTrue(strpos(drupal_get_title(), '') !== FALSE, t('Tags in title are not converted to entities when $output is PASS_THROUGH.'));
+ // Generate node content.
+ $edit = array(
+ 'title' => '!SimpleTest! ' . $title . $this->randomName(20),
+ 'body' => '!SimpleTest! test body' . $this->randomName(200),
+ );
+ // Create the node with HTML in the title.
+ $this->drupalPost('node/add/page', $edit, t('Save'));
+
+ $node = $this->drupalGetNodeByTitle($edit['title']);
+ $this->assertNotNull($node, 'Node created and found in database');
+ $this->drupalGet("node/" . $node->nid);
+ $this->assertText(check_plain($edit['title']), 'Check to make sure tags in the node title are converted.');
+ }
+}
+
+/**
+ * Test front page functionality and administration.
+ */
+class IsFrontPageUnitTest extends DrupalWebTestCase {
+ function getInfo() {
+ return array(
+ 'name' => t('Front page'),
+ 'description' => t('Tests front page functionality and administration.'),
+ 'group' => t('Path'),
+ );
+ }
+
+ function setUp() {
+ parent::setUp('path_test');
+
+ // Create admin user, log in admin user, and create one node.
+ $this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration'));
+ $this->drupalLogin($this->admin_user);
+ $this->node_path = "node/" . $this->drupalCreateNode(array('promote' => 1))->nid;
+
+ // Enable front page logging in path_test.module.
+ variable_set('front_page_output', 1);
+ }
+
+ /**
+ * Test front page functionality.
+ */
+ function testDrupalIsFrontPage() {
+ $this->drupalGet('');
+ $this->assertText(t('On front page.'), t('Path is the front page.'));
+ $this->drupalGet('node');
+ $this->assertText(t('On front page.'), t('Path is the front page.'));
+ $this->drupalGet($this->node_path);
+ $this->assertNoText(t('On front page.'), t('Path is not the front page.'));
+
+ // Change the front page to an invalid path.
+ $edit = array('site_frontpage' => 'kittens');
+ $this->drupalPost('admin/settings/site-information', $edit, t('Save configuration'));
+ $this->assertText(t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $edit['site_frontpage'])));
+
+ // Change the front page to a valid path.
+ $edit['site_frontpage'] = $this->node_path;
+ $this->drupalPost('admin/settings/site-information', $edit, t('Save configuration'));
+ $this->assertText(t('The configuration options have been saved.'), t('The front page path has been saved.'));
+
+ $this->drupalGet('');
+ $this->assertText(t('On front page.'), t('Path is the front page.'));
+ $this->drupalGet('node');
+ $this->assertNoText(t('On front page.'), t('Path is not the front page.'));
+ $this->drupalGet($this->node_path);
+ $this->assertText(t('On front page.'), t('Path is the front page.'));
+ }
+}
+
+/**
+ * Tests for the drupal_get_path_segment() function.
+ */
+class PathGetSegmentUnitTest extends DrupalWebTestCase {
+ function getInfo() {
+ return array(
+ 'name' => t('Tests for the drupal_get_path_segment() function'),
+ 'description' => t('Confirm that drupal_get_path_segment() works correctly with various input.'),
+ 'group' => t('Path'),
+ );
+ }
+
+ function testPathGetSegment() {
+ $segments = array(
+ 0 => 'test/kittens/drupal is fun?/seriously!',
+ 1 => 'kittens/drupal is fun?/seriously!',
+ 2 => 'drupal is fun?/seriously!',
+ 3 => 'seriously!',
+ 4 => '',
+ );
+
+ foreach ($segments as $pos => $segment) {
+ $this->assertIdentical($segments[$pos], drupal_get_path_segment($pos, $segments[0]));
+ }
+ }
+}
+
Index: modules/simpletest/tests/path_test.info
===================================================================
RCS file: modules/simpletest/tests/path_test.info
diff -N modules/simpletest/tests/path_test.info
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/tests/path_test.info 25 Feb 2009 23:12:57 -0000
@@ -0,0 +1,8 @@
+; $Id$
+name = Path test
+description = Support module for path testing.
+package = Testing
+version = VERSION
+core = 7.x
+files[] = path_test.module
+hidden = TRUE
Index: modules/simpletest/tests/path_test.module
===================================================================
RCS file: modules/simpletest/tests/path_test.module
diff -N modules/simpletest/tests/path_test.module
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/tests/path_test.module 25 Feb 2009 23:12:57 -0000
@@ -0,0 +1,12 @@
+