Skip to content
Snippets Groups Projects
Verified Commit 7365716b 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 5e30c259
No related branches found
No related tags found
7 merge requests!12227Issue #3181946 by jonmcl, mglaman,!12079Issue #3523476 by matthiasm11: Add empty check on operator,!12024Fix: DocBlock comment for return value of Drupal\Core\Database\Connection::transactionManager(),!11974Draft: Issue #3495165 by catch, joeyroth, berdir, texas-bronius: Better warning...,!11934Issue #3520997: DefaultLazyPluginCollection unnecessarily instantiates plugins when sorting collection,!11887Issue #3520065: The migrate Row class API is incomplete,!11636Draft: Issue #3515643 by macsim: fieldNameExists method is inconsistent
Pipeline #455679 canceled
Pipeline: drupal

#455682

    ...@@ -72,6 +72,7 @@ public static function defaultStorageSettings() { ...@@ -72,6 +72,7 @@ public static function defaultStorageSettings() {
    'width' => NULL, 'width' => NULL,
    'height' => NULL, 'height' => NULL,
    ], ],
    'display_default' => TRUE,
    ] + parent::defaultStorageSettings(); ] + parent::defaultStorageSettings();
    } }
    ......
    ...@@ -5,14 +5,20 @@ ...@@ -5,14 +5,20 @@
    namespace Drupal\Tests\image\Kernel; namespace Drupal\Tests\image\Kernel;
    use Drupal\Core\Database\Database; 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\FieldItemInterface;
    use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
    use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface;
    use Drupal\Core\Form\FormBuilderInterface;
    use Drupal\Core\Form\FormState;
    use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_test\Entity\EntityTest;
    use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
    use Drupal\Tests\field\Kernel\FieldKernelTestBase;
    use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
    use Drupal\file\Entity\File; use Drupal\file\Entity\File;
    use Drupal\Tests\field\Kernel\FieldKernelTestBase;
    use Drupal\user\Entity\Role; use Drupal\user\Entity\Role;
    /** /**
    ...@@ -92,6 +98,9 @@ protected function setUp(): void { ...@@ -92,6 +98,9 @@ protected function setUp(): void {
    ]); ]);
    $this->image->save(); $this->image->save();
    $this->imageFactory = $this->container->get('image.factory'); $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 { ...@@ -198,4 +207,22 @@ public function testImageItemMalformed(): void {
    $this->assertEmpty($entity->image_test->height); $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