RequestFormatRouteFilter example

/** * @coversDefaultClass \Drupal\Core\Routing\RequestFormatRouteFilter * @group Routing */
class RequestFormatRouteFilterTest extends UnitTestCase {

  /** * @covers ::filter * @dataProvider filterProvider */
  public function testFilter(RouteCollection $collection$request_format, array $expected_filtered_collection) {
    $route_filter = new RequestFormatRouteFilter();

    $request = new Request();
    $request->setRequestFormat($request_format);
    $collection = $route_filter->filter($collection$request);

    $this->assertSameSize($expected_filtered_collection$collection);
    $this->assertSame($expected_filtered_collectionarray_keys($collection->all()));
  }

  public function filterProvider() {
    $route_without_format = new Route('/test');
    
Home | Imprint | This part of the site doesn't use cookies.