You are here

public function ActivityTypePluginTest::testDeletion in CRM Core 8.3

Test deletion.

File

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

Class

ActivityTypePluginTest
Unit test for activity type plugin.

Namespace

Drupal\Tests\crm_core_activity\Kernel

Code

public function testDeletion() : void {

  /** @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.',
  ]);
  $activity_type
    ->save();

  /** @var \Drupal\crm_core_activity\Entity\ActivityType $activity_type */
  $activity = $this->container
    ->get('entity_type.manager')
    ->getStorage('crm_core_activity')
    ->create([
    'name' => 'Test activity',
    'type' => 'test_type',
    'description' => 'Test type description.',
  ]);
  $activity
    ->save();
  $activity_type
    ->delete();

  /** @var \Psr\Log\Test\TestLogger $logger */
  $logger = $this->container
    ->get('logger.channel.crm_core_activity');
  $logger
    ->hasInfoThatContains('Deleted 1 activities due to deletion of activity type.');
}