ReportFieldsTest.php in Drupal 10
File
core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php
View source
<?php
namespace Drupal\Tests\views_ui\Functional;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
class ReportFieldsTest extends UITestBase {
public static $testViews = [
'test_field_field_test',
];
protected $defaultTheme = 'stark';
protected static $modules = [
'entity_test',
];
public function testReportFields() {
$this
->drupalGet('admin/reports/fields/views-fields');
$this
->assertSession()
->pageTextContains('Used in views');
$this
->assertSession()
->pageTextContains('No fields have been used in views yet.');
$field_storage = FieldStorageConfig::create([
'field_name' => 'field_test',
'type' => 'integer',
'entity_type' => 'entity_test',
]);
$field_storage
->save();
$field = FieldConfig::create([
'field_name' => 'field_test',
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
]);
$field
->save();
$this
->drupalGet('admin/reports/fields/views-fields');
$this
->assertSession()
->responseContains('<td>field_test</td>');
$this
->assertSession()
->responseContains('>test_field_field_test</a>');
$this
->assertSession()
->pageTextContains('Used in views');
}
}