You are here

public function ActivityTypePluginTest::testActivityTypePlugin in CRM Core 8

Same name and namespace in other branches
  1. 8.3 modules/crm_core_activity/tests/src/Kernel/ActivityTypePluginTest.php \Drupal\Tests\crm_core_activity\Kernel\ActivityTypePluginTest::testActivityTypePlugin()
  2. 8.2 modules/crm_core_activity/tests/src/Kernel/ActivityTypePluginTest.php \Drupal\Tests\crm_core_activity\Kernel\ActivityTypePluginTest::testActivityTypePlugin()

Tests activity type plugin.

File

modules/crm_core_activity/tests/src/Kernel/ActivityTypePluginTest.php, line 55

Class

ActivityTypePluginTest
Unit test for activity type plugin.

Namespace

Drupal\Tests\crm_core_activity\Kernel

Code

public function testActivityTypePlugin() {

  /** @var \Drupal\crm_core_activity\Entity\ActivityType $activity_type */
  $activity_type = $this->container
    ->get('entity_type.manager')
    ->getStorage('crm_core_activity_type')
    ->create([
    'name' => 'Test type',
    'type' => 'test_type',
    'description' => 'Test type description.',
    'plugin_id' => 'generic',
  ]);
  $activity_type
    ->save();
  $individual_1 = Individual::create([
    'type' => 'customer',
    'name' => [
      'given' => 'John',
      'family' => 'Smith',
    ],
    'email_value' => 'test1@example.com',
    'email_type' => 'private',
  ]);
  $individual_1
    ->save();
  $individual_2 = Individual::create([
    'type' => 'customer',
    'name' => [
      'given' => 'Mark',
      'family' => 'Jones',
    ],
    'email_value' => 'test2@example.com',
    'email_type' => 'corporate',
  ]);
  $individual_2
    ->save();
  $activity = Activity::create([
    'type' => 'test_type',
    'title' => 'Activity title',
    'activity_participants' => [
      $individual_1,
      $individual_2,
    ],
  ]);
  $instance = $this->pluginManager
    ->createInstance('generic');
  $this
    ->assertEquals($instance
    ->display($activity), []);
  $this
    ->assertEquals($instance
    ->label($activity), $activity
    ->label());
  $this
    ->assertEquals($activity
    ->label(), 'Activity title');
}