instantiateServer example

->ignoreDotFiles(FALSE)
      ->exclude(['sites/simpletest'])
      ->path('/^.ht.router.php$/')
      ->getIterator();
    $this->copyCodebase($iterator);
    /** @var \Symfony\Component\Process\Process[] $processes */
    $processes = [];
    $count = 15;
    for ($i = 0; $i <= $count$i++) {
      $port = $this->findAvailablePort();
      $this->assertArrayNotHasKey($port$processes, 'Port ' . $port . ' was already in use by a process.');
      $processes[$port] = $this->instantiateServer($port);
      $this->assertNotEmpty($processes[$port]);
      $this->assertTrue($processes[$port]->isRunning(), 'Process on port ' . $port . ' is not still running.');
      $this->assertFalse($this->checkPortIsAvailable($port));
    }

    // Clean up after ourselves.     foreach ($processes as $process) {
      $process->stop();
    }
  }

  

  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;
      }
    }
  }

  /** * Do the work of making a server process. * * Test authors should call visit() or assertVisit() instead. * * When initializing the server, if '.ht.router.php' exists in the root, it is * leveraged. If testing with a version of Drupal before 8.5.x., this file * does not exist. * * @param int $port * The port number for the server. * @param string|null $working_dir * (optional) Server docroot relative to the workspace filesystem. Defaults * to the workspace directory. * * @return \Symfony\Component\Process\Process * The server process. * * @throws \RuntimeException * Thrown if we were unable to start a web server. */
Home | Imprint | This part of the site doesn't use cookies.