Skip to content

Commit 5117a8a

Browse files
Use --uri from commandline over uri in an alias (#3966)
1 parent 5e1beb7 commit 5117a8a

File tree

6 files changed

+39
-16
lines changed

6 files changed

+39
-16
lines changed

src/Preflight/PreflightArgs.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ public function uri($default = false)
276276
return $this->get(self::URI, $default);
277277
}
278278

279+
public function hasUri()
280+
{
281+
return $this->has(self::URI);
282+
}
283+
279284
/**
280285
* Set the uri option
281286
*/

src/Preflight/PreflightSiteLocator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ public function __construct(SiteAliasManager $siteAliasManager)
3737
public function findSite(PreflightArgsInterface $preflightArgs, Environment $environment, $root)
3838
{
3939
$aliasName = $preflightArgs->alias();
40-
return $this->determineSelf($preflightArgs, $environment, $root);
40+
$self = $this->determineSelf($preflightArgs, $environment, $root);
41+
42+
// If the user provided a uri on the commandline, inject it
43+
// into the alias that we found.
44+
if ($preflightArgs->hasUri()) {
45+
$self->setUri($preflightArgs->uri());
46+
}
47+
48+
return $self;
4149
}
4250

4351
/**

tests/functional/ConfigPullTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,27 @@ public function testConfigPull()
2626
$this->markTestSkipped('rsync paths may not contain colons on Windows.');
2727
}
2828

29+
$options = ['yes' => null, 'uri' => 'OMIT'];
30+
2931
$aliases = $this->getAliases();
3032
$source = $aliases['stage'];
3133
$destination = $aliases['dev'];
3234
// Make UUID match.
33-
$this->drush('config:get', ['system.site', 'uuid'], ['yes' => null], $source);
35+
$this->drush('config:get', ['system.site', 'uuid'], $options, $source);
3436
list($name, $uuid) = explode(' ', $this->getOutput());
35-
$this->drush('config-set', ['system.site', 'uuid', $uuid], ['yes' => null], $destination);
37+
$this->drush('config-set', ['system.site', 'uuid', $uuid], $options, $destination);
3638

37-
$this->drush('config:set', ['system.site', 'name', 'testConfigPull'], ['yes' => null], $source);
38-
$this->drush('config:pull', [$source, $destination]);
39-
$this->drush('config:import', [], ['yes' => null], $destination);
40-
$this->drush('config:get', ['system.site', 'name'], [], $source);
39+
$this->drush('config:set', ['system.site', 'name', 'testConfigPull'], $options, $source);
40+
$this->drush('config:pull', [$source, $destination], $options);
41+
$this->drush('config:import', [], $options, $destination);
42+
$this->drush('config:get', ['system.site', 'name'], $options, $source);
4143
$this->assertEquals("'system.site:name': testConfigPull", $this->getOutput(), 'Config was successfully pulled.');
4244

4345
// Test that custom target dir works
4446
$target = Path::join($this->getSandbox(), __CLASS__);
4547
$this->recursiveDelete($target);
4648
$this->mkdir($target);
47-
$this->drush('config:pull', [$source, "$destination:$target"]);
49+
$this->drush('config:pull', [$source, "$destination:$target"], $options);
4850
$this->assertFileExists(Path::join($target, 'system.site.yml'));
4951
}
5052
}

tests/functional/RedispatchTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RedispatchTest extends CommandUnishTestCase
1717
*/
1818
public function testDispatchUsingAlias()
1919
{
20-
$options = ['alias-path' => Path::join(__DIR__, 'resources/alias-fixtures'), 'simulate' => null];
20+
$options = ['uri' => 'OMIT', 'alias-path' => Path::join(__DIR__, 'resources/alias-fixtures'), 'simulate' => null];
2121
$this->drush('status', [], $options, '@example.live');
2222
$this->assertContains("[notice] Simulating: ssh -o PasswordAuthentication=example [email protected] '/example/path/to/drush --no-interaction status --uri=https://example.com --root=/path/on/service-provider'", $this->getSimplifiedErrorOutput());
2323
}

tests/functional/RsyncTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function setUp()
2929
public function testRsyncSimulated()
3030
{
3131
$options = [
32+
'uri' => 'OMIT',
3233
'simulate' => null,
3334
'alias-path' => __DIR__ . '/resources/alias-fixtures',
3435
];

tests/functional/SqlSyncTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function testSimulatedSqlSync()
4040
];
4141
$this->setUpSettings($fixtureSites, 'synctest');
4242
$options = [
43+
'uri' => 'OMIT',
4344
'simulate' => null,
4445
'alias-path' => __DIR__ . '/resources/alias-fixtures',
4546
];
@@ -88,34 +89,39 @@ public function localSqlSync()
8889
{
8990

9091
$options = [
91-
'uri' => 'stage',
9292
'yes' => null,
93+
'uri' => 'OMIT',
9394
];
9495

96+
$stage_options = [
97+
'uri' => 'stage',
98+
] + $options;
99+
95100
// Create a user in the staging site
96101
$name = 'joe.user';
97102
$mail = "[email protected]";
98103

99104
// Add user fields and a test User.
100-
$this->drush('pm-enable', ['field,text,telephone,comment'], $options + ['yes' => null]);
101-
$this->drush('php-script', ['user_fields-D8', $name, $mail], $options + ['script-path' => __DIR__ . '/resources',]);
105+
$this->drush('pm-enable', ['field,text,telephone,comment'], $stage_options + ['yes' => null]);
106+
$this->drush('php-script', ['user_fields-D8', $name, $mail], $stage_options + ['script-path' => __DIR__ . '/resources',]);
102107

103108
// Copy stage to dev, and then sql:sanitize.
104109
$sync_options = [
105110
'yes' => null,
111+
'uri' => 'OMIT',
106112
// Test wildcards expansion from within sql-sync. Also avoid D8 persistent entity cache.
107113
'structure-tables-list' => 'cache,cache*',
108114
];
109115
$this->drush('sql-sync', ['@sut.stage', '@sut.dev'], $sync_options);
110-
$this->drush('sql-sanitize', [], ['yes' => null], '@sut.dev');
116+
$this->drush('sql-sanitize', [], ['yes' => null, 'uri' => 'dev',], '@sut.dev');
111117

112118
// Confirm that the sample user is unchanged on the staging site
113119
$this->drush('user-information', [$name], $options + ['format' => 'json'], '@sut.stage');
114120
$info = $this->getOutputFromJSON(2);
115121
$this->assertEquals($mail, $info->mail, 'Email address is unchanged on source site.');
116122
$this->assertEquals($name, $info->name);
117123
// Get the unchanged pass.
118-
$this->drush('user-information', [$name], $options + ['field' => 'pass']);
124+
$this->drush('user-information', [$name], $stage_options + ['field' => 'pass']);
119125
$original_hashed_pass = $this->getOutput();
120126

121127
// Confirm that the sample user's email and password have been sanitized on the dev site
@@ -128,11 +134,12 @@ public function localSqlSync()
128134
// Copy stage to dev with --sanitize and a fixed sanitized email
129135
$sync_options = [
130136
'yes' => null,
137+
'uri' => 'OMIT',
131138
// Test wildcards expansion from within sql-sync. Also avoid D8 persistent entity cache.
132139
'structure-tables-list' => 'cache,cache*',
133140
];
134141
$this->drush('sql-sync', ['@sut.stage', '@sut.dev'], $sync_options);
135-
$this->drush('sql-sanitize', [], ['yes' => null, 'sanitize-email' => '[email protected]'], '@sut.dev');
142+
$this->drush('sql-sanitize', [], ['yes' => null, 'sanitize-email' => '[email protected]', 'uri' => 'OMIT',], '@sut.dev');
136143

137144
// Confirm that the sample user's email address has been sanitized on the dev site
138145
$this->drush('user-information', [$name], $options + ['yes' => null, 'format' => 'json'], '@sut.dev');
@@ -172,7 +179,7 @@ public function assertUserFieldContents($field_name, $value, $should_contain = f
172179
{
173180
$table = 'user__' . $field_name;
174181
$column = $field_name . '_value';
175-
$this->drush('sql-query', ["SELECT $column FROM $table LIMIT 1"], [], '@sut.dev');
182+
$this->drush('sql-query', ["SELECT $column FROM $table LIMIT 1"], ['uri' => 'OMIT',], '@sut.dev');
176183
$output = $this->getOutput();
177184
$this->assertNotEmpty($output);
178185

0 commit comments

Comments
 (0)