function ImageItemTest::testImageItemSampleValueGeneration
Same name in other branches
- 11.x core/modules/image/tests/src/Kernel/ImageItemTest.php \Drupal\Tests\image\Kernel\ImageItemTest::testImageItemSampleValueGeneration()
Tests generateSampleItems() method under different dimensions.
File
-
core/
modules/ image/ tests/ src/ Kernel/ ImageItemTest.php, line 159
Class
- ImageItemTest
- Tests using entity fields of the image field type.
Namespace
Drupal\Tests\image\KernelCode
public function testImageItemSampleValueGeneration() : void {
// Default behavior. No dimensions configuration.
$entity = EntityTest::create();
$entity->image_test
->generateSampleItems();
$this->entityValidateAndSave($entity);
$this->assertEquals('image/jpeg', $entity->image_test->entity
->get('filemime')->value);
// Max dimensions bigger than 600x600.
$entity->image_test_generation
->generateSampleItems();
$this->entityValidateAndSave($entity);
$imageItem = $entity->image_test_generation
->first()
->getValue();
$this->assertEquals('800', $imageItem['width']);
$this->assertEquals('800', $imageItem['height']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.