RelationshipJoinTestBase.php in Drupal 9
File
core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php
View source
<?php
namespace Drupal\Tests\views\Kernel\Plugin;
use Drupal\user\Entity\User;
use Drupal\views\Views;
abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
protected static $modules = [
'system',
'user',
'field',
];
protected $rootUser;
protected function setUpFixtures() {
$this
->installEntitySchema('user');
$this
->installConfig([
'user',
]);
parent::setUpFixtures();
$this->rootUser = User::create([
'name' => $this
->randomMachineName(),
]);
$this->rootUser
->save();
Views::viewsData()
->clear();
}
protected function schemaDefinition() {
$schema = parent::schemaDefinition();
$schema['views_test_data']['fields']['uid'] = [
'description' => "The {users_field_data}.uid of the author of the beatle entry.",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
];
return $schema;
}
protected function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['uid'] = [
'title' => t('UID'),
'help' => t('The test data UID'),
'relationship' => [
'id' => 'standard',
'base' => 'users_field_data',
'base field' => 'uid',
],
];
return $data;
}
}