Backup of db before drupal security update
[yaffs-website] / web / core / modules / views_ui / tests / src / Functional / ReportFieldsTest.php
1 <?php
2
3 namespace Drupal\Tests\views_ui\Functional;
4
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\field\Entity\FieldStorageConfig;
7
8 /**
9  * Tests the Views fields report page.
10  *
11  * @group views_ui
12  */
13 class ReportFieldsTest extends UITestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $testViews = ['test_field_field_test'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public static $modules = ['entity_test'];
24
25   /**
26    * Tests the Views fields report page.
27    */
28   public function testReportFields() {
29     $this->drupalGet('admin/reports/fields/views-fields');
30     $this->assertRaw('Used in views', 'Title appears correctly');
31     $this->assertRaw('No fields have been used in views yet.', 'No results message appears correctly.');
32
33     // Set up the field_test field.
34     $field_storage = FieldStorageConfig::create([
35       'field_name' => 'field_test',
36       'type' => 'integer',
37       'entity_type' => 'entity_test',
38     ]);
39     $field_storage->save();
40
41     $field = FieldConfig::create([
42       'field_name' => 'field_test',
43       'entity_type' => 'entity_test',
44       'bundle' => 'entity_test',
45     ]);
46     $field->save();
47
48     $this->drupalGet('admin/reports/fields/views-fields');
49     // Assert that the newly created field appears in the overview.
50     $this->assertRaw('<td>field_test</td>', 'Field name appears correctly');
51     $this->assertRaw('>test_field_field_test</a>', 'View name appears correctly');
52     $this->assertRaw('Used in views', 'Title appears correctly');
53   }
54
55 }