diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install index a763639..aab9ea5 100644 --- a/core/modules/aggregator/aggregator.install +++ b/core/modules/aggregator/aggregator.install @@ -37,3 +37,16 @@ function aggregator_update_8001() { /** * @} End of "addtogroup updates-8.0.0-rc". */ + +/** + * Promote 'guid' field to uuid entity key. + */ +function aggregator_update_8002() { + $manager = \Drupal::entityDefinitionUpdateManager(); + $entity_type = $manager->getEntityType('aggregator_item'); + $entity_keys = $entity_type->getKeys(); + $entity_keys['uuid'] = 'guid'; + $entity_type->set('entity_keys', $entity_keys); + $manager->updateEntityType($entity_type); + $manager->updateFieldStorageDefinition($manager->getFieldStorageDefinition('guid', 'aggregator_item')); +} diff --git a/core/modules/aggregator/src/Entity/Item.php b/core/modules/aggregator/src/Entity/Item.php index 4c6d104..a367399 100644 --- a/core/modules/aggregator/src/Entity/Item.php +++ b/core/modules/aggregator/src/Entity/Item.php @@ -36,6 +36,7 @@ * "id" = "iid", * "label" = "title", * "langcode" = "langcode", + * "uuid" = "guid", * } * ) */ diff --git a/core/modules/aggregator/src/Tests/AggregatorTitleTest.php b/core/modules/aggregator/src/Tests/AggregatorTitleTest.php index d599d9a..cea30fd 100644 --- a/core/modules/aggregator/src/Tests/AggregatorTitleTest.php +++ b/core/modules/aggregator/src/Tests/AggregatorTitleTest.php @@ -54,6 +54,7 @@ public function testStringFormatter() { $aggregator_feed = Feed::create([ 'title' => 'testing title', 'url' => 'http://www.example.com', + 'guid' => $this->randomMachineName(), ]); $aggregator_feed->save(); @@ -62,6 +63,7 @@ public function testStringFormatter() { 'title' => 'test title', 'fid' => $aggregator_feed->id(), 'link' => 'http://www.example.com', + 'guid' => $this->randomMachineName(), ]); $aggregator_item->save(); diff --git a/core/modules/aggregator/src/Tests/Views/AggregatorItemViewsFieldAccessTest.php b/core/modules/aggregator/src/Tests/Views/AggregatorItemViewsFieldAccessTest.php index b1c23c5..b020131 100644 --- a/core/modules/aggregator/src/Tests/Views/AggregatorItemViewsFieldAccessTest.php +++ b/core/modules/aggregator/src/Tests/Views/AggregatorItemViewsFieldAccessTest.php @@ -40,12 +40,14 @@ public function testAggregatorItemFields() { $feed = Feed::create([ 'title' => 'Drupal org', 'url' => 'https://www.drupal.org/rss.xml', + 'guid' => $this->randomMachineName(), ]); $feed->save(); $item = Item::create([ 'title' => 'Test title', 'fid' => $feed->id(), 'description' => 'Test description', + 'guid' => $this->randomMachineName(), ]); $item->save(); diff --git a/core/modules/aggregator/src/Tests/Views/IntegrationTest.php b/core/modules/aggregator/src/Tests/Views/IntegrationTest.php index 98598c4..89b6a2d 100644 --- a/core/modules/aggregator/src/Tests/Views/IntegrationTest.php +++ b/core/modules/aggregator/src/Tests/Views/IntegrationTest.php @@ -91,7 +91,7 @@ public function testAggregatorItemView() { // Add a image to ensure that the sanitizing can be tested below. $values['author'] = $this->randomMachineName() . '"'; $values['link'] = 'https://www.drupal.org/node/' . mt_rand(1000, 10000); - $values['guid'] = $this->randomString(); + $values['guid'] = 'guid-' . $i; $aggregator_item = $this->itemStorage->create($values); $aggregator_item->save(); @@ -134,6 +134,16 @@ public function testAggregatorItemView() { }); $this->assertEqual($output, $expected_description, 'Ensure the author got filtered'); } + + // Test if a aggregator item can be rendered in the header. + $view = Views::getView('test_aggregator_items'); + $view->setDisplay('default'); + $this->executeView($view); + $output = $view->render(); + $output = \Drupal::service('renderer')->renderRoot($output); + $this->setRawContent($output); + $header = $this->cssSelect('header h3 a'); + $this->assertEqual(trim($header[0]), $expected[1]['title']); } } diff --git a/core/modules/aggregator/tests/modules/aggregator_test_views/test_views/views.view.test_aggregator_items.yml b/core/modules/aggregator/tests/modules/aggregator_test_views/test_views/views.view.test_aggregator_items.yml index db7b203..6776ef2 100644 --- a/core/modules/aggregator/tests/modules/aggregator_test_views/test_views/views.view.test_aggregator_items.yml +++ b/core/modules/aggregator/tests/modules/aggregator_test_views/test_views/views.view.test_aggregator_items.yml @@ -182,6 +182,20 @@ display: entity_type: aggregator_item entity_field: iid order: 'ASC' + header: + entity_aggregator_item: + id: entity_aggregator_item + table: views + field: entity_aggregator_item + relationship: none + group_type: group + admin_label: '' + empty: false + tokenize: true + target: guid-1 + view_mode: default + bypass_access: true + plugin_id: entity feed_1: display_plugin: feed id: feed_1