class TarTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Archiver/TarTest.php \Drupal\KernelTests\Core\Archiver\TarTest

@coversDefaultClass \Drupal\Core\Archiver\Tar
@group tar

Hierarchy

Expanded class hierarchy of TarTest

File

core/tests/Drupal/KernelTests/Core/Archiver/TarTest.php, line 13

Namespace

Drupal\KernelTests\Core\Archiver
View source
class TarTest extends ArchiverTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected $archiverPluginId = 'Tar';
  
  /**
   * Tests that the Tar archive is created if it does not exist.
   */
  public function testCreateArchive() : void {
    $textFile = current($this->getTestFiles('text'));
    $archiveFilename = $this->fileSystem
      ->realpath('public://' . $this->randomMachineName() . '.tar');
    $tar = new Tar($archiveFilename);
    $tar->add($this->fileSystem
      ->realPath($textFile->uri));
    $this->assertFileExists($archiveFilename, 'Archive is automatically created if the file does not exist.');
    $this->assertArchiveContainsFile($archiveFilename, $this->fileSystem
      ->realPath($textFile->uri));
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ArchiverTestBase::$fileSystem protected property The file system service.
ArchiverTestBase::assertArchiveContainsFile protected function Asserts an archive contains a given file.
ArchiverTestBase::assertArchiveNotContainsFile protected function Asserts an archive does not contain a given file.
ArchiverTestBase::setUp protected function
TarTest::$archiverPluginId protected property The archiver plugin identifier. Overrides ArchiverTestBase::$archiverPluginId
TarTest::testCreateArchive public function Tests that the Tar archive is created if it does not exist.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.