You are here

protected function ConfigEntityQueryTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php \Drupal\system\Tests\Entity\ConfigEntityQueryTest::setUp()

Performs setup tasks before each individual test method is run.

Overrides KernelTestBase::setUp

File

core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php, line 49
Contains \Drupal\system\Tests\Entity\ConfigEntityQueryTest.

Class

ConfigEntityQueryTest
Tests Config Entity Query functionality.

Namespace

Drupal\system\Tests\Entity

Code

protected function setUp() {
  parent::setUp();
  $this->entities = array();
  $this->factory = $this->container
    ->get('entity.query');

  // These two are here to make sure that matchArray needs to go over several
  // non-matches on every levels.
  $array['level1']['level2a'] = 9;
  $array['level1a']['level2'] = 9;

  // The tests match array.level1.level2.
  $array['level1']['level2'] = 1;
  $entity = entity_create('config_query_test', array(
    'label' => $this
      ->randomMachineName(),
    'id' => '1',
    'number' => 31,
    'array' => $array,
  ));
  $this->entities[] = $entity;
  $entity
    ->enforceIsNew();
  $entity
    ->save();
  $array['level1']['level2'] = 2;
  $entity = entity_create('config_query_test', array(
    'label' => $this
      ->randomMachineName(),
    'id' => '2',
    'number' => 41,
    'array' => $array,
  ));
  $this->entities[] = $entity;
  $entity
    ->enforceIsNew();
  $entity
    ->save();
  $array['level1']['level2'] = 1;
  $entity = entity_create('config_query_test', array(
    'label' => 'test_prefix_' . $this
      ->randomMachineName(),
    'id' => '3',
    'number' => 59,
    'array' => $array,
  ));
  $this->entities[] = $entity;
  $entity
    ->enforceIsNew();
  $entity
    ->save();
  $array['level1']['level2'] = 2;
  $entity = entity_create('config_query_test', array(
    'label' => $this
      ->randomMachineName() . '_test_suffix',
    'id' => '4',
    'number' => 26,
    'array' => $array,
  ));
  $this->entities[] = $entity;
  $entity
    ->enforceIsNew();
  $entity
    ->save();
  $array['level1']['level2'] = 3;
  $entity = entity_create('config_query_test', array(
    'label' => $this
      ->randomMachineName() . '_TEST_contains_' . $this
      ->randomMachineName(),
    'id' => '5',
    'number' => 53,
    'array' => $array,
  ));
  $this->entities[] = $entity;
  $entity
    ->enforceIsNew();
  $entity
    ->save();
}