1 views_handler_field_bulk_form.test public ViewsHandlerFieldBulkFormTest::testNodeAndUserBulkForm()

Test Bulk Forms for user entities joined to nodes by uid.

User entities are accessed through a relationship to node entities.

File

core/modules/views/tests/handlers/views_handler_field_bulk_form.test, line 165
Definition of ViewsHandlerFieldBulkFormTest.

Class

ViewsHandlerFieldBulkFormTest

Code

public function testNodeAndUserBulkForm() {
  // Add a relationship field to author (user).
  $this->view->add_item('default', 'relationship', 'node', 'uid', array(
    'id' => 'uid',
    'table' => 'node',
    'field' => 'uid',
    'relationship' => 'none',
    'label' => 'author',
  ));

  // Add the field uid from the user entity.
  $this->view->add_item('default', 'field', 'users', 'uid', array(
    'id' => 'uid',
    'table' => 'users',
    'field' => 'uid',
    'relationship' => 'uid',
  ));

  // Add the bulk_form field from the user entity.
  $this->view->add_item('default', 'field', 'users', 'bulk_form', array(
    'id' => 'bulk_form',
    'table' => 'users',
    'field' => 'bulk_form',
    'relationship' => 'uid',
  ));

  $this->view->save();
  $this->backdropGet('test-bulk-form');

  // Verify that the view contains bulk form checkboxes with values that match
  // the ids of the correct entity (in this case, uid).
  $this->assertCorrectBulkFormEntityIds('uid', 'user');

  // Verify that the available actions belong to the user entity by checking
  // that the checkbox for user_block_user_action exists in the form.
  $this->backdropGet('admin/structure/views/nojs/config-item/test_bulk_form/page_1/field/bulk_form');
  $this->assertFieldByName('options[selected_actions][user_block_user_action]', 'user_block_user_action', 'Found a checkbox for user_block_user_action in the Bulk configuration form.');
}