You are here

protected function BuildTestBase::standUpServer in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/BuildTests/Framework/BuildTestBase.php \Drupal\BuildTests\Framework\BuildTestBase::standUpServer()

Makes a local test server using PHP's internal HTTP server.

Test authors should call visit() or assertVisit() instead.

Parameters

string|null $working_dir: (optional) Server docroot relative to the workspace file system. Defaults to the workspace directory.

2 calls to BuildTestBase::standUpServer()
BuildTestBase::visit in core/tests/Drupal/BuildTests/Framework/BuildTestBase.php
Visit a URI on the HTTP server.
BuildTestTest::testStandUpServer in core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php
@covers ::standUpServer

File

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

Class

BuildTestBase
Provides a workspace to test build processes.

Namespace

Drupal\BuildTests\Framework

Code

protected function standUpServer($working_dir = NULL) {

  // If the user wants to test a new docroot, we have to shut down the old
  // server process and generate a new port number.
  if ($working_dir !== $this->serverDocroot && !empty($this->serverProcess)) {
    $this
      ->stopServer();
  }

  // If there's not a server at this point, make one.
  if (!$this->serverProcess || $this->serverProcess
    ->isTerminated()) {
    $this->serverProcess = $this
      ->instantiateServer($this
      ->getPortNumber(), $working_dir);
    if ($this->serverProcess) {
      $this->serverDocroot = $working_dir;
    }
  }
}