You are here

protected function SupportTicketTestBase::supportTicketCreateSupportTicketType in Support Ticketing System 8

Creates a custom ticket type based on default settings.

Parameters

array $values: An array of settings to change from the defaults. Example: 'type' => 'foo'.

Return value

\Drupal\support_ticket\Entity\SupportTicketType Created support ticket type.

File

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

Class

SupportTicketTestBase
Sets up ticket type.

Namespace

Drupal\support_ticket\Tests

Code

protected function supportTicketCreateSupportTicketType(array $values = array()) {

  // Find a non-existent random type name.
  if (!isset($values['type'])) {
    do {
      $id = strtolower($this
        ->randomMachineName(8));
    } while (SupportTicketType::load($id));
  }
  else {
    $id = $values['type'];
  }
  $values += array(
    'type' => $id,
    'name' => $id,
  );
  $type = entity_create('support_ticket_type', $values);
  $status = $type
    ->save();
  support_ticket_add_body_field($type);
  \Drupal::service('router.builder')
    ->rebuild();
  $this
    ->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created support ticket type %type.', array(
    '%type' => $type
      ->id(),
  )));
  return $type;
}