function BuildTestBase::visit

Same name in other branches
  1. 8.9.x core/tests/Drupal/BuildTests/Framework/BuildTestBase.php \Drupal\BuildTests\Framework\BuildTestBase::visit()
  2. 10 core/tests/Drupal/BuildTests/Framework/BuildTestBase.php \Drupal\BuildTests\Framework\BuildTestBase::visit()
  3. 11.x core/tests/Drupal/BuildTests/Framework/BuildTestBase.php \Drupal\BuildTests\Framework\BuildTestBase::visit()

Visit a URI on the HTTP server.

The concept here is that there could be multiple potential docroots in the workspace, so you can use whichever ones you want.

Parameters

string $request_uri: (optional) The non-host part of the URL. Example: /some/path?foo=bar. Defaults to visiting the homepage.

string $working_dir: (optional) Relative path within the test workspace file system that will be the docroot for the request. Defaults to the workspace directory.

Return value

\Behat\Mink\Mink The Mink object. Perform assertions against this.

Throws

\InvalidArgumentException Thrown when $request_uri does not start with a slash.

4 calls to BuildTestBase::visit()
GenerateThemeTest::test in core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php
Tests the generate-theme command.
HtRouterTest::testHtRouter in core/tests/Drupal/BuildTests/Framework/Tests/HtRouterTest.php
@covers ::instantiateServer
InstallTest::testInstall in core/tests/Drupal/BuildTests/TestSiteApplication/InstallTest.php
QuickStartTestBase::formLogin in core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php
Helper that uses Drupal's user/login form to log in.

File

core/tests/Drupal/BuildTests/Framework/BuildTestBase.php, line 370

Class

BuildTestBase
Provides a workspace to test build processes.

Namespace

Drupal\BuildTests\Framework

Code

public function visit($request_uri = '/', $working_dir = NULL) {
    if ($request_uri[0] !== '/') {
        throw new \InvalidArgumentException('URI: ' . $request_uri . ' must be relative. Example: /some/path?foo=bar');
    }
    // Try to make a server.
    $this->standUpServer($working_dir);
    $request = 'http://localhost:' . $this->getPortNumber() . $request_uri;
    $this->mink
        ->getSession()
        ->visit($request);
    return $this->mink;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.