class ViewsFormAlterTest

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/src/Functional/ViewsFormAlterTest.php \Drupal\Tests\views\Functional\ViewsFormAlterTest
  2. 10 core/modules/views/tests/src/Functional/ViewsFormAlterTest.php \Drupal\Tests\views\Functional\ViewsFormAlterTest

Tests hook_form_BASE_FORM_ID_alter for a ViewsForm.

@group views

Hierarchy

Expanded class hierarchy of ViewsFormAlterTest

File

core/modules/views/tests/src/Functional/ViewsFormAlterTest.php, line 10

Namespace

Drupal\Tests\views\Functional
View source
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() {
    $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');
  }

}

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