3 namespace Drupal\Tests\views\Kernel\Plugin;
5 use Drupal\user\Entity\User;
6 use Drupal\views\Views;
9 * Provides a base class for a testing a relationship.
11 * @see \Drupal\views\Tests\Handler\JoinTest
12 * @see \Drupal\views\Tests\Plugin\RelationshipTest
14 abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
21 public static $modules = ['system', 'user', 'field'];
24 * @var \Drupal\user\Entity\User
31 protected function setUpFixtures() {
32 $this->installEntitySchema('user');
33 $this->installConfig(['user']);
34 parent::setUpFixtures();
36 // Create a record for uid 1.
37 $this->rootUser = User::create(['name' => $this->randomMachineName()]);
38 $this->rootUser->save();
40 Views::viewsData()->clear();
44 * Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition().
46 * Adds a uid column to test the relationships.
50 protected function schemaDefinition() {
51 $schema = parent::schemaDefinition();
53 $schema['views_test_data']['fields']['uid'] = [
54 'description' => "The {users_field_data}.uid of the author of the beatle entry.",
65 * Overrides \Drupal\views\Tests\ViewTestBase::viewsData().
67 * Adds a relationship for the uid column.
69 protected function viewsData() {
70 $data = parent::viewsData();
71 $data['views_test_data']['uid'] = [
73 'help' => t('The test data UID'),
76 'base' => 'users_field_data',
77 'base field' => 'uid',