function LinkTest::mockUrlAssembler

Same name in other branches
  1. 8.9.x 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()
  3. 11.x core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php \Drupal\Tests\jsonapi\Unit\JsonApiResource\LinkTest::mockUrlAssembler()

Mocks the unrouted URL assembler.

3 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

File

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

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')
        ->willReturnCallback(function ($uri) {
        return (new GeneratedUrl())->setGeneratedUrl($uri);
    });
    $container = new ContainerBuilder();
    $container->set('unrouted_url_assembler', $url_assembler);
    \Drupal::setContainer($container);
}

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