You are here

protected function LinkTest::mockUrlAssembler in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php \Drupal\Tests\jsonapi\Unit\JsonApiResource\LinkTest::mockUrlAssembler()
  2. 10 core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php \Drupal\Tests\jsonapi\Unit\JsonApiResource\LinkTest::mockUrlAssembler()

Mocks the unrouted URL assembler.

4 calls to LinkTest::mockUrlAssembler()
LinkTest::linkComparisonProvider in core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php
Provides test data for link comparison.
LinkTest::linkMergeProvider in core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php
Provides test data for link merging.
LinkTest::testGetLinkRelationType in core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php
@covers ::getLinkRelationType
LinkTest::testLinkDeprecations in core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php
@group legacy @expectedDeprecation Constructing a Drupal\jsonapi\JsonApiResource\Link with an array of link relation types is deprecated in drupal:8.8.0 and will throw a fatal error in drupal:9.0.0. Pass a single string instead. See…

File

core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php, line 150

Class

LinkTest
@coversDefaultClass \Drupal\jsonapi\JsonApiResource\Link @group jsonapi

Namespace

Drupal\Tests\jsonapi\Unit\JsonApiResource

Code

protected function mockUrlAssembler() {
  $url_assembler = $this
    ->getMockBuilder(UnroutedUrlAssemblerInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $url_assembler
    ->method('assemble')
    ->will($this
    ->returnCallback(function ($uri) {
    return (new GeneratedUrl())
      ->setGeneratedUrl($uri);
  }));
  $container = new ContainerBuilder();
  $container
    ->set('unrouted_url_assembler', $url_assembler);
  \Drupal::setContainer($container);
}