diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php b/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php index eecf864..a5f3d5b 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php @@ -22,7 +22,7 @@ class EditLoadingTest extends WebTestBase { * * @var array */ - public static $modules = array('contextual', 'edit', 'filter', 'node'); + public static $modules = array('contextual', 'edit', 'filter', 'node', 'edit_test'); public static function getInfo() { return array( @@ -291,4 +291,16 @@ function testUserWithPermission() { } } + /** + * Tests that edit module doesn't add metadata for pseudo fields. + */ + function testEditPseudoFields() { + // Login author + $this->drupalLogin($this->author_user); + $this->drupalGet('node/1'); + + // Check that the metadata is not added + $this->assertNoRaw('node/1/edit_test_pseudo_field/und/default'); + } + } diff --git a/core/modules/edit/tests/modules/edit_test.module b/core/modules/edit/tests/modules/edit_test.module index d74528d..559ad55 100644 --- a/core/modules/edit/tests/modules/edit_test.module +++ b/core/modules/edit/tests/modules/edit_test.module @@ -4,3 +4,38 @@ * @file * Helper module for the Edit tests. */ + +use Drupal\Core\Language\Language; +use Drupal\Core\Entity\EntityInterface; +use Drupal\entity\Entity\EntityDisplay; + +/** + * Implements hook_entity_view_alter(). + */ +function edit_test_entity_view_alter(&$build, EntityInterface $entity, EntityDisplay $display) { + + if ($entity->entityType() == 'node' && $entity->bundle() == 'article') { + $build['pseudo'] = array( + '#theme' => 'field', + '#title' => 'My pseudo field', + '#field_name' => 'edit_test_pseudo_field', + '#label_display' => 'Label', + '#entity_type' => $entity->entityType(), + '#bundle' => $entity->bundle(), + '#language' => Language::LANGCODE_NOT_SPECIFIED, + '#field_type' => 'pseudo', + '#view_mode' => 'default', + '#object' => $entity, + '#access' => TRUE, + '#items' => array( + 0 => array( + 'value' => 'pseudo field', + ), + ), + 0 => array( + '#markup' => 'pseudo field', + ), + ); + } + +}