From 340558858472426ecd9033c18c3737fb83105196 Mon Sep 17 00:00:00 2001 From: Kevin Wenger Date: Fri, 26 Apr 2024 08:49:11 +0200 Subject: [PATCH] fix phpstan usage of deprecated FileSystemInterface::EXISTS_REPLACE on Drupal 10.3 --- .../tests/src/Kernel/LocalFileStorageTest.php | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/entity_to_text_tika/tests/src/Kernel/LocalFileStorageTest.php b/modules/entity_to_text_tika/tests/src/Kernel/LocalFileStorageTest.php index b4753a2..a1652de 100644 --- a/modules/entity_to_text_tika/tests/src/Kernel/LocalFileStorageTest.php +++ b/modules/entity_to_text_tika/tests/src/Kernel/LocalFileStorageTest.php @@ -61,7 +61,13 @@ protected function setUp(): void { public function testloadPublic(): void { // Create an OCR file for testing. $file_uri = $this->createUri('390-foo.txt.en.ocr.txt', 'Ipsum excepteur id cupidatat commodo', 'private'); - $this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/390-foo.txt.en.ocr.txt', FileSystemInterface::EXISTS_REPLACE); + + // Since Drupal 10.3 FileSystemInterface replaced with an enum. + // @see https://www.drupal.org/node/3426517 + // @codingStandardsIgnoreStart + $exists_replace = version_compare(\Drupal::VERSION, '10.3', '<>') ? FileSystemInterface::EXISTS_REPLACE : \Drupal\Core\File\FileExists::Replace; + $this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/390-foo.txt.en.ocr.txt', $exists_replace); + // @codingStandardsIgnoreEnd // Create a file that correspond to the previous OCR file. $file = File::create([ @@ -79,7 +85,13 @@ public function testloadPublic(): void { public function testloadPrivate(): void { // Create an OCR file for testing. $file_uri = $this->createUri('390-foo.txt.en.ocr.txt', 'Ipsum excepteur id cupidatat commodo', 'private'); - $this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/390-foo.txt.en.ocr.txt', FileSystemInterface::EXISTS_REPLACE); + + // Since Drupal 10.3 FileSystemInterface replaced with an enum. + // @see https://www.drupal.org/node/3426517 + // @codingStandardsIgnoreStart + $exists_replace = version_compare(\Drupal::VERSION, '10.3', '<') ? FileSystemInterface::EXISTS_REPLACE : \Drupal\Core\File\FileExists::Replace; + $this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/390-foo.txt.en.ocr.txt', $exists_replace); + // @codingStandardsIgnoreEnd // Create a file that correspond to the previous OCR file. $file = File::create([ @@ -97,7 +109,13 @@ public function testloadPrivate(): void { public function testloadSubDirectory(): void { // Create an OCR file for testing. $file_uri = $this->createUri('420-foo.txt.en.ocr.txt', 'Ipsum excepteur id cupidatat commodo', 'private'); - $this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/420-foo.txt.en.ocr.txt', FileSystemInterface::EXISTS_REPLACE); + + // Since Drupal 10.3 FileSystemInterface replaced with an enum. + // @see https://www.drupal.org/node/3426517 + // @codingStandardsIgnoreStart + $exists_replace = version_compare(\Drupal::VERSION, '10.3', '<>') ? FileSystemInterface::EXISTS_REPLACE : \Drupal\Core\File\FileExists::Replace; + $this->fileSystem->move($file_uri, 'private://entity-to-text/ocr/420-foo.txt.en.ocr.txt', $exists_replace); + // @codingStandardsIgnoreEnd // Create a file that correspond to the previous OCR file. $file = File::create([ @@ -148,7 +166,13 @@ public function testSave(): void { public function testSaveWhenOcrFileAlreadyExists(): void { // Create an OCR file for testing. $file_ocr_uri = $this->createUri('400-foo.txt.en.ocr.txt', 'Ipsum excepteur id cupidatat commodo', 'private'); - $this->fileSystem->move($file_ocr_uri, 'private://entity-to-text/ocr/400-foo.txt.en.ocr.txt', FileSystemInterface::EXISTS_REPLACE); + + // Since Drupal 10.3 FileSystemInterface replaced with an enum. + // @see https://www.drupal.org/node/3426517 + // @codingStandardsIgnoreStart + $exists_replace = version_compare(\Drupal::VERSION, '10.3', '<') ? FileSystemInterface::EXISTS_REPLACE : \Drupal\Core\File\FileExists::Replace; + $this->fileSystem->move($file_ocr_uri, 'private://entity-to-text/ocr/400-foo.txt.en.ocr.txt', $exists_replace); + // @codingStandardsIgnoreEnd // Create a file for testing. $file = File::create([