64bdb8e0181093522496c20257f1ae8435a97c1f
[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  */
12 class AggregatorUpdateTest extends UpdatePathTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   protected function setDatabaseDumpFiles() {
18     $this->databaseDumpFiles = [
19       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz',
20     ];
21   }
22
23   /**
24    * Tests that the 'Source feed' field is required.
25    *
26    * @see aggregator_update_8200()
27    */
28   public function testSourceFeedRequired() {
29     // Check that the 'fid' field is not required prior to the update.
30     $field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('fid', 'aggregator_item');
31     $this->assertFalse($field_definition->isRequired());
32
33     // Run updates.
34     $this->runUpdates();
35
36     // Check that the 'fid' field is now required.
37     $field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('fid', 'aggregator_item');
38     $this->assertTrue($field_definition->isRequired());
39   }
40
41   /**
42    * Tests that the 'Update interval' field has a default value.
43    */
44   public function testUpdateIntervalDefaultValue() {
45     // Check that the 'refresh' field does not have a default value prior to the
46     // update.
47     $field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('refresh', 'aggregator_feed');
48     $this->assertSame([], $field_definition->getDefaultValueLiteral());
49
50     // Run updates.
51     $this->runUpdates();
52
53     // Check that the 'refresh' has a default value now.
54     $field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('refresh', 'aggregator_feed');
55     $this->assertSame([['value' => 3600]], $field_definition->getDefaultValueLiteral());
56   }
57
58 }