You are here

protected function RestfulJsonApiTestCase::createEntities in RESTful 7.2

Create test entities.

Return value

Entity[] An array of entities.

3 calls to RestfulJsonApiTestCase::createEntities()
RestfulJsonApiTestCase::setUp in tests/RestfulJsonApiTestCase.test
Sets up a Drupal site for running functional and integration tests.
RestfulJsonApiTestCase::testAlternativeIdField in tests/RestfulJsonApiTestCase.test
Test alternative ID field.
RestfulJsonApiTestCase::testPagination in tests/RestfulJsonApiTestCase.test
Test pagination.

File

tests/RestfulJsonApiTestCase.test, line 80
Contains \RestfulJsonApiTestCase.

Class

RestfulJsonApiTestCase
Class RestfulJsonApiTestCase.

Code

protected function createEntities() {
  $entities = array();
  $entities[] = entity_create('entity_test', array(
    'name' => 'main',
    'uid' => $this->account->uid,
  ));
  $entities[0]
    ->save();
  $entities[] = entity_create('entity_test', array(
    'name' => 'main',
    'uid' => $this->account->uid,
  ));
  $entities[1]
    ->save();
  $entities[] = entity_create('entity_test', array(
    'name' => 'main',
    'uid' => $this->account->uid,
  ));
  $entities[0]->entity_reference_single[LANGUAGE_NONE][] = array(
    'target_id' => $entities[1]->pid,
  );
  $entities[0]
    ->save();
  $entities[2]->entity_reference_single[LANGUAGE_NONE][] = array(
    'target_id' => $entities[0]->pid,
  );
  $entities[2]->entity_reference_multiple[LANGUAGE_NONE][] = array(
    'target_id' => $entities[0]->pid,
  );
  $entities[2]->entity_reference_multiple[LANGUAGE_NONE][] = array(
    'target_id' => $entities[1]->pid,
  );
  $entities[2]
    ->save();
  return $entities;
}