Commit f749eac3 authored by catch's avatar catch

Revert "Issue #2238149 by Berdir: Apply formatters and widgets in EntityTestFormCotroller."

This reverts commit 3ac426f9.
parent 3ac426f9
...@@ -37,4 +37,15 @@ protected function getTranslatorPermissions() { ...@@ -37,4 +37,15 @@ protected function getTranslatorPermissions() {
return array_merge(parent::getTranslatorPermissions(), array('administer entity_test content')); return array_merge(parent::getTranslatorPermissions(), array('administer entity_test content'));
} }
/**
* Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues().
*/
protected function getNewEntityValues($langcode) {
$user = $this->drupalCreateUser();
return array(
'name' => $this->randomMachineName(),
'user_id' => $user->id(),
) + parent::getNewEntityValues($langcode);
}
} }
...@@ -101,6 +101,8 @@ function testDateField() { ...@@ -101,6 +101,8 @@ function testDateField() {
$time_format = entity_load('date_format', 'html_time')->getPattern(); $time_format = entity_load('date_format', 'html_time')->getPattern();
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value][date]" => $date->format($date_format), "{$field_name}[0][value][date]" => $date->format($date_format),
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -168,6 +170,8 @@ function testDatetimeField() { ...@@ -168,6 +170,8 @@ function testDatetimeField() {
$time_format = entity_load('date_format', 'html_time')->getPattern(); $time_format = entity_load('date_format', 'html_time')->getPattern();
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value][date]" => $date->format($date_format), "{$field_name}[0][value][date]" => $date->format($date_format),
"{$field_name}[0][value][time]" => $date->format($time_format), "{$field_name}[0][value][time]" => $date->format($time_format),
); );
...@@ -254,7 +258,10 @@ function testDatelistWidget() { ...@@ -254,7 +258,10 @@ function testDatelistWidget() {
// Submit a valid date and ensure it is accepted. // Submit a valid date and ensure it is accepted.
$date_value = array('year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 5, 'minute' => 15); $date_value = array('year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 5, 'minute' => 15);
$edit = array(); $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
);
// Add the ampm indicator since we are testing 12 hour time. // Add the ampm indicator since we are testing 12 hour time.
$date_value['ampm'] = 'am'; $date_value['ampm'] = 'am';
foreach ($date_value as $part => $value) { foreach ($date_value as $part => $value) {
......
...@@ -59,6 +59,7 @@ protected function setUp() { ...@@ -59,6 +59,7 @@ protected function setUp() {
* Tests the entity reference field with all its supported field widgets. * Tests the entity reference field with all its supported field widgets.
*/ */
public function testSupportedEntityTypesAndWidgets() { public function testSupportedEntityTypesAndWidgets() {
$user_id = mt_rand(128, 256);
foreach ($this->getTestEntities() as $referenced_entities) { foreach ($this->getTestEntities() as $referenced_entities) {
$this->fieldName = 'field_test_' . $referenced_entities[0]->getEntityTypeId(); $this->fieldName = 'field_test_' . $referenced_entities[0]->getEntityTypeId();
...@@ -68,9 +69,15 @@ public function testSupportedEntityTypesAndWidgets() { ...@@ -68,9 +69,15 @@ public function testSupportedEntityTypesAndWidgets() {
// Test the default 'entity_reference_autocomplete' widget. // Test the default 'entity_reference_autocomplete' widget.
entity_get_form_display($this->entityType, $this->bundle, 'default')->setComponent($this->fieldName)->save(); entity_get_form_display($this->entityType, $this->bundle, 'default')->setComponent($this->fieldName)->save();
$user_id++;
entity_create('user', array(
'uid' => $user_id,
'name' => $this->randomString(),
))->save();
$entity_name = $this->randomMachineName(); $entity_name = $this->randomMachineName();
$edit = array( $edit = array(
'name[0][value]' => $entity_name, 'name' => $entity_name,
'user_id' => $user_id,
$this->fieldName . '[0][target_id]' => $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')', $this->fieldName . '[0][target_id]' => $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')',
// Test an input of the entity label without a ' (entity_id)' suffix. // Test an input of the entity label without a ' (entity_id)' suffix.
$this->fieldName . '[1][target_id]' => $referenced_entities[1]->label(), $this->fieldName . '[1][target_id]' => $referenced_entities[1]->label(),
...@@ -93,8 +100,14 @@ public function testSupportedEntityTypesAndWidgets() { ...@@ -93,8 +100,14 @@ public function testSupportedEntityTypesAndWidgets() {
$target_id = $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')'; $target_id = $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')';
// Test an input of the entity label without a ' (entity_id)' suffix. // Test an input of the entity label without a ' (entity_id)' suffix.
$target_id .= ', ' . $referenced_entities[1]->label(); $target_id .= ', ' . $referenced_entities[1]->label();
$user_id++;
entity_create('user', array(
'uid' => $user_id,
'name' => $this->randomString(),
))->save();
$edit = array( $edit = array(
'name[0][value]' => $entity_name, 'name' => $entity_name,
'user_id' => $user_id,
$this->fieldName . '[target_id]' => $target_id, $this->fieldName . '[target_id]' => $target_id,
); );
$this->drupalPostForm($this->entityType . '/add', $edit, t('Save')); $this->drupalPostForm($this->entityType . '/add', $edit, t('Save'));
...@@ -109,7 +122,8 @@ public function testSupportedEntityTypesAndWidgets() { ...@@ -109,7 +122,8 @@ public function testSupportedEntityTypesAndWidgets() {
// Test all the other widgets supported by the entity reference field. // Test all the other widgets supported by the entity reference field.
// Since we don't know the form structure for these widgets, just test // Since we don't know the form structure for these widgets, just test
// that editing and saving an already created entity works. // that editing and saving an already created entity works.
$exclude = array('entity_reference_autocomplete', 'entity_reference_autocomplete_tags'); // Also exclude the special author reference widgets.
$exclude = array('entity_reference_autocomplete', 'entity_reference_autocomplete_tags', 'route_based_autocomplete', 'author_autocomplete');
$entity = current(entity_load_multiple_by_properties($this->entityType, array('name' => $entity_name))); $entity = current(entity_load_multiple_by_properties($this->entityType, array('name' => $entity_name)));
$supported_widgets = \Drupal::service('plugin.manager.field.widget')->getOptions('entity_reference'); $supported_widgets = \Drupal::service('plugin.manager.field.widget')->getOptions('entity_reference');
$supported_widget_types = array_diff(array_keys($supported_widgets), $exclude); $supported_widget_types = array_diff(array_keys($supported_widgets), $exclude);
......
...@@ -49,7 +49,6 @@ class EntityReferenceRelationshipTest extends ViewUnitTestBase { ...@@ -49,7 +49,6 @@ class EntityReferenceRelationshipTest extends ViewUnitTestBase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test'); $this->installEntitySchema('entity_test');
ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views')); ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views'));
......
...@@ -103,6 +103,8 @@ function testBooleanField() { ...@@ -103,6 +103,8 @@ function testBooleanField() {
// Submit and ensure it is accepted. // Submit and ensure it is accepted.
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[value]" => 1, "{$field_name}[value]" => 1,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
......
...@@ -90,6 +90,8 @@ function testEmailField() { ...@@ -90,6 +90,8 @@ function testEmailField() {
// Submit a valid email address and ensure it is accepted. // Submit a valid email address and ensure it is accepted.
$value = 'test@example.com'; $value = 'test@example.com';
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value, "{$field_name}[0][value]" => $value,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
......
...@@ -114,6 +114,8 @@ function testFieldFormSingle() { ...@@ -114,6 +114,8 @@ function testFieldFormSingle() {
// Submit with invalid value (field-level validation). // Submit with invalid value (field-level validation).
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => -1 "{$field_name}[0][value]" => -1
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -123,6 +125,8 @@ function testFieldFormSingle() { ...@@ -123,6 +125,8 @@ function testFieldFormSingle() {
// Create an entity // Create an entity
$value = mt_rand(1, 127); $value = mt_rand(1, 127);
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value, "{$field_name}[0][value]" => $value,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -140,6 +144,8 @@ function testFieldFormSingle() { ...@@ -140,6 +144,8 @@ function testFieldFormSingle() {
// Update the entity. // Update the entity.
$value = mt_rand(1, 127); $value = mt_rand(1, 127);
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value, "{$field_name}[0][value]" => $value,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -151,6 +157,8 @@ function testFieldFormSingle() { ...@@ -151,6 +157,8 @@ function testFieldFormSingle() {
// Empty the field. // Empty the field.
$value = ''; $value = '';
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value "{$field_name}[0][value]" => $value
); );
$this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save')); $this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save'));
...@@ -182,6 +190,8 @@ function testFieldFormDefaultValue() { ...@@ -182,6 +190,8 @@ function testFieldFormDefaultValue() {
// Try to submit an empty value. // Try to submit an empty value.
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => '', "{$field_name}[0][value]" => '',
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -211,6 +221,8 @@ function testFieldFormSingleRequired() { ...@@ -211,6 +221,8 @@ function testFieldFormSingleRequired() {
// Create an entity // Create an entity
$value = mt_rand(1, 127); $value = mt_rand(1, 127);
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value, "{$field_name}[0][value]" => $value,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -223,6 +235,8 @@ function testFieldFormSingleRequired() { ...@@ -223,6 +235,8 @@ function testFieldFormSingleRequired() {
// Edit with missing required value. // Edit with missing required value.
$value = ''; $value = '';
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value, "{$field_name}[0][value]" => $value,
); );
$this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save')); $this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save'));
...@@ -266,7 +280,10 @@ function testFieldFormUnlimited() { ...@@ -266,7 +280,10 @@ function testFieldFormUnlimited() {
$count = 3; $count = 3;
$delta_range = $count - 1; $delta_range = $count - 1;
$values = $weights = $pattern = $expected_values = array(); $values = $weights = $pattern = $expected_values = array();
$edit = array(); $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
);
for ($delta = 0; $delta <= $delta_range; $delta++) { for ($delta = 0; $delta <= $delta_range; $delta++) {
// Assign unique random values and weights. // Assign unique random values and weights.
do { do {
...@@ -446,6 +463,8 @@ function testFieldFormMultipleWidget() { ...@@ -446,6 +463,8 @@ function testFieldFormMultipleWidget() {
// Create entity with three values. // Create entity with three values.
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
$field_name => '1, 2, 3', $field_name => '1, 2, 3',
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -524,6 +543,8 @@ function testFieldFormAccess() { ...@@ -524,6 +543,8 @@ function testFieldFormAccess() {
// Create entity. // Create entity.
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => 1, "{$field_name}[0][value]" => 1,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -537,6 +558,8 @@ function testFieldFormAccess() { ...@@ -537,6 +558,8 @@ function testFieldFormAccess() {
// Create a new revision. // Create a new revision.
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => 2, "{$field_name}[0][value]" => 2,
'revision' => TRUE, 'revision' => TRUE,
); );
...@@ -578,7 +601,7 @@ function testHiddenField() { ...@@ -578,7 +601,7 @@ function testHiddenField() {
// Create an entity and test that the default value is assigned correctly to // Create an entity and test that the default value is assigned correctly to
// the field that uses the hidden widget. // the field that uses the hidden widget.
$this->assertNoField("{$field_name}[0][value]", 'The field does not appear in the form'); $this->assertNoField("{$field_name}[0][value]", 'The field does not appear in the form');
$this->drupalPostForm(NULL, array(), t('Save')); $this->drupalPostForm(NULL, array('user_id' => 1, 'name' => $this->randomMachineName()), t('Save'));
preg_match('|' . $entity_type . '/manage/(\d+)|', $this->url, $match); preg_match('|' . $entity_type . '/manage/(\d+)|', $this->url, $match);
$id = $match[1]; $id = $match[1];
$this->assertText(t('entity_test_rev @id has been created.', array('@id' => $id)), 'Entity was created'); $this->assertText(t('entity_test_rev @id has been created.', array('@id' => $id)), 'Entity was created');
......
...@@ -79,6 +79,8 @@ function testNumberDecimalField() { ...@@ -79,6 +79,8 @@ function testNumberDecimalField() {
// Submit a signed decimal value within the allowed precision and scale. // Submit a signed decimal value within the allowed precision and scale.
$value = '-1234.5678'; $value = '-1234.5678';
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value, "{$field_name}[0][value]" => $value,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -170,6 +172,8 @@ function testNumberIntegerField() { ...@@ -170,6 +172,8 @@ function testNumberIntegerField() {
// Submit a valid integer // Submit a valid integer
$value = rand($minimum, $maximum); $value = rand($minimum, $maximum);
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value, "{$field_name}[0][value]" => $value,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -180,6 +184,8 @@ function testNumberIntegerField() { ...@@ -180,6 +184,8 @@ function testNumberIntegerField() {
// Try to set a value below the minimum value // Try to set a value below the minimum value
$this->drupalGet('entity_test/add'); $this->drupalGet('entity_test/add');
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $minimum - 1, "{$field_name}[0][value]" => $minimum - 1,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -188,6 +194,8 @@ function testNumberIntegerField() { ...@@ -188,6 +194,8 @@ function testNumberIntegerField() {
// Try to set a decimal value // Try to set a decimal value
$this->drupalGet('entity_test/add'); $this->drupalGet('entity_test/add');
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => 1.5, "{$field_name}[0][value]" => 1.5,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -196,6 +204,8 @@ function testNumberIntegerField() { ...@@ -196,6 +204,8 @@ function testNumberIntegerField() {
// Try to set a value above the maximum value // Try to set a value above the maximum value
$this->drupalGet('entity_test/add'); $this->drupalGet('entity_test/add');
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $maximum + 1, "{$field_name}[0][value]" => $maximum + 1,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -211,6 +221,8 @@ function testNumberIntegerField() { ...@@ -211,6 +221,8 @@ function testNumberIntegerField() {
foreach ($valid_entries as $valid_entry) { foreach ($valid_entries as $valid_entry) {
$this->drupalGet('entity_test/add'); $this->drupalGet('entity_test/add');
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $valid_entry, "{$field_name}[0][value]" => $valid_entry,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
...@@ -262,6 +274,8 @@ function testNumberFloatField() { ...@@ -262,6 +274,8 @@ function testNumberFloatField() {
// Submit a signed decimal value within the allowed precision and scale. // Submit a signed decimal value within the allowed precision and scale.
$value = '-1234.5678'; $value = '-1234.5678';
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $value, "{$field_name}[0][value]" => $value,
); );
$this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
......
...@@ -109,6 +109,8 @@ function testFieldFormTranslationRevisions() { ...@@ -109,6 +109,8 @@ function testFieldFormTranslationRevisions() {
// Create a new revision. // Create a new revision.
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][value]" => $entity->{$field_name}->value, "{$field_name}[0][value]" => $entity->{$field_name}->value,
'revision' => TRUE, 'revision' => TRUE,
); );
......
...@@ -36,6 +36,7 @@ public function testNormalize() { ...@@ -36,6 +36,7 @@ public function testNormalize() {
$values = array( $values = array(
'langcode' => 'de', 'langcode' => 'de',
'name' => $this->randomMachineName(), 'name' => $this->randomMachineName(),
'user_id' => 1,
'field_test_text' => array( 'field_test_text' => array(
'value' => $this->randomMachineName(), 'value' => $this->randomMachineName(),
'format' => 'full_html', 'format' => 'full_html',
......
...@@ -149,6 +149,8 @@ function testURLValidation() { ...@@ -149,6 +149,8 @@ function testURLValidation() {
protected function assertValidEntries($field_name, array $valid_entries) { protected function assertValidEntries($field_name, array $valid_entries) {
foreach ($valid_entries as $value) { foreach ($valid_entries as $value) {
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][url]" => $value, "{$field_name}[0][url]" => $value,
); );
$this->drupalPostForm('entity_test/add', $edit, t('Save')); $this->drupalPostForm('entity_test/add', $edit, t('Save'));
...@@ -170,6 +172,8 @@ protected function assertValidEntries($field_name, array $valid_entries) { ...@@ -170,6 +172,8 @@ protected function assertValidEntries($field_name, array $valid_entries) {
protected function assertInvalidEntries($field_name, array $invalid_entries) { protected function assertInvalidEntries($field_name, array $invalid_entries) {
foreach ($invalid_entries as $invalid_value) { foreach ($invalid_entries as $invalid_value) {
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][url]" => $invalid_value, "{$field_name}[0][url]" => $invalid_value,
); );
$this->drupalPostForm('entity_test/add', $edit, t('Save')); $this->drupalPostForm('entity_test/add', $edit, t('Save'));
...@@ -266,6 +270,8 @@ function testLinkTitle() { ...@@ -266,6 +270,8 @@ function testLinkTitle() {
// Verify that a link without link text is rendered using the URL as text. // Verify that a link without link text is rendered using the URL as text.
$value = 'http://www.example.com/'; $value = 'http://www.example.com/';
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][url]" => $value, "{$field_name}[0][url]" => $value,
"{$field_name}[0][title]" => '', "{$field_name}[0][title]" => '',
); );
...@@ -281,6 +287,8 @@ function testLinkTitle() { ...@@ -281,6 +287,8 @@ function testLinkTitle() {
// Verify that a link with text is rendered using the link text. // Verify that a link with text is rendered using the link text.
$title = $this->randomMachineName(); $title = $this->randomMachineName();
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][title]" => $title, "{$field_name}[0][title]" => $title,
); );
$this->drupalPostForm("entity_test/manage/$id", $edit, t('Save')); $this->drupalPostForm("entity_test/manage/$id", $edit, t('Save'));
...@@ -338,6 +346,8 @@ function testLinkFormatter() { ...@@ -338,6 +346,8 @@ function testLinkFormatter() {
// Intentionally contains an ampersand that needs sanitization on output. // Intentionally contains an ampersand that needs sanitization on output.
$title2 = 'A very long & strange example title that could break the nice layout of the site'; $title2 = 'A very long & strange example title that could break the nice layout of the site';
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][url]" => $url1, "{$field_name}[0][url]" => $url1,
// Note that $title1 is not submitted. // Note that $title1 is not submitted.
"{$field_name}[0][title]" => '', "{$field_name}[0][title]" => '',
...@@ -476,6 +486,8 @@ function testLinkSeparateFormatter() { ...@@ -476,6 +486,8 @@ function testLinkSeparateFormatter() {
// Intentionally contains an ampersand that needs sanitization on output. // Intentionally contains an ampersand that needs sanitization on output.
$title2 = 'A very long & strange example title that could break the nice layout of the site'; $title2 = 'A very long & strange example title that could break the nice layout of the site';
$edit = array( $edit = array(
'user_id' => 1,
'name' => $this->randomMachineName(),
"{$field_name}[0][url]" => $url1, "{$field_name}[0][url]" => $url1,
"{$field_name}[1][url]" => $url2, "{$field_name}[1][url]" => $url2,
"{$field_name}[1][title]" => $title2, "{$field_name}[1][title]" => $title2,
......
...@@ -42,7 +42,6 @@ protected function setUp() { ...@@ -42,7 +42,6 @@ protected function setUp() {
$this->fields = new \ArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS); $this->fields = new \ArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS);
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test'); $this->installEntitySchema('entity_test');
$this->installConfig(array('field', 'filter')); $this->installConfig(array('field', 'filter'));
} }
......
...@@ -61,7 +61,8 @@ protected function assertFormCRUD($entity_type) { ...@@ -61,7 +61,8 @@ protected function assertFormCRUD($entity_type) {
$name2 = $this->randomMachineName(10); $name2 = $this->randomMachineName(10);
$edit = array( $edit = array(
'name[0][value]' => $name1, 'name' => $name1,
'user_id' => mt_rand(0, 128),
'field_test_text[0][value]' => $this->randomMachineName(16), 'field_test_text[0][value]' => $this->randomMachineName(16),
); );
...@@ -69,7 +70,7 @@ protected function assertFormCRUD($entity_type) { ...@@ -69,7 +70,7 @@ protected function assertFormCRUD($entity_type) {
$entity = $this->loadEntityByName($entity_type, $name1); $entity = $this->loadEntityByName($entity_type, $name1);
$this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array('%entity_type' => $entity_type))); $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array('%entity_type' => $entity_type)));
$edit['name[0][value]'] = $name2; $edit['name'] = $name2;
$this->drupalPostForm($entity_type . '/manage/' . $entity->id(), $edit, t('Save')); $this->drupalPostForm($entity_type . '/manage/' . $entity->id(), $edit, t('Save'));
$entity = $this->loadEntityByName($entity_type, $name1); $entity = $this->loadEntityByName($entity_type, $name1);
$this->assertFalse($entity, format_string('%entity_type: The entity has been modified.', array('%entity_type' => $entity_type))); $this->assertFalse($entity, format_string('%entity_type: The entity has been modified.', array('%entity_type' => $entity_type)));
......
...@@ -98,7 +98,7 @@ protected function assertRevisions($entity_type) { ...@@ -98,7 +98,7 @@ protected function assertRevisions($entity_type) {
// Confirm the correct revision text appears in the edit form. // Confirm the correct revision text appears in the edit form.
$entity = entity_load($entity_type, $entity->id->value); $entity = entity_load($entity_type, $entity->id->value);
$this->drupalGet($entity_type . '/manage/' . $entity->id->value); $this->drupalGet($entity_type . '/manage/' . $entity->id->value);
$this->assertFieldById('edit-name-0-value', $entity->name->value, format_string('%entity_type: Name matches in UI.', array('%entity_type' => $entity_type))); $this->assertFieldById('edit-name', $entity->name->value, format_string('%entity_type: Name matches in UI.', array('%entity_type' => $entity_type)));
$this->assertFieldById('edit-field-test-text-0-value', $entity->field_test_text->value, format_string('%entity_type: Text matches in UI.', array('%entity_type' => $entity_type))); $this->assertFieldById('edit-field-test-text-0-value', $entity->field_test_text->value, format_string('%entity_type: Text matches in UI.', array('%entity_type' => $entity_type)));
} }
} }
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
use Drupal\Core\Entity\EntityMalformedException; use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityStorageException;
use Drupal\simpletest\KernelTestBase; use Drupal\simpletest\DrupalUnitTestBase;
/** /**
* Tests KeyValueEntityStorage for content entities. * Tests KeyValueEntityStorage for content entities.
* *
* @group KeyValueStore * @group KeyValueStore
*/ */
class KeyValueContentEntityStorageTest extends KernelTestBase { class KeyValueContentEntityStorageTest extends DrupalUnitTestBase {
/** /**
* Modules to enable. * Modules to enable.
...@@ -25,14 +25,6 @@ class KeyValueContentEntityStorageTest extends KernelTestBase { ...@@ -25,14 +25,6 @@ class KeyValueContentEntityStorageTest extends KernelTestBase {
*/ */
public static $modules = array('entity', 'user', 'entity_test', 'keyvalue_test'); public static $modules = array('entity', 'user', 'entity_test', 'keyvalue_test');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('user');
}
/** /**
* Tests CRUD operations. * Tests CRUD operations.
*/ */
......
...@@ -7,4 +7,3 @@ core: 8.x ...@@ -7,4 +7,3 @@ core: 8.x
dependencies: dependencies:
- field - field
- text - text
- entity_reference
...@@ -88,10 +88,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ...@@ -88,10 +88,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
'label' => 'hidden', 'label' => 'hidden',
'type' => 'string', 'type' => 'string',
'weight' => -5, 'weight' => -5,
))
->setDisplayOptions('form', array(
'type' => 'string',
'weight' => -5,
)); ));
// @todo: Add allowed values validation. // @todo: Add allowed values validation.
...@@ -103,22 +99,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ...@@ -103,22 +99,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['user_id'] = BaseFieldDefinition::create('entity_reference') $fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('User ID')) ->setLabel(t('User ID'))
->setDescription(t('The ID of the associated user.')) ->setDescription(t('The ID of the associated user.'))
->setSetting('target_type', 'user') ->setSettings(array('target_type' => 'user'))
->setSetting('handler', 'default') ->setTranslatable(TRUE);
// Default EntityTest entities to have the root user as the owner, to
// simplify testing.
->setDefaultValue(array(0 => 1))