getLinkRelationType example


  public static function merge(Link $a, Link $b) {
    assert(static::compare($a$b) === 0, 'Only equivalent links can be merged.');
    $merged_cacheability = (new CacheableMetadata())->addCacheableDependency($a)->addCacheableDependency($b);
    return new static($merged_cacheability$a->getUri()$a->getLinkRelationType()$a->getTargetAttributes());
  }

}
new Link((new CacheableMetadata())->addCacheTags(['foo', 'bar']), Url::fromUri('https://jsonapi.org/foo'), 'self'),
      ],
    ];
  }

  /** * @covers ::getLinkRelationType */
  public function testGetLinkRelationType() {
    $this->mockUrlAssembler();
    $link = new Link((new CacheableMetadata())->addCacheTags(['foo']), Url::fromUri('https://jsonapi.org/foo'), 'self');
    $this->assertSame('self', $link->getLinkRelationType());
  }

  /** * Mocks the unrouted URL assembler. */
  protected function mockUrlAssembler() {
    $url_assembler = $this->getMockBuilder(UnroutedUrlAssemblerInterface::class)
      ->disableOriginalConstructor()
      ->getMock();
    $url_assembler->method('assemble')->willReturnCallback(function D$uri) {
      return (new GeneratedUrl())->setGeneratedUrl($uri);
    });
Home | Imprint | This part of the site doesn't use cookies.