Issue #1434670 by AlPotapov, bleen18 | ericduran: Add test for verticle_tabs default.
parent
8b246745f8
commit
6fa0c8885e
|
@ -58,4 +58,12 @@ class ElementsVerticalTabsTest extends WebTestBase {
|
||||||
$wrapper = $this->xpath("//div[@data-vertical-tabs-panes]");
|
$wrapper = $this->xpath("//div[@data-vertical-tabs-panes]");
|
||||||
$this->assertFalse(isset($wrapper[0]), 'Vertical tab wrappers are not displayed to unprivileged users.');
|
$this->assertFalse(isset($wrapper[0]), 'Vertical tab wrappers are not displayed to unprivileged users.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures that default vertical tab is correctly selected.
|
||||||
|
*/
|
||||||
|
function testDefaultTab() {
|
||||||
|
$this->drupalGet('form_test/vertical-tabs');
|
||||||
|
$this->assertFieldByName('vertical_tabs__active_tab', 'edit-tab3', t('The default vertical tab is correctly selected.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,29 +23,26 @@ class FormTestVerticalTabsForm extends FormBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||||
|
$tab_count = 3;
|
||||||
|
|
||||||
$form['vertical_tabs'] = array(
|
$form['vertical_tabs'] = array(
|
||||||
'#type' => 'vertical_tabs',
|
'#type' => 'vertical_tabs',
|
||||||
|
'#default_tab' => 'edit-tab' . $tab_count,
|
||||||
);
|
);
|
||||||
$form['tab1'] = array(
|
|
||||||
'#type' => 'details',
|
for ($i = 1; $i <= $tab_count; $i++) {
|
||||||
'#title' => t('Tab 1'),
|
$form['tab' . $i] = array(
|
||||||
'#group' => 'vertical_tabs',
|
'#type' => 'fieldset',
|
||||||
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
|
'#title' => t('Tab !num', array('!num' => $i)),
|
||||||
);
|
'#group' => 'vertical_tabs',
|
||||||
$form['tab1']['field1'] = array(
|
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
|
||||||
'#title' => t('Field 1'),
|
);
|
||||||
'#type' => 'textfield',
|
$form['tab' . $i]['field' . $i] = array(
|
||||||
);
|
'#title' => t('Field !num', array('!num' => $i)),
|
||||||
$form['tab2'] = array(
|
'#type' => 'textfield',
|
||||||
'#type' => 'details',
|
|
||||||
'#title' => t('Tab 2'),
|
);
|
||||||
'#group' => 'vertical_tabs',
|
}
|
||||||
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
|
|
||||||
);
|
|
||||||
$form['tab2']['field2'] = array(
|
|
||||||
'#title' => t('Field 2'),
|
|
||||||
'#type' => 'textfield',
|
|
||||||
);
|
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue