public function LinkManagerTest::testGetRequestLink in JSON:API 8
@covers ::getRequestLink
File
- tests/
src/ Unit/ LinkManager/ LinkManagerTest.php, line 184
Class
- LinkManagerTest
- @coversDefaultClass \Drupal\jsonapi\LinkManager\LinkManager @group jsonapi
Namespace
Drupal\Tests\jsonapi\Unit\LinkManagerCode
public function testGetRequestLink() {
$assembler = $this
->prophesize(UnroutedUrlAssemblerInterface::class);
$assembler
->assemble(Argument::type('string'), [
'external' => TRUE,
'query' => [
'dolor' => 'sid',
],
], FALSE)
->will(function ($args) {
return $args[0] . '?dolor=sid';
})
->shouldBeCalled();
$container = new ContainerBuilder();
$container
->set('unrouted_url_assembler', $assembler
->reveal());
\Drupal::setContainer($container);
$request = $this
->prophesize(Request::class);
$request
->getUri()
->willReturn('https://example.com/drupal/jsonapi/node/article/07c870e9-491b-4173-8e2b-4e059400af72?amet=pax');
$request
->getBaseUrl()
->willReturn('/drupal');
$request
->getPathInfo()
->willReturn('');
$request
->getSchemeAndHttpHost()
->willReturn('https://example.com');
$request
->getBaseUrl()
->willReturn('/drupal');
$request
->getPathInfo()
->willReturn('/jsonapi/node/article/07c870e9-491b-4173-8e2b-4e059400af72');
$this
->assertSame('https://example.com/drupal/jsonapi/node/article/07c870e9-491b-4173-8e2b-4e059400af72?dolor=sid', $this->linkManager
->getRequestLink($request
->reveal(), [
'dolor' => 'sid',
]));
// Get the default query from the request object.
$this
->assertSame('https://example.com/drupal/jsonapi/node/article/07c870e9-491b-4173-8e2b-4e059400af72?amet=pax', $this->linkManager
->getRequestLink($request
->reveal()));
}