You are here

protected function RelationTestBase::saveRelation in Relation 8

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

Saves a relation.

Parameters

string $relation_type: Machine name of the relation type.

array $endpoints: An array containing the endpoints.

Return value

string|int|null

4 calls to RelationTestBase::saveRelation()
RelationTestBase::createRelationDirectional in src/Tests/RelationTestBase.php
Creates a Directional relation.
RelationTestBase::createRelationOctopus in src/Tests/RelationTestBase.php
Creates an Octopus (4-ary) relation.
RelationTestBase::createRelationSymmetric in src/Tests/RelationTestBase.php
Creates a Symmetric relation.
RelationTestBase::createRelationUnary in src/Tests/RelationTestBase.php
Creates an Unary relation.

File

src/Tests/RelationTestBase.php, line 256

Class

RelationTestBase
Provides common helper methods for Taxonomy module tests.

Namespace

Drupal\relation\Tests

Code

protected function saveRelation($relation_type, array $endpoints) {
  $relation = Relation::create(array(
    'relation_type' => $relation_type,
  ));
  $relation->endpoints = $endpoints;
  $relation
    ->save();
  if ($this->sleep) {
    sleep(1);
  }
  return $relation
    ->id();
}