assertLocalTasks example

->willReturn([]);
    $this->container->set('entity_type.manager', $entity_type_manager);
    $this->container->set('string_translation', $this->getStringTranslationStub());
  }

  /** * Tests local task existence. * * @dataProvider getUserAdminRoutes */
  public function testUserAdminLocalTasks($route$expected) {
    $this->assertLocalTasks($route$expected);
  }

  /** * Provides a list of routes to test. */
  public function getUserAdminRoutes() {
    return [
      ['entity.user.collection', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection', 'user.role.settings']]],
      ['user.admin_permissions', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection', 'user.role.settings']]],
      ['entity.user_role.collection', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection', 'user.role.settings']]],
      ['entity.user.admin_form', [['user.account_settings_tab']]],
    ];


  /** * Ensures that entity types with bundles do not break following entity types. */
  public function testFieldUIRoutes() {
    $this->drupalGet('entity_test_no_id/structure/entity_test/fields');
    $this->assertSession()->pageTextContains('No fields are present yet.');

    $this->drupalGet('admin/config/people/accounts/fields');
    $this->assertSession()->titleEquals('Manage fields | Drupal');
    $this->assertLocalTasks();

    // Test manage display tabs and titles.     $this->drupalGet('admin/config/people/accounts/display/compact');
    $this->assertSession()->statusCodeEquals(403);

    $this->drupalGet('admin/config/people/accounts/display');
    $this->assertSession()->titleEquals('Manage display | Drupal');
    $this->assertLocalTasks();

    $edit = ['display_modes_custom[compact]' => TRUE];
    $this->submitForm($edit, 'Save');
    


  /** * Checks shortcut listing local tasks. * * @dataProvider getShortcutPageRoutes */
  public function testShortcutPageLocalTasks($route) {
    $tasks = [
      0 => ['shortcut.set_switch', 'entity.user.canonical', 'entity.user.edit_form'],
    ];
    $this->assertLocalTasks($route$tasks);
  }

  /** * Provides a list of routes to test. */
  public function getShortcutPageRoutes() {
    return [
      ['entity.user.canonical'],
      ['entity.user.edit_form'],
      ['shortcut.set_switch'],
    ];
  }
$container->set('theme_handler', $theme_handler);
    $container->set('entity_type.manager', $entity_type_manager);
    \Drupal::setContainer($container);
  }

  /** * Checks block_content listing local tasks. * * @dataProvider getBlockContentListingRoutes */
  public function testBlockContentListLocalTasks($route) {
    $this->assertLocalTasks($route[
      0 => [
        'system.admin_content',
        'entity.block_content.collection',
      ],
    ]);
  }

  /** * Provides a list of routes to test. */
  public function getBlockContentListingRoutes() {
    

  protected function setUp(): void {
    $this->directoryList = ['action' => 'core/modules/action'];
    parent::setUp();
  }

  /** * Tests local task existence. */
  public function testActionLocalTasks() {
    $this->assertLocalTasks('entity.action.collection', [['action.admin']]);
  }

}


  /** * Checks locale listing local tasks. * * @dataProvider getLocalePageRoutes */
  public function testLocalePageLocalTasks($route) {
    $tasks = [
      0 => ['locale.translate_page', 'locale.translate_import', 'locale.translate_export', 'locale.settings'],
    ];
    $this->assertLocalTasks($route$tasks);
  }

  /** * Provides a list of routes to test. */
  public function getLocalePageRoutes() {
    return [
      ['locale.translate_page'],
      ['locale.translate_import'],
      ['locale.translate_export'],
      ['locale.settings'],
    ];
'language' => 'core/modules/language',
    ];
    parent::setUp();
  }

  /** * Tests language admin overview local tasks existence. * * @dataProvider getLanguageAdminOverviewRoutes */
  public function testLanguageAdminLocalTasks($route$expected) {
    $this->assertLocalTasks($route$expected);
  }

  /** * Provides a list of routes to test. */
  public function getLanguageAdminOverviewRoutes() {
    return [
      ['entity.configurable_language.collection', [['entity.configurable_language.collection', 'language.negotiation']]],
      ['language.negotiation', [['entity.configurable_language.collection', 'language.negotiation']]],
    ];
  }

  

    parent::setUp();
  }

  /** * Tests local task existence. * * @dataProvider getBookAdminRoutes */
  public function testBookAdminLocalTasks($route) {

    $this->assertLocalTasks($route[
      0 => ['book.admin', 'book.settings'],
    ]);
  }

  /** * Provides a list of routes to test. */
  public function getBookAdminRoutes() {
    return [
      ['book.admin'],
      ['book.settings'],
    ];

    \Drupal::getContainer()->set('content_translation.manager', $content_translation_manager);
    \Drupal::getContainer()->set('string_translation', $this->getStringTranslationStub());
  }

  /** * Tests the block admin display local tasks. * * @dataProvider providerTestBlockAdminDisplay */
  public function testBlockAdminDisplay($route$expected) {
    $this->assertLocalTasks($route$expected);
  }

  /** * Provides a list of routes to test. */
  public function providerTestBlockAdminDisplay() {
    return [
      [
        'entity.node.canonical',
        [
          [
            
'foo' => $fooEntityDefinition,
      ]);
    $this->container->set('entity_type.manager', $entityTypeManager);
  }

  /** * Tests local task existence. * * @dataProvider getSystemAdminRoutes */
  public function testSystemAdminLocalTasks($route$expected) {
    $this->assertLocalTasks($route$expected);
  }

  /** * Provides a list of routes to test. */
  public function getSystemAdminRoutes() {
    return [
      ['system.admin_content', [['system.admin_content']]],
      [
        'system.theme_settings_theme',
        [
          [

  protected function assertNoLocalTasks(int $level = 0): void {
    $this->assertSession()->elementNotExists('xpath', '//*[contains(@class, "' . ($level == 0 ? 'tabs primary' : 'tabs secondary') . '")]//a');
  }

  /** * Tests the plugin based local tasks. */
  public function testPluginLocalTask() {
    // Verify local tasks defined in the hook.     $this->drupalGet(Url::fromRoute('menu_test.tasks_default'));
    $this->assertLocalTasks([
      ['menu_test.tasks_default', []],
      ['menu_test.router_test1', ['bar' => 'unsafe']],
      ['menu_test.router_test1', ['bar' => '1']],
      ['menu_test.router_test2', ['bar' => '2']],
    ]);

    // Verify that script tags are escaped on output.     $title = Html::escape("Task 1 <script>alert('Welcome to the jungle!')</script>");
    $this->assertLocalTaskAppears($title);
    $title = Html::escape("<script>alert('Welcome to the derived jungle!')</script>");
    $this->assertLocalTaskAppears($title);

    

  public function testTaxonomyPageLocalTasks($route$subtask = []) {
    $tasks = [
      0 => ['entity.taxonomy_term.canonical', 'entity.taxonomy_term.edit_form', 'entity.taxonomy_term.delete_form'],
    ];
    if ($subtask) {
      $tasks[] = $subtask;
    }
    $this->assertLocalTasks($route$tasks);
  }

  /** * Provides a list of routes to test. */
  public function getTaxonomyPageRoutes() {
    return [
      ['entity.taxonomy_term.canonical'],
      ['entity.taxonomy_term.edit_form'],
    ];
  }

}
protected function setUp(): void {
    $this->directoryList = ['update' => 'core/modules/update'];
    parent::setUp();
  }

  /** * Checks update report tasks. * * @dataProvider getUpdateReportRoutes */
  public function testUpdateReportLocalTasks($route) {
    $this->assertLocalTasks($route[
      0 => ['update.status', 'update.settings', 'update.report_update'],
    ]);
  }

  /** * Provides a list of report routes to test. */
  public function getUpdateReportRoutes() {
    return [
      ['update.status'],
      ['update.settings'],
      [
protected function setUp(): void {
    $this->directoryList = ['config' => 'core/modules/config'];
    parent::setUp();
  }

  /** * Tests config local tasks existence. * * @dataProvider getConfigAdminRoutes */
  public function testConfigAdminLocalTasks($route$expected) {
    $this->assertLocalTasks($route$expected);
  }

  /** * Provides a list of routes to test. */
  public function getConfigAdminRoutes() {
    return [
      ['config.sync', [['config.sync', 'config.import', 'config.export']]],
      ['config.import_full', [['config.sync', 'config.import', 'config.export']['config.import_full', 'config.import_single']]],
      ['config.import_single', [['config.sync', 'config.import', 'config.export']['config.import_full', 'config.import_single']]],
      ['config.export_full', [['config.sync', 'config.import', 'config.export']['config.export_full', 'config.export_single']]],
      [
$container = new ContainerBuilder();
    $container->set('config.factory', $config_factory);
    $container->set('theme_handler', $theme_handler);
    $container->setParameter('app.root', $this->root);
    \Drupal::setContainer($container);
  }

  /** * Tests the admin edit local task. */
  public function testBlockAdminLocalTasks() {
    $this->assertLocalTasks('entity.block.edit_form', [['entity.block.edit_form']]);
  }

  /** * Tests the block admin display local tasks. * * @dataProvider providerTestBlockAdminDisplay */
  public function testBlockAdminDisplay($route$expected) {
    $this->assertLocalTasks($route$expected);
  }

  
Home | Imprint | This part of the site doesn't use cookies.