function ViewExecutableTest::testGetUrlWithPlaceholdersAndArgs

Tests get url with placeholders and args.

@legacy-covers ::getUrl

File

core/modules/views/tests/src/Unit/ViewExecutableTest.php, line 235

Class

ViewExecutableTest
Tests Drupal\views\ViewExecutable.

Namespace

Drupal\Tests\views\Unit

Code

public function testGetUrlWithPlaceholdersAndArgs() : void {
  $this->displayHandler
    ->expects($this->any())
    ->method('getRoutedDisplay')
    ->willReturn($this->displayHandler);
  $this->displayHandlers
    ->expects($this->any())
    ->method('get')
    ->willReturn($this->displayHandler);
  $this->displayHandler
    ->expects($this->any())
    ->method('getUrlInfo')
    ->willReturn(Url::fromRoute('views.test.page_1'));
  $this->displayHandler
    ->expects($this->any())
    ->method('getPath')
    ->willReturn('test-path/%');
  $route = new Route('/test-path/{arg_0}');
  $this->routeProvider
    ->expects($this->any())
    ->method('getRouteByName')
    ->with('views.test.page_1')
    ->willReturn($route);
  $this->assertEquals(Url::fromRoute('views.test.page_1', [
    'arg_0' => 'test',
  ]), $this->executable
    ->getUrl([
    'test',
  ]));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.