public function ViewEditTest::testOtherOptions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views_ui/src/Tests/ViewEditTest.php \Drupal\views_ui\Tests\ViewEditTest::testOtherOptions()
Tests the machine name and administrative comment forms.
File
- core/
modules/ views_ui/ src/ Tests/ ViewEditTest.php, line 49 - Contains \Drupal\views_ui\Tests\ViewEditTest.
Class
- ViewEditTest
- Tests some general functionality of editing views, like deleting a view.
Namespace
Drupal\views_ui\TestsCode
public function testOtherOptions() {
$this
->drupalGet('admin/structure/views/view/test_view');
// Add a new attachment display.
$this
->drupalPostForm(NULL, array(), 'Add Attachment');
// Test that a long administrative comment is truncated.
$edit = array(
'display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen',
);
$this
->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_comment', $edit, 'Apply');
$this
->assertText('one two three four five six seven eight nine ten eleven twelve thirteen fourteen...');
// Change the machine name for the display from page_1 to test_1.
$edit = array(
'display_id' => 'test_1',
);
$this
->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_id', $edit, 'Apply');
$this
->assertLink(t('test_1'));
// Save the view, and test the new ID has been saved.
$this
->drupalPostForm(NULL, array(), 'Save');
$view = \Drupal::entityManager()
->getStorage('view')
->load('test_view');
$displays = $view
->get('display');
$this
->assertTrue(!empty($displays['test_1']), 'Display data found for new display ID key.');
$this
->assertIdentical($displays['test_1']['id'], 'test_1', 'New display ID matches the display ID key.');
$this
->assertFalse(array_key_exists('attachment_1', $displays), 'Old display ID not found.');
// Test the form validation with invalid IDs.
$machine_name_edit_url = 'admin/structure/views/nojs/display/test_view/test_1/display_id';
$error_text = t('Display name must be letters, numbers, or underscores only.');
// Test that potential invalid display ID requests are detected
$this
->drupalGet('admin/structure/views/ajax/handler/test_view/fake_display_name/filter/title');
$this
->assertText('Invalid display id fake_display_name');
$edit = array(
'display_id' => 'test 1',
);
$this
->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this
->assertText($error_text);
$edit = array(
'display_id' => 'test_1#',
);
$this
->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this
->assertText($error_text);
// Test using an existing display ID.
$edit = array(
'display_id' => 'default',
);
$this
->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this
->assertText(t('Display id should be unique.'));
// Test that the display ID has not been changed.
$this
->drupalGet('admin/structure/views/view/test_view/edit/test_1');
$this
->assertLink(t('test_1'));
}