You are here

protected function SupportTicketTestBase::drupalCreateSupportTicket in Support Ticketing System 8

Creates a support_ticket based on default settings.

Parameters

array $settings: (optional) An associative array of settings for the support_ticket, as used in entity_create(). Override the defaults by specifying the key and value in the array, for example:

$this
  ->drupalCreateNode(array(
  'title' => t('Hello, world!'),
  'type' => 'article',
));

The following defaults are provided:

  • body: Random string using the default filter format:
$settings['body'][0] = array(
  'value' => $this
    ->randomMachineName(32),
  'format' => filter_default_format(),
);
  • title: Random string.
  • type: 'page'.
  • uid: The currently logged in user, or anonymous.

Return value

\Drupal\support_ticket\Entity\SupportTicket The created support ticket.

5 calls to SupportTicketTestBase::drupalCreateSupportTicket()
SupportTicketAccessTest::testSupportTicketAccess in modules/support_ticket/src/Tests/SupportTicketAccessTest.php
Runs basic tests for support_ticket_access function.
SupportTicketTitleXSSTest::testSupportTicketTitleXSS in modules/support_ticket/src/Tests/SupportTicketTitleXSSTest.php
Tests XSS functionality with a support_ticket entity.
SupportTicketViewLanguageTest::testViewLanguage in modules/support_ticket/src/Tests/SupportTicketViewLanguageTest.php
Tests the language extra field display.
SupportTicketViewTest::testHtmlHeadLinks in modules/support_ticket/src/Tests/SupportTicketViewTest.php
Tests the html head links.
SupportTicketViewTest::testMultiByteUtf8 in modules/support_ticket/src/Tests/SupportTicketViewTest.php
Tests that we store and retrieve multi-byte UTF-8 characters correctly.

File

modules/support_ticket/src/Tests/SupportTicketTestBase.php, line 193
Contains \Drupal\support_ticket\Tests\SupportTicketTestBase.

Class

SupportTicketTestBase
Sets up ticket type.

Namespace

Drupal\support_ticket\Tests

Code

protected function drupalCreateSupportTicket(array $settings = array()) {

  // Populate defaults array.
  $settings += array(
    'body' => array(
      array(
        'value' => $this
          ->randomMachineName(32),
        'format' => filter_default_format(),
      ),
    ),
    'title' => $this
      ->randomMachineName(8),
    'support_ticket_type' => 'ticket',
    'uid' => \Drupal::currentUser()
      ->id(),
  );
  $support_ticket = entity_create('support_ticket', $settings);
  $support_ticket
    ->save();
  return $support_ticket;
}