Commit 22716ab7 authored by alexpott's avatar alexpott
Browse files

Issue #2602662 by mikeryan, phenaproxima: Feed ID should be required base...

Issue #2602662 by mikeryan, phenaproxima: Feed ID should be required base field for aggregator items
parent 9fc4d2ec
...@@ -21,3 +21,19 @@ function aggregator_requirements($phase) { ...@@ -21,3 +21,19 @@ function aggregator_requirements($phase) {
} }
return $requirements; return $requirements;
} }
/**
* @addtogroup updates-8.0.0-rc
* @{
*/
/**
* The simple presence of this update function clears cached field definitions.
*/
function aggregator_update_8001() {
// Feed ID base field is now required.
}
/**
* @} End of "addtogroup updates-8.0.0-rc".
*/
...@@ -60,6 +60,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ...@@ -60,6 +60,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['fid'] = BaseFieldDefinition::create('entity_reference') $fields['fid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Source feed')) ->setLabel(t('Source feed'))
->setRequired(TRUE)
->setDescription(t('The aggregator feed entity associated with this item.')) ->setDescription(t('The aggregator feed entity associated with this item.'))
->setSetting('target_type', 'aggregator_feed') ->setSetting('target_type', 'aggregator_feed')
->setDisplayOptions('view', array( ->setDisplayOptions('view', array(
......
<?php
/**
* @file
* Contains \Drupal\aggregator\Tests\ItemWithoutFeedTest.
*/
namespace Drupal\aggregator\Tests;
use Drupal\aggregator\Entity\Item;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests clean handling of an item with a missing feed ID.
*
* @group aggregator
*/
class ItemWithoutFeedTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['aggregator', 'options'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('aggregator_feed');
$this->installEntitySchema('aggregator_item');
}
/**
* Tests attempting to create a feed item without a feed.
*/
public function testEntityCreation() {
$entity = Item::create([
'title' => t('Llama 2'),
'path' => 'https://groups.drupal.org/',
]);
$violations = $entity->validate();
$this->assertCount(1, $violations);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment