Commit ffd4d6a8 authored by alexpott's avatar alexpott

Issue #2840595 by amateescu, Berdir: The 'Source feed' field of aggregator...

Issue #2840595 by amateescu, Berdir: The 'Source feed' field of aggregator items has to be updated and marked as required
parent 622deefb
......@@ -37,3 +37,24 @@ function aggregator_update_8001() {
/**
* @} End of "addtogroup updates-8.0.0-rc".
*/
/**
* @addtogroup updates-8.2.x
* @{
*/
/**
* Make the 'Source feed' field for aggregator items required.
*/
function aggregator_update_8200() {
// aggregator_update_8001() did not update the last installed field storage
// definition for the aggregator item's 'Source feed' field.
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$field_definition = $definition_update_manager->getFieldStorageDefinition('fid', 'aggregator_item');
$field_definition->setRequired(TRUE);
$definition_update_manager->updateFieldStorageDefinition($field_definition);
}
/**
* @} End of "addtogroup updates-8.2.x".
*/
<?php
namespace Drupal\aggregator\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
/**
* Tests that node settings are properly updated during database updates.
*
* @group aggregator
*/
class AggregatorUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz',
];
}
/**
* Tests that the 'Source feed' field is required.
*
* @see aggregator_update_8200()
*/
public function testSourceFeedRequired() {
// Check that the 'fid' field is not required prior to the update.
$field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('fid', 'aggregator_item');
$this->assertFalse($field_definition->isRequired());
// Run updates.
$this->runUpdates();
// Check that the 'fid' field is now required.
$field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('fid', 'aggregator_item');
$this->assertTrue($field_definition->isRequired());
}
}
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