function MessageResourceTestBase::createEntity
Creates the entity to be tested.
Return value
\Drupal\Core\Entity\EntityInterface The entity to be tested.
Overrides EntityResourceTestBase::createEntity
File
- 
              core/modules/ contact/ tests/ src/ Functional/ Rest/ MessageResourceTestBase.php, line 50 
Class
- MessageResourceTestBase
- Resource test base for the ContactMessage entity.
Namespace
Drupal\Tests\contact\Functional\RestCode
protected function createEntity() {
  if (!ContactForm::load('camelids')) {
    // Create a "Camelids" contact form.
    ContactForm::create([
      'id' => 'camelids',
      'label' => 'Llama',
      'message' => 'Let us know what you think about llamas',
      'reply' => 'Llamas are indeed awesome!',
      'recipients' => [
        '[email protected]',
        '[email protected]',
      ],
    ])->save();
  }
  $message = Message::create([
    'contact_form' => 'camelids',
    'subject' => 'Llama Gabilondo',
    'message' => 'Llamas are awesome!',
  ]);
  $message->save();
  return $message;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
