From 5916a08e87040a704f7f87a77fc35032b823fa53 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Fri, 24 Feb 2017 14:49:30 +0000 Subject: [PATCH] Issue #2855260 by hchonov, tameeshb, klausi: Cannot make static method PHPUnit_Framework_Assert::assertFileExists() non static in class Drupal\Tests\file\Functional\FileFieldTestBase --- .../src/Functional/FileFieldTestBase.php | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/core/modules/file/tests/src/Functional/FileFieldTestBase.php b/core/modules/file/tests/src/Functional/FileFieldTestBase.php index d2f3bee5cd7f..9cc981bd46fa 100644 --- a/core/modules/file/tests/src/Functional/FileFieldTestBase.php +++ b/core/modules/file/tests/src/Functional/FileFieldTestBase.php @@ -258,10 +258,19 @@ function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) { /** * Asserts that a file exists physically on disk. + * + * Overrides PHPUnit_Framework_Assert::assertFileExists() to also work with + * file entities. + * + * @param \Drupal\File\FileInterface|string $file + * Either the file entity or the file URI. + * @param string $message + * (optional) A message to display with the assertion. */ - function assertFileExists($file, $message = NULL) { + public static function assertFileExists($file, $message = NULL) { $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri())); - $this->assertTrue(is_file($file->getFileUri()), $message); + $filename = $file instanceof FileInterface ? $file->getFileUri() : $file; + parent::assertFileExists($filename, $message); } /** @@ -276,10 +285,19 @@ function assertFileEntryExists($file, $message = NULL) { /** * Asserts that a file does not exist on disk. + * + * Overrides PHPUnit_Framework_Assert::assertFileExists() to also work with + * file entities. + * + * @param \Drupal\File\FileInterface|string $file + * Either the file entity or the file URI. + * @param string $message + * (optional) A message to display with the assertion. */ - function assertFileNotExists($file, $message = NULL) { + public static function assertFileNotExists($file, $message = NULL) { $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri())); - $this->assertFalse(is_file($file->getFileUri()), $message); + $filename = $file instanceof FileInterface ? $file->getFileUri() : $file; + parent::assertFileNotExists($filename, $message); } /** -- GitLab