You are here

public function PathPluginBaseTest::testCollectRoutesWithArgumentsNotSpecifiedInPath in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest::testCollectRoutesWithArgumentsNotSpecifiedInPath()
  2. 9 core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest::testCollectRoutesWithArgumentsNotSpecifiedInPath()

Tests the collectRoutes method with arguments not specified in the path.

See also

\Drupal\views\Plugin\views\display\PathPluginBase::collectRoutes()

File

core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php, line 174
Contains \Drupal\Tests\views\Unit\Plugin\display\PathPluginBaseTest.

Class

PathPluginBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\display\PathPluginBase @group views

Namespace

Drupal\Tests\views\Unit\Plugin\display

Code

public function testCollectRoutesWithArgumentsNotSpecifiedInPath() {
  [
    $view,
  ] = $this
    ->setupViewExecutableAccessPlugin();
  $display = [];
  $display['display_plugin'] = 'page';
  $display['id'] = 'page_1';
  $display['display_options'] = [
    'path' => 'test_with_arguments',
  ];
  $display['display_options']['arguments'] = [
    'test_id' => [],
  ];
  $this->pathPlugin
    ->initDisplay($view, $display);
  $collection = new RouteCollection();
  $result = $this->pathPlugin
    ->collectRoutes($collection);
  $this
    ->assertEquals([
    'test_id.page_1' => 'view.test_id.page_1',
  ], $result);
  $route = $collection
    ->get('view.test_id.page_1');
  $this
    ->assertInstanceOf(Route::class, $route);
  $this
    ->assertEquals('test_id', $route
    ->getDefault('view_id'));
  $this
    ->assertEquals('page_1', $route
    ->getDefault('display_id'));
  $this
    ->assertEquals([
    'arg_0' => 'arg_0',
  ], $route
    ->getOption('_view_argument_map'));
  $this
    ->assertEquals('Drupal\\views\\Routing\\ViewPageController::getTitle', $route
    ->getDefault('_title_callback'));
}