You are here

trait CategoryCreationTrait in Mass Contact 8

Helper methods to create mass contact categories for testing.

Hierarchy

2 files declare their use of CategoryCreationTrait
MassContactCategoryTest.php in tests/src/Kernel/Entity/MassContactCategoryTest.php
MassContactTestBase.php in tests/src/Functional/MassContactTestBase.php

File

tests/src/Kernel/CategoryCreationTrait.php, line 11

Namespace

Drupal\Tests\mass_contact\Kernel
View source
trait CategoryCreationTrait {

  /**
   * Creates a category.
   *
   * @return \Drupal\mass_contact\Entity\MassContactCategoryInterface
   *   The new category entity.
   */
  public function createCategory(array $settings = []) {
    $settings += [
      'id' => mb_strtolower($this
        ->randomMachineName()),
      'label' => $this
        ->randomString(),
      'recipients' => [],
      'selected' => FALSE,
    ];
    $category = MassContactCategory::create($settings);
    $category
      ->save();
    return $category;
  }

}

Members