You are here

public function FeedsEntityProcessorPropertyTest::testDefaultValues in Feeds entity processor 7

Tests if default values are used for properties that are not mapped.

File

tests/src/FeedsEntityProcessorPropertyTest.test, line 118
Contains FeedsEntityProcessorPropertyTest.

Class

FeedsEntityProcessorPropertyTest
Tests importing entities with properties of various data types.

Code

public function testDefaultValues() {
  $title = $this
    ->randomString();
  $created = REQUEST_TIME - 86400;

  // Set bundle and set default values for required properties.
  $this
    ->setSettings('syndication', 'FeedsEntityProcessorFeeds_entity_processor_test', array(
    'bundle' => $this->bundle,
    'values[title]' => $title,
    'values[status]' => '1',
    'values[created]' => $created,
    'values[entity][entity_type]' => 'node',
    'values[entity][entity_id]' => $this->node->nid,
    'values[user]' => 1,
  ));
  $this
    ->addMappings('syndication', array(
    0 => array(
      'source' => 'guid',
      'target' => 'guid',
      'unique' => TRUE,
    ),
  ));

  // Run import.
  $this
    ->importURL('syndication', $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds_entity_processor') . '/tests/resources/test_content.csv');
  $this
    ->assertText('Created 1 test entity');

  // Check values of imported entity.
  $entity = entity_load_single('feeds_entity_processor_test', 1);
  $this
    ->assertEqual($title, $entity->title);
  $this
    ->assertEqual($this->bundle, $entity->type);
  $this
    ->assertEqual(1, $entity->status);
  $this
    ->assertEqual(1, $entity->uid);
  $this
    ->assertEqual($this->node->nid, $entity->etid);
  $this
    ->assertEqual('node', $entity->entity_type);
  $this
    ->assertEqual($created, $entity->created);
}