You are here

protected function WebformEntityPrintFunctionalTest::getArchiveContents in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_entity_print/tests/src/Functional/WebformEntityPrintFunctionalTest.php \Drupal\Tests\webform_entity_print\Functional\WebformEntityPrintFunctionalTest::getArchiveContents()

Get archive contents.

Parameters

string $filepath: Archive file path.

Return value

array Array of archive contents.

1 call to WebformEntityPrintFunctionalTest::getArchiveContents()
WebformEntityPrintFunctionalTest::testEntityPrint in modules/webform_entity_print/tests/src/Functional/WebformEntityPrintFunctionalTest.php
Test entity print.

File

modules/webform_entity_print/tests/src/Functional/WebformEntityPrintFunctionalTest.php, line 185

Class

WebformEntityPrintFunctionalTest
Webform entity print test.

Namespace

Drupal\Tests\webform_entity_print\Functional

Code

protected function getArchiveContents($filepath) {
  if (strpos($filepath, '.zip') !== FALSE) {
    $archive = new \ZipArchive();
    $archive
      ->open($filepath);
    $files = [];
    for ($i = 0; $i < $archive->numFiles; $i++) {
      $files[] = $archive
        ->getNameIndex($i);
    }
  }
  else {
    $archive = new \Archive_Tar($filepath, 'gz');
    $files = [];
    foreach ($archive
      ->listContent() as $file_data) {
      $files[] = $file_data['filename'];
    }
  }
  return array_combine($files, $files);
}