diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/src/Tests/DateTimeFieldTest.php index 281e78c..4bf3196 100644 --- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php @@ -9,8 +9,8 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Entity\Entity\EntityViewDisplay; -use Drupal\simpletest\WebTestBase; use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\simpletest\WebTestBase; /** * Tests Datetime field functionality. @@ -20,6 +20,15 @@ class DateTimeFieldTest extends WebTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array @@ -141,6 +150,7 @@ function testDateField() { // Verify that the plain formatter works. $this->display_options['type'] = 'datetime_plain'; + $this->display_options['settings'] = array(); entity_get_display($this->field->entity_type, $this->field->bundle, 'full') ->setComponent($field_name, $this->display_options) ->save(); @@ -206,6 +216,7 @@ function testDatetimeField() { // Verify that the plain formatter works. $this->display_options['type'] = 'datetime_plain'; + $this->display_options['settings'] = array(); entity_get_display($this->field->entity_type, $this->field->bundle, 'full') ->setComponent($field_name, $this->display_options) ->save(); diff --git a/core/modules/field/src/Tests/Email/EmailFieldTest.php b/core/modules/field/src/Tests/Email/EmailFieldTest.php index 2ce3c46..bfc8e86 100644 --- a/core/modules/field/src/Tests/Email/EmailFieldTest.php +++ b/core/modules/field/src/Tests/Email/EmailFieldTest.php @@ -18,6 +18,15 @@ class EmailFieldTest extends WebTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php index ca1fbb0..d84fa65 100644 --- a/core/modules/field/src/Tests/Number/NumberFieldTest.php +++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php @@ -18,6 +18,15 @@ class NumberFieldTest extends WebTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/field/src/Tests/String/StringFieldTest.php b/core/modules/field/src/Tests/String/StringFieldTest.php new file mode 100644 index 0000000..f9a6df2 --- /dev/null +++ b/core/modules/field/src/Tests/String/StringFieldTest.php @@ -0,0 +1,107 @@ +web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content')); + $this->drupalLogin($this->web_user); + } + + // Test fields. + + /** + * Test widgets. + */ + function testTextfieldWidgets() { + $this->_testTextfieldWidgets('string', 'string_textfield'); + $this->_testTextfieldWidgets('string_long', 'string_textarea'); + } + + /** + * Helper function for testTextfieldWidgets(). + */ + function _testTextfieldWidgets($field_type, $widget_type) { + // Create a field. + $field_name = Unicode::strtolower($this->randomMachineName()); + $field_storage = entity_create('field_storage_config', array( + 'field_name' => $field_name, + 'entity_type' => 'entity_test', + 'type' => $field_type + )); + $field_storage->save(); + entity_create('field_config', array( + 'field_storage' => $field_storage, + 'bundle' => 'entity_test', + 'label' => $this->randomMachineName() . '_label', + ))->save(); + entity_get_form_display('entity_test', 'entity_test', 'default') + ->setComponent($field_name, array( + 'type' => $widget_type, + 'settings' => array( + 'placeholder' => 'A placeholder on ' . $widget_type, + ), + )) + ->save(); + entity_get_display('entity_test', 'entity_test', 'full') + ->setComponent($field_name) + ->save(); + + // Display creation form. + $this->drupalGet('entity_test/add'); + $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed'); + $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed'); + $this->assertRaw(format_string('placeholder="A placeholder on !widget_type"', array('!widget_type' => $widget_type))); + + // Submit with some value. + $value = $this->randomMachineName(); + $edit = array( + "{$field_name}[0][value]" => $value, + ); + $this->drupalPostForm(NULL, $edit, t('Save')); + preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + $id = $match[1]; + $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created'); + + // Display the entity. + $entity = entity_load('entity_test', $id); + $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); + $content = $display->build($entity); + $this->drupalSetContent(drupal_render($content)); + $this->assertText($value, 'Filtered tags are not displayed'); + } +} diff --git a/core/modules/image/src/Tests/ImageFieldTestBase.php b/core/modules/image/src/Tests/ImageFieldTestBase.php index 33e7fc1..efbbfea 100644 --- a/core/modules/image/src/Tests/ImageFieldTestBase.php +++ b/core/modules/image/src/Tests/ImageFieldTestBase.php @@ -28,6 +28,15 @@ abstract class ImageFieldTestBase extends WebTestBase { /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/options/tests/options_config_install_test/config/install/core.entity_form_display.node.options_install_test.default.yml b/core/modules/options/tests/options_config_install_test/config/install/core.entity_form_display.node.options_install_test.default.yml index b24ca9e..c3540f9 100644 --- a/core/modules/options/tests/options_config_install_test/config/install/core.entity_form_display.node.options_install_test.default.yml +++ b/core/modules/options/tests/options_config_install_test/config/install/core.entity_form_display.node.options_install_test.default.yml @@ -36,13 +36,13 @@ content: promote: type: boolean_checkbox settings: - display_label: '1' + display_label: true weight: 15 third_party_settings: { } sticky: type: boolean_checkbox settings: - display_label: '1' + display_label: true weight: 16 third_party_settings: { } body: diff --git a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php index 94fe38b..91abf5e 100644 --- a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php +++ b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php @@ -103,7 +103,6 @@ public function _testResponsiveImageFieldFormatters($scheme) { // Use the responsive image formatter linked to file formatter. $display_options = array( 'type' => 'responsive_image', - 'module' => 'responsive_image', 'settings' => array( 'image_link' => 'file' ), diff --git a/core/modules/text/src/Tests/TextFieldTest.php b/core/modules/text/src/Tests/TextFieldTest.php index 0cb7b3f..515097a 100644 --- a/core/modules/text/src/Tests/TextFieldTest.php +++ b/core/modules/text/src/Tests/TextFieldTest.php @@ -9,31 +9,21 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; -use Drupal\simpletest\WebTestBase; +use Drupal\field\Tests\String\StringFieldTest; /** * Tests the creation of text fields. * * @group text */ -class TextFieldTest extends WebTestBase { - - /** - * Modules to enable. - * - * @var array - */ - public static $modules = array('entity_test'); +class TextFieldTest extends StringFieldTest { protected $admin_user; - protected $web_user; protected function setUp() { parent::setUp(); $this->admin_user = $this->drupalCreateUser(array('administer filters')); - $this->web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content')); - $this->drupalLogin($this->web_user); } // Test fields. @@ -82,59 +72,6 @@ function testTextfieldWidgets() { } /** - * Helper function for testTextfieldWidgets(). - */ - function _testTextfieldWidgets($field_type, $widget_type) { - // Create a field. - $field_name = Unicode::strtolower($this->randomMachineName()); - $field_storage = entity_create('field_storage_config', array( - 'field_name' => $field_name, - 'entity_type' => 'entity_test', - 'type' => $field_type - )); - $field_storage->save(); - entity_create('field_config', array( - 'field_storage' => $field_storage, - 'bundle' => 'entity_test', - 'label' => $this->randomMachineName() . '_label', - ))->save(); - entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($field_name, array( - 'type' => $widget_type, - 'settings' => array( - 'placeholder' => 'A placeholder on ' . $widget_type, - ), - )) - ->save(); - entity_get_display('entity_test', 'entity_test', 'full') - ->setComponent($field_name) - ->save(); - - // Display creation form. - $this->drupalGet('entity_test/add'); - $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed'); - $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed'); - $this->assertRaw(format_string('placeholder="A placeholder on !widget_type"', array('!widget_type' => $widget_type))); - - // Submit with some value. - $value = $this->randomMachineName(); - $edit = array( - "{$field_name}[0][value]" => $value, - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); - $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created'); - - // Display the entity. - $entity = entity_load('entity_test', $id); - $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); - $content = $display->build($entity); - $this->drupalSetContent(drupal_render($content)); - $this->assertText($value, 'Filtered tags are not displayed'); - } - - /** * Test widgets + 'formatted_text' setting. */ function testTextfieldWidgetsFormatted() {