You are here

relation_rules_test.module in Relation 7

Test for Relation's Rules implementation.

File

tests/relation_rules_test.module
View source
<?php

/**
 * @file
 * Test for Relation's Rules implementation.
 */

/**
 * Implementation of hook_default_rules_configuration().
 */
function relation_rules_test_default_rules_configuration() {
  $nid = variable_get('relation_rules_test_nid', 0);
  $items = array();
  $items['rules_test'] = entity_import('rules_config', '{ "rules_test" : {
    "LABEL" : "test",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "relation" ],
    "ON" : [ "node_insert" ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "list\\u003centity\\u003e", "value" : [ "" ] },
          "PROVIDE" : { "variable_added" : { "new_relation" : "New relation" } }
        }
      },
      { "list_add" : { "list" : [ "new-relation" ], "item" : [ "node" ] } },
      { "variable_add" : {
          "USING" : { "type" : "node", "value" : "' . $nid . '" },
          "PROVIDE" : { "variable_added" : { "node_1" : "Node 1" } }
        }
      },
      { "list_add" : { "list" : [ "new-relation" ], "item" : [ "node-1" ] } },
      { "entity_create" : {
          "USING" : {
            "type" : "relation",
            "param_relation_type" : "symmetric",
            "param_endpoints" : [ "new-relation" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "entity_save" : { "data" : [ "entity-created" ], "immediate" : 1 } },
      { "relation_rules_load_related" : {
          "USING" : { "left" : [ "node" ], "relation_type" : "symmetric" },
          "PROVIDE" : { "endpoints" : { "endpoints" : "List of related entities" } }
        }
      },
      { "entity_delete" : { "data" : [ "endpoints:0" ] } }
    ]
  }
}');
  return $items;
}