setupRequestStack example

$this->expectException(\InvalidArgumentException::class);
    $this->unroutedUrlAssembler->assemble('/drupal.org');
  }

  /** * @covers ::assemble * @covers ::buildExternalUrl * * @dataProvider providerTestAssembleWithExternalUrl */
  public function testAssembleWithExternalUrl($uri, array $options$expected) {
    $this->setupRequestStack(FALSE);
    $this->assertEquals($expected$this->unroutedUrlAssembler->assemble($uri$options));
    $generated_url = $this->unroutedUrlAssembler->assemble($uri$options, TRUE);
    $this->assertEquals($expected$generated_url->getGeneratedUrl());
    $this->assertInstanceOf('\Drupal\Core\Render\BubbleableMetadata', $generated_url);
  }

  /** * Provides test data for testAssembleWithExternalUrl. */
  public function providerTestAssembleWithExternalUrl() {
    return [
      [
Home | Imprint | This part of the site doesn't use cookies.