public function InPlaceUpdateTest::testContribUpdate in Automatic Updates 8
@covers ::update @dataProvider contribProjectsProvider
File
- tests/
src/ Build/ InPlaceUpdateTest.php, line 82
Class
- InPlaceUpdateTest
- @coversDefaultClass \Drupal\automatic_updates\Services\InPlaceUpdate
Namespace
Drupal\Tests\automatic_updates\BuildCode
public function testContribUpdate($project, $project_type, $from_version, $to_version) {
$this
->markTestSkipped('Contrib updates are not currently supported');
$this
->copyCodebase();
$fs = new SymfonyFilesystem();
$fs
->chmod($this
->getWorkspaceDirectory() . '/sites/default', 0700);
$this
->executeCommand('COMPOSER_DISCARD_CHANGES=true composer install --no-dev --no-interaction');
$this
->assertErrorOutputContains('Generating autoload files');
$this
->installQuickStart('standard');
// Download the project.
$fs
->mkdir($this
->getWorkspaceDirectory() . "/{$project_type}s/contrib/{$project}");
$this
->executeCommand("curl -fsSL https://ftp.drupal.org/files/projects/{$project}-{$from_version}.tar.gz | tar xvz -C {$project_type}s/contrib/{$project} --strip 1");
$this
->assertCommandSuccessful();
$finder = new Finder();
$finder
->files()
->in($this
->getWorkspaceDirectory())
->path("{$project_type}s/contrib/{$project}/{$project}.info.yml");
$finder
->contains("/version: '{$from_version}'/");
$this
->assertTrue($finder
->hasResults(), "Expected version {$from_version} does not exist in {$this->getWorkspaceDirectory()}/core/lib/Drupal.php");
// Assert files slated for deletion still exist.
foreach ($this
->getDeletions($project, $from_version, $to_version) as $deletion) {
$this
->assertFileExists($this
->getWorkspaceDirectory() . DIRECTORY_SEPARATOR . $deletion);
}
// Currently, this test has to use extension_discovery_scan_tests so we can
// install test modules.
$fs = new SymfonyFilesystem();
$settings_php = $this
->getWorkspaceDirectory() . '/sites/default/settings.php';
$fs
->chmod($settings_php, 0640);
$fs
->appendToFile($settings_php, '$settings[\'extension_discovery_scan_tests\'] = TRUE;' . PHP_EOL);
// Log in so that we can install projects.
$this
->formLogin($this->adminUsername, $this->adminPassword);
$this
->moduleInstall('update');
$this
->moduleInstall('automatic_updates');
$this
->moduleInstall('test_automatic_updates');
$this
->{"{$project_type}Install"}($project);
// Assert that the site is functional before updating.
$this
->visit();
$this
->assertDrupalVisit();
// Update the contrib project.
$assert = $this
->visit("/test_automatic_updates/in-place-update/{$project}/{$project_type}/{$from_version}/{$to_version}")
->assertSession();
$assert
->statusCodeEquals(200);
$this
->assertDrupalVisit();
// Assert that the update worked.
$assert
->pageTextContains('Update successful');
$finder = new Finder();
$finder
->files()
->in($this
->getWorkspaceDirectory())
->path("{$project_type}s/contrib/{$project}/{$project}.info.yml");
$finder
->contains("/version: '{$to_version}'/");
$this
->assertTrue($finder
->hasResults(), "Expected version {$to_version} does not exist in {$this->getWorkspaceDirectory()}/core/lib/Drupal.php");
$this
->assertDrupalVisit();
// Assert files slated for deletion are now gone.
foreach ($this
->getDeletions($project, $from_version, $to_version) as $deletion) {
$this
->assertFileNotExists($this
->getWorkspaceDirectory() . DIRECTORY_SEPARATOR . $deletion);
}
}