You are here

public function FormatSpecificGetBcRouteTestTrait::testFormatSpecificGetBcRoute in Drupal 8

@group legacy

See also

\Drupal\rest\RouteProcessor\RestResourceGetRouteProcessorBC

File

core/modules/rest/tests/src/Functional/EntityResource/FormatSpecificGetBcRouteTestTrait.php, line 20

Class

FormatSpecificGetBcRouteTestTrait
Provides test methods to assert BC on format-specific GET routes.

Namespace

Drupal\Tests\rest\Functional\EntityResource

Code

public function testFormatSpecificGetBcRoute() {
  $this
    ->provisionEntityResource();
  $url = $this
    ->getEntityResourceUrl();

  // BC: Format-specific GET routes are deprecated. They are available on both
  // new and old sites, but trigger deprecation notices.
  $bc_route = Url::fromRoute('rest.entity.' . static::$entityTypeId . '.GET.' . static::$format, $url
    ->getRouteParameters(), $url
    ->getOptions());
  $bc_route
    ->setUrlGenerator($this->container
    ->get('url_generator'));
  $this
    ->addExpectedDeprecationMessage(sprintf("The 'rest.entity.entity_test.GET.%s' route is deprecated since version 8.5.x and will be removed in 9.0.0. Use the 'rest.entity.entity_test.GET' route instead.", static::$format));
  $this
    ->assertSame($url
    ->toString(TRUE)
    ->getGeneratedUrl(), $bc_route
    ->toString(TRUE)
    ->getGeneratedUrl());
}