Projet

Général

Profil

Révision 950416da

Ajouté par Assos Assos il y a plus de 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/rules/tests/rules_test.rules.inc
1 1
<?php
2 2

  
3 3
/**
4
 * @file Includes any rules integration provided by the module.
4
 * @file
5
 * Includes any rules integration provided by the module.
5 6
 */
6 7

  
7 8
/**
8 9
 * Implements hook_rules_event_info().
9 10
 */
10 11
function rules_test_rules_event_info() {
11
  return array('rules_test_event' => array(
12
    'label' => t('Test event'),
13
    'class' => 'RulesTestEventHandler',
14
  ));
12
  return array(
13
    'rules_test_event' => array(
14
      'label' => t('Test event'),
15
      'class' => 'RulesTestEventHandler',
16
    ),
17
  );
15 18
}
16 19

  
17 20
/**
......
51 54
    'label' => t('Test condition returning false'),
52 55
    'group' => t('Rules test'),
53 56
  );
57
  $items['rules_test_condition_apostrophe'] = array(
58
    'label' => t("Test use of an apostrophe (') in a condition label"),
59
    'group' => t('Rules test'),
60
  );
54 61
  // A condition for testing passing entities wrapped.
55 62
  $items['rules_test_condition_node_wrapped'] = array(
56 63
    'label' => t('Content is published'),
......
85 92
  return FALSE;
86 93
}
87 94

  
95
/**
96
 * Condition testing use of an apostrophe in a condition label.
97
 *
98
 * Specifically, we want to ensure that special characters do not show up as
99
 * HTML-encoded in the user interface.
100
 */
101
function rules_test_condition_apostrophe($settings, $state, $element) {
102
  if (!$element instanceof RulesCondition) {
103
    throw new Exception('Rules element has not been passed to condition.');
104
  }
105
  rules_log('condition apostrophe called');
106
  return TRUE;
107
}
108

  
88 109
/**
89 110
 * Condition implementation receiving the node wrapped.
90 111
 */
......
198 219
      'base' => 'rules_test_type_save',
199 220
      'label' => t('Save test type'),
200 221
      'parameter' => array(
201
        'node' => array('type' => 'rules_test_type', 'label' => t('Test content'), 'save' => TRUE),
222
        'node' => array(
223
          'type' => 'rules_test_type',
224
          'label' => t('Test content'),
225
          'save' => TRUE,
226
        ),
202 227
      ),
203 228
      'group' => t('Node'),
204 229
    ),
......
240 265
  public function execute($node) {
241 266
    rules_log('Action called with node ' . $node->nid);
242 267
  }
268

  
243 269
}
244 270

  
245 271
/**
......
269 295
 */
270 296
class RulesTestTypeWrapper extends RulesIdentifiableDataWrapper implements RulesDataWrapperSavableInterface {
271 297

  
298
  /**
299
   * Overrides RulesIdentifiableDataWrapper::extractIdentifier().
300
   */
272 301
  protected function extractIdentifier($data) {
273 302
    return $data->nid;
274 303
  }
275 304

  
305
  /**
306
   * Overrides RulesIdentifiableDataWrapper::load().
307
   */
276 308
  protected function load($id) {
277 309
    return node_load($id);
278 310
  }
279 311

  
312
  /**
313
   * Implements RulesDataWrapperSavableInterface::save().
314
   */
280 315
  public function save() {
281 316
    node_save($this->value());
282 317
  }
318

  
283 319
}
284 320

  
285 321
/**
......
307 343
  public function evaluate(RulesState $state) {
308 344
    // Do nothing.
309 345
  }
346

  
310 347
}
311 348

  
312 349
/**

Formats disponibles : Unified diff