diff --git a/core/lib/Drupal/Core/CacheDecorator/CacheDecoratorInterface.php b/core/lib/Drupal/Core/CacheDecorator/CacheDecoratorInterface.php index e7c9c69..48d8422 100644 --- a/core/lib/Drupal/Core/CacheDecorator/CacheDecoratorInterface.php +++ b/core/lib/Drupal/Core/CacheDecorator/CacheDecoratorInterface.php @@ -16,7 +16,7 @@ * Specify the key to use when writing the cache. */ public function setCacheKey($key); - + /** * Write the cache. */ diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 7d14ca0..964b16b 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -760,6 +760,12 @@ protected function setUp() { variable_set('mail_system', array('default-system' => 'Drupal\Core\Mail\VariableLog')); drupal_set_time_limit($this->timeLimit); + // Temporary fix so that when running from run-tests.sh we don't get an + // empty current path which would indicate we're on the home page. + $path = current_path(); + if (empty($path)) { + _current_path('run-tests'); + } $this->setup = TRUE; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php index 41fd626..353ba18 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php @@ -40,7 +40,8 @@ function testUrlAlter() { $name = $account->name; // Test a single altered path. - $this->assertUrlInboundAlter("user/$name", "user/$uid"); + $this->drupalGet("user/$name"); + $this->assertResponse('200', 'The user/username path gets resolved correctly'); $this->assertUrlOutboundAlter("user/$uid", "user/$name"); // Test that a path always uses its alias. @@ -49,32 +50,33 @@ function testUrlAlter() { $this->assertUrlInboundAlter('alias/test1', "user/$uid/test1"); $this->assertUrlOutboundAlter("user/$uid/test1", 'alias/test1'); - // Test that alias source paths are normalized in the interface. - $edit = array('source' => "user/$name/edit", 'alias' => 'alias/test2'); + // Test adding an alias via the UI. + $edit = array('source' => "user/$uid/edit", 'alias' => 'alias/test2'); $this->drupalPost('admin/config/search/path/add', $edit, t('Save')); $this->assertText(t('The alias has been saved.')); - - // Test that a path always uses its alias. - $this->assertUrlInboundAlter('alias/test2', "user/$uid/edit"); + $this->drupalGet('alias/test2'); + $this->assertResponse('200', 'The path alias gets resolved correctly'); $this->assertUrlOutboundAlter("user/$uid/edit", 'alias/test2'); // Test a non-existent user is not altered. $uid++; - $this->assertUrlInboundAlter("user/$uid", "user/$uid"); $this->assertUrlOutboundAlter("user/$uid", "user/$uid"); // Test that 'forum' is altered to 'community' correctly, both at the root // level and for a specific existing forum. - $this->assertUrlInboundAlter('community', 'forum'); + $this->drupalGet('community'); + $this->assertText('General discussion', 'The community path gets resolved correctly'); $this->assertUrlOutboundAlter('forum', 'community'); $forum_vid = config('forum.settings')->get('vocabulary'); + $term_name = $this->randomName(); $tid = db_insert('taxonomy_term_data') ->fields(array( - 'name' => $this->randomName(), + 'name' => $term_name, 'vid' => $forum_vid, )) ->execute(); - $this->assertUrlInboundAlter("community/$tid", "forum/$tid"); + $this->drupalGet("community/$tid"); + $this->assertText($term_name, 'The community/{tid} path gets resolved correctly'); $this->assertUrlOutboundAlter("forum/$tid", "community/$tid"); } @@ -88,14 +90,6 @@ function testCurrentUrlRequestedPath() { } /** - * Tests that current_path() is initialized when the request path is empty. - */ - function testGetQInitialized() { - $this->drupalGet(''); - $this->assertText("current_path() is non-empty with an empty request path.", 'current_path() is initialized with an empty request path.'); - } - - /** * Assert that an outbound path is altered to an expected value. * * @param $original diff --git a/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathSubscriber.php b/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathSubscriber.php new file mode 100644 index 0000000..e79cd01 --- /dev/null +++ b/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathSubscriber.php @@ -0,0 +1,59 @@ +getRequest(); + $path = $this->extractPath($request); + // Rewrite user/username to user/uid. + if (preg_match('!^user/([^/]+)(/.*)?!', $path, $matches)) { + if ($account = user_load_by_name($matches[1])) { + $matches += array(2 => ''); + $path = 'user/' . $account->uid . $matches[2]; + } + } + + // Rewrite community/ to forum/. + if ($path == 'community' || strpos($path, 'community/') === 0) { + $path = 'forum' . substr($path, 9); + } + + if ($path == 'url-alter-test/bar') { + $path = 'url-alter-test/foo'; + } + + $this->setPath($request, $path); + } + + /** + * Registers the methods in this class that should be listeners. + * + * @return array + * An array of event listener definitions. + */ + static function getSubscribedEvents() { + $events[KernelEvents::REQUEST][] = array('onKernelRequestPathResolve', 100); + return $events; + } +} diff --git a/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/UrlAlterTestBundle.php b/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/UrlAlterTestBundle.php new file mode 100644 index 0000000..dc2f5cf --- /dev/null +++ b/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/UrlAlterTestBundle.php @@ -0,0 +1,24 @@ +register('url_alter_test.path_subscriber', 'Drupal\url_alter_test\PathSubscriber') + ->addTag('event_subscriber'); + } +} diff --git a/core/modules/system/tests/modules/url_alter_test/url_alter_test.module b/core/modules/system/tests/modules/url_alter_test/url_alter_test.module index a5ca13d..61cc625 100644 --- a/core/modules/system/tests/modules/url_alter_test/url_alter_test.module +++ b/core/modules/system/tests/modules/url_alter_test/url_alter_test.module @@ -27,32 +27,6 @@ function url_alter_test_foo() { } /** - * Implements hook_url_inbound_alter(). - */ -function url_alter_test_url_inbound_alter(&$path, $original_path, $path_language) { - if (!request_path() && current_path()) { - drupal_set_message("current_path() is non-empty with an empty request path."); - } - - // Rewrite user/username to user/uid. - if (preg_match('!^user/([^/]+)(/.*)?!', $path, $matches)) { - if ($account = user_load_by_name($matches[1])) { - $matches += array(2 => ''); - $path = 'user/' . $account->uid . $matches[2]; - } - } - - // Rewrite community/ to forum/. - if ($path == 'community' || strpos($path, 'community/') === 0) { - $path = 'forum' . substr($path, 9); - } - - if ($path == 'url-alter-test/bar') { - $path = 'url-alter-test/foo'; - } -} - -/** * Implements hook_url_outbound_alter(). */ function url_alter_test_url_outbound_alter(&$path, &$options, $original_path) {