function FileFieldPathTest::assertPathMatch
Same name in other branches
- 9 core/modules/file/tests/src/Functional/FileFieldPathTest.php \Drupal\Tests\file\Functional\FileFieldPathTest::assertPathMatch()
- 10 core/modules/file/tests/src/Functional/FileFieldPathTest.php \Drupal\Tests\file\Functional\FileFieldPathTest::assertPathMatch()
- 11.x core/modules/file/tests/src/Functional/FileFieldPathTest.php \Drupal\Tests\file\Functional\FileFieldPathTest::assertPathMatch()
Asserts that a file is uploaded to the right location.
Parameters
string $expected_path: The location where the file is expected to be uploaded. Duplicate file names to not need to be taken into account.
string $actual_path: Where the file was actually uploaded.
string $message: The message to display with this assertion.
1 call to FileFieldPathTest::assertPathMatch()
- FileFieldPathTest::testUploadPath in core/
modules/ file/ tests/ src/ Functional/ FileFieldPathTest.php - Tests the normal formatter display on node display.
File
-
core/
modules/ file/ tests/ src/ Functional/ FileFieldPathTest.php, line 89
Class
- FileFieldPathTest
- Tests that files are uploaded to proper locations.
Namespace
Drupal\Tests\file\FunctionalCode
public function assertPathMatch($expected_path, $actual_path, $message) {
// Strip off the extension of the expected path to allow for _0, _1, etc.
// suffixes when the file hits a duplicate name.
$pos = strrpos($expected_path, '.');
$base_path = substr($expected_path, 0, $pos);
$extension = substr($expected_path, $pos + 1);
$result = (bool) preg_match('/' . preg_quote($base_path, '/') . '(_[0-9]+)?\\.' . preg_quote($extension, '/') . '/', $actual_path);
$this->assertTrue($result, $message);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.