Skip to content

Commit

Permalink
fix phpstan usage of deprecated FileSystemInterface::EXISTS_REPLACE o…
Browse files Browse the repository at this point in the history
…n Drupal 10.3
  • Loading branch information
WengerK committed Apr 26, 2024
1 parent 1b0d4cd commit 3405588
Showing 1 changed file with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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([
Expand All @@ -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([
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit 3405588

Please sign in to comment.