public function SalesforceMappingEntitiesTestCase::testObjectTypeMapEntity in Salesforce Suite 7.3
Test the salesforce_mapping entity.
File
- modules/
salesforce_mapping/ tests/ salesforce_mapping.entities.test, line 75
Class
- SalesforceMappingEntitiesTestCase
- Tests the entities storing the Drupal to Salesforce mapping.
Code
public function testObjectTypeMapEntity() {
// Map entity type exists.
$entity_info = entity_get_info('salesforce_mapping');
$this
->assertTrue(isset($entity_info['label']), 'Entity has a label');
$this
->assertEqual('Salesforce Mapping', $entity_info['label'], 'Entity has expected label.');
// Create a salesforce_mapping entity object.
$test_map = entity_create('salesforce_mapping', $this->example_map);
$this
->assertEqual('salesforce_mapping', $test_map
->entityType(), 'Creating a new entity object works as expected.');
// Save the entity to the database.
$result = entity_save('salesforce_mapping', $test_map);
$this
->assertEqual(SAVED_NEW, $result, 'Entity saved as new.');
$test_map_dbs = entity_load_multiple_by_name('salesforce_mapping', array(
$this->example_map['name'],
));
$test_map_db = reset($test_map_dbs);
$this
->assertEqual('bar', $test_map_db->salesforce_object_type, 'Newly created entity has the correct object type.');
// Save the entity again and see it be updated.
$result = entity_save('salesforce_mapping', $test_map);
$this
->assertEqual(SAVED_UPDATED, $result, 'Re-saved entity saved as updated.');
// Delete the entity from the database.
entity_delete('salesforce_mapping', $this->example_map['name']);
$all_entities = entity_load('salesforce_mapping');
$this
->assertTrue(empty($all_entities));
}