Project

General

Profile

Paste
Download (2.34 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / webform_validation / tests / WebformValidationUuidFeaturesTestCase.test @ 65389548

1
<?php
2

    
3
/**
4
 * Test the features integration of webform_validation.
5
 */
6
class WebformValidationUuidFeaturesTestCase extends DrupalWebTestCase {
7

    
8
  /**
9
   * {@inheritdoc}
10
   */
11
  public static function getInfo() {
12
    return array(
13
      'name' => t('Webform Validation: UUID features integration'),
14
      'description' => t('Test the integration of webform_validation and uuid_features.'),
15
      'group' => t('Webform'),
16
      'dependencies' => array('webform_validation_testing'),
17
    );
18
  }
19

    
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public function setUp() {
24
    parent::setUp(array('webform_validation_testing'));
25
    module_load_include('entity.inc', 'uuid');
26
  }
27

    
28
  /**
29
   * Test whether the validations are loaded properly by enabling the feature.
30
   */
31
  public function testValidationsLoaded() {
32
    $uuids = array('4ca52408-9bbd-49fa-baae-698c37dc5f42');
33
    $nids = entity_get_id_by_uuid('node', $uuids);
34
    $nid = reset($nids);
35
    $rules = webform_validation_get_node_rules($nid);
36
    $this->assertEqual(1, count($rules));
37
    $rule = reset($rules);
38
    unset($rule['ruleid']);
39
    unset($rule['nid']);
40
    $k = array_keys($rule['components']);
41
    $rule['components'] = array_combine($k, $k);
42
    $this->assertEqual(array(
43
      'rulename' => 'answer_42',
44
      'validator' => 'specific_value',
45
      'data' => '42',
46
      'error_message' => 'That’s the wrong answer.',
47
      'negate' => FALSE,
48
      'weight' => '0',
49
      'components' => array(
50
        1 => 1,
51
      ),
52
    ), $rule);
53
  }
54

    
55
  /**
56
   * Test whether re-exporting the feature yields the same result.
57
   */
58
  public function testValidationExport() {
59
    features_include_defaults();
60

    
61
    // Get data for a new export.
62
    $uuids = array('4ca52408-9bbd-49fa-baae-698c37dc5f42');
63
    $data = features_invoke('uuid_node', 'features_export_render', 'webform_validation_uuid_features_test', $uuids);
64
    $nodes = eval($data['uuid_features_default_content']);
65
    $this->assertEqual(1, count($nodes));
66
    $node = (object) reset($nodes);
67
    $this->assertEqual($uuids[0], $node->uuid);
68
    $this->assertTrue(!empty($node->webform['validation']));
69

    
70
    // Compare data with the defaults in the feature.
71
    $defaults = features_get_default('uuid_node', 'webform_validation_testing');
72
    $default_node = (object) reset($defaults);
73
    $this->assertEqual($default_node->webform['validation'], $node->webform['validation']);
74
  }
75

    
76
}