From 5e8c04df413abb4e4bf1aab7f56b91e4be38c2e7 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 3 Apr 2017 15:25:27 +0100 Subject: [PATCH] Issue #2780063 by mpdonadio, Jo Fitzgerald, GoZ, boaloysius, klausi, Lendude: Convert web tests to browser tests for datetime and datetime_range modules --- .../datetime/src/Tests/DateTestBase.php | 5 + .../tests/src/Functional/DateTestBase.php | 184 ++++++++++++++++++ .../src/Functional}/DateTimeFieldTest.php | 70 +++---- .../src/Functional}/DateRangeFieldTest.php | 162 +++++++-------- 4 files changed, 311 insertions(+), 110 deletions(-) create mode 100644 core/modules/datetime/tests/src/Functional/DateTestBase.php rename core/modules/datetime/{src/Tests => tests/src/Functional}/DateTimeFieldTest.php (90%) rename core/modules/datetime_range/{src/Tests => tests/src/Functional}/DateRangeFieldTest.php (87%) diff --git a/core/modules/datetime/src/Tests/DateTestBase.php b/core/modules/datetime/src/Tests/DateTestBase.php index 81e7550c060..a234ae08f7c 100644 --- a/core/modules/datetime/src/Tests/DateTestBase.php +++ b/core/modules/datetime/src/Tests/DateTestBase.php @@ -2,6 +2,8 @@ namespace Drupal\datetime\Tests; +@trigger_error('\Drupal\datetime\Tests\DateTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\Tests\BrowserTestBase instead. See https://www.drupal.org/node/2780063.', E_USER_DEPRECATED); + use Drupal\Component\Utility\Unicode; use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Core\Entity\Entity\EntityViewDisplay; @@ -13,6 +15,9 @@ use Drupal\simpletest\WebTestBase; /** * Provides a base class for testing Datetime field functionality. + * + * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. + * Use \Drupal\Tests\BrowserTestBase instead. */ abstract class DateTestBase extends WebTestBase { diff --git a/core/modules/datetime/tests/src/Functional/DateTestBase.php b/core/modules/datetime/tests/src/Functional/DateTestBase.php new file mode 100644 index 00000000000..369e793343d --- /dev/null +++ b/core/modules/datetime/tests/src/Functional/DateTestBase.php @@ -0,0 +1,184 @@ +drupalCreateUser([ + 'access content', + 'view test entity', + 'administer entity_test content', + 'administer entity_test form display', + 'administer content types', + 'administer node fields', + ]); + $this->drupalLogin($web_user); + + // Create a field with settings to validate. + $this->createField(); + + $this->dateFormatter = $this->container->get('date.formatter'); + } + + /** + * Creates a date test field. + */ + protected function createField() { + $field_name = Unicode::strtolower($this->randomMachineName()); + $type = $this->getTestFieldType(); + $widget_type = $formatter_type = $type . '_default'; + + $this->fieldStorage = FieldStorageConfig::create([ + 'field_name' => $field_name, + 'entity_type' => 'entity_test', + 'type' => $type, + 'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATE], + ]); + $this->fieldStorage->save(); + $this->field = FieldConfig::create([ + 'field_storage' => $this->fieldStorage, + 'bundle' => 'entity_test', + 'description' => 'Description for ' . $field_name, + 'required' => TRUE, + ]); + $this->field->save(); + + EntityFormDisplay::load('entity_test.entity_test.default') + ->setComponent($field_name, ['type' => $widget_type]) + ->save(); + + $this->displayOptions = [ + 'type' => $formatter_type, + 'label' => 'hidden', + 'settings' => ['format_type' => 'medium'] + $this->defaultSettings, + ]; + EntityViewDisplay::create([ + 'targetEntityType' => $this->field->getTargetEntityTypeId(), + 'bundle' => $this->field->getTargetBundle(), + 'mode' => 'full', + 'status' => TRUE, + ])->setComponent($field_name, $this->displayOptions) + ->save(); + } + + /** + * Renders a entity_test and sets the output in the internal browser. + * + * @param int $id + * The entity_test ID to render. + * @param string $view_mode + * (optional) The view mode to use for rendering. Defaults to 'full'. + * @param bool $reset + * (optional) Whether to reset the entity_test controller cache. Defaults to + * TRUE to simplify testing. + * + * @return string + * The rendered HTML output. + */ + protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) { + if ($reset) { + $this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]); + } + $entity = EntityTest::load($id); + $display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode); + $build = $display->build($entity); + return (string) $this->container->get('renderer')->renderRoot($build); + } + + /** + * Sets the site timezone to a given timezone. + * + * @param string $timezone + * The timezone identifier to set. + */ + protected function setSiteTimezone($timezone) { + // Set an explicit site timezone, and disallow per-user timezones. + $this->config('system.date') + ->set('timezone.user.configurable', 0) + ->set('timezone.default', $timezone) + ->save(); + } + +} diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php similarity index 90% rename from core/modules/datetime/src/Tests/DateTimeFieldTest.php rename to core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php index 827c811f56a..ab03ff5772f 100644 --- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php @@ -1,6 +1,6 @@ $date->format($date_format), ]; $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertRaw($date->format($date_format)); @@ -115,8 +115,9 @@ class DateTimeFieldTest extends DateTestBase { // field, it is expected to display the time as 00:00:00. $expected = format_date($date->getTimestamp(), $new_value, '', DATETIME_STORAGE_TIMEZONE); $expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE); - $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso])); + $output = $this->renderTestEntity($id); + $expected_markup = ''; + $this->assertContains($expected_markup, $output, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso])); break; } } @@ -129,8 +130,8 @@ class DateTimeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format(DATETIME_DATE_STORAGE_FORMAT); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_custom' formatter works. $this->displayOptions['type'] = 'datetime_custom'; @@ -139,8 +140,8 @@ class DateTimeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format($this->displayOptions['settings']['date_format']); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); // Test that allowed markup in custom format is preserved and XSS is // removed. @@ -149,8 +150,8 @@ class DateTimeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = '' . $date->format('m/d/Y') . 'alert(String.fromCharCode(88,83,83))'; - $this->renderTestEntity($id); - $this->assertRaw($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_time_ago' formatter works for intervals in the // past. First update the test entity so that the date difference always @@ -176,8 +177,8 @@ class DateTimeFieldTest extends DateTestBase { $expected = SafeMarkup::format($this->displayOptions['settings']['past_format'], [ '@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]) ]); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains((string) $expected, $output, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_time_ago' formatter works for intervals in the // future. First update the test entity so that the date difference always @@ -197,8 +198,8 @@ class DateTimeFieldTest extends DateTestBase { $expected = SafeMarkup::format($this->displayOptions['settings']['future_format'], [ '@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]) ]); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains((string) $expected, $output, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); } } @@ -215,7 +216,7 @@ class DateTimeFieldTest extends DateTestBase { $this->drupalGet('entity_test/add'); $this->assertFieldByName("{$field_name}[0][value][date]", '', 'Date element found.'); $this->assertFieldByName("{$field_name}[0][value][time]", '', 'Time element found.'); - $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend//text()', $field_name, 'Fieldset and label found'); + $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend', $field_name, 'Fieldset and label found'); $this->assertFieldByXPath('//fieldset[@aria-describedby="edit-' . $field_name . '-0--description"]', NULL, 'ARIA described-by found'); $this->assertFieldByXPath('//div[@id="edit-' . $field_name . '-0--description"]', NULL, 'ARIA description found'); @@ -235,7 +236,7 @@ class DateTimeFieldTest extends DateTestBase { "{$field_name}[0][value][time]" => $date->format($time_format), ]; $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertRaw($date->format($date_format)); @@ -259,8 +260,9 @@ class DateTimeFieldTest extends DateTestBase { // Verify that a date is displayed. $expected = format_date($date->getTimestamp(), $new_value); $expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); - $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso])); + $output = $this->renderTestEntity($id); + $expected_markup = ''; + $this->assertContains($expected_markup, $output, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso])); break; } } @@ -273,8 +275,8 @@ class DateTimeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format(DATETIME_DATETIME_STORAGE_FORMAT); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_custom' formatter works. $this->displayOptions['type'] = 'datetime_custom'; @@ -283,8 +285,8 @@ class DateTimeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format($this->displayOptions['settings']['date_format']); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'timezone_override' setting works. $this->displayOptions['type'] = 'datetime_custom'; @@ -293,8 +295,8 @@ class DateTimeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_time_ago' formatter works for intervals in the // past. First update the test entity so that the date difference always @@ -320,8 +322,8 @@ class DateTimeFieldTest extends DateTestBase { $expected = SafeMarkup::format($this->displayOptions['settings']['past_format'], [ '@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]) ]); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains((string) $expected, $output, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_time_ago' formatter works for intervals in the // future. First update the test entity so that the date difference always @@ -341,8 +343,8 @@ class DateTimeFieldTest extends DateTestBase { $expected = SafeMarkup::format($this->displayOptions['settings']['future_format'], [ '@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]) ]); - $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains((string) $expected, $output, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); } /** @@ -368,7 +370,7 @@ class DateTimeFieldTest extends DateTestBase { // Display creation form. $this->drupalGet('entity_test/add'); - $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend//text()', $field_name, 'Fieldset and label found'); + $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend', $field_name, 'Fieldset and label found'); $this->assertFieldByXPath('//fieldset[@aria-describedby="edit-' . $field_name . '-0--description"]', NULL, 'ARIA described-by found'); $this->assertFieldByXPath('//div[@id="edit-' . $field_name . '-0--description"]', NULL, 'ARIA description found'); @@ -381,7 +383,7 @@ class DateTimeFieldTest extends DateTestBase { $this->drupalGet($fieldEditUrl); // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit"); + $this->drupalPostForm(NULL, [], $field_name . "_settings_edit"); $xpathIncr = "//select[starts-with(@id, \"edit-fields-$field_name-settings-edit-form-settings-increment\")]"; $this->assertNoFieldByXPath($xpathIncr, NULL, 'Increment element not found for Date Only.'); @@ -407,7 +409,7 @@ class DateTimeFieldTest extends DateTestBase { $this->drupalGet($fieldEditUrl); // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit"); + $this->drupalPostForm(NULL, [], $field_name . "_settings_edit"); $this->assertFieldByXPath($xpathIncr, NULL, 'Increment element found for Date and time.'); // Display creation form. @@ -444,7 +446,7 @@ class DateTimeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -485,7 +487,7 @@ class DateTimeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -539,7 +541,7 @@ class DateTimeFieldTest extends DateTestBase { $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertResponse(200); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); diff --git a/core/modules/datetime_range/src/Tests/DateRangeFieldTest.php b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php similarity index 87% rename from core/modules/datetime_range/src/Tests/DateRangeFieldTest.php rename to core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php index f5533150ee5..23ba8fab034 100644 --- a/core/modules/datetime_range/src/Tests/DateRangeFieldTest.php +++ b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php @@ -1,12 +1,12 @@ assertFieldByXPath('//*[@id="edit-' . $field_name . '-wrapper"]//label[contains(@class, "js-form-required")]', TRUE, 'Required markup found'); $this->assertNoFieldByName("{$field_name}[0][value][time]", '', 'Start time element not found.'); $this->assertNoFieldByName("{$field_name}[0][end_value][time]", '', 'End time element not found.'); - $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend//text()', $field_name, 'Fieldset and label found'); + $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend', $field_name, 'Fieldset and label found'); $this->assertFieldByXPath('//fieldset[@aria-describedby="edit-' . $field_name . '-0--description"]', NULL, 'ARIA described-by found'); $this->assertFieldByXPath('//div[@id="edit-' . $field_name . '-0--description"]', NULL, 'ARIA description found'); @@ -83,7 +83,7 @@ class DateRangeFieldTest extends DateTestBase { "{$field_name}[0][end_value][date]" => $end_date->format($date_format), ]; $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertRaw($start_date->format($date_format)); @@ -128,20 +128,22 @@ class DateRangeFieldTest extends DateTestBase { $start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long', '', DATETIME_STORAGE_TIMEZONE); $start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE); + $start_expected_markup = ''; $end_expected = $this->dateFormatter->format($end_date->getTimestamp(), 'long', '', DATETIME_STORAGE_TIMEZONE); $end_expected_iso = $this->dateFormatter->format($end_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE); - $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $start_expected_iso . '"]', $start_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', [ + $end_expected_markup = ''; + $output = $this->renderTestEntity($id); + $this->assertContains($start_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', [ '%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso, ])); - $this->assertFieldByXPath('//time[@datetime="' . $end_expected_iso . '"]', $end_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', [ + $this->assertContains($end_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', [ '%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso, ])); - $this->assertText(' THESEPARATOR ', 'Found proper separator'); + $this->assertContains(' THESEPARATOR ', $output, 'Found proper separator'); // Verify that hook_entity_prepare_view can add attributes. // @see entity_test_entity_prepare_view() @@ -155,8 +157,8 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATE_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATE_STORAGE_FORMAT); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); // Verify that the custom formatter works. $this->displayOptions['type'] = 'daterange_custom'; @@ -165,8 +167,8 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); // Test that allowed markup in custom format is preserved and XSS is // removed. @@ -175,8 +177,8 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = '' . $start_date->format('m/d/Y') . 'alert(String.fromCharCode(88,83,83)) - ' . $end_date->format('m/d/Y') . 'alert(String.fromCharCode(88,83,83))'; - $this->renderTestEntity($id); - $this->assertRaw($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); // Test formatters when start date and end date are the same $this->drupalGet('entity_test/add'); @@ -192,7 +194,7 @@ class DateRangeFieldTest extends DateTestBase { ]; $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -213,13 +215,14 @@ class DateRangeFieldTest extends DateTestBase { $start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long', '', DATETIME_STORAGE_TIMEZONE); $start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE); - $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $start_expected_iso . '"]', $start_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', [ + $start_expected_markup = ''; + $output = $this->renderTestEntity($id); + $this->assertContains($start_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', [ '%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso, ])); - $this->assertNoText(' THESEPARATOR ', 'Separator not found on page'); + $this->assertNotContains(' THESEPARATOR ', $output, 'Separator not found on page'); // Verify that hook_entity_prepare_view can add attributes. // @see entity_test_entity_prepare_view() @@ -232,9 +235,9 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATE_STORAGE_FORMAT); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); - $this->assertNoText(' THESEPARATOR ', 'Separator not found on page'); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); + $this->assertNotContains(' THESEPARATOR ', $output, 'Separator not found on page'); $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = ['date_format' => 'm/d/Y'] + $this->defaultSettings; @@ -242,9 +245,9 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); - $this->assertNoText(' THESEPARATOR ', 'Separator not found on page'); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $this->assertNotContains(' THESEPARATOR ', $output, 'Separator not found on page'); } } @@ -264,7 +267,7 @@ class DateRangeFieldTest extends DateTestBase { $this->assertFieldByName("{$field_name}[0][value][time]", '', 'Start time element found.'); $this->assertFieldByName("{$field_name}[0][end_value][date]", '', 'End date element found.'); $this->assertFieldByName("{$field_name}[0][end_value][time]", '', 'End time element found.'); - $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend//text()', $field_name, 'Fieldset and label found'); + $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend', $field_name, 'Fieldset and label found'); $this->assertFieldByXPath('//fieldset[@aria-describedby="edit-' . $field_name . '-0--description"]', NULL, 'ARIA described-by found'); $this->assertFieldByXPath('//div[@id="edit-' . $field_name . '-0--description"]', NULL, 'ARIA description found'); @@ -289,7 +292,7 @@ class DateRangeFieldTest extends DateTestBase { "{$field_name}[0][end_value][time]" => $end_date->format($time_format), ]; $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertRaw($start_date->format($date_format)); @@ -308,12 +311,14 @@ class DateRangeFieldTest extends DateTestBase { $start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long'); $start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); + $start_expected_markup = ''; $end_expected = $this->dateFormatter->format($end_date->getTimestamp(), 'long'); $end_expected_iso = $this->dateFormatter->format($end_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); - $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $start_expected_iso . '"]', $start_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso])); - $this->assertFieldByXPath('//time[@datetime="' . $end_expected_iso . '"]', $end_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso])); - $this->assertText(' THESEPARATOR ', 'Found proper separator'); + $end_expected_markup = ''; + $output = $this->renderTestEntity($id); + $this->assertContains($start_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso])); + $this->assertContains($end_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso])); + $this->assertContains(' THESEPARATOR ', $output, 'Found proper separator'); // Verify that hook_entity_prepare_view can add attributes. // @see entity_test_entity_prepare_view() @@ -327,8 +332,8 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_custom' formatter works. $this->displayOptions['type'] = 'daterange_custom'; @@ -337,8 +342,8 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'timezone_override' setting works. $this->displayOptions['type'] = 'daterange_custom'; @@ -348,8 +353,8 @@ class DateRangeFieldTest extends DateTestBase { ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); $expected .= ' - ' . $end_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); // Test formatters when start date and end date are the same $this->drupalGet('entity_test/add'); @@ -368,7 +373,7 @@ class DateRangeFieldTest extends DateTestBase { ]; $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -387,9 +392,10 @@ class DateRangeFieldTest extends DateTestBase { $start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long'); $start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); - $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $start_expected_iso . '"]', $start_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso])); - $this->assertNoText(' THESEPARATOR ', 'Separator not found on page'); + $start_expected_markup = ''; + $output = $this->renderTestEntity($id); + $this->assertContains($start_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso])); + $this->assertNotContains(' THESEPARATOR ', $output, 'Separator not found on page'); // Verify that hook_entity_prepare_view can add attributes. // @see entity_test_entity_prepare_view() @@ -402,9 +408,9 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); - $this->assertNoText(' THESEPARATOR ', 'Separator not found on page'); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); + $this->assertNotContains(' THESEPARATOR ', $output, 'Separator not found on page'); $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A'] + $this->defaultSettings; @@ -412,9 +418,9 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); - $this->assertNoText(' THESEPARATOR ', 'Separator not found on page'); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $this->assertNotContains(' THESEPARATOR ', $output, 'Separator not found on page'); } /** @@ -434,7 +440,7 @@ class DateRangeFieldTest extends DateTestBase { $this->assertFieldByXPath('//*[@id="edit-' . $field_name . '-wrapper"]//label[contains(@class, "js-form-required")]', TRUE, 'Required markup found'); $this->assertNoFieldByName("{$field_name}[0][value][time]", '', 'Start time element not found.'); $this->assertNoFieldByName("{$field_name}[0][end_value][time]", '', 'End time element not found.'); - $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend//text()', $field_name, 'Fieldset and label found'); + $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend', $field_name, 'Fieldset and label found'); $this->assertFieldByXPath('//fieldset[@aria-describedby="edit-' . $field_name . '-0--description"]', NULL, 'ARIA described-by found'); $this->assertFieldByXPath('//div[@id="edit-' . $field_name . '-0--description"]', NULL, 'ARIA description found'); @@ -453,7 +459,7 @@ class DateRangeFieldTest extends DateTestBase { "{$field_name}[0][end_value][date]" => $end_date->format($date_format), ]; $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertRaw($start_date->format($date_format)); @@ -472,12 +478,14 @@ class DateRangeFieldTest extends DateTestBase { $start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long'); $start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); + $start_expected_markup = ''; $end_expected = $this->dateFormatter->format($end_date->getTimestamp(), 'long'); $end_expected_iso = $this->dateFormatter->format($end_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); - $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $start_expected_iso . '"]', $start_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso])); - $this->assertFieldByXPath('//time[@datetime="' . $end_expected_iso . '"]', $end_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso])); - $this->assertText(' THESEPARATOR ', 'Found proper separator'); + $end_expected_markup = ''; + $output = $this->renderTestEntity($id); + $this->assertContains($start_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso])); + $this->assertContains($end_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso])); + $this->assertContains(' THESEPARATOR ', $output, 'Found proper separator'); // Verify that hook_entity_prepare_view can add attributes. // @see entity_test_entity_prepare_view() @@ -491,8 +499,8 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); // Verify that the custom formatter works. $this->displayOptions['type'] = 'daterange_custom'; @@ -501,8 +509,8 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'timezone_override' setting works. $this->displayOptions['type'] = 'daterange_custom'; @@ -512,8 +520,8 @@ class DateRangeFieldTest extends DateTestBase { ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); $expected .= ' - ' . $end_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); // Test formatters when start date and end date are the same $this->drupalGet('entity_test/add'); @@ -531,7 +539,7 @@ class DateRangeFieldTest extends DateTestBase { "{$field_name}[0][end_value][date]" => $start_date->format($date_format), ]; $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -550,12 +558,14 @@ class DateRangeFieldTest extends DateTestBase { $start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long'); $start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); + $start_expected_markup = ''; $end_expected = $this->dateFormatter->format($end_date->getTimestamp(), 'long'); $end_expected_iso = $this->dateFormatter->format($end_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); - $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $start_expected_iso . '"]', $start_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso])); - $this->assertFieldByXPath('//time[@datetime="' . $end_expected_iso . '"]', $end_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso])); - $this->assertText(' THESEPARATOR ', 'Found proper separator'); + $end_expected_markup = ''; + $output = $this->renderTestEntity($id); + $this->assertContains($start_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso])); + $this->assertContains($end_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso])); + $this->assertContains(' THESEPARATOR ', $output, 'Found proper separator'); // Verify that hook_entity_prepare_view can add attributes. // @see entity_test_entity_prepare_view() @@ -567,9 +577,9 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' THESEPARATOR ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); - $this->assertText(' THESEPARATOR ', 'Found proper separator'); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); + $this->assertContains(' THESEPARATOR ', $output, 'Found proper separator'); $this->displayOptions['type'] = 'daterange_custom'; $this->displayOptions['settings']['date_format'] = 'm/d/Y'; @@ -577,9 +587,9 @@ class DateRangeFieldTest extends DateTestBase { ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' THESEPARATOR ' . $end_date->format($this->displayOptions['settings']['date_format']); - $this->renderTestEntity($id); - $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); - $this->assertText(' THESEPARATOR ', 'Found proper separator'); + $output = $this->renderTestEntity($id); + $this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected])); + $this->assertContains(' THESEPARATOR ', $output, 'Found proper separator'); } @@ -606,7 +616,7 @@ class DateRangeFieldTest extends DateTestBase { // Display creation form. $this->drupalGet('entity_test/add'); - $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend//text()', $field_name, 'Fieldset and label found'); + $this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend', $field_name, 'Fieldset and label found'); $this->assertFieldByXPath('//fieldset[@aria-describedby="edit-' . $field_name . '-0--description"]', NULL, 'ARIA described-by found'); $this->assertFieldByXPath('//div[@id="edit-' . $field_name . '-0--description"]', NULL, 'ARIA description found'); @@ -622,7 +632,7 @@ class DateRangeFieldTest extends DateTestBase { $this->drupalGet($fieldEditUrl); // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit"); + $this->drupalPostForm(NULL, [], $field_name . "_settings_edit"); $xpathIncr = "//select[starts-with(@id, \"edit-fields-$field_name-settings-edit-form-settings-increment\")]"; $this->assertNoFieldByXPath($xpathIncr, NULL, 'Increment element not found for Date Only.'); @@ -656,7 +666,7 @@ class DateRangeFieldTest extends DateTestBase { $this->drupalGet($fieldEditUrl); // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit"); + $this->drupalPostForm(NULL, [], $field_name . "_settings_edit"); $xpathIncr = "//select[starts-with(@id, \"edit-fields-$field_name-settings-edit-form-settings-increment\")]"; $this->assertNoFieldByXPath($xpathIncr, NULL, 'Increment element not found for Date Only.'); @@ -683,7 +693,7 @@ class DateRangeFieldTest extends DateTestBase { $this->drupalGet($fieldEditUrl); // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit"); + $this->drupalPostForm(NULL, [], $field_name . "_settings_edit"); $this->assertFieldByXPath($xpathIncr, NULL, 'Increment element found for Date and time.'); // Display creation form. @@ -712,7 +722,7 @@ class DateRangeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -767,7 +777,7 @@ class DateRangeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -834,7 +844,7 @@ class DateRangeFieldTest extends DateTestBase { $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertResponse(200); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));