14eeaa3f2b01b161783414148e1bde40ce29127e
[yaffs-website] / web / core / modules / image / tests / src / Kernel / ImageImportTest.php
1 <?php
2
3 namespace Drupal\Tests\image\Kernel;
4
5 use Drupal\image\Entity\ImageStyle;
6 use Drupal\KernelTests\KernelTestBase;
7
8 /**
9  * Tests config import for Image styles.
10  *
11  * @group image
12  */
13 class ImageImportTest extends KernelTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['system', 'image', 'image_module_test'];
19
20   /**
21    * Tests importing image styles.
22    */
23   public function testImport() {
24     $style = ImageStyle::create([
25       'name' => 'test'
26     ]);
27
28     $style->addImageEffect(['id' => 'image_module_test_null']);
29     $style->addImageEffect(['id' => 'image_module_test_null']);
30     $style->save();
31
32     $this->assertEqual(count($style->getEffects()), 2);
33
34     $uuid = \Drupal::service('uuid')->generate();
35     $style->set('effects', [
36       $uuid => [
37         'id' => 'image_module_test_null',
38       ],
39     ]);
40     $style->save();
41
42     $style = ImageStyle::load('test');
43     $this->assertEqual(count($style->getEffects()), 1);
44   }
45
46 }