You are here

protected function EntityShareClientFunctionalTestBase::preparePhysicalFilesAndFileEntitiesData in Entity Share 8.3

Same name and namespace in other branches
  1. 8.2 modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php \Drupal\Tests\entity_share_client\Functional\EntityShareClientFunctionalTestBase::preparePhysicalFilesAndFileEntitiesData()

Helper function.

Return value

array An array of data.

6 calls to EntityShareClientFunctionalTestBase::preparePhysicalFilesAndFileEntitiesData()
AuthenticationAnonymousTest::getEntitiesDataArray in modules/entity_share_client/tests/src/Functional/AuthenticationAnonymousTest.php
Helper function to get a mapping of the entities data.
AuthenticationTestBase::getEntitiesDataArray in modules/entity_share_client/tests/src/Functional/AuthenticationTestBase.php
Helper function to get a mapping of the entities data.
EmbeddedEntityTest::getEntitiesDataArray in modules/entity_share_client/tests/src/Functional/EmbeddedEntityTest.php
Helper function to get a mapping of the entities data.
FileDeletedTest::getEntitiesDataArray in modules/entity_share_client/tests/src/Functional/FileDeletedTest.php
Helper function to get a mapping of the entities data.
FileTest::getEntitiesDataArray in modules/entity_share_client/tests/src/Functional/FileTest.php
Helper function to get a mapping of the entities data.

... See full list

File

modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php, line 986

Class

EntityShareClientFunctionalTestBase
Base class for Entity Share Client functional tests.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

protected function preparePhysicalFilesAndFileEntitiesData() {
  $files_entities_data = [];
  foreach (static::$filesData as $file_uuid => $file_data) {
    $stream_wrapper = $this->streamWrapperManager
      ->getViaUri($file_data['uri']);
    $directory_uri = $stream_wrapper
      ->dirname($file_data['uri']);
    $this->fileSystem
      ->prepareDirectory($directory_uri, FileSystemInterface::CREATE_DIRECTORY);
    if (isset($file_data['file_content'])) {
      file_put_contents($file_data['uri'], $file_data['file_content']);
      $this->filesSize[$file_uuid] = filesize($file_data['uri']);
    }
    elseif (isset($file_data['file_content_callback'])) {
      $this
        ->{$file_data['file_content_callback']}($file_uuid, $file_data);
    }
    $files_entities_data[$file_uuid] = [
      'filename' => [
        'value' => $file_data['filename'],
        'checker_callback' => 'getValue',
      ],
      'uri' => [
        'value' => $file_data['uri'],
        'checker_callback' => 'getValue',
      ],
      'filemime' => [
        'value' => $file_data['filemime'],
        'checker_callback' => 'getValue',
      ],
      'status' => [
        'value' => FILE_STATUS_PERMANENT,
        'checker_callback' => 'getValue',
      ],
    ];
  }
  return $files_entities_data;
}