function RelationshipsTestBase::setUp

Same name in other branches
  1. 4.0.x tests/src/Kernel/RelationshipsTestBase.php \Drupal\Tests\ctools\Kernel\RelationshipsTestBase::setUp()

Overrides KernelTestBase::setUp

File

tests/src/Kernel/RelationshipsTestBase.php, line 42

Class

RelationshipsTestBase

Namespace

Drupal\Tests\ctools\Kernel

Code

protected function setUp() : void {
    parent::setUp();
    $this->installSchema('system', [
        'sequences',
    ]);
    $this->installEntitySchema('user');
    $this->installEntitySchema('node_type');
    $this->installEntitySchema('node');
    $this->installConfig('node');
    $page = $this->createEntity('node_type', [
        'type' => 'page',
        'name' => 'Page',
    ]);
    node_add_body_field($page);
    $article = $this->createEntity('node_type', [
        'type' => 'article',
        'name' => 'Article',
    ]);
    // Not adding the body field the articles so that we can perform a test.
    $foo = $this->createEntity('node_type', [
        'type' => 'foo',
        'name' => 'Foo',
    ]);
    node_add_body_field($foo);
    $this->relationshipManager = $this->container
        ->get('plugin.manager.ctools.relationship');
    $user = $this->createEntity('user', [
        'name' => 'test_user',
        'password' => 'password',
        'mail' => 'mail@test.com',
        'status' => 1,
    ]);
    $node1 = $this->createEntity('node', [
        'title' => 'Node 1',
        'type' => 'page',
        'uid' => $user->id(),
        'body' => 'This is a test',
    ]);
    $node2 = $this->createEntity('node', [
        'title' => 'Node 2',
        'type' => 'article',
        'uid' => $user->id(),
    ]);
    $node3 = $this->createEntity('node', [
        'title' => 'Node 3',
        'type' => 'foo',
        'uid' => $user->id(),
    ]);
    $node4 = $this->createEntity('node', [
        'title' => 'Node 4',
        'type' => 'foo',
    ])
        ->set('uid', NULL);
    $this->entities = [
        'user' => $user,
        'node1' => $node1,
        'node2' => $node2,
        'node3' => $node3,
        'node4' => $node4,
    ];
}