Commit 09c1f350 authored by Jonathan Smith's avatar Jonathan Smith Committed by Jonathan Smith
Browse files

Issue #3150881 by jonathan1055: Remove allownace for testing at 8.3. See...

Issue #3150881 by jonathan1055: Remove allownace for testing at 8.3. See https://www.drupal.org/node/2873108
parent 17e747d9
Loading
Loading
Loading
Loading
+4 −17
Changes for tests/src/Functional/SchedulerPermissionsTest.php: 4 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -30,13 +30,6 @@ class SchedulerPermissionsTest extends SchedulerBrowserTestBase {
    $this->assertSession()->fieldNotExists('publish_on[0][value][date]');
    $this->assertSession()->fieldNotExists('unpublish_on[0][value][date]');

    // At core 8.4 an enhancement will be committed to change the 'save and ...'
    // button into a 'save' with a corresponding status checkbox. This test has
    // to pass at 8.3 but the core change will not be backported. Hence derive
    // the button text and whether we need a 'status'field.
    // @see https://www.drupal.org/node/2873108
    $checkbox = $this->xpath('//input[@type="checkbox" and @id="edit-status-value"]');

    // Initially run tests when publishing and unpublishing are not required.
    $this->nodetype->setThirdPartySetting('scheduler', 'publish_required', FALSE)
      ->setThirdPartySetting('scheduler', 'unpublish_required', FALSE)
@@ -44,21 +37,15 @@ class SchedulerPermissionsTest extends SchedulerBrowserTestBase {

    // Check that a new node can be saved and published.
    $title = $this->randomString(15);
    $edit = ['title[0][value]' => $title];
    if ($checkbox) {
      $edit['status[value]'] = TRUE;
    }
    $this->drupalPostForm('node/add/' . $this->type, $edit, $checkbox ? 'Save' : 'Save and publish');
    $edit = ['title[0][value]' => $title, 'status[value]' => TRUE];
    $this->drupalPostForm('node/add/' . $this->type, $edit, 'Save');
    $this->assertSession()->pageTextContains(sprintf('%s %s has been created.', $this->typeName, $title));
    $this->assertTrue($this->drupalGetNodeByTitle($title)->isPublished(), 'The new node is published');

    // Check that a new node can be saved as unpublished.
    $title = $this->randomString(15);
    $edit = ['title[0][value]' => $title];
    if ($checkbox) {
      $edit['status[value]'] = FALSE;
    }
    $this->drupalPostForm('node/add/' . $this->type, $edit, $checkbox ? 'Save' : 'Save as unpublished');
    $edit = ['title[0][value]' => $title, 'status[value]' => FALSE];
    $this->drupalPostForm('node/add/' . $this->type, $edit, 'Save');
    $this->assertSession()->pageTextContains(sprintf('%s %s has been created.', $this->typeName, $title));
    $this->assertFalse($this->drupalGetNodeByTitle($title)->isPublished(), 'The new node is unpublished');

+3 −15
Changes for tests/src/Functional/SchedulerValidationTest.php: 3 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -33,14 +33,7 @@ class SchedulerValidationTest extends SchedulerBrowserTestBase {
    ];
    $this->drupalGet('node/' . $node->id() . '/edit');

    // At core 8.4 an enhancement will be committed to change the 'save and ...'
    // button into a 'save' with a corresponding status checkbox. This test has
    // to pass at 8.3 but the core change will not be backported. Hence derive
    // the button text and whether we need a 'status'field.
    // @see https://www.drupal.org/node/2873108
    $checkbox = $this->xpath('//input[@type="checkbox" and @id="edit-status-value"]');

    $this->submitForm($edit, $checkbox ? 'Save' : 'Save and keep unpublished');
    $this->submitForm($edit, 'Save');
    // Check that validation prevents entering a publish-on date with no
    // unpublish-on date if unpublishing is required.
    $this->assertSession()->pageTextContains("If you set a 'publish on' date then you must also set an 'unpublish on' date.");
@@ -52,13 +45,8 @@ class SchedulerValidationTest extends SchedulerBrowserTestBase {
      'type' => $this->type,
      'status' => FALSE,
    ]);
    if ($checkbox) {
    $edit = ['status[value]' => TRUE];
    }
    else {
      $edit = [];
    }
    $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, $checkbox ? 'Save' : 'Save and publish');
    $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save');
    // Check that validation prevents publishing the node directly without an
    // unpublish-on date if unpublishing is required.
    $this->assertSession()->pageTextContains("Either you must set an 'unpublish on' date or save this node as unpublished.");
@@ -76,7 +64,7 @@ class SchedulerValidationTest extends SchedulerBrowserTestBase {
      'unpublish_on[0][value][date]' => $this->dateFormatter->format($this->requestTime + 1800, 'custom', 'Y-m-d'),
      'unpublish_on[0][value][time]' => $this->dateFormatter->format($this->requestTime + 1800, 'custom', 'H:i:s'),
    ];
    $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, $checkbox ? 'Save' : 'Save and keep unpublished');
    $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save');
    // Check that validation prevents entering an unpublish-on date which is
    // earlier than the publish-on date.
    $this->assertSession()->pageTextContains("The 'unpublish on' date must be later than the 'publish on' date.");