diff --git a/core/modules/image/tests/src/Functional/FileMoveTest.php b/core/modules/image/tests/src/Kernel/FileMoveTest.php similarity index 69% rename from core/modules/image/tests/src/Functional/FileMoveTest.php rename to core/modules/image/tests/src/Kernel/FileMoveTest.php index 6de0c1bb2cabcab53da351dc1d0e1942e439e7f7..e052251adc80b4469a598a004533a69d862bb40d 100644 --- a/core/modules/image/tests/src/Functional/FileMoveTest.php +++ b/core/modules/image/tests/src/Kernel/FileMoveTest.php @@ -1,11 +1,12 @@ <?php -namespace Drupal\Tests\image\Functional; +namespace Drupal\Tests\image\Kernel; use Drupal\Core\File\FileSystemInterface; use Drupal\file\Entity\File; +use Drupal\file\FileRepository; use Drupal\image\Entity\ImageStyle; -use Drupal\Tests\BrowserTestBase; +use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\TestFileCreationTrait; /** @@ -13,44 +14,51 @@ * * @group image */ -class FileMoveTest extends BrowserTestBase { +class FileMoveTest extends KernelTestBase { use TestFileCreationTrait { getTestFiles as drupalGetTestFiles; compareFiles as drupalCompareFiles; } - /** - * Modules to enable. - * - * @var array - */ - protected static $modules = ['image']; - /** * {@inheritdoc} */ - protected $defaultTheme = 'stark'; + protected static $modules = [ + 'file', + 'image', + 'system', + 'user', + ]; /** * The file repository service. - * - * @var \Drupal\file\FileRepository */ - protected $fileRepository; + protected FileRepository $fileRepository; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); + + $this->installConfig(['system']); + $this->installEntitySchema('file'); + $this->installEntitySchema('user'); + $this->installSchema('file', ['file_usage']); + + ImageStyle::create([ + 'name' => 'main_style', + 'label' => 'Main', + ])->save(); + $this->fileRepository = $this->container->get('file.repository'); } /** * Tests moving a randomly generated image. */ - public function testNormal() { + public function testNormal(): void { // Pick a file for testing. $file = File::create((array) current($this->drupalGetTestFiles('image'))); @@ -64,7 +72,7 @@ public function testNormal() { // Check if derivative image exists. $this->assertFileExists($derivative_uri); - // Clone the object so we don't have to worry about the function changing + // Clone the object, so we don't have to worry about the function changing // our reference copy. $desired_filepath = 'public://' . $this->randomMachineName(); $result = $this->fileRepository->move(clone $file, $desired_filepath, FileSystemInterface::EXISTS_ERROR);