protected function FileUploadResourceTestBase::getExpectedNormalizedEntity in Drupal 8
Same name and namespace in other branches
- 9 core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php \Drupal\Tests\rest\Functional\FileUploadResourceTestBase::getExpectedNormalizedEntity()
- 10 core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php \Drupal\Tests\rest\Functional\FileUploadResourceTestBase::getExpectedNormalizedEntity()
Gets the expected file entity.
Parameters
int $fid: The file ID to load and create normalized data for.
string $expected_filename: The expected filename for the stored file.
bool $expected_as_filename: Whether the expected filename should be the filename property too.
Return value
array The expected normalized data array.
8 calls to FileUploadResourceTestBase::getExpectedNormalizedEntity()
- FileUploadHalJsonTestBase::getExpectedNormalizedEntity in core/
modules/ file/ tests/ src/ Functional/ Hal/ FileUploadHalJsonTestBase.php - Gets the expected file entity.
- FileUploadResourceTestBase::testFileUploadMaliciousExtension in core/
modules/ rest/ tests/ src/ Functional/ FileUploadResourceTestBase.php - Tests using the file upload POST route with malicious extensions.
- FileUploadResourceTestBase::testFileUploadNoExtensionSetting in core/
modules/ rest/ tests/ src/ Functional/ FileUploadResourceTestBase.php - Tests using the file upload POST route no extension configured.
- FileUploadResourceTestBase::testFileUploadStrippedFilePath in core/
modules/ rest/ tests/ src/ Functional/ FileUploadResourceTestBase.php - Tests using the file upload route with any path prefixes being stripped.
- FileUploadResourceTestBase::testFileUploadUnicodeFilename in core/
modules/ rest/ tests/ src/ Functional/ FileUploadResourceTestBase.php - Tests using the file upload route with a unicode file name.
1 method overrides FileUploadResourceTestBase::getExpectedNormalizedEntity()
- FileUploadHalJsonTestBase::getExpectedNormalizedEntity in core/
modules/ file/ tests/ src/ Functional/ Hal/ FileUploadHalJsonTestBase.php - Gets the expected file entity.
File
- core/
modules/ rest/ tests/ src/ Functional/ FileUploadResourceTestBase.php, line 670
Class
- FileUploadResourceTestBase
- Tests binary data file upload route.
Namespace
Drupal\Tests\rest\FunctionalCode
protected function getExpectedNormalizedEntity($fid = 1, $expected_filename = 'example.txt', $expected_as_filename = FALSE) {
$author = User::load(static::$auth ? $this->account
->id() : 0);
$file = File::load($fid);
$expected_normalization = [
'fid' => [
[
'value' => (int) $file
->id(),
],
],
'uuid' => [
[
'value' => $file
->uuid(),
],
],
'langcode' => [
[
'value' => 'en',
],
],
'uid' => [
[
'target_id' => (int) $author
->id(),
'target_type' => 'user',
'target_uuid' => $author
->uuid(),
'url' => base_path() . 'user/' . $author
->id(),
],
],
'filename' => [
[
'value' => $expected_as_filename ? $expected_filename : 'example.txt',
],
],
'uri' => [
[
'value' => 'public://foobar/' . $expected_filename,
'url' => base_path() . $this->siteDirectory . '/files/foobar/' . rawurlencode($expected_filename),
],
],
'filemime' => [
[
'value' => 'text/plain',
],
],
'filesize' => [
[
'value' => strlen($this->testFileData),
],
],
'status' => [
[
'value' => FALSE,
],
],
'created' => [
$this
->formatExpectedTimestampItemValues($file
->getCreatedTime()),
],
'changed' => [
$this
->formatExpectedTimestampItemValues($file
->getChangedTime()),
],
];
return $expected_normalization;
}