You are here

protected function InPlaceUpdateTest::getDeletions in Automatic Updates 8

Helper method to retrieve files slated for deletion.

3 calls to InPlaceUpdateTest::getDeletions()
InPlaceUpdateTest::assertCoreUpgradeFailed in tests/src/Build/InPlaceUpdateTest.php
Assert an upgraded failed and was handle appropriately.
InPlaceUpdateTest::assertCoreUpgradeSuccess in tests/src/Build/InPlaceUpdateTest.php
Assert an upgrade succeeded.
InPlaceUpdateTest::testContribUpdate in tests/src/Build/InPlaceUpdateTest.php
@covers ::update @dataProvider contribProjectsProvider

File

tests/src/Build/InPlaceUpdateTest.php, line 218

Class

InPlaceUpdateTest
@coversDefaultClass \Drupal\automatic_updates\Services\InPlaceUpdate

Namespace

Drupal\Tests\automatic_updates\Build

Code

protected function getDeletions($project, $from_version, $to_version) {
  if (isset($this->deletions)) {
    return $this->deletions;
  }
  $this->deletions = [];
  $filesystem = new SymfonyFilesystem();
  $this->deletionsDestination = DrupalFileSystem::getOsTemporaryDirectory() . DIRECTORY_SEPARATOR . "{$project}-" . mt_rand(10000, 99999) . microtime(TRUE);
  $filesystem
    ->mkdir($this->deletionsDestination);
  $file_name = "{$project}-{$from_version}-to-{$to_version}.zip";
  $zip_file = $this->deletionsDestination . DIRECTORY_SEPARATOR . $file_name;
  $this
    ->doGetArchive($project, $file_name, $zip_file);
  $zip = new \ZipArchive();
  $zip
    ->open($zip_file);
  $zip
    ->extractTo($this->deletionsDestination, [
    InPlaceUpdate::DELETION_MANIFEST,
  ]);
  $handle = fopen($this->deletionsDestination . DIRECTORY_SEPARATOR . InPlaceUpdate::DELETION_MANIFEST, 'r');
  if ($handle) {
    while (($deletion = fgets($handle)) !== FALSE) {
      if ($result = trim($deletion)) {
        $this->deletions[] = $result;
      }
    }
    fclose($handle);
  }
  return $this->deletions;
}