1 views_handler_field_bulk_form.test | public ViewsHandlerFieldBulkFormTest::testNodeAndCustomEntityBulkForm() |
Test Bulk Forms for a custom entity joined to nodes by nid.
The custom entities are accessed through a relationship to node entities. Importantly, the 'real field' for the custom entity's Bulk Form is not nid, but rather 'id'. This tests verifies that the Bulk Form checkboxes match the 'id' value, rather than the 'nid', so that the bulk operation is performed on the correct custom entity.
File
- core/
modules/ views/ tests/ handlers/ views_handler_field_bulk_form.test, line 213 - Definition of ViewsHandlerFieldBulkFormTest.
Class
Code
public function testNodeAndCustomEntityBulkForm() {
// Enable the test module that defines the views_test entity.
module_enable(array('views_test_entity'));
// Add a relationship field to views_test entity.
$this->view->add_item('default', 'relationship', 'node', 'views_test', array(
'id' => 'uid',
'table' => 'node',
'field' => 'views_test',
'relationship' => 'none',
'label' => 'views_test',
));
// Add the field id from the views_test entity.
$this->view->add_item('default', 'field', 'views_test', 'id', array(
'id' => 'id',
'table' => 'views_test',
'field' => 'id',
'relationship' => 'views_test',
));
// Add the bulk_form field from the views_test entity.
$this->view->add_item('default', 'field', 'views_test', 'bulk_form', array(
'id' => 'bulk_form',
'table' => 'views_test',
'field' => 'bulk_form',
'relationship' => 'views_test',
));
$this->view->save();
$this->backdropGet('test-bulk-form');
// Verify that the view contains bulk form checkboxes with values that match
// the ids of the views_test entities.
$this->assertCorrectBulkFormEntityIds('id', 'views_test');
}