Skip to content
Snippets Groups Projects
Commit 8f138ab1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2719701 by jhedstrom: BrowserTestBase::drupalGet() incompatible with...

Issue #2719701 by jhedstrom: BrowserTestBase::drupalGet() incompatible with WebTestBase::drupalGet()
parent ffcbce2c
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\simpletest\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -31,6 +32,14 @@ public function testGoTo() {
// Test page contains some text.
$this->assertSession()->pageTextContains('Test page text.');
// Test drupalGet with a url object.
$url = Url::fromRoute('test_page_test.render_title');
$this->drupalGet($url);
$this->assertSession()->statusCodeEquals(200);
// Test page contains some text.
$this->assertSession()->pageTextContains('Hello Drupal');
}
/**
......
......@@ -549,7 +549,7 @@ protected function prepareRequest() {
/**
* Retrieves a Drupal path or an absolute path.
*
* @param string $path
* @param string|\Drupal\Core\Url $path
* Drupal path or URL to load into Mink controlled browser.
* @param array $options
* (optional) Options to be forwarded to the url generator.
......@@ -560,9 +560,15 @@ protected function prepareRequest() {
protected function drupalGet($path, array $options = array()) {
$options['absolute'] = TRUE;
if ($path instanceof Url) {
$url_options = $path->getOptions();
$options = $url_options + $options;
$path->setOptions($options);
$url = $path->setAbsolute()->toString();
}
// The URL generator service is not necessarily available yet; e.g., in
// interactive installer tests.
if ($this->container->has('url_generator')) {
elseif ($this->container->has('url_generator')) {
if (UrlHelper::isExternal($path)) {
$url = Url::fromUri($path, $options)->toString();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment