Skip to content

Commit

Permalink
add empty and explicitly treat @none as empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
joelpittet committed Sep 30, 2017
1 parent 82e050e commit df63c2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Commands/core/SiteCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function siteSet($site = '@none')
@rename($filename, $last_site_filename);
}
$success_message = dt('Site set to @site', array('@site' => $site));
if ($site == '@none') {
if ($site == '@none' || $site == '') {
if (drush_delete_dir($filename)) {
$this->logger()->success(dt('Site unset.'));
}
Expand Down
15 changes: 10 additions & 5 deletions tests/siteSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,30 @@ public function testSiteSet()
$sites = $this->setUpDrupal(2, true);
$site_names = array_keys($sites);
$this->assertCount(2, $site_names, 'Has 2 drupal sites setup');

// Test changing aliases.
foreach ($site_names as $site_name) {
$this->drush('site-set', ['@' . $site_name]);
$this->drush('site:set', ['@' . $site_name]);
$output = $this->getErrorOutput();
$this->assertEquals('[success] Site set to @' . $site_name, $output);
}

// Toggle between the previous set alias and back again.
$this->drush('site-set', ['-']);
$this->drush('site:set', ['-']);
$output = $this->getErrorOutput();
$this->assertEquals('[success] Site set to @' . $site_names[0], $output);
$this->drush('site-set', ['-']);
$this->drush('site:set', ['-']);
$output = $this->getErrorOutput();
$this->assertEquals('[success] Site set to @' . $site_names[1], $output);

// Test setting the site to the special @none alias.
$this->drush('site-set', ['@none']);
$this->drush('site:set', ['@none']);
$output = $this->getErrorOutput();
$this->assertEquals('[success] Site unset.', $output);


// Alternative to '@none'.
$this->drush('site:set', ['']);
$output = $this->getErrorOutput();
$this->assertEquals('[success] Site unset.', $output);
}
}

0 comments on commit df63c2b

Please sign in to comment.