Pull merge.
[yaffs-website] / web / core / modules / aggregator / tests / src / Functional / Update / AggregatorUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\aggregator\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests that node settings are properly updated during database updates.
9  *
10  * @group aggregator
11  * @group legacy
12  */
13 class AggregatorUpdateTest extends UpdatePathTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setDatabaseDumpFiles() {
19     $this->databaseDumpFiles = [
20       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz',
21     ];
22   }
23
24   /**
25    * Tests that the 'Source feed' field is required.
26    *
27    * @see aggregator_update_8200()
28    */
29   public function testSourceFeedRequired() {
30     // Check that the 'fid' field is not required prior to the update.
31     $field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('fid', 'aggregator_item');
32     $this->assertFalse($field_definition->isRequired());
33
34     // Run updates.
35     $this->runUpdates();
36
37     // Check that the 'fid' field is now required.
38     $field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('fid', 'aggregator_item');
39     $this->assertTrue($field_definition->isRequired());
40   }
41
42   /**
43    * Tests that the 'Update interval' field has a default value.
44    */
45   public function testUpdateIntervalDefaultValue() {
46     // Check that the 'refresh' field does not have a default value prior to the
47     // update.
48     $field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('refresh', 'aggregator_feed');
49     $this->assertSame([], $field_definition->getDefaultValueLiteral());
50
51     // Run updates.
52     $this->runUpdates();
53
54     // Check that the 'refresh' has a default value now.
55     $field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('refresh', 'aggregator_feed');
56     $this->assertSame([['value' => 3600]], $field_definition->getDefaultValueLiteral());
57   }
58
59 }