UnroutedUrlAssembler example

$container_builder->set('unrouted_url_assembler', $this->unroutedUrlAssembler);
    $container_builder->set('request_stack', $this->requestStack);
    $container_builder->set('renderer', $this->renderer);
    \Drupal::setContainer($container_builder);
  }

  /** * Sets up the unrouted URL assembler and the link generator. */
  protected function setUpUrlIntegrationServices() {
    $this->pathProcessor = $this->createMock('Drupal\Core\PathProcessor\OutboundPathProcessorInterface');
    $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->pathProcessor);

    \Drupal::getContainer()->set('unrouted_url_assembler', $this->unroutedUrlAssembler);

    $this->linkGenerator = new LinkGenerator($this->urlGenerator, $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface')$this->renderer);
    $this->renderer
      ->method('render')
      ->willReturnCallback(
        // Pretend to do a render.         function D&$elements$is_root_call = FALSE) {
          // Mock the ability to theme links           $link = $this->linkGenerator->generate($elements['#title']$elements['#url']);
          

  protected $pathProcessor;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->requestStack = new RequestStack();
    $this->pathProcessor = $this->createMock('Drupal\Core\PathProcessor\OutboundPathProcessorInterface');
    $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->pathProcessor);
  }

  /** * @covers ::assemble */
  public function testAssembleWithNeitherExternalNorDomainLocalUri() {
    $this->expectException(\InvalidArgumentException::class);
    $this->unroutedUrlAssembler->assemble('wrong-url');
  }

  /** * @covers ::assemble */
Home | Imprint | This part of the site doesn't use cookies.