Skip to content
Snippets Groups Projects
Verified Commit 6bb7ed74 authored by Dave Long's avatar Dave Long
Browse files

Issue #3513317 by annmarysruthy, larowlan, wim leers:...

Issue #3513317 by annmarysruthy, larowlan, wim leers: ImageItem::defaultStorageSettings() should override display_default

(cherry picked from commit 72658312)
parent e2461026
No related branches found
No related tags found
No related merge requests found
Pipeline #453932 passed with warnings
Pipeline: drupal

#453965

    Pipeline: drupal

    #453958

      Pipeline: drupal

      #453947

        +1
        ......@@ -72,6 +72,7 @@ public static function defaultStorageSettings() {
        'width' => NULL,
        'height' => NULL,
        ],
        'display_default' => TRUE,
        ] + parent::defaultStorageSettings();
        }
        ......
        ......@@ -5,14 +5,20 @@
        namespace Drupal\Tests\image\Kernel;
        use Drupal\Core\Database\Database;
        use Drupal\Core\Entity\ContentEntityForm;
        use Drupal\Core\Entity\Entity\EntityFormDisplay;
        use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
        use Drupal\Core\Entity\EntityTypeManagerInterface;
        use Drupal\Core\Field\FieldItemInterface;
        use Drupal\Core\Field\FieldItemListInterface;
        use Drupal\Core\Field\FieldStorageDefinitionInterface;
        use Drupal\Core\Form\FormBuilderInterface;
        use Drupal\Core\Form\FormState;
        use Drupal\entity_test\Entity\EntityTest;
        use Drupal\field\Entity\FieldConfig;
        use Drupal\Tests\field\Kernel\FieldKernelTestBase;
        use Drupal\field\Entity\FieldStorageConfig;
        use Drupal\file\Entity\File;
        use Drupal\Tests\field\Kernel\FieldKernelTestBase;
        use Drupal\user\Entity\Role;
        /**
        ......@@ -92,6 +98,9 @@ protected function setUp(): void {
        ]);
        $this->image->save();
        $this->imageFactory = $this->container->get('image.factory');
        $this->container->get(EntityDisplayRepositoryInterface::class)
        ->getFormDisplay('entity_test', 'entity_test')
        ->setComponent('image_test', ['type' => 'image_image'])->save();
        }
        /**
        ......@@ -198,4 +207,22 @@ public function testImageItemMalformed(): void {
        $this->assertEmpty($entity->image_test->height);
        }
        /**
        * Tests display_default.
        */
        public function testDisplayDefaultValue(): void {
        $entity = EntityTest::create([
        'name' => $this->randomMachineName(),
        ]);
        $form_object = $this->container->get(EntityTypeManagerInterface::class)->getFormObject('entity_test', 'default');
        \assert($form_object instanceof ContentEntityForm);
        $form_object->setEntity($entity);
        $form_display = EntityFormDisplay::collectRenderDisplay($entity, 'default');
        \assert($form_display instanceof EntityFormDisplay);
        $form_state = new FormState();
        $form_object->setFormDisplay($form_display, $form_state);
        $this->container->get(FormBuilderInterface::class)->buildForm($form_object, $form_state);
        self::assertEquals(1, $form_state->getValue(['image_test', 0, 'display']));
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment