Projet

Général

Profil

Paste
Télécharger (2,1 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / feeds / tests / feeds_mapper_hooks.test @ ed9a13f1

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains FeedsMapperHookTestCase.
6
 */
7

    
8
/**
9
 * Test case for the various callbacks implemented for mappers.
10
 */
11
class FeedsMapperHookTestCase extends FeedsMapperTestCase {
12

    
13
  /**
14
   * {@inheritdoc}
15
   */
16
  public static function getInfo() {
17
    return array(
18
      'name' => 'Mapper: Hooks and callbacks',
19
      'description' => 'Test case for the various callbacks implemented for mappers.',
20
      'group' => 'Feeds',
21
    );
22
  }
23

    
24
  /**
25
   * Basic test loading a double entry CSV file.
26
   */
27
  public function test() {
28

    
29
    // Create and configure importer.
30
    $this->createImporterConfiguration();
31
    $this->addMappings('syndication', array(
32
      0 => array(
33
        'source' => 'title',
34
        'target' => 'title',
35
      ),
36
      1 => array(
37
        'source' => 'description',
38
        'target' => 'test_target',
39
      ),
40
    ));
41

    
42
    // Checks that alter hooks are invoked.
43
    $this->assertText(t('The target description was altered.'));
44

    
45
    // Inherently tests preprocess callbacks.
46
    // @see feeds_tests_mapper_set_target()
47
    $nid = $this->createFeedNode();
48
    $this->drupalGet('node/2/edit');
49
    $body_value = $this->xpath('//*[@name = "body[und][0][value]"]');
50
    $value = unserialize((string) $body_value[0]);
51
    $this->assertTrue(!empty($value));
52

    
53
    // Tests old-style target keys.
54
    $this->addMappings('syndication', array(
55
      2 => array(
56
        'source' => 'url',
57
        'target' => 'test_target_compat',
58
      ),
59
    ));
60

    
61
    // Click gear to get form.
62
    $this->drupalPostAJAX(NULL, array(), 'mapping_settings_edit_2');
63

    
64
    // Set some settings.
65
    $edit = array(
66
      'config[2][settings][checkbox]' => 1,
67
      'config[2][settings][textfield]' => 'Some text',
68
      'config[2][settings][textarea]' => 'Textarea value: Didery dofffffffffffffffffffffffffffffffffffff',
69
      'config[2][settings][radios]' => 'option1',
70
      'config[2][settings][select]' => 'option4',
71
    );
72
    $this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_2');
73
    $this->assertText(t('* Changes made to target configuration are stored temporarily. Click Save to make your changes permanent.'));
74
  }
75

    
76
}