diff --git a/tests/src/Functional/FillPdfUploadTestBase.php b/tests/src/Functional/FillPdfUploadTestBase.php index 2553e56a824eb85348744eb7243ef39453dd559d..95306893ace22b44c443a1ff894b9c1e4b45fe25 100644 --- a/tests/src/Functional/FillPdfUploadTestBase.php +++ b/tests/src/Functional/FillPdfUploadTestBase.php @@ -131,9 +131,12 @@ abstract class FillPdfUploadTestBase extends FillPdfTestBase { // removed both from the disk and the database. $this->submitForm([], self::OP_REMOVE); $this->assertFileDoesNotExist($new_file->getFileUri()); - // @todo Simplify once Core bug gets fixed. + // @todo Remove $message when resolved: // @see https://www.drupal.org/project/drupal/issues/3043127 - $this->assertFileEntryNotExists($new_file, NULL); + $message = (string) new FormattableMarkup('File %file exists in database at the correct path.', [ + '%file' => $new_file->getFileUri(), + ]); + $this->assertFileEntryNotExists($new_file, $message); break; case self::OP_CREATE: @@ -150,7 +153,12 @@ abstract class FillPdfUploadTestBase extends FillPdfTestBase { $this->assertSession()->elementsCount('css', 'tbody > tr', 4); // Make sure the file is permanent and correctly placed. - $this->assertFileIsPermanent($new_file); + // @todo Remove $message when resolved: + // @see https://www.drupal.org/project/drupal/issues/3043127 + $message = (string) new FormattableMarkup('File %file is permanent.', [ + '%file' => $new_file->getFileUri(), + ]); + $this->assertFileIsPermanent($new_file, $message); $expected_file_uri = FillPdf::buildFileUri($this->config('fillpdf.settings')->get('template_scheme'), "fillpdf/{$new_filename}"); $this->assertEquals($new_file->getFileUri(), $expected_file_uri); break; @@ -161,7 +169,12 @@ abstract class FillPdfUploadTestBase extends FillPdfTestBase { $this->assertSession()->pageTextContains('Your previous field mappings have been transferred to the new PDF template you uploaded.'); // Make sure the file is permanent and correctly placed. - $this->assertFileIsPermanent($new_file); + // @todo Remove $message when resolved: + // @see https://www.drupal.org/project/drupal/issues/3043127 + $message = (string) new FormattableMarkup('File %file is permanent.', [ + '%file' => $new_file->getFileUri(), + ]); + $this->assertFileIsPermanent($new_file, $message); $expected_file_uri = FillPdf::buildFileUri($this->config('fillpdf.settings')->get('template_scheme'), "fillpdf/{$new_filename}"); $this->assertEquals($new_file->getFileUri(), $expected_file_uri); diff --git a/tests/src/Functional/HandlePdfControllerTest.php b/tests/src/Functional/HandlePdfControllerTest.php index ccdf5bb01a86e829059ea19901e6d6f60523adf3..9e3b7082a9ac62c2af681a9ad245836ff412638e 100644 --- a/tests/src/Functional/HandlePdfControllerTest.php +++ b/tests/src/Functional/HandlePdfControllerTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\fillpdf\Functional; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Url; use Drupal\file\Entity\File; use Symfony\Component\HttpFoundation\ResponseHeaderBag; @@ -213,7 +214,12 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase { $this->assertEquals("public://fillpdf/{$expected}/{$expected}.pdf", $uri, "Test case $id: The file has the expected URI."); // Check if file is permanent and has the right format. - $this->assertFileIsPermanent($file); + // @todo Remove $message when resolved: + // @see https://www.drupal.org/project/drupal/issues/3043127 + $message = (string) new FormattableMarkup('File %file is permanent.', [ + '%file' => $file->getFileUri(), + ]); + $this->assertFileIsPermanent($file, $message); $this->drupalGet(\Drupal::service('file_url_generator')->generateAbsoluteString($uri)); $maybe_pdf = $this->getSession()->getPage()->getContent(); static::assertEquals('application/pdf', $this->getMimeType($maybe_pdf), "Test case $id: The file has the correct MIME type.");