public function MediaFeedsMapperEnclosureTestCase::test in Media Feeds 7
Test importing.
File
- tests/
media_feeds_mapper_enclosure.test, line 52 - Test case for the Feeds mapping API for the media module using SimplePieParser and FeedsEncolsure.
Class
- MediaFeedsMapperEnclosureTestCase
- Class for testing the Media Feeds media_internet mapper using FeedsEnclosure.
Code
public function test() {
// Create a content type with a media field.
$contentType = $this
->createContentType(array(), array(
'alpha' => array(
'type' => 'media',
'widget' => 'media_generic',
),
));
// Create a FeedsSimplePieParser configuration.
$this
->createImporterConfiguration();
$this
->setPlugin('syndication', 'FeedsSimplePieParser');
$this
->setSettings('syndication', 'FeedsNodeProcessor', array(
'content_type' => $contentType,
));
$this
->addMappings('syndication', array(
array(
'source' => 'title',
'target' => 'title',
),
array(
'source' => 'enclosures',
'target' => 'field_alpha',
),
));
// Import.
$this
->createFeedNode('syndication', url('testing/feeds/flickr.xml', array(
'absolute' => TRUE,
)));
$this
->assertText('Created 4 nodes');
// Assert: Files imported.
$files = array(
'tubing.jpeg',
'foosball.jpeg',
'attersee.jpeg',
'hstreet.jpeg',
);
$entities = db_select('feeds_item')
->fields('feeds_item', array(
'entity_id',
))
->condition('id', 'syndication')
->execute();
foreach ($entities as $entity) {
$this
->drupalGet('node/' . $entity->entity_id . '/edit');
$this
->assertRaw(array_shift($files));
}
$this
->assertTrue(count($files) == 0, 'All files found.');
}