Commit f28179d4 authored by alexpott's avatar alexpott

Issue #1074108 by pwolanin, webchick, BlakeLawson, jayeshanandani, Devin...

Issue #1074108 by pwolanin, webchick, BlakeLawson, jayeshanandani, Devin Carlson, harijari, David_Rothstein, c_lehel, Haza, oriol_e9g: Profile selection form not skipped if there is only one visible profile
parent 0116e11e
......@@ -1111,6 +1111,7 @@ function install_select_profile(&$install_state) {
* 3. A discovered profile that is a distribution.
* If multiple profiles are distributions, then the first discovered profile
* will be selected.
* 4. Only one visible profile is available.
*
* @param array $install_state
* The current installer state, containing a 'profiles' key, which is an
......@@ -1138,6 +1139,16 @@ function _install_select_profile(&$install_state) {
return $profile->getName();
}
}
// Get all visible (not hidden) profiles.
$visible_profiles = array_filter($install_state['profiles'], function ($profile) {
$profile_info = install_profile_info($profile->getName());
return !isset($profile_info['hidden']) || !$profile_info['hidden'];
});
if (count($visible_profiles) == 1) {
return (key($visible_profiles));
}
}
/**
......
<?php
/**
* @file
* Contains \Drupal\system\Tests\Installer\SingleVisibleProfileTest.
*/
namespace Drupal\system\Tests\Installer;
use Drupal\Component\Serialization\Yaml;
use Drupal\simpletest\InstallerTestBase;
/**
* Tests distribution profile support.
*
* @group Installer
*/
class SingleVisibleProfileTest extends InstallerTestBase {
/**
* The installation profile to install.
*
* Not needed when only one is visible.
*
* @var string
*/
protected $profile = NULL;
/**
* The install profile info.
*
* @var array
*/
protected $info;
protected function setUp() {
$this->info = array(
'type' => 'profile',
'core' => \Drupal::CORE_COMPATIBILITY,
'name' => 'Override standard',
'hidden' => TRUE,
);
// File API functions are not available yet.
$path = $this->siteDirectory . '/profiles/standard';
mkdir($path, 0777, TRUE);
file_put_contents("$path/standard.info.yml", Yaml::encode($this->info));
parent::setUp();
}
/**
* Overrides InstallerTest::setUpProfile().
*/
protected function setUpProfile() {
// This step is skipped, because there is only one visible profile.
}
/**
* Confirms that the installation succeeded.
*/
public function testInstalled() {
$this->assertUrl('user/1');
$this->assertResponse(200);
// Confirm that we are logged-in after installation.
$this->assertText($this->root_user->getUsername());
// Confirm that the minimal profile was installed.
$this->assertEqual(drupal_get_profile(), 'minimal');
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment