ViewsFormAlterTest.php

Same filename and directory in other branches
  1. 9 core/modules/views/tests/src/Functional/ViewsFormAlterTest.php
  2. 11.x core/modules/views/tests/src/Functional/ViewsFormAlterTest.php

Namespace

Drupal\Tests\views\Functional

File

core/modules/views/tests/src/Functional/ViewsFormAlterTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\views\Functional;


/**
 * Tests hook_form_BASE_FORM_ID_alter for a ViewsForm.
 *
 * @group views
 */
class ViewsFormAlterTest extends ViewTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'views_form_test',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  
  /**
   * Tests hook_form_BASE_FORM_ID_alter for a ViewsForm.
   */
  public function testViewsFormAlter() : void {
    $this->drupalLogin($this->createUser([
      'access media overview',
    ]));
    $this->drupalGet('admin/content/media');
    $count = $this->container
      ->get('state')
      ->get('hook_form_BASE_FORM_ID_alter_count');
    $this->assertEquals(1, $count, 'hook_form_BASE_FORM_ID_alter was invoked only once');
  }

}

Classes

Title Deprecated Summary
ViewsFormAlterTest Tests hook_form_BASE_FORM_ID_alter for a ViewsForm.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.