public function SchedulerFieldsDisplayTest::testDisabledFields in Scheduler 8
Same name and namespace in other branches
- 2.x tests/src/Functional/SchedulerFieldsDisplayTest.php \Drupal\Tests\scheduler\Functional\SchedulerFieldsDisplayTest::testDisabledFields()
Tests the edit form when scheduler fields have been disabled.
This test covers scheduler_form_node_form_alter().
File
- tests/
src/ Functional/ SchedulerFieldsDisplayTest.php, line 154
Class
- SchedulerFieldsDisplayTest
- Tests the display of date entry fields and form elements.
Namespace
Drupal\Tests\scheduler\FunctionalCode
public function testDisabledFields() {
$this
->drupalLogin($this->adminUser2);
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
// 1. Set the publish_on field to 'hidden' in the node edit form.
$edit = [
'fields[publish_on][region]' => 'hidden',
];
$this
->drupalPostForm('admin/structure/types/manage/' . $this->type . '/form-display', $edit, 'Save');
// Check that a scheduler vertical tab is displayed.
$this
->drupalGet('node/add/' . $this->type);
$assert
->elementExists('xpath', '//div[contains(@class, "form-type-vertical-tabs")]//details[@id = "edit-scheduler-settings"]');
// Check the publish_on field is not shown, but the unpublish_on field is.
$this
->assertSession()
->FieldNotExists('publish_on[0][value][date]');
$this
->assertSession()
->FieldExists('unpublish_on[0][value][date]');
// 2. Set publish_on to be displayed but hide the unpublish_on field.
$edit = [
'fields[publish_on][region]' => 'content',
'fields[unpublish_on][region]' => 'hidden',
];
$this
->drupalPostForm('admin/structure/types/manage/' . $this->type . '/form-display', $edit, 'Save');
// Check that a scheduler vertical tab is displayed.
$this
->drupalGet('node/add/' . $this->type);
$assert
->elementExists('xpath', '//div[contains(@class, "form-type-vertical-tabs")]//details[@id = "edit-scheduler-settings"]');
// Check the publish_on field is not shown, but the unpublish_on field is.
$this
->assertSession()
->FieldExists('publish_on[0][value][date]');
$this
->assertSession()
->FieldNotExists('unpublish_on[0][value][date]');
// 3. Set both fields to be hidden.
$edit = [
'fields[publish_on][region]' => 'hidden',
'fields[unpublish_on][region]' => 'hidden',
];
$this
->drupalPostForm('admin/structure/types/manage/' . $this->type . '/form-display', $edit, 'Save');
// Check that no vertical tab is displayed.
$this
->drupalGet('node/add/' . $this->type);
$assert
->elementNotExists('xpath', '//div[contains(@class, "form-type-vertical-tabs")]//details[@id = "edit-scheduler-settings"]');
// Check the neither field is displayed.
$this
->assertSession()
->FieldNotExists('publish_on[0][value][date]');
$this
->assertSession()
->FieldNotExists('unpublish_on[0][value][date]');
}