You are here

public function PMPAPIPushWebTestCase::setUp in Public Media Platform API Integration 7

Sets up the test environment.

Overrides DrupalWebTestCase::setUp

See also

DrupalWebTestCase::setUp()

File

pmpapi_push/tests/pmpapi_push.test, line 26

Class

PMPAPIPushWebTestCase
Tests the functionality of the PMPAPI push module.

Code

public function setUp() {
  parent::setUp(array(
    'pmpapi_push',
    'file_entity',
  ));

  // Create and log in our privileged user.
  $this->privileged_user = $this
    ->drupalCreateUser(array(
    'administer PMP API',
  ));
  $this
    ->drupalLogin($this->privileged_user);

  // Set up client_id, client_secret, host
  // @TODO: Throw this into a separate test -- using GUI?
  module_load_include('php', 'pmpapi', 'tests/settings');
  $vars = pmpapi_test_get_secret_vars();
  variable_set('pmpapi_auth_client_id', $vars['client_id']);
  variable_set('pmpapi_auth_client_secret', $vars['client_secret']);
  variable_set('pmpapi_base_url', $vars['host']);

  // Turn off caching
  variable_set('pmpapi_cache', FALSE);
  $this
    ->assertTrue(variable_get('pmpapi_push_push_active'), 'Push is active.');
  $this
    ->setUpFiles();

  // Set up node mapping
  $this->nodetype = 'testnode';
  $node_settings = array(
    'entity_type' => 'node',
    'bundle_name' => $this->nodetype,
    'target_profile' => 'story',
    'mapping' => array(
      'title' => 'title',
      'body' => 'contentencoded',
      'field_image' => 'item-image',
    ),
  );
  $this
    ->setUpEntityMapping($node_settings);

  // Set up image mapping
  $image_settings = array(
    'entity_type' => 'file',
    'bundle_name' => 'image',
    'target_profile' => 'image',
    'mapping' => array(
      'filename' => 'title',
    ),
  );
  $this
    ->setUpEntityMapping($image_settings);
}