You are here

protected function RelationTestBase::createRelationDirectional in Relation 8.2

Same name and namespace in other branches
  1. 8 src/Tests/RelationTestBase.php \Drupal\relation\Tests\RelationTestBase::createRelationDirectional()

Creates a Directional relation.

1 call to RelationTestBase::createRelationDirectional()
RelationTestBase::setUp in src/Tests/RelationTestBase.php
Sets up a Drupal site for running functional and integration tests.

File

src/Tests/RelationTestBase.php, line 192

Class

RelationTestBase
Provides common helper methods for Taxonomy module tests.

Namespace

Drupal\relation\Tests

Code

protected function createRelationDirectional() {

  // Article 1 --> Page 3
  $this->endpoints_directional = $this->endpoints;
  $this->endpoints_directional[1]['target_id'] = $this->node3
    ->id();
  $this->endpoints_directional[1]['delta'] = 1;
  $this->relation_type_directional = $this->relation_types['directional']['id'];
  $this->relation_id_directional = $this
    ->saveRelation($this->relation_type_directional, $this->endpoints_directional);

  // Page 3 --> Page 4
  $this->endpoints_directional2 = $this->endpoints;
  $this->endpoints_directional2[0]['target_id'] = $this->node3
    ->id();
  $this->endpoints_directional2[1]['target_id'] = $this->node4
    ->id();
  $this
    ->saveRelation($this->relation_type_directional, $this->endpoints_directional2);

  // Page 3 --> Page 4
  $this->endpoints_entitysame[1]['delta'] = 1;
  $this->relation_type_directional_entitysame = $this->relation_types['directional_entitysame']['id'];
  $this
    ->saveRelation($this->relation_type_directional_entitysame, $this->endpoints_entitysame);

  // Page 3 --> Page 5
  $this->endpoints_entitysame[1]['target_id'] = $this->node5
    ->id();
  $this
    ->saveRelation($this->relation_type_directional_entitysame, $this->endpoints_entitysame);

  // Page 4 --> Page 3
  $this->endpoints_entitysame[0]['target_id'] = $this->node4
    ->id();
  $this->endpoints_entitysame[1]['target_id'] = $this->node3
    ->id();
  $this
    ->saveRelation($this->relation_type_directional_entitysame, $this->endpoints_entitysame);

  // User 1 --> Page 3
  $this->endpoints_entitydifferent[1]['delta'] = 1;
  $this->relation_type_directional_entitydifferent = $this->relation_types['directional_entitydifferent']['id'];
  $this
    ->saveRelation($this->relation_type_directional_entitydifferent, $this->endpoints_entitydifferent);

  // User 1 --> Page 4
  $this->endpoints_entitydifferent[1]['target_id'] = $this->node4
    ->id();
  $this
    ->saveRelation($this->relation_type_directional_entitydifferent, $this->endpoints_entitydifferent);
}