ImageStyleWarmerTestBase.php in Image Style Warmer 8
File
tests/src/Functional/ImageStyleWarmerTestBase.php
View source
<?php
namespace Drupal\Tests\image_style_warmer\Functional;
use Drupal\file\Entity\File;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\TestFileCreationTrait;
abstract class ImageStyleWarmerTestBase extends BrowserTestBase {
use TestFileCreationTrait {
getTestFiles as drupalGetTestFiles;
}
protected $adminUser;
protected $defaultTheme = 'stark';
protected static $modules = [
'file',
'image',
'image_style_warmer',
];
protected $testInitialStyle;
protected $testQueueStyle;
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer site configuration',
]);
$this->testInitialStyle = $this->container
->get('entity_type.manager')
->getStorage('image_style')
->create([
'name' => 'test_initial',
'label' => 'Test initial image style',
'effects' => [],
]);
$this->testInitialStyle
->save();
$this->testQueueStyle = $this->container
->get('entity_type.manager')
->getStorage('image_style')
->create([
'name' => 'test_queue',
'label' => 'Test queue image style',
'effects' => [],
]);
$this->testQueueStyle
->save();
}
public function getTestFile($type_name, $size = NULL) {
$this->testFile = current($this
->drupalGetTestFiles($type_name, $size));
$this->testFile->filesize = filesize($this->testFile->uri);
return File::create((array) $this->testFile);
}
}