function ArchiverTestBase::assertArchiveContainsFile

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Archiver/ArchiverTestBase.php \Drupal\KernelTests\Core\Archiver\ArchiverTestBase::assertArchiveContainsFile()

Asserts an archive contains a given file.

Parameters

string $path: Absolute file path to an archived file.

string $file: File to assert does exist within the archived file.

array $configuration: Optional configuration to pass to the archiver plugin.

3 calls to ArchiverTestBase::assertArchiveContainsFile()
TarTest::testCreateArchive in core/tests/Drupal/KernelTests/Core/Archiver/TarTest.php
Tests that the Tar archive is created if it does not exist.
ZipTest::testCreateArchive in core/tests/Drupal/KernelTests/Core/Archiver/ZipTest.php
Tests that the Zip archive is created if it does not exist.
ZipTest::testOverwriteArchive in core/tests/Drupal/KernelTests/Core/Archiver/ZipTest.php
Tests that the Zip archiver is created and overwritten.

File

core/tests/Drupal/KernelTests/Core/Archiver/ArchiverTestBase.php, line 49

Class

ArchiverTestBase
Provides archive specific assertions and helper properties for archive tests.

Namespace

Drupal\KernelTests\Core\Archiver

Code

protected function assertArchiveContainsFile($path, $file, array $configuration = []) {
    $configuration['filepath'] = $path;
    
    /** @var \Drupal\Core\Archiver\ArchiverManager $manager */
    $manager = $this->container
        ->get('plugin.manager.archiver');
    $archive = $manager->createInstance($this->archiverPluginId, $configuration);
    $this->assertContains($file, $archive->listContents(), sprintf('The "%s" archive contains the "%s" file.', $path, $file));
}

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