Verified Commit 4a64d35c authored by Jibran Ijaz's avatar Jibran Ijaz Committed by Jibran Ijaz
Browse files

Issue #2283919 by jibran: Fixed failing HEAD for Drupal 10.

parent 72d33512
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -6,16 +6,22 @@ workflows:
      - test:
          matrix:
            parameters:
              php: ["8.0"]
              php: ["8.0", "8.1"]
              drupal-version: ["9.3.x", "9.4.x", "10.0.x"]
            exclude:
            - php: "8.0"
              drupal-version: "10.0.x"
  # Run nightly tests every day 8 AM.
  nightly:
    jobs:
    - test:
        matrix:
          parameters:
            php: ["8.0"]
            php: ["8.0", "8.1"]
            drupal-version: ["9.3.x", "9.4.x", "10.0.x"]
          exclude:
          - php: "8.0"
            drupal-version: "10.0.x"
    triggers:
    - schedule:
        # Weekday (22=10pm UTC). Evaluates to 8am AEST.
@@ -23,8 +29,8 @@ workflows:
        filters:
          branches:
            only:
            - 8.x-1.x
            - 8.x-2.x
            - 3.x
            - 4.x

jobs:
  test:
@@ -67,6 +73,12 @@ jobs:
        command: |
          composer install --prefer-dist --no-progress
          composer require --dev "phpstan/phpstan-deprecation-rules:^1.0"
    - when:
        name: Fetch drupal 10 dependencies, dev dependencies, and module test dependencies
        condition:
          equal: [ "10.0.x", << parameters.drupal-version >> ]
        steps:
          - run: composer require 'drupal/hal-hal:^1.0'

    - checkout:
        path: modules/${MODULE_NAME}
+44 −11
Original line number Diff line number Diff line
@@ -101,12 +101,18 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {
    // Test a valid reference.
    $referenced_entity = $entity_type_manager
      ->getStorage($this->referencedEntityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $referenced_entity->save();

    $entity = $entity_type_manager
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $entity->{$this->fieldName}->target_type = $referenced_entity->getEntityTypeId();
    $entity->{$this->fieldName}->target_id = $referenced_entity->id();
    $violations = $entity->{$this->fieldName}->validate();
@@ -114,7 +120,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {

    $entity = $entity_type_manager
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $entity->{$this->fieldName}->entity = $referenced_entity;
    $violations = $entity->{$this->fieldName}->validate();
    $this->assertEquals($violations->count(), 0, 'Validation passes.');
@@ -122,7 +131,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {
    // Test an invalid reference.
    $entity = $entity_type_manager
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $entity->{$this->fieldName}->target_type = $referenced_entity->getEntityTypeId();
    $entity->{$this->fieldName}->target_id = 9999;
    $violations = $entity->{$this->fieldName}->validate();
@@ -135,7 +147,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {
    // Test an invalid target_type.
    $entity = $entity_type_manager
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $entity->{$this->fieldName}->target_type = $entity->getEntityTypeId();
    $entity->{$this->fieldName}->target_id = $referenced_entity->id();
    $violations = $entity->{$this->fieldName}->validate();
@@ -145,7 +160,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {
    // Test an invalid entity.
    $entity = $entity_type_manager
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $entity->{$this->fieldName}->entity = $entity;
    $violations = $entity->{$this->fieldName}->validate();
    $this->assertEquals($violations->count(), 1, 'Validation throws a violation.');
@@ -168,7 +186,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {

    $entity = $entity_type_manager
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $entity->{$this->fieldName}->target_type = $referenced_entity->getEntityTypeId();
    $entity->{$this->fieldName}->target_id = $referenced_entity->id();
    $violations = $entity->{$this->fieldName}->validate();
@@ -197,7 +218,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {

    $entity = $entity_type_manager
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $entity->{$this->fieldName}->target_type = $referenced_entity->getEntityTypeId();
    $entity->{$this->fieldName}->target_id = $referenced_entity->id();
    $violations = $entity->{$this->fieldName}->validate();
@@ -219,7 +243,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {
    // Create the parent entity.
    $entity = $entity_type_manager
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);

    // Create three target entities and attach them to parent field.
    $target_entities = [];
@@ -227,7 +254,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {
    for ($i = 0; $i < 3; $i++) {
      $target_entity = $entity_type_manager
        ->getStorage($this->referencedEntityType)
        ->create(['type' => $this->bundle]);
        ->create([
          'name' => $this->randomMachineName(),
          'type' => $this->bundle,
        ]);
      $target_entity->save();
      $target_entities[] = $target_entity;
      $reference_field[] = [
@@ -263,7 +293,10 @@ class DynamicEntityReferenceFieldTest extends EntityKernelTestBase {
    // "autocreate" feature.
    $target_entity_unsaved = $entity_type_manager
      ->getStorage($this->referencedEntityType)
      ->create(['type' => $this->bundle, 'name' => $this->randomString()]);
      ->create([
        'name' => $this->randomMachineName(),
        'type' => $this->bundle,
      ]);
    $reference_field[8]['entity'] = $target_entity_unsaved;
    $target_entities[8] = $target_entity_unsaved;