You are here

public function ActivityUiTest::testActivityRevisions in CRM Core 8

Same name and namespace in other branches
  1. 8.2 modules/crm_core_activity/src/Tests/ActivityUiTest.php \Drupal\crm_core_activity\Tests\ActivityUiTest::testActivityRevisions()

Test activity revisions.

File

modules/crm_core_activity/src/Tests/ActivityUiTest.php, line 272

Class

ActivityUiTest
Tests the UI for Activity CRUD operations.

Namespace

Drupal\crm_core_activity\Tests

Code

public function testActivityRevisions() {
  $user = $this
    ->drupalCreateUser([
    'administer crm_core_activity entities',
    'view all crm_core_activity revisions',
  ]);
  $this
    ->drupalLogin($user);

  // Create customer contact.
  $customer = Individual::create([
    'name' => [
      'given' => 'John',
      'family' => 'Smith',
    ],
    'type' => 'customer',
  ]);
  $customer
    ->save();
  $meeting_activity = [
    'title[0][value]' => 'Pellentesque',
    'activity_date[0][value][date]' => $this
      ->randomDate(),
    'activity_date[0][value][time]' => $this
      ->randomTime(),
    'activity_notes[0][value]' => $this
      ->randomString(),
    'activity_participants[0][target_id]' => $customer
      ->label() . ' (' . $customer
      ->id() . ')',
  ];
  $this
    ->drupalPostForm('crm-core/activity/add/meeting', $meeting_activity, 'Save Activity');
  $meeting_activity_1 = [
    'title[0][value]' => 'Pellentesque rev1',
  ];
  $this
    ->drupalPostForm('crm-core/activity/1/edit', $meeting_activity_1, 'Save Activity');
  $meeting_activity_2 = [
    'title[0][value]' => 'Pellentesque rev2',
  ];
  $this
    ->drupalPostForm('crm-core/activity/1/edit', $meeting_activity_2, 'Save Activity');
  $this
    ->drupalGet('crm-core/activity/1/revisions');
  $this
    ->assertLinkByHref('crm-core/activity/1');
  $this
    ->assertLinkByHref('crm-core/activity/1/revisions/2/view');
  $this
    ->drupalGet('crm-core/activity/1/revisions/2/view');
  $this
    ->assertText('Pellentesque rev2');
}