standUpServer example

public function testInstall() {
    $this->copyCodebase();
    $fs = new Filesystem();
    $fs->chmod($this->getWorkspaceDirectory() . '/sites/default', 0700, 0000);

    // Composer tells you stuff in error output.     $this->executeCommand('COMPOSER_DISCARD_CHANGES=true composer install --no-interaction');
    $this->assertErrorOutputContains('Generating autoload files');

    // We have to stand up the server first so we can know the port number to     // pass along to the install command.     $this->standUpServer();

    $php_finder = new PhpExecutableFinder();
    $install_command = [
      $php_finder->find(),
      './core/scripts/test-site.php',
      'install',
      '--base-url=http://localhost:' . $this->getPortNumber(),
      '--db-url=sqlite://localhost/foo.sqlite',
      '--install-profile=minimal',
      '--json',
    ];
    
// Clean up after ourselves.     foreach ($processes as $process) {
      $process->stop();
    }
  }

  /** * @covers ::standUpServer */
  public function testStandUpServer() {
    // Stand up a server with working directory 'first'.     $this->standUpServer('first');

    // Get the process object for the server.     $ref_process = new \ReflectionProperty(parent::class, 'serverProcess');
    $first_process = $ref_process->getValue($this);

    // Standing up the server again should not change the server process.     $this->standUpServer('first');
    $this->assertSame($first_process$ref_process->getValue($this));

    // Standing up the server with working directory 'second' should give us a     // new server process.

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

  /** * Makes a local test server using PHP's internal HTTP server. * * Test authors should call visit() or assertVisit() instead. * * @param string|null $working_dir * (optional) Server docroot relative to the workspace file system. Defaults * to the workspace directory. */
Home | Imprint | This part of the site doesn't use cookies.