source: sipes/modules_contrib/feeds/tests/feeds_mapper_filefield.test @ 92213c1

stableversion-3.0
Last change on this file since 92213c1 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 2.6 KB
Línea 
1<?php
2module_load_include('test', 'feeds', 'tests/feeds_mapper');
3
4/**
5 * @file
6 * Test case for Filefield mapper mappers/filefield.inc.
7 */
8
9/**
10 * Class for testing Feeds FileField mapper.
11 *
12 * @todo Add a test for enclosures returned as array
13 * @todo Add a test for enclosures returned as string
14 * @todo Add a test for enclosures using local file
15 */
16class FeedsMapperFileFieldTestCase extends FeedsMapperTestCase {
17  public static function getInfo() {
18    return array(
19      'name' => 'Mapper: FileField',
20      'description' => 'Test Feeds Mapper support for FileField CCK fields. <strong>Requires SimplePie library</strong>.',
21      'group' => 'Feeds',
22      'dependencies' => array('content', 'filefield', 'libraries'),
23    );
24  }
25
26  public function setUp() {
27    parent::setUp(array('content', 'filefield', 'libraries'));
28  }
29
30  /**
31   * Basic test loading a single entry CSV file.
32   */
33  public function test() {
34    $static_title = $this->randomName();
35    //Create content type
36    $typename = $this->createContentType(array(), array(
37      'files' => array(
38        'type' => 'filefield',
39        'settings' => array(
40          'multiple' =>  '1',
41          'file_extensions' => 'jpg'
42        ),
43      ),
44    ));
45
46    // Create importer configuration.
47    $this->createImporterConfiguration(); //Create a default importer configuration
48    $this->setPlugin('syndication', 'FeedsSimplePieParser');
49    $this->setSettings('syndication', 'FeedsNodeProcessor', array('content_type' => $typename)); //Processor settings
50    $this->addMappings('syndication', array(
51      array(
52        'source' => 'title',
53        'target' => 'title'
54      ),
55      array(
56        'source' => 'timestamp',
57        'target' => 'created'
58      ),
59      array(
60        'source' => 'description',
61        'target' => 'body'
62      ),
63      array(
64        'source' => 'enclosures',
65        'target' => 'field_files'
66      ),
67    ));
68
69    $nid = $this->createFeedNode('syndication', $GLOBALS['base_url'] .'/'. drupal_get_path('module', 'feeds') .'/tests/feeds/flickr.xml');
70    $this->assertText('Created 4 '. $typename .' nodes.');
71
72    $filename = array('3596408735_ce2f0c4824_b', '2640019371_495c3f51a2_b', '3686290986_334c427e8c_b', '2640845934_85c11e5a18_b');
73    for ($i = 0; $i < 4; $i++) {
74      $this->drupalGet('node/'. ($i+2) .'/edit');
75      $this->assertText($filename[$i]);
76    }
77  }
78
79  /**
80   * Handle file field widgets.
81   */
82  public function selectFieldWidget($fied_name, $field_type) {
83    if ($field_type == 'filefield') {
84      return 'filefield_widget';
85    }
86    else {
87      return parent::selectFieldWidget($fied_name, $field_type);
88    }
89  }
90}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.