You are here

protected function EntitySerializationTest::setUp in Zircon Profile 8

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

Overrides NormalizerTestBase::setUp

File

core/modules/serialization/src/Tests/EntitySerializationTest.php, line 61
Contains \Drupal\serialization\Tests\EntitySerializationTest.

Class

EntitySerializationTest
Tests that entities can be serialized to supported core formats.

Namespace

Drupal\serialization\Tests

Code

protected function setUp() {
  parent::setUp();

  // User create needs sequence table.
  $this
    ->installSchema('system', array(
    'sequences',
  ));

  // Create a test user to use as the entity owner.
  $this->user = \Drupal::entityManager()
    ->getStorage('user')
    ->create([
    'name' => 'serialization_test_user',
    'mail' => 'foo@example.com',
    'pass' => '123456',
  ]);
  $this->user
    ->save();

  // Create a test entity to serialize.
  $this->values = array(
    'name' => $this
      ->randomMachineName(),
    'user_id' => $this->user
      ->id(),
    'field_test_text' => array(
      'value' => $this
        ->randomMachineName(),
      'format' => 'full_html',
    ),
  );
  $this->entity = entity_create('entity_test_mulrev', $this->values);
  $this->entity
    ->save();
  $this->serializer = $this->container
    ->get('serializer');
  $this
    ->installConfig(array(
    'field',
  ));
}