protected function InstantArticleContentEntityNormalizerTest::setUp in Facebook Instant Articles 8.2
Same name and namespace in other branches
- 3.x 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\KernelCode
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,
]);
}