You are here

protected function InstantArticleContentEntityNormalizerTest::setUp in Facebook Instant Articles 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/InstantArticleContentEntityNormalizerTest.php \Drupal\Tests\fb_instant_articles\Kernel\InstantArticleContentEntityNormalizerTest::setUp()

Overrides KernelTestBase::setUp

File

tests/src/Kernel/InstantArticleContentEntityNormalizerTest.php, line 69

Class

InstantArticleContentEntityNormalizerTest
Test the Drupal Client wrapper.

Namespace

Drupal\Tests\fb_instant_articles\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this->serializer = $this->container
    ->get('serializer');
  $this
    ->installSchema('system', 'sequences');
  $this
    ->installConfig([
    'system',
    'field',
  ]);
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('node');

  // Create a user to use for testing.
  $this->userName = $this
    ->randomMachineName();
  $account = User::create([
    'name' => $this->userName,
    'status' => 1,
  ]);
  $account
    ->enforceIsNew();
  $account
    ->save();
  $this->account = $account;

  // Create the node bundles required for testing.
  $type = NodeType::create([
    'type' => 'article',
    'name' => 'article',
  ]);
  $type
    ->save();

  // Create a couple fields attached to entity_test entity type, which comes
  // from entity_test module.
  foreach ([
    'field_one',
    'field_two',
  ] as $field_name) {
    $field_storage = FieldStorageConfig::create([
      'field_name' => $field_name,
      'entity_type' => 'node',
      'type' => 'string_long',
    ]);
    $field_storage
      ->save();
    $instance = FieldConfig::create([
      'field_storage' => $field_storage,
      'bundle' => 'article',
      'label' => $this
        ->randomMachineName(),
    ]);
    $instance
      ->save();
  }

  // Create a view mode for testing.
  $this->display = EntityViewDisplay::create([
    'targetEntityType' => 'node',
    'bundle' => 'article',
    'mode' => 'default',
    'status' => TRUE,
  ]);
}