public function SchedulerHooksLegacyTest::testHideField in Scheduler 2.x
Test the hooks which allow hiding of scheduler input fields.
This covers hook_scheduler_hide_publish_on_field and hook_scheduler_hide_unpublish_on_field.
File
- tests/
src/ Functional/ SchedulerHooksLegacyTest.php, line 329
Class
- SchedulerHooksLegacyTest
- Tests the legacy API hook functions of the Scheduler module.
Namespace
Drupal\Tests\scheduler\FunctionalCode
public function testHideField() {
$this
->drupalLogin($this->schedulerUser);
// Create test nodes.
$node1 = $this
->drupalCreateNode([
'type' => $this->type,
'title' => 'Red Legacy will not have either field hidden',
]);
$node2 = $this
->drupalCreateNode([
'type' => $this->type,
'title' => 'Orange Legacy will have the publish-on field hidden',
]);
$node3 = $this
->drupalCreateNode([
'type' => $this->type,
'title' => 'Yellow Legacy will have the unpublish-on field hidden',
]);
$node4 = $this
->drupalCreateNode([
'type' => $this->type,
'title' => 'Green Legacy will have both Scheduler fields hidden',
]);
// Set the scheduler fieldset to always expand, for ease during development.
$this->nodetype
->setThirdPartySetting('scheduler', 'expand_fieldset', 'always')
->save();
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
// Node 1 'red' should have both fields displayed.
$this
->drupalGet('node/' . $node1
->id() . '/edit');
$assert
->ElementExists('xpath', '//input[@id = "edit-publish-on-0-value-date"]');
$assert
->ElementExists('xpath', '//input[@id = "edit-unpublish-on-0-value-date"]');
// Node 2 'orange' should have only the publish-on field hidden.
$this
->drupalGet('node/' . $node2
->id() . '/edit');
$assert
->ElementNotExists('xpath', '//input[@id = "edit-publish-on-0-value-date"]');
$assert
->ElementExists('xpath', '//input[@id = "edit-unpublish-on-0-value-date"]');
// Node 3 'yellow' should have only the unpublish-on field hidden.
$this
->drupalGet('node/' . $node3
->id() . '/edit');
$assert
->ElementExists('xpath', '//input[@id = "edit-publish-on-0-value-date"]');
$assert
->ElementNotExists('xpath', '//input[@id = "edit-unpublish-on-0-value-date"]');
// Node 4 'green' should have both publish-on and unpublish-on hidden.
$this
->drupalGet('node/' . $node4
->id() . '/edit');
$assert
->ElementNotExists('xpath', '//input[@id = "edit-publish-on-0-value-date"]');
$assert
->ElementNotExists('xpath', '//input[@id = "edit-unpublish-on-0-value-date"]');
}