Commit 78ab9dc9 authored by Jonathan Smith's avatar Jonathan Smith Committed by Jonathan Smith
Browse files

Issue #3260070 by jonathan1055: Improve PastDates with method_exists check....

Issue #3260070 by jonathan1055: Improve PastDates with method_exists check. Update Travis deprecations.
parent 353410ff
Loading
Loading
Loading
Loading
+11 −11
Changes for .travis.yml: 11 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -31,26 +31,26 @@ jobs:
        - DRUPAL_CORE=9.2.x
        - MEDIA=YES
        - RULES=YES
        # ---- Remaining self deprecation notices (1794)
        # 1774 EventDispatcher with string event (Rules and Commerce)
        #   11 Creating an instance of class ... getConnection()->condition()
        #    7 Symfony\Component\EventDispatcher\Event is deprecated (Rules)
        # ---- Remaining self deprecation notices (1208)
        #  801 Symfony KernelEvent::isMasterRequest()
        #  240 hook_field_widget_form_alter (Commerce)
        #  165 EventDispatcher with string event (Rules and Commerce)
        #    2 Kernel $modules property must be declared protected
        # ---- Remaining direct deprecation notices (0)
        - DEPRECATIONS=3000
        - DEPRECATIONS=1208
    - php: 7.4
      env:
        - DRUPAL_CORE=9.3.x
        # Just run Node and Product.
        # Just run Node and Product tests.
        - NODE=YES
        - PRODUCT=YES
        # ---- Remaining self deprecation notices (2455)
        # 1174 Symfony isMasterRequest() is deprecated, use isMainRequest()
        #  927 EventDispatcher with string event (Rules and Commerce)
        #  352 hook_field_widget_form_alter() in Commerce_product setup.
        # ---- Remaining self deprecation notices (1078)
        #  746 Symfony KernelEvent::isMasterRequest()
        #  204 hook_field_widget_form_alter (Commerce)
        #  126 EventDispatcher with string event (Rules and Commerce)
        #    2 Kernel $modules property must be declared protected
        # ---- Remaining direct deprecation notices (0)
        - DEPRECATIONS=2455
        - DEPRECATIONS=1078

# Be sure to cache composer downloads.
cache:
+2 −2
Changes for tests/src/Functional/SchedulerEntityAccessTest.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -89,8 +89,8 @@ class SchedulerEntityAccessTest extends SchedulerBrowserTestBase {
   *   Each row has values: [entity type id, bundle id, field name, status].
   */
  public function dataEntityAccess() {
    // This test is only applicable to node entity types because media and
    // products do not have a hook access grant system.
    // This test is only applicable to node entity types because the other
    // entity types do not have a hook access grant system.
    // @todo Investigate how scheduler_access_test module can be expanded to
    // deny access to other entity types using a different method.
    $data = [
+11 −5
Changes for tests/src/Functional/SchedulerPastDatesTest.php: 11 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -32,7 +32,11 @@ class SchedulerPastDatesTest extends SchedulerBrowserTestBase {

    // Create an unpublished entity.
    $entity = $this->createEntity($entityTypeId, $bundle, ['status' => FALSE]);
    // Some entities do not have a 'created' date and if that is the case we
    // skip the specific parts of this test that relate to this.
    if ($check_created_time = method_exists($entity, 'getCreatedTime')) {
      $created_time = $entity->getCreatedTime();
    }

    // Test the default behavior: an error message should be shown when the user
    // enters a publication date that is in the past.
@@ -64,13 +68,13 @@ class SchedulerPastDatesTest extends SchedulerBrowserTestBase {
    $this->assertTrue($entity->isPublished(), 'The entity has been published immediately when the publication date is in the past and the "publish" behavior is chosen.');
    $this->assertNull($entity->publish_on->value, 'The entity publish_on date has been removed after publishing when the "publish" behavior is chosen.');
    $this->assertEquals($entity->getChangedTime(), strtotime('-1 day', $this->requestTime), 'The changed time of the entity has been updated to the publish_on time when published immediately.');
    $this->assertEquals($entity->getCreatedTime(), $created_time, 'The created time of the entity has not been changed when the "publish" behavior is chosen.');
    $check_created_time ? $this->assertEquals($entity->getCreatedTime(), $created_time, 'The created time of the entity has not been changed when the "publish" behavior is chosen.') : NULL;

    // Test the 'schedule' behavior: the entity should be unpublished and become
    // published on the next cron run. Use a new unpublished entity.
    $entityType->setThirdPartySetting('scheduler', 'publish_past_date', 'schedule')->save();
    $entity = $this->createEntity($entityTypeId, $bundle, ['status' => FALSE]);
    $created_time = $entity->getCreatedTime();
    $check_created_time ? $created_time = $entity->getCreatedTime() : NULL;

    // Edit, save and check that no error is shown when the publish_on date is
    // in the past.
@@ -94,9 +98,11 @@ class SchedulerPastDatesTest extends SchedulerBrowserTestBase {
    $entity = $storage->load($entity->id());
    $this->assertTrue($entity->isPublished(), 'The entity with publication date in the past and the "schedule" behavior has now been published by cron.');
    $this->assertEquals($entity->getChangedTime(), strtotime('-1 day', $this->requestTime), 'The changed time of the entity has been updated to the publish_on time when published via cron.');
    $this->assertEquals($entity->getCreatedTime(), $created_time, 'The created time of the entity has not been changed when the "schedule" behavior is chosen.');
    $check_created_time ? $this->assertEquals($entity->getCreatedTime(), $created_time, 'The created time of the entity has not been changed when the "schedule" behavior is chosen.') : NULL;

    // Test the option to alter the creation time if the publishing time is
    // earlier than the entity created time.
    if ($check_created_time) {
      $entityType->setThirdPartySetting('scheduler', 'publish_past_date_created', TRUE)->save();
      $past_date_options = [
        'publish' => 'publish',
@@ -118,9 +124,9 @@ class SchedulerPastDatesTest extends SchedulerBrowserTestBase {
        $storage->resetCache([$entity->id()]);
        $entity = $storage->load($entity->id());

      // Check that the created time has been altered to match publishing time.
        // Check that the created time is altered to match publishing time.
        $this->assertEquals($entity->getCreatedTime(), strtotime('-1 day', $this->requestTime), sprintf('The created time of the entity has not been changed when the %s option is chosen.', $option));

      }
    }

    // Check that an Unpublish date in the past fails validation.