summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2018-02-05 22:12:20 (GMT)
committerwebchick2018-02-05 22:12:20 (GMT)
commitfa3e38e10d26400d8ea83a9f718be716460a3112 (patch)
tree33e7aaea39bbb23c77c2bccdef48256dcedb5bca
parent7f1193a749c586e9c2e49a151f6c01f4a35db57e (diff)
Issue #2938185 by tedbow, JayKandari, navneet0693, acbramley, Eli-T, larowlan, webchick, markconroy, andrewmacpherson, David_Rothstein, smaz, ckrina: When installing Umami, only show warning if 'Demo Umami' radio button is selected (and ensure that it is obvious that warning message only applies to the Umami profile)
-rw-r--r--core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php29
-rw-r--r--core/profiles/demo_umami/demo_umami.info.yml4
-rw-r--r--core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php132
3 files changed, 163 insertions, 2 deletions
diff --git a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php
index ea209ad..488242a 100644
--- a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php
+++ b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php
@@ -72,6 +72,11 @@ class SelectProfileForm extends FormBase {
];
foreach (array_keys($names) as $profile_name) {
$form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this->t($profiles[$profile_name]['description']) : '';
+ // @todo Remove hardcoding of 'demo_umami' profile for a generic warning
+ // system in https://www.drupal.org/project/drupal/issues/2822414.
+ if ($profile_name === 'demo_umami') {
+ $this->addUmamiWarning($form);
+ }
}
$form['actions'] = ['#type' => 'actions'];
$form['actions']['submit'] = [
@@ -90,4 +95,28 @@ class SelectProfileForm extends FormBase {
$install_state['parameters']['profile'] = $form_state->getValue('profile');
}
+ /**
+ * Show profile warning if 'demo_umami' profile is selected.
+ */
+ protected function addUmamiWarning(array &$form) {
+ // Warning to show when this profile is selected.
+ $description = $form['profile']['demo_umami']['#description'];
+ // Re-defines radio #description to show warning when selected.
+ $form['profile']['demo_umami']['#description'] = [
+ 'warning' => [
+ '#type' => 'item',
+ '#markup' => $this->t('This profile is intended for demonstration purposes only.'),
+ '#wrapper_attributes' => [
+ 'class' => ['messages', 'messages--warning'],
+ ],
+ '#states' => [
+ 'visible' => [
+ ':input[name="profile"]' => ['value' => 'demo_umami'],
+ ],
+ ],
+ ],
+ 'description' => ['#markup' => $description],
+ ];
+ }
+
}
diff --git a/core/profiles/demo_umami/demo_umami.info.yml b/core/profiles/demo_umami/demo_umami.info.yml
index aa9367e..8e10250 100644
--- a/core/profiles/demo_umami/demo_umami.info.yml
+++ b/core/profiles/demo_umami/demo_umami.info.yml
@@ -1,6 +1,6 @@
-name: Umami Demo - <strong>Experimental</strong>
+name: 'Demo: Umami Food Magazine (Experimental)'
type: profile
-description: 'Install with the <i>Umami</i> food magazine demonstration website, a sample Drupal website that shows off some of the features of what is possible with Drupal "Out of the Box".<br><div role="contentinfo" aria-label="Warning message" class="messages messages--warning">Warning: this is a sample website, you should not use it as the basis for your website.</div>'
+description: 'Install an example site that shows off some of Drupal’s capabilities.'
version: VERSION
core: 8.x
dependencies:
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php
new file mode 100644
index 0000000..efad210
--- /dev/null
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php
@@ -0,0 +1,132 @@
+<?php
+
+namespace Drupal\FunctionalJavascriptTests\Core\Installer\Form;
+
+use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\Language\Language;
+use Drupal\Core\Session\UserSession;
+use Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware;
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use GuzzleHttp\HandlerStack;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RequestStack;
+
+/**
+ * Tests the select profile form.
+ *
+ * @group Installer
+ */
+class SelectProfileFormTest extends JavascriptTestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ $this->setupBaseUrl();
+
+ $this->prepareDatabasePrefix();
+
+ // Install Drupal test site.
+ $this->prepareEnvironment();
+
+ // Define information about the user 1 account.
+ $this->rootUser = new UserSession([
+ 'uid' => 1,
+ 'name' => 'admin',
+ 'mail' => 'admin@example.com',
+ 'pass_raw' => $this->randomMachineName(),
+ ]);
+
+ // If any $settings are defined for this test, copy and prepare an actual
+ // settings.php, so as to resemble a regular installation.
+ if (!empty($this->settings)) {
+ // Not using File API; a potential error must trigger a PHP warning.
+ copy(DRUPAL_ROOT . '/sites/default/default.settings.php', DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php');
+ $this->writeSettings($this->settings);
+ }
+
+ // Note that FunctionalTestSetupTrait::installParameters() returns form
+ // input values suitable for a programmed
+ // \Drupal::formBuilder()->submitForm().
+ // @see InstallerTestBase::translatePostValues()
+ $this->parameters = $this->installParameters();
+
+ // Set up a minimal container (required by BrowserTestBase). Set cookie and
+ // server information so that XDebug works.
+ // @see install_begin_request()
+ $request = Request::create($GLOBALS['base_url'] . '/core/install.php', 'GET', [], $_COOKIE, [], $_SERVER);
+ $this->container = new ContainerBuilder();
+ $request_stack = new RequestStack();
+ $request_stack->push($request);
+ $this->container
+ ->set('request_stack', $request_stack);
+ $this->container
+ ->setParameter('language.default_values', Language::$defaultValues);
+ $this->container
+ ->register('language.default', 'Drupal\Core\Language\LanguageDefault')
+ ->addArgument('%language.default_values%');
+ $this->container
+ ->register('string_translation', 'Drupal\Core\StringTranslation\TranslationManager')
+ ->addArgument(new Reference('language.default'));
+ $this->container
+ ->register('http_client', 'GuzzleHttp\Client')
+ ->setFactory('http_client_factory:fromOptions');
+ $this->container
+ ->register('http_client_factory', 'Drupal\Core\Http\ClientFactory')
+ ->setArguments([new Reference('http_handler_stack')]);
+ $handler_stack = HandlerStack::create();
+ $test_http_client_middleware = new TestHttpClientMiddleware();
+ $handler_stack->push($test_http_client_middleware(), 'test.http_client.middleware');
+ $this->container
+ ->set('http_handler_stack', $handler_stack);
+
+ $this->container
+ ->set('app.root', DRUPAL_ROOT);
+ \Drupal::setContainer($this->container);
+
+ // Setup Mink.
+ $this->initMink();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function initMink() {
+ // The temporary files directory doesn't exist yet, as install_base_system()
+ // has not run. We need to create the template cache directory recursively.
+ $path = $this->tempFilesDirectory . DIRECTORY_SEPARATOR . 'browsertestbase-templatecache';
+ if (!file_exists($path)) {
+ mkdir($path, 0777, TRUE);
+ }
+
+ parent::initMink();
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * BrowserTestBase::refreshVariables() tries to operate on persistent storage,
+ * which is only available after the installer completed.
+ */
+ protected function refreshVariables() {
+ // Intentionally empty as the site is not yet installed.
+ }
+
+ /**
+ * Tests a warning message is displayed when the Umami profile is selected.
+ */
+ public function testUmamiProfileWarningMessage() {
+ $this->drupalGet($GLOBALS['base_url'] . '/core/install.php');
+ $edit = [
+ 'langcode' => 'en',
+ ];
+ $this->drupalPostForm(NULL, $edit, 'Save and continue');
+ $page = $this->getSession()->getPage();
+ $warning_message = $page->find('css', '.description .messages--warning');
+ $this->assertFalse($warning_message->isVisible());
+ $page->selectFieldOption('profile', 'demo_umami');
+ $this->assertTrue($warning_message->isVisible());
+ }
+
+}