protected function QuickStartTestBase::installCore in Automatic Updates 8
Prepare core for testing.
Parameters
string $starting_version: The starting version.
4 calls to QuickStartTestBase::installCore()
- InPlaceUpdateTest::testCoreRollbackUpdate in tests/
src/ Build/ InPlaceUpdateTest.php - @covers ::update
- InPlaceUpdateTest::testCoreUpdate in tests/
src/ Build/ InPlaceUpdateTest.php - @covers ::update @dataProvider coreVersionsSuccessProvider
- InPlaceUpdateTest::testCronCoreUpdate in tests/
src/ Build/ InPlaceUpdateTest.php - Test in-place update via cron run.
- ModifiedFilesTest::testCoreModified in tests/
src/ Build/ ModifiedFilesTest.php - @covers ::getModifiedFiles @dataProvider coreProjectProvider
File
- tests/
src/ Build/ QuickStart/ QuickStartTestBase.php, line 57
Class
- QuickStartTestBase
- Helper methods for using the quickstart feature of Drupal.
Namespace
Drupal\Tests\automatic_updates\Build\QuickStartCode
protected function installCore($starting_version) {
// Get tarball of drupal core.
$drupal_tarball = "drupal-{$starting_version}.zip";
$destination = DrupalFileSystem::getOsTemporaryDirectory() . DIRECTORY_SEPARATOR . 'drupal-' . random_int(10000, 99999) . microtime(TRUE);
$fs = new SymfonyFilesystem();
$fs
->mkdir($destination);
$http_client = new Client();
$http_client
->get("https://ftp.drupal.org/files/projects/{$drupal_tarball}", [
'sink' => $destination . DIRECTORY_SEPARATOR . $drupal_tarball,
]);
$zip = new Zip($destination . DIRECTORY_SEPARATOR . $drupal_tarball);
$zip
->extract($destination);
// Move the tarball codebase over to the test workspace.
$finder = new Finder();
$finder
->files()
->ignoreUnreadableDirs()
->ignoreDotFiles(FALSE)
->in("{$destination}/drupal-{$starting_version}");
$options = [
'override' => TRUE,
'delete' => FALSE,
];
$fs
->mirror("{$destination}/drupal-{$starting_version}", $this
->getWorkingPath(), $finder
->getIterator(), $options);
$fs
->remove("{$destination}/drupal-{$starting_version}");
// Copy in this module from the original code base.
$finder = new Finder();
$finder
->files()
->ignoreUnreadableDirs()
->in($this
->getDrupalRoot())
->path('automatic_updates');
$this
->copyCodebase($finder
->getIterator());
$fs
->chmod($this
->getWorkspaceDirectory() . '/sites/default', 0700);
$this
->installQuickStart('minimal');
// Currently, this test has to use extension_discovery_scan_tests so we can
// install test modules.
$settings_php = $this
->getWorkspaceDirectory() . '/sites/default/settings.php';
$fs
->chmod($this
->getWorkspaceDirectory() . '/sites/default', 0755);
$fs
->chmod($settings_php, 0640);
$fs
->appendToFile($settings_php, '$settings[\'extension_discovery_scan_tests\'] = TRUE;' . PHP_EOL);
// Log in so that we can install modules.
$this
->formLogin($this->adminUsername, $this->adminPassword);
$this
->moduleInstall('update');
$this
->moduleInstall('automatic_updates');
$this
->moduleInstall('test_automatic_updates');
// Confirm we are running correct Drupal version.
$finder = new Finder();
$finder
->files()
->in($this
->getWorkspaceDirectory())
->path('core/lib/Drupal.php');
$finder
->contains("/const VERSION = '{$starting_version}'/");
$this
->assertTrue($finder
->hasResults(), "Expected version {$starting_version} does not exist in {$this->getWorkspaceDirectory()}/core/lib/Drupal.php");
// Assert that the site is functional after install.
$this
->visit();
$this
->assertDrupalVisit();
}