You are here

public function SalesforceMappingMapTestCase::testMapOverview in Salesforce Suite 7.3

Tests mapping overview form.

File

modules/salesforce_mapping/tests/salesforce_mapping.map.test, line 43

Class

SalesforceMappingMapTestCase
Tests the user interface for mapping Drupal entities to Salesforce objects.

Code

public function testMapOverview() {

  // Form throws message if it cannot connect to Salesforce.
  $this
    ->drupalGet($this->adminPath);
  $this
    ->assertText('You are not authorized to access this page.', 'Message appears when Salesforce is not connected.');

  // Map overview page appears after connecting to Salesforce.
  $this
    ->salesforceConnect();
  $this
    ->drupalGet($this->adminPath);
  $this
    ->assertLink('Add salesforce mapping', 0, 'Add new mapping link appears.');
  $this
    ->assertLink('Import salesforce mapping', 0, 'Import mapping link appears.');
  $this
    ->assertRaw('<table id="entity-ui-overview-form"', 'Map listing table appears.');
  $this
    ->assertRaw('<td colspan="10" class="empty message">None.</td>', 'Map listing table is empty.');

  // Create a map.
  $this
    ->createSalesforceMapping('foo', 'foobar');
  $this
    ->drupalGet($this->adminPath);
  $this
    ->assertRaw('<td>user</td>', 'Drupal entity type shows up in the table.');
  $this
    ->assertRaw('<td>Contact</td>', 'Salesforce object type shows up in the table.');
  $this
    ->assertRaw('<span class=\'entity-status-custom\' title=\'A custom configuration by a user.\'>Custom</span>', 'Status declared as custom.');
  $this
    ->assertRaw('<a href="/admin/structure/salesforce/mappings/manage/foobar">edit</a>', 'Edit link is in table.');
  $this
    ->assertRaw('<a href="/admin/structure/salesforce/mappings/manage/foobar/clone">clone</a>', 'Clone link is in table.');
  $this
    ->assertRaw('<a href="/admin/structure/salesforce/mappings/manage/foobar/delete?destination=admin/structure/salesforce/mappings">delete</a>', 'Delete link is in table.');
  $this
    ->assertRaw('<a href="/admin/structure/salesforce/mappings/manage/foobar/export">export</a>', 'Export link is in table.');

  // Delete map.
  $this
    ->clickLink('delete');
  $this
    ->drupalPost(NULL, array(), 'Confirm');
  $this
    ->assertText('Deleted Salesforce Mapping foo.', 'Delete request posted correctly.');
  $this
    ->assertRaw('<td colspan="10" class="empty message">None.</td>', 'Map listing table is empty after deleting map.');
}