Skip to content
Snippets Groups Projects
Commit 2fde44f9 authored by Michael Anello's avatar Michael Anello
Browse files

Issue #3378342 by ultimike, lostcarpark: Undefined array key "#title"

parent 767c7708
Branches
Tags 1.0.0-beta4
1 merge request!1Issue #3378342: Undefined array key "#title"
Pipeline #15803 passed
......@@ -5,3 +5,6 @@ filter_settings.markdown_easy:
flavor:
type: string
label: Flavor
tips:
type: string
label: Tips
......@@ -40,10 +40,10 @@ function _markdown_easy_filter_format_form_submit(array $form, FormStateInterfac
$messenger_service = \Drupal::service('messenger');
if (isset($weights['markdown_easy'])) {
if (!isset($weights['filter_html']) || ($weights['filter_html'] < $weights['markdown_easy'])) {
$messenger_service->addWarning(t('The text format %format is potentially configured insecurely. The "Limit allowed HTML tags and correct faulty HTML" filter is strongly recommended and should be configured to run after the Markdown Easy filter.', ['%format' => $form['#title']]));
$messenger_service->addWarning(t('The text format %format is potentially configured insecurely. The "Limit allowed HTML tags and correct faulty HTML" filter is strongly recommended and should be configured to run after the Markdown Easy filter.', ['%format' => $form_state->getValue('name')]));
}
if (!isset($weights['filter_autop']) || ($weights['filter_autop'] < $weights['markdown_easy'])) {
$messenger_service->addWarning(t('The text format %format is potentially configured incorrectly. The "Convert line breaks into HTML" filter is recommended and should be configured to run after the Markdown Easy filter.', ['%format' => $form['#title']]));
$messenger_service->addWarning(t('The text format %format is potentially configured incorrectly. The "Convert line breaks into HTML" filter is recommended and should be configured to run after the Markdown Easy filter.', ['%format' => $form_state->getValue('name')]));
}
}
......
<?php
namespace Drupal\Tests\markdown_easy\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Test Markdown Easy warnings when adding or editing a text format.
*
* @group markdown_easy
*/
class AddEditFormatTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $modules = [
'markdown_easy',
'node',
'field',
'filter',
'text',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->drupalLogin($this->rootUser);
}
/**
* Test various warning messages on format page when using Markdown Easy.
*
* @test
*/
public function testAddEditFormat(): void {
// Start the browsing session.
$session = $this->assertSession();
// Navigate to the add text format page.
$this->drupalGet('/admin/config/content/formats/add');
$session->statusCodeEquals(200);
// Populate the new text format form.
$edit = [
'name' => 'Markdown Easy format page test',
'format' => 'markdown_easy_format_page_test',
'filters[markdown_easy][status]' => 1,
'filters[markdown_easy][settings][flavor]' => 'standard',
];
$this->submitForm($edit, 'Save configuration');
$session->statusCodeEquals(200);
$session->pageTextContainsOnce('Added text format Markdown Easy format page test.');
$session->pageTextContainsOnce('The text format Markdown Easy format page test is potentially configured insecurely. The "Limit allowed HTML tags and correct faulty HTML" filter is strongly recommended and should be configured to run after the Markdown Easy filter.');
$session->pageTextContainsOnce('The text format Markdown Easy format page test is potentially configured incorrectly. The "Convert line breaks into HTML" filter is recommended and should be configured to run after the Markdown Easy filter.');
// Navigate back to the edit text format page.
$this->drupalGet('/admin/config/content/formats/manage/markdown_easy_format_page_test');
$session->statusCodeEquals(200);
$this->submitForm($edit, 'Save configuration');
$session->statusCodeEquals(200);
$session->pageTextContainsOnce('The text format Markdown Easy format page test has been updated.');
$session->pageTextContainsOnce('The text format Markdown Easy format page test is potentially configured insecurely. The "Limit allowed HTML tags and correct faulty HTML" filter is strongly recommended and should be configured to run after the Markdown Easy filter.');
$session->pageTextContainsOnce('The text format Markdown Easy format page test is potentially configured incorrectly. The "Convert line breaks into HTML" filter is recommended and should be configured to run after the Markdown Easy filter.');
// Navigate back to the edit text format page.
$this->drupalGet('/admin/config/content/formats/manage/markdown_easy_format_page_test');
$session->statusCodeEquals(200);
$edit = [
'name' => 'Markdown Easy format page test',
'format' => 'markdown_easy_format_page_test',
'filters[markdown_easy][status]' => 1,
'filters[markdown_easy][weight]' => 10,
'filters[markdown_easy][settings][flavor]' => 'standard',
'filters[filter_html][status]' => 1,
'filters[filter_html][weight]' => 20,
'filters[filter_autop][status]' => 1,
'filters[filter_autop][weight]' => 30,
];
$this->submitForm($edit, 'Save configuration');
$session->statusCodeEquals(200);
$session->pageTextContainsOnce('The text format Markdown Easy format page test has been updated.');
$session->pageTextNotContains('The text format Markdown Easy format page test is potentially configured insecurely. The "Limit allowed HTML tags and correct faulty HTML" filter is strongly recommended and should be configured to run after the Markdown Easy filter.');
$session->pageTextNotContains('The text format Markdown Easy format page test is potentially configured incorrectly. The "Convert line breaks into HTML" filter is recommended and should be configured to run after the Markdown Easy filter.');
}
}
......@@ -83,7 +83,7 @@ final class FilterTest extends BrowserTestBase {
'id' => 1,
'type' => 'article',
'body' => [
'value' => '**This should be strong.** _This is emphasized._ ~This is striked.~',
'value' => '**This should be strong.** _This is emphasized._ ~This is struck.~',
'format' => 'test_standard_markdown',
],
])->save();
......@@ -120,7 +120,7 @@ final class FilterTest extends BrowserTestBase {
'id' => 2,
'type' => 'article',
'body' => [
'value' => '**This should be strong.** _This is emphasized._ ~This is striked.~',
'value' => '**This should be strong.** _This is emphasized._ ~This is struck.~',
'format' => 'test_github_markdown',
],
])->save();
......@@ -137,13 +137,13 @@ final class FilterTest extends BrowserTestBase {
$session->statusCodeEquals(200);
$session->elementExists('css', 'strong:contains("This should be strong.")');
$session->elementExists('css', 'em:contains("This is emphasized.")');
$session->elementNotExists('css', 'del:contains("This is striked.")');
$session->elementNotExists('css', 'del:contains("This is struck.")');
$this->drupalGet('/node/2');
$session->statusCodeEquals(200);
$session->elementExists('css', 'strong:contains("This should be strong.")');
$session->elementExists('css', 'em:contains("This is emphasized.")');
$session->elementExists('css', 'del:contains("This is striked.")');
$session->elementExists('css', 'del:contains("This is struck.")');
}
}
......@@ -83,7 +83,7 @@ final class FilterWarningsTest extends BrowserTestBase {
'id' => 1,
'type' => 'article',
'body' => [
'value' => '**This should be strong.** _This is emphasized._ ~This is striked.~',
'value' => '**This should be strong.** _This is emphasized._ ~This is struck.~',
'format' => 'securely_configured_format',
],
])->save();
......@@ -120,7 +120,7 @@ final class FilterWarningsTest extends BrowserTestBase {
'id' => 2,
'type' => 'article',
'body' => [
'value' => '**This should be strong.** _This is emphasized._ ~This is striked.~',
'value' => '**This should be strong.** _This is emphasized._ ~This is struck.~',
'format' => 'not_securely_configured_format_1',
],
])->save();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment