You are here

trait S3FileMapTestTrait in Acquia Content Hub 8.2

Provides helper methods for s3 file map table interactions.

@package Drupal\Tests\acquia_contenthub_s3\Kernel

Hierarchy

File

modules/acquia_contenthub_s3/tests/src/Kernel/S3FileMapTestTrait.php, line 12

Namespace

Drupal\Tests\acquia_contenthub_s3\Kernel
View source
trait S3FileMapTestTrait {

  /**
   * Clears s3 file map table.
   */
  protected function truncateS3FileMap() : void {
    \Drupal::database()
      ->truncate(S3FileMap::TABLE_NAME)
      ->execute();
  }

  /**
   * Returns every entry from S3FileMap table.
   *
   * @return array
   *   Associative array, keyed by file_uuid.
   *
   * @throws \Exception
   */
  protected function fetchAllData() : array {
    return \Drupal::database()
      ->select(S3FileMap::TABLE_NAME, 'acs3')
      ->fields('acs3')
      ->execute()
      ->fetchAllAssoc('file_uuid', \PDO::FETCH_ASSOC);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
S3FileMapTestTrait::fetchAllData protected function Returns every entry from S3FileMap table.
S3FileMapTestTrait::truncateS3FileMap protected function Clears s3 file map table.