Skip to content

Commit 70f75ea

Browse files
rmuitgreg-1-anderson
authored andcommitted
Don't call bootstrapValidate commands repeatedly, and add --uri tests (#3978)
1 parent 7d32f65 commit 70f75ea

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

src/Boot/BootstrapManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ public function bootstrapValidate($phase)
346346
$phases = $this->bootstrapPhases(true);
347347
static $result_cache = [];
348348

349-
if (!array_key_exists($phase, $result_cache)) {
350-
$validated_phase = -1;
351-
foreach ($phases as $phase_index => $current_phase) {
349+
$validated_phase = -1;
350+
foreach ($phases as $phase_index => $current_phase) {
351+
if (!array_key_exists($phase_index, $result_cache)) {
352352
if ($phase_index > $phase) {
353353
break;
354354
}

sut/sites/example.sites.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@
5353
* @see \Drupal\Core\DrupalKernel::getSitePath()
5454
* @see https://www.drupal.org/documentation/install/multi-site
5555
*/
56+
// The following are used by functional tests, at least testOptionsUri():
57+
$sites["test.uri"] = "dev";
58+
$sites["test.uri.subpath"] = "stage";

tests/functional/CoreTest.php

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,40 @@ public function testSiteSelectionViaCwd()
4040

4141
public function testOptionsUri()
4242
{
43-
// Put a yml file in the drush folder.
43+
// Test whether a URI in a config file resolves correctly, and test
44+
// various URI values for their expected Site URI and path.
4445
$drush_config_file = Path::join($this->webrootSlashDrush(), 'drush.yml');
45-
$test_uri = 'http://test.uri';
46-
$options_with_uri = [
47-
'options' => [
48-
'uri' => $test_uri,
49-
],
50-
];
51-
$options = [
46+
$command_options = [
5247
'format' => 'json',
5348
'uri' => 'OMIT', // A special value which causes --uri to not be specified.
5449
];
55-
file_put_contents($drush_config_file, Yaml::dump($options_with_uri, PHP_INT_MAX, 2));
56-
$this->drush('core-status', [], $options);
57-
unlink($drush_config_file);
58-
$output = $this->getOutputFromJSON();
59-
$this->assertEquals($test_uri, $output->uri);
50+
foreach ([
51+
'test.uri' => ['http://test.uri', 'sites/dev'],
52+
'test.uri/' => ['http://test.uri/', 'sites/dev'],
53+
'test.uri/subpath' => ['http://test.uri/subpath', 'sites/stage'],
54+
'test.uri/subpath/' => ['http://test.uri/subpath/', 'sites/stage'],
55+
'http://test.uri' => ['http://test.uri', 'sites/dev'],
56+
'http://test.uri/' => ['http://test.uri/', 'sites/dev'],
57+
'http://test.uri/subpath' => ['http://test.uri/subpath', 'sites/stage'],
58+
'http://test.uri/subpath/' => ['http://test.uri/subpath/', 'sites/stage'],
59+
'https://test.uri' => ['https://test.uri', 'sites/dev'],
60+
'https://test.uri/' => ['https://test.uri/', 'sites/dev'],
61+
'https://test.uri/subpath' => ['https://test.uri/subpath', 'sites/stage'],
62+
'https://test.uri/subpath/' => ['https://test.uri/subpath/', 'sites/stage'],
63+
] as $test_uri => $expected) {
64+
// Put a yml file in the drush folder.
65+
$config_options = [
66+
'options' => [
67+
'uri' => $test_uri,
68+
],
69+
];
70+
file_put_contents($drush_config_file, Yaml::dump($config_options, PHP_INT_MAX, 2));
71+
$this->drush('core-status', [], $command_options);
72+
unlink($drush_config_file);
73+
$output = $this->getOutputFromJSON();
74+
// Include the test URI, for some context in errors.
75+
$this->assertEquals([$test_uri => $expected], [$test_uri => [$output->uri, $output->site]]);
76+
}
6077
}
6178

6279
public function testRecursiveConfigLoading()

0 commit comments

Comments
 (0)