more module updates
This commit is contained in:
		| @@ -17,11 +17,17 @@ $plugin = array( | ||||
|   'get children' => 'uuid_entity_uuid_get_children', | ||||
| ); | ||||
|  | ||||
| /** | ||||
|  * @todo document me properly | ||||
|  */ | ||||
| function uuid_entity_uuid_get_child($plugin, $parent, $child) { | ||||
|   $plugins = uuid_entity_uuid_get_children($plugin, $parent); | ||||
|   return $plugins[$parent . ':' . $child]; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * @todo document me properly | ||||
|  */ | ||||
| function uuid_entity_uuid_get_children($original_plugin, $parent) { | ||||
|   $entities = entity_get_info(); | ||||
|   $plugins = array(); | ||||
|   | ||||
| @@ -121,14 +121,14 @@ function hook_uuid_entities_post_rebuild($plan_name) { | ||||
| /** | ||||
|  * Let other modules do things before default entities are created on revert. | ||||
|  */ | ||||
| function hook_uuid_entities_pre_rebuild($plan_name) { | ||||
| function hook_uuid_entities_pre_revert($plan_name) { | ||||
|  | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Let other modules do things after default entities are created on revert. | ||||
|  */ | ||||
| function hook_uuid_entities_post_rebuild($plan_name) { | ||||
| function hook_uuid_entities_post_revert($plan_name) { | ||||
|  | ||||
| } | ||||
|  | ||||
| @@ -152,12 +152,6 @@ function hook_uuid_entities_features_export_field_alter($entity_type, &$entity, | ||||
| function hook_uuid_uri_data($data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Alter UUID URI data after processing. | ||||
|  */ | ||||
| function hook_uuid_uri_data($data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Alter entity URI before creating UUID URI. | ||||
|  */ | ||||
|   | ||||
| @@ -125,10 +125,52 @@ function file_entity_uuid_load(&$entities, $entity_type) { | ||||
| function file_entity_uuid_presave(&$entity, $entity_type) { | ||||
|   if ($entity_type == 'file') { | ||||
|     entity_property_uuid_to_id($entity, 'user', 'uid'); | ||||
|  | ||||
|     // Write the new file to the local filesystem. | ||||
|     if (isset($entity->file_contents)) { | ||||
|       $directory = drupal_dirname($entity->uri); | ||||
|       // Don't try to write it if it uses a stream wrapper that isn't writeable | ||||
|       // (for example, if it is a remotely-hosted video). | ||||
|       $scheme = file_uri_scheme($entity->uri); | ||||
|       $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE); | ||||
|       if (empty($wrappers[$scheme])) { | ||||
|         return; | ||||
|       } | ||||
|  | ||||
|       // Check for an existing file with the same URI. | ||||
|       $existing_files = file_load_multiple(array(), array('uri' => $entity->uri)); | ||||
|       $existing = (object) array('uri' => NULL, 'uuid' => NULL); | ||||
|       if (count($existing_files)) { | ||||
|         $existing = reset($existing_files); | ||||
|       } | ||||
|  | ||||
|       // If this is a new file and there is an existing file with the same URI, | ||||
|       // but a different uuid then rename this file. | ||||
|       if ($entity->is_new && $entity->uri == $existing->uri && $entity->uuid != $existing->uuid) { | ||||
|         $uri = $entity->uri; | ||||
|         $replace = FILE_EXISTS_RENAME; | ||||
|       } | ||||
|       // If this has an id, meaning UUID has already matched the uuid to an | ||||
|       // existing file, but it has a URI that matches a file with a different | ||||
|       // uuid, then load the file with the matching uuid and use the URI from | ||||
|       // that file. The existing file with the matching uuid is most likely a | ||||
|       // file that was previously renamed, e.g. as in the condition above, to | ||||
|       // avoid conflict. The uuid matches because they are the same file, but | ||||
|       // the URI does not because an incrementing number was added as part of | ||||
|       // the renaming. | ||||
|       elseif ($entity->uri == $existing->uri && $entity->uuid != $existing->uuid) { | ||||
|         $file = file_load($entity->fid); | ||||
|         $uri = $file->uri; | ||||
|         $replace = FILE_EXISTS_REPLACE; | ||||
|       } | ||||
|       // Otherwise create a new file or replace the existing file contents. | ||||
|       else { | ||||
|         $uri = $entity->uri; | ||||
|         $replace = FILE_EXISTS_REPLACE; | ||||
|       } | ||||
|  | ||||
|       $directory = drupal_dirname($uri); | ||||
|       file_prepare_directory($directory, FILE_CREATE_DIRECTORY); | ||||
|       file_unmanaged_save_data(base64_decode($entity->file_contents), $entity->uri, FILE_EXISTS_REPLACE); | ||||
|       $entity->uri = file_unmanaged_save_data(base64_decode($entity->file_contents), $uri, $replace); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @@ -368,7 +410,7 @@ function node_uuid_entities_features_export_entity_alter(&$entity, $entity_type) | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implementation of hook_uuid_entities_features_export_entity_alter(). | ||||
|  * Implementations hook_uuid_entities_features_export_entity_alter(). | ||||
|  */ | ||||
| function user_uuid_entities_features_export_entity_alter(&$entity, $entity_type) { | ||||
|   if ($entity_type == 'user') { | ||||
|   | ||||
| @@ -76,9 +76,9 @@ function uuid_get_core_entity_info() { | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_entity_info_alter(). | ||||
|  * Implements hook_entity_info_alter(). | ||||
|  * | ||||
|  * @see uuid_core_entity_info(). | ||||
|  * @see uuid_core_entity_info() | ||||
|  */ | ||||
| function uuid_entity_info_alter(&$info) { | ||||
|   foreach (uuid_get_core_entity_info() as $entity_type => $core_info) { | ||||
| @@ -91,21 +91,24 @@ function uuid_entity_info_alter(&$info) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_entity_property_info_alter(). | ||||
|  * Implements hook_entity_property_info_alter(). | ||||
|  * | ||||
|  * This adds the UUID as an entity property for all UUID-enabled entities | ||||
|  * which automatically gives us token and Rules integration. | ||||
|  */ | ||||
| function uuid_entity_property_info_alter(&$info) { | ||||
|   foreach (entity_get_info() as $entity_type => $entity_info) { | ||||
|     if (isset($entity_info['uuid']) && $entity_info['uuid'] == TRUE && !empty($entity_info['entity keys']['uuid'])) { | ||||
|     if (isset($entity_info['uuid']) && $entity_info['uuid'] == TRUE  | ||||
|       && !empty($entity_info['entity keys']['uuid']) | ||||
|       && empty($info[$entity_type]['properties'][$entity_info['entity keys']['uuid']])) { | ||||
|       $info[$entity_type]['properties'][$entity_info['entity keys']['uuid']] = array( | ||||
|         'label' => t('UUID'), | ||||
|         'type' => 'text', | ||||
|         'description' => t('The universally unique ID.'), | ||||
|         'schema field' => $entity_info['entity keys']['uuid'], | ||||
|       ); | ||||
|       if (!empty($entity_info['entity keys']['revision uuid'])) { | ||||
|       if (!empty($entity_info['entity keys']['revision uuid'])  | ||||
|         && empty($info[$entity_type]['properties'][$entity_info['entity keys']['revision uuid']])) { | ||||
|         $info[$entity_type]['properties'][$entity_info['entity keys']['revision uuid']] = array( | ||||
|           'label' => t('Revision UUID'), | ||||
|           'type' => 'text', | ||||
| @@ -118,7 +121,7 @@ function uuid_entity_property_info_alter(&$info) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_entity_presave(). | ||||
|  * Implements hook_entity_presave(). | ||||
|  * | ||||
|  * This is where all UUID-enabled entities get their UUIDs. | ||||
|  */ | ||||
| @@ -131,7 +134,19 @@ function uuid_entity_presave($entity, $entity_type) { | ||||
|     } | ||||
|     if (!empty($info['entity keys']['revision uuid'])) { | ||||
|       $vuuid_key = $info['entity keys']['revision uuid']; | ||||
|       if ((isset($entity->revision) && $entity->revision == TRUE) || empty($entity->{$vuuid_key})) { | ||||
|       // If this entity comes from a remote environment and have a revision UUID | ||||
|       // that exists locally we should not create a new revision. Because | ||||
|       // otherwise revisions won't be tracked universally. | ||||
|       // TODO: Move code dependent on the uuid_services module into it's own | ||||
|       // implementation of hook_entity_presave(). | ||||
|       if (!empty($entity->uuid_services) && isset($entity->{$vuuid_key})) { | ||||
|         $vuuid_exists = (bool) entity_get_id_by_uuid($entity_type, array($entity->{$vuuid_key}), TRUE); | ||||
|         if ($vuuid_exists) { | ||||
|           $entity->revision = FALSE; | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       if ((isset($entity->revision) && $entity->revision == TRUE && empty($entity->uuid_services)) || empty($entity->{$vuuid_key})) { | ||||
|         $entity->{$vuuid_key} = uuid_generate(); | ||||
|       } | ||||
|     } | ||||
| @@ -151,12 +166,26 @@ function uuid_entity_presave($entity, $entity_type) { | ||||
| /** | ||||
|  * Load entities by their UUID, that only should containing UUID references. | ||||
|  * | ||||
|  * Optionally load revisions by their VUUID by passing it into $conditions. | ||||
|  * Ex. $conditions['vuuid'][$vuuid] | ||||
|  * | ||||
|  * This function is mostly useful if you want to load an entity from the local | ||||
|  * database that only should contain UUID references. | ||||
|  * | ||||
|  * @see entity_load() | ||||
|  */ | ||||
| function entity_uuid_load($entity_type, $uuids = array(), $conditions = array(), $reset = FALSE) { | ||||
|   // Allow Revision UUID to be passed in $conditions and translate. | ||||
|   $entity_info[$entity_type] = entity_get_info($entity_type); | ||||
|   $revision_key = $entity_info[$entity_type]['entity keys']['revision']; | ||||
|   if (isset($entity_info[$entity_type]['entity keys']['revision uuid'])) { | ||||
|     $revision_uuid_key = $entity_info[$entity_type]['entity keys']['revision uuid']; | ||||
|   } | ||||
|   if (isset($revision_uuid_key) && isset($conditions[$revision_uuid_key])) { | ||||
|     $revision_id = entity_get_id_by_uuid($entity_type, array($conditions[$revision_uuid_key]), TRUE); | ||||
|     $conditions[$revision_key] = $revision_id[$conditions[$revision_uuid_key]]; | ||||
|     unset($conditions[$revision_uuid_key]); | ||||
|   } | ||||
|   $ids = entity_get_id_by_uuid($entity_type, $uuids); | ||||
|   $results = entity_load($entity_type, $ids, $conditions, $reset); | ||||
|   $entities = array(); | ||||
| @@ -209,6 +238,23 @@ function entity_uuid_save($entity_type, $entity) { | ||||
|     throw new UuidEntityException(t('Calling %function requires the Entity API module (!link).', array('%function' => __FUNCTION__, '!link' => 'http://drupal.org/project/entity'))); | ||||
|   } | ||||
|  | ||||
|   $info = entity_get_info($entity_type); | ||||
|   $uuid_key = $info['entity keys']['uuid']; | ||||
|   if (empty($entity->{$uuid_key}) || !uuid_is_valid($entity->{$uuid_key})) { | ||||
|     watchdog('Entity UUID', 'Attempted to save an entity with an invalid UUID', array(), WATCHDOG_ERROR); | ||||
|     return FALSE; | ||||
|   } | ||||
|  | ||||
|   // Falling back on the variable node_options_[type] is not something an API | ||||
|   // function should take care of. With normal (non UUID) nodes this is dealt | ||||
|   // with in the form submit handler, i.e. not in node_save(). | ||||
|   // But since using entity_uuid_save() usually means you're trying to manage | ||||
|   // entities remotely we do respect this variable here to make it work as the | ||||
|   // node form, but only if we explicitly haven't set $node->revision already. | ||||
|   if ($entity_type == 'node' && !isset($entity->revision) && in_array('revision', variable_get('node_options_' . $entity->type, array()))) { | ||||
|     $entity->revision = 1; | ||||
|   } | ||||
|  | ||||
|   entity_make_entity_local($entity_type, $entity); | ||||
|  | ||||
|   // Save the entity. | ||||
| @@ -259,6 +305,10 @@ function entity_make_entity_local($entity_type, $entity) { | ||||
|       $vid = NULL; | ||||
|       // Fetch the local revision ID by its UUID. | ||||
|       if (isset($entity->{$vuuid_key})) { | ||||
|         // It's important to note that the revision UUID might be set here but | ||||
|         // there might not exist a correspondant local revision ID in which case | ||||
|         // we should unset the assigned revision ID to not confuse anyone with | ||||
|         // revision IDs that might come from other environments. | ||||
|         $vids = entity_get_id_by_uuid($entity_type, array($entity->{$vuuid_key}), TRUE); | ||||
|         $vid = reset($vids); | ||||
|       } | ||||
| @@ -268,9 +318,10 @@ function entity_make_entity_local($entity_type, $entity) { | ||||
|       elseif (!empty($vid)) { | ||||
|         $entity->{$vid_key} = $vid; | ||||
|       } | ||||
|       // Nodes need this when trying to save an existing node without a vid. | ||||
|       // If the revision ID was unset before this (or just missing for some | ||||
|       // reason) we fetch the current revision ID to build a better | ||||
|       // representation of the node object we're working with. | ||||
|       if ($entity_type == 'node' && !isset($entity->vid) && !$entity->is_new) { | ||||
|         $entity->revision = 0; | ||||
|         $entity->vid = db_select('node', 'n') | ||||
|           ->condition('n.nid', $entity->nid) | ||||
|           ->fields('n', array('vid')) | ||||
| @@ -312,6 +363,7 @@ function entity_uuid_delete($entity_type, $uuid) { | ||||
|     // Fetch the local ID by its UUID. | ||||
|     $ids = entity_get_id_by_uuid($entity_type, array($uuid)); | ||||
|     $id = reset($ids); | ||||
|     $entity = entity_load($entity_type, array($id)); | ||||
|  | ||||
|     // Let other modules transform UUID references to local ID references. | ||||
|     $hook = 'entity_uuid_delete'; | ||||
| @@ -322,6 +374,9 @@ function entity_uuid_delete($entity_type, $uuid) { | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     if (empty($entity)) { | ||||
|       return FALSE; | ||||
|     } | ||||
|     // Delete the entity. | ||||
|     return entity_delete($entity_type, $id); | ||||
|   } | ||||
|   | ||||
| @@ -167,7 +167,7 @@ function _uuid_generate_pecl() { | ||||
| /** | ||||
|  * Generates a UUID v4 using PHP code. | ||||
|  * | ||||
|  * Based on code from @see http://php.net/uniqid#65879 , but corrected. | ||||
|  * Based on code from http://php.net/uniqid#65879, but corrected. | ||||
|  */ | ||||
| function _uuid_generate_php() { | ||||
|   // The field names refer to RFC 4122 section 4.1.2. | ||||
| @@ -188,6 +188,7 @@ function _uuid_generate_php() { | ||||
|  | ||||
|  | ||||
| // This is wrapped in an if block to avoid conflicts with PECL's uuid_is_valid(). | ||||
| if (!function_exists('uuid_is_valid')) { | ||||
|   /** | ||||
|    * Check that a string appears to be in the format of a UUID. | ||||
|    * | ||||
| @@ -197,7 +198,6 @@ function _uuid_generate_php() { | ||||
|    * @return | ||||
|    *   TRUE if the string is well formed. | ||||
|    */ | ||||
| if (!function_exists('uuid_is_valid')) { | ||||
|   function uuid_is_valid($uuid) { | ||||
|     return preg_match('/^' . UUID_PATTERN . '$/', $uuid); | ||||
|   } | ||||
|   | ||||
| @@ -4,10 +4,12 @@ core = 7.x | ||||
| package = UUID | ||||
| configure = admin/config/system/uuid | ||||
| files[] = uuid.test | ||||
| dependencies[] = node | ||||
| dependencies[] = user | ||||
|  | ||||
| ; Information added by drupal.org packaging script on 2013-09-11 | ||||
| version = "7.x-1.0-alpha5+0-dev" | ||||
| ; Information added by Drupal.org packaging script on 2014-09-23 | ||||
| version = "7.x-1.0-alpha6" | ||||
| core = "7.x" | ||||
| project = "uuid" | ||||
| datestamp = "1378899072" | ||||
| datestamp = "1411455150" | ||||
|  | ||||
|   | ||||
| @@ -29,7 +29,7 @@ function uuid_schema_field_definition() { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_schema_alter(). | ||||
|  * Implements hook_schema_alter(). | ||||
|  */ | ||||
| function uuid_schema_alter(&$schema = array()) { | ||||
|   $field = uuid_schema_field_definition(); | ||||
| @@ -230,3 +230,45 @@ function uuid_update_7102() { | ||||
|   _uuid_install_uuid_fields(); | ||||
|   uuid_sync_all(); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Modify the labels of all example entities created by the now removed | ||||
|  * uuid_default_entities_example.module to make it clear they're examples. | ||||
|  * Also remove the administrator role of any example user. | ||||
|  */ | ||||
| function uuid_update_7103() { | ||||
|   // These are UUIDs of all the example entities that might exist after having | ||||
|   // installed uuid_default_entities_example.module. | ||||
|   $info = entity_get_info(); | ||||
|   $uuids = array( | ||||
|     'node' => array( | ||||
|       'b0558664-c94b-3674-d9df-3e1696b2e471', | ||||
|       '5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837', | ||||
|     ), | ||||
|     'user' => array( | ||||
|       '7cf875e6-dc15-4404-f190-5a7c3e91d14c', | ||||
|     ), | ||||
|   ); | ||||
|   // we can't assume taxonomy is enabled | ||||
|   if (isset($info['taxonomy_term'])) { | ||||
|     $uuids['taxonomy_term'] = array( | ||||
|       'bcb92ce8-2236-e264-65c8-0c163ae716d1', | ||||
|       '4293a15c-531a-6164-7d1b-668ed019a6bd', | ||||
|       'af738a46-f278-cf84-d94d-9e03879fd71e', | ||||
|     ); | ||||
|   } | ||||
|   foreach (array_keys($uuids) as $entity_type) { | ||||
|     $info = entity_get_info($entity_type); | ||||
|     $entity_ids = entity_get_id_by_uuid($entity_type, $uuids[$entity_type]); | ||||
|     $entities = entity_load($entity_type, $entity_ids); | ||||
|     foreach ($entities as $entity) { | ||||
|       // Update the label to make it clear this is example content. | ||||
|       $entity->{$info['entity keys']['label']} = $entity->{$info['entity keys']['label']} . ' (UUID example)'; | ||||
|       // Remove the administrator role from any user. | ||||
|       if ($entity_type == 'user' && $rid = array_search('administrator', $entity->roles)) { | ||||
|         unset($entity->roles[$rid]); | ||||
|       } | ||||
|       entity_save($entity); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -25,7 +25,7 @@ module_load_include('inc', 'uuid', 'uuid.entity'); | ||||
| module_load_include('inc', 'uuid', 'uuid.core'); | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_menu(). | ||||
|  * Implements hook_menu(). | ||||
|  */ | ||||
| function uuid_menu() { | ||||
|   $items = array(); | ||||
| @@ -72,7 +72,7 @@ function uuid_menu() { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_ctools_plugin_directory(). | ||||
|  * Implements hook_ctools_plugin_directory(). | ||||
|  */ | ||||
| function uuid_ctools_plugin_directory($module, $plugin) { | ||||
|   if ($module == 'ctools') { | ||||
| @@ -81,7 +81,7 @@ function uuid_ctools_plugin_directory($module, $plugin) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_permission(). | ||||
|  * Implements hook_permission(). | ||||
|  */ | ||||
| function uuid_permission() { | ||||
|   return array( | ||||
| @@ -125,7 +125,7 @@ function uuid_hook_info() { | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * Implementation of hook_views_api(). | ||||
|  * Implements hook_views_api(). | ||||
|  */ | ||||
| function uuid_views_api() { | ||||
|   return array( | ||||
| @@ -135,24 +135,24 @@ function uuid_views_api() { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_module_implements_alter(). | ||||
|  * Implements hook_module_implements_alter(). | ||||
|  * | ||||
|  * Moves implementation of hook_entity_info_alter() to the bottom so it is | ||||
|  * Moves hook_entity_info_alter() implementation to the bottom so it is | ||||
|  * invoked after all modules relying on the entity API. | ||||
|  * | ||||
|  * @see uuid_entity_info_alter() | ||||
|  */ | ||||
| function uuid_module_implements_alter(&$Implementss, $hook) { | ||||
| function uuid_module_implements_alter(&$implementss, $hook) { | ||||
|   if ($hook == 'entity_info_alter') { | ||||
|     // Move our hook Implements to the bottom. | ||||
|     $group = $Implementss['uuid']; | ||||
|     unset($Implementss['uuid']); | ||||
|     $Implementss['uuid'] = $group; | ||||
|     $group = $implementss['uuid']; | ||||
|     unset($implementss['uuid']); | ||||
|     $implementss['uuid'] = $group; | ||||
|   } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements of hook_uuid_sync(). | ||||
|  * Implements hook_uuid_sync(). | ||||
|  */ | ||||
| function uuid_uuid_sync() { | ||||
|   foreach (entity_get_info() as $entity_type => $info) { | ||||
| @@ -185,7 +185,7 @@ function _uuid_sync_table($table, $id_field, $uuid_field) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implementation of hook_features_api(). | ||||
|  * Implements hook_features_api(). | ||||
|  * | ||||
|  * The Features support consists of exporting entities from a Deploy | ||||
|  * <em>fetch-only</em> plan. Deploy is only required to generate the feature | ||||
|   | ||||
| @@ -10,6 +10,9 @@ | ||||
|  */ | ||||
| class UUIDTestCase extends DrupalWebTestCase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   function setUp() { | ||||
|     parent::setUp(func_get_args()); | ||||
|   } | ||||
| @@ -27,6 +30,9 @@ class UUIDTestCase extends DrupalWebTestCase { | ||||
|  */ | ||||
| class UUIDAPITestCase extends UUIDTestCase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'UUID API', | ||||
| @@ -35,10 +41,16 @@ class UUIDAPITestCase extends UUIDTestCase { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   function setUp() { | ||||
|     parent::setUp('uuid'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Tests uuid function calls. | ||||
|    */ | ||||
|   function testAPIFunctions() { | ||||
|     // This is a valid UUID, we know that. | ||||
|     $valid_uuid = '0ab26e6b-f074-4e44-9da6-1205fa0e9761'; | ||||
| @@ -62,6 +74,9 @@ class UUIDAPITestCase extends UUIDTestCase { | ||||
|  */ | ||||
| class UUIDEntityTestCase extends UUIDTestCase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'Entity API functions', | ||||
| @@ -70,6 +85,9 @@ class UUIDEntityTestCase extends UUIDTestCase { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   function setUp() { | ||||
|     parent::setUp('uuid'); | ||||
|   } | ||||
| @@ -101,6 +119,9 @@ class UUIDEntityTestCase extends UUIDTestCase { | ||||
|  */ | ||||
| class UUIDUserTestCase extends UUIDTestCase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'User implementation', | ||||
| @@ -109,6 +130,9 @@ class UUIDUserTestCase extends UUIDTestCase { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   function setUp() { | ||||
|     // Some tests depends on the optional Entity API module. | ||||
|     if (module_exists('entity')) { | ||||
| @@ -161,6 +185,9 @@ class UUIDUserTestCase extends UUIDTestCase { | ||||
|  */ | ||||
| class UUIDNodeTestCase extends UUIDTestCase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'Node implementation', | ||||
| @@ -169,6 +196,9 @@ class UUIDNodeTestCase extends UUIDTestCase { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   function setUp() { | ||||
|     // Some tests depends on the optional Entity API module. | ||||
|     if (module_exists('entity')) { | ||||
| @@ -181,6 +211,9 @@ class UUIDNodeTestCase extends UUIDTestCase { | ||||
|  | ||||
|   /** | ||||
|    * Tests CRUD on nodes with UUID functions. | ||||
|    * | ||||
|    * @todo | ||||
|    *   Break out into multiple test methods to loosen coupling between tests. | ||||
|    */ | ||||
|   function testNodeCRUD() { | ||||
|     // Create some entities that we will work with. | ||||
| @@ -192,12 +225,16 @@ class UUIDNodeTestCase extends UUIDTestCase { | ||||
|  | ||||
|     // Test node update, without creating new revision. | ||||
|     $node_test = clone $node; | ||||
|     $node_test->title = 'new title'; | ||||
|     $node_test->title = 'original title'; | ||||
|     $node_test->revision = FALSE; | ||||
|     node_save($node_test); | ||||
|     $node_test = node_load($node->nid, FALSE, TRUE); | ||||
|     $this->assertEqual($node_test->uuid, $node->uuid, 'Node UUID was intact after update, when not creating new revision.'); | ||||
|     $this->assertEqual($node_test->vuuid, $node->vuuid, 'Node revision UUID was intact after updating, when not creating new revision.'); | ||||
|     // Save the original revision IDs that we will test with later. | ||||
|     $vid_old = $node_test->vid; | ||||
|     $vuuid_old = $node_test->vuuid; | ||||
|     $uuid_old = $node_test->uuid; | ||||
|  | ||||
|     // Test node update, with new revision. | ||||
|     $node_test = clone $node; | ||||
| @@ -210,10 +247,28 @@ class UUIDNodeTestCase extends UUIDTestCase { | ||||
|     $this->assertUUID($node_test->vuuid, 'The new node revision UUID was valid.'); | ||||
|  | ||||
|     // Test entity_uuid_load(). | ||||
|     // Save some variables that we will test against. | ||||
|     $nid_test = $node_test->nid; | ||||
|     $vid_test = $node_test->vid; | ||||
|     $uid_test = $user->uuid; | ||||
|     $uuid_test = $node_test->uuid; | ||||
|     $vuuid_test = $node_test->vuuid; | ||||
|     $nodes = entity_uuid_load('node', array($node->uuid), array(), TRUE); | ||||
|     $node_test = reset($nodes); | ||||
|     $this->assertEqual($node_test->nid, $node->nid, 'Node was correctly loaded with UUID.'); | ||||
|     $this->assertEqual($node_test->uid, $user->uuid, "Node property 'uid' was transformed to UUID when loaded with UUID."); | ||||
|     $this->assertEqual($node_test->nid, $nid_test, 'Node ID was correct when loading with UUID.'); | ||||
|     $this->assertEqual($node_test->vid, $vid_test, 'Node revision ID was correct when loading with UUID.'); | ||||
|     $this->assertEqual($node_test->uid, $uid_test, "Node author ID was transformed to UUID when loaded with UUID."); | ||||
|     $this->assertEqual($node_test->uuid, $uuid_test, 'Node UUID was correct when loading with UUID.'); | ||||
|     $this->assertEqual($node_test->vuuid, $vuuid_test, 'Node revision UUID was correct when loading with UUID.'); | ||||
|  | ||||
|     // Test entity_uuid_load() with conditions. | ||||
|     // Load the previous revision UUID that we saved earlier. | ||||
|     $nodes = entity_uuid_load('node', array($uuid_test), array('vuuid' => $vuuid_old)); | ||||
|     $node_test = reset($nodes); | ||||
|     $this->assertTrue((($node_test->uuid == $uuid_test) && ($node_test->nid && $node->nid)), 'The correct entity was loaded when loading a universal entity with a revision UUID condition.'); | ||||
|     $this->assertEqual($node_test->vuuid, $vuuid_old, 'Correct revision UUID was loaded when loading a universal entity with a revision UUID condition.'); | ||||
|     $this->assertEqual($node_test->vid, $vid_old, 'Correct revision ID was loaded when loading a universal entity with a revision UUID condition.'); | ||||
|     $this->assertEqual($node_test->title, 'original title', 'Correct title was loaded when loading a universal entity with a revision UUID condition.'); | ||||
|  | ||||
|     // The following tests depends on the optional Entity API module. | ||||
|     if (module_exists('entity')) { | ||||
| @@ -248,6 +303,72 @@ class UUIDNodeTestCase extends UUIDTestCase { | ||||
|       $this->assertUUID($node_test->vuuid, 'New node revision UUID was valid.'); | ||||
|       $this->assertEqual($node_test->uid, $node->uid, "Node property 'uid' was intact after saving with UUID, when creating new revision."); | ||||
|  | ||||
|       // Test the same thing again, but now triggering a new revision from a | ||||
|       // remote environment. | ||||
|       // TODO: Move this test to the uuid_services module. | ||||
|       $nodes = entity_uuid_load('node', array($node->uuid), array(), TRUE); | ||||
|       $node_test = reset($nodes); | ||||
|       // Store the current local revision ID to test with later. | ||||
|       $vid_old1 = $node_test->vid; | ||||
|       $vuuid_old1 = $node_test->vuuid; | ||||
|       // Simulate this node coming from a remote environment by generating | ||||
|       // IDs that won't match. Only the UUID match at this point. | ||||
|       $node_test->uuid_services = TRUE; | ||||
|       $nid_remote = rand(); | ||||
|       $vid_remote = rand(); | ||||
|       $vuuid_test = uuid_generate(); | ||||
|       $node_test->nid = $nid_test; | ||||
|       $node_test->vid = $vid_test; | ||||
|       $node_test->vuuid = $vuuid_test; | ||||
|       $node_test->revision = TRUE; | ||||
|       entity_uuid_save('node', $node_test); | ||||
|       $node_test = node_load($node->nid, FALSE, TRUE); | ||||
|       $this->assertNotEqual($node_test->vid, $vid_old1, 'A new revision was created, when trying to create new revision with new revision UUID from remote site'); | ||||
|       $this->assertEqual($node_test->vuuid, $vuuid_test, 'The revison UUID was preserved after saving with UUID, when trying to create new revision with new revision UUID from remote site.'); | ||||
|  | ||||
|       // Test the same thing again from a remote environment, but now with the | ||||
|       // same vuuid as once previosuly. This should not trigger a new revision. | ||||
|       // This covers the case of "dupe deployments" where a client might push a | ||||
|       // node several times. | ||||
|       // TODO: Move this test to the uuid_services module. | ||||
|       $nodes = entity_uuid_load('node', array($node->uuid), array(), TRUE); | ||||
|       $node_test = reset($nodes); | ||||
|       // Store the current local revision ID to test with later. | ||||
|       $vid_old2 = $node_test->vid; | ||||
|       // Simulate this node coming from a remote environment by generating | ||||
|       // IDs that won't match. | ||||
|       $node_test->uuid_services = TRUE; | ||||
|       $node_test->nid = $nid_test; | ||||
|       $node_test->vid = $vid_test; | ||||
|       $node_test->vuuid = $vuuid_test; | ||||
|       $node_test->revision = TRUE; | ||||
|       entity_uuid_save('node', $node_test); | ||||
|       $node_test = node_load($node->nid, FALSE, TRUE); | ||||
|       $this->assertEqual($node_test->vid, $vid_old2, 'A new revision was not created, when trying to create new revision with existing revision UUID from remote site.'); | ||||
|       $this->assertEqual($node_test->vuuid, $vuuid_test, 'The revison UUID was preserved after saving with UUID, when trying to create new revision with existing revision UUID from remote site.'); | ||||
|  | ||||
|       // Test the same this again, but now with an old revision. | ||||
|       $nodes = entity_uuid_load('node', array($uuid_old), array('vuuid' => $vuuid_old), TRUE); | ||||
|       $node_test = reset($nodes); | ||||
|       // Simulate this node coming from a remote environment by generating | ||||
|       // IDs that won't match. | ||||
|       $node_test->uuid_services = TRUE; | ||||
|       $node_test->nid = rand(); | ||||
|       $node_test->vid = rand(); | ||||
|       $node_test->revision = TRUE; | ||||
|       $node_test->title = 'newest title'; | ||||
|       entity_uuid_save('node', $node_test); | ||||
|       $node_test = node_load($node->nid, $vid_old, TRUE); | ||||
|       $this->assertEqual($node_test->title, 'newest title', 'The revision was updated, when updating old revision with existing revision UUID from remote site.'); | ||||
|       $this->assertEqual($node_test->vuuid, $vuuid_old, 'The revison UUID was preserved after saving with UUID, when updating old revision with existing revision UUID from remote site.'); | ||||
|  | ||||
|       // Setting the node options variable should also trigger a new revision. | ||||
|       $nodes = entity_uuid_load('node', array($node->uuid), array(), TRUE); | ||||
|       $node_test = reset($nodes); | ||||
|       variable_set('node_options_' . $node_test->type, array('revision')); | ||||
|       entity_uuid_save('node', $node_test); | ||||
|       $this->assertNotEqual($node_test->vuuid, $node->vuuid, 'A new node revison ID was generated after saving with UUID, when relying on the node options variable.'); | ||||
|  | ||||
|       // Test entity_uuid_delete() for nodes. | ||||
|       entity_uuid_delete('node', $node->uuid); | ||||
|       $node_test = node_load($node->nid); | ||||
| @@ -264,6 +385,9 @@ class UUIDNodeTestCase extends UUIDTestCase { | ||||
|  */ | ||||
| class UUIDCommentTestCase extends CommentHelperCase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'Comment implementation', | ||||
| @@ -339,6 +463,9 @@ class UUIDCommentTestCase extends CommentHelperCase { | ||||
|  */ | ||||
| class UUIDTaxonomyTestCase extends TaxonomyWebTestCase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'Taxonomy implementation', | ||||
| @@ -348,6 +475,8 @@ class UUIDTaxonomyTestCase extends TaxonomyWebTestCase { | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    * | ||||
|    * A lot of code here is taken from TaxonomyTermTestCase::setUp(). | ||||
|    */ | ||||
|   function setUp() { | ||||
| @@ -420,6 +549,9 @@ class UUIDTaxonomyTestCase extends TaxonomyWebTestCase { | ||||
|  */ | ||||
| class UUIDSyncTestCase extends UUIDTestCase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'UUID sync', | ||||
| @@ -435,17 +567,12 @@ class UUIDSyncTestCase extends UUIDTestCase { | ||||
|    *   There are something weird around this assertion. | ||||
|    */ | ||||
|   function assertTableColumn($table, $column, $message) { | ||||
|     $result = db_query("SHOW COLUMNS FROM {$table}"); | ||||
|     $exists = FALSE; | ||||
|     foreach ($result as $record) { | ||||
|       if ($record->field == $column) { | ||||
|         $exists = TRUE; | ||||
|         break; | ||||
|       } | ||||
|     } | ||||
|     $this->assertTrue($exists, $message); | ||||
|     $this->assertTrue(db_field_exists($table, $column), $message); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Tests creating UUIDs for entities that don't have them. | ||||
|    */ | ||||
|   function testSync() { | ||||
|     // These entities will not have UUID from the start, since the UUID module | ||||
|     // isn't installed yet. | ||||
| @@ -481,210 +608,3 @@ class UUIDSyncTestCase extends UUIDTestCase { | ||||
|     $this->assertUUID($user_test->uuid, 'User UUID was generated when clicking the sync button.'); | ||||
|   } | ||||
| } | ||||
|  | ||||
| class UUIDExportEntitiesWithDeploy extends DrupalWebTestCase { | ||||
|  | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'Export UUID entities', | ||||
|       'description' => 'Test exporting UUID entities with Deploy and Features.', | ||||
|       'group' => 'UUID', | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   function setUp() { | ||||
|     parent::setUp('taxonomy', 'uuid', 'entity', 'features', 'deploy', 'deploy_example'); | ||||
|   } | ||||
|  | ||||
|   function testExport() { | ||||
|     $test_user = $this->drupalCreateUser(); | ||||
|     $test_node = $this->drupalCreateNode(array( | ||||
|       'uid' => $test_user->uid, | ||||
|     )); | ||||
|     deploy_manager_add_to_plan('deploy_example_plan', 'node', $test_node); | ||||
|     // TODO: Test the actual insert. | ||||
|     $this->assertTrue(TRUE, 'Added a node with a user dependency to be exported as a Feature module.'); | ||||
|  | ||||
|     // Login and recreate the example feature. The feature isn't installed. But | ||||
|     // Features can still export the code, and we can test it. | ||||
|     $web_user = $this->drupalCreateUser(array('administer features')); | ||||
|     $this->drupalLogin($web_user); | ||||
|     $code = $this->drupalPost('admin/structure/features/uuid_default_entities_example/recreate', array(), t('Download feature')); | ||||
|     $this->assertTrue($code, 'Feature module was exported.'); | ||||
|  | ||||
|     // Ensure that we find what we expect in the exported code. | ||||
|     $node_test1 = preg_match('/' . $test_node->title . '/', $code); | ||||
|     $node_test2 = preg_match("/'uri' => 'node\/" . $test_node->uuid . "'/", $code); | ||||
|     $this->assertTrue($node_test1, 'Node title was found in the expoted code.'); | ||||
|     $this->assertTrue($node_test2, 'Node URI was found in the expoted code.'); | ||||
|     $user_test1 = preg_match('/' . $test_user->name . '/', $code); | ||||
|     $user_test2 = preg_match("/'uri' => 'user\/" . $test_user->uuid . "'/", $code); | ||||
|     $this->assertTrue($user_test1, 'User was found in the expoted code.'); | ||||
|     $this->assertTrue($user_test2, 'User URI was found in the expoted code.'); | ||||
|   } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Tests for the UUID synchronization. | ||||
|  */ | ||||
| class UUIDImportEntitiesTestCase extends UUIDTestCase { | ||||
|  | ||||
|   /** | ||||
|    * Representation of the UUIDs that is exported in our example feature, that | ||||
|    * we use for testing. | ||||
|    */ | ||||
|   public $term1_uuid = 'bcb92ce8-2236-e264-65c8-0c163ae716d1'; | ||||
|   public $term2_uuid = '4293a15c-531a-6164-7d1b-668ed019a6bd'; | ||||
|   public $term3_uuid = 'af738a46-f278-cf84-d94d-9e03879fd71e'; | ||||
|   public $node1_uuid = 'b0558664-c94b-3674-d9df-3e1696b2e471'; | ||||
|   public $node2_uuid = '5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837'; | ||||
|   public $user1_uuid = '7cf875e6-dc15-4404-f190-5a7c3e91d14c'; | ||||
|  | ||||
|   /** | ||||
|    * Helper method to assert the uuid_entities component in any features. | ||||
|    */ | ||||
|   function assertFeatureState($feature, $state, $message = '') { | ||||
|     if (empty($message)) { | ||||
|       switch ($state) { | ||||
|         case FEATURES_DEFAULT: | ||||
|           $readable_state = 'default'; | ||||
|           break; | ||||
|         case FEATURES_OVERRIDDEN: | ||||
|           $readable_state = 'overridden'; | ||||
|           break; | ||||
|         default: | ||||
|           $readable_state = 'unknown'; | ||||
|           break; | ||||
|       } | ||||
|       $message = format_string('%component in %feature had state: %state', array('%component' => 'uuid_entities', '%feature' => $feature, '%state' => $readable_state)); | ||||
|     } | ||||
|     // Ensure that the features we used is in default state. | ||||
|     $states = features_get_component_states(array($feature), TRUE, TRUE); | ||||
|     if (!$this->assertEqual($states[$feature]['uuid_entities'], $state, $message)) { | ||||
|       debug(format_string('Enabling functionality to show diff output for debug purposes.')); | ||||
|       $success = module_enable(array('diff')); | ||||
|       if ($success) { | ||||
|         // Make sure we run on cold caches. | ||||
|         drupal_flush_all_caches(); | ||||
|         drupal_static_reset(); | ||||
|  | ||||
|         $user = $this->drupalCreateUser(array('administer features')); | ||||
|         $this->drupalLogin($user); | ||||
|         $this->drupalGet('admin/structure/features/' . $feature . '/diff'); | ||||
|       } | ||||
|       else { | ||||
|         debug(format_string('Download !module to see diff output for debug purposes.', array('!module' => 'diff.module'))); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   function getEntityByUuid($entity_type, $uuid) { | ||||
|     $ids = entity_get_id_by_uuid($entity_type, array($uuid)); | ||||
|     $entities = entity_load($entity_type, $ids, NULL, TRUE); | ||||
|     return reset($entities); | ||||
|   } | ||||
|  | ||||
|   function enableFeature($feature) { | ||||
|     $success = module_enable(array($feature), TRUE); | ||||
|     $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', array($feature))))); | ||||
|     // Make sure we run on cold caches. | ||||
|     drupal_flush_all_caches(); | ||||
|     drupal_static_reset(); | ||||
|   } | ||||
|  | ||||
|   function revertFeature($feature) { | ||||
|     features_revert(array($feature => array('uuid_entities'))); | ||||
|     $this->assertTrue(TRUE, format_string('Reverted feature: %feature', array('%feature' => $feature))); | ||||
|   } | ||||
|  | ||||
|   function testImport() { | ||||
|     $term1 = $this->getEntityByUuid('taxonomy_term', $this->term1_uuid); | ||||
|     $term2 = $this->getEntityByUuid('taxonomy_term', $this->term2_uuid); | ||||
|     $term3 = $this->getEntityByUuid('taxonomy_term', $this->term3_uuid); | ||||
|     $node1 = $this->getEntityByUuid('node', $this->node1_uuid); | ||||
|     $node2 = $this->getEntityByUuid('node', $this->node2_uuid); | ||||
|     $user1 = $this->getEntityByUuid('user', $this->user1_uuid); | ||||
|  | ||||
|     // Ensure that we don't have our entities yet. | ||||
|     $this->assertTrue(empty($term1), 'Term 1 has not been created yet.'); | ||||
|     $this->assertTrue(empty($term2), 'Term 2 has not been created yet.'); | ||||
|     $this->assertTrue(empty($term3), 'Term 3 has not been created yet.'); | ||||
|     $this->assertTrue(empty($node1), 'Node 1 has not been created yet.'); | ||||
|     $this->assertTrue(empty($node2), 'Node 2 has not been created yet.'); | ||||
|     $this->assertTrue(empty($user1), 'User 1 has not been created yet.'); | ||||
|  | ||||
|     $this->enableFeature('uuid_default_entities_example'); | ||||
|  | ||||
|     $term1 = $this->getEntityByUuid('taxonomy_term', $this->term1_uuid); | ||||
|     $term2 = $this->getEntityByUuid('taxonomy_term', $this->term2_uuid); | ||||
|     $term3 = $this->getEntityByUuid('taxonomy_term', $this->term3_uuid); | ||||
|     $node1 = $this->getEntityByUuid('node', $this->node1_uuid); | ||||
|     $node2 = $this->getEntityByUuid('node', $this->node2_uuid); | ||||
|     $user1 = $this->getEntityByUuid('user', $this->user1_uuid); | ||||
|  | ||||
|     // Ensure that our entities was created. | ||||
|     $this->assertEqual($term1->uuid, $this->term1_uuid, 'Term 1 was created.'); | ||||
|     $this->assertEqual($term2->uuid, $this->term2_uuid, 'Term 2 was created.'); | ||||
|     $this->assertEqual($term3->uuid, $this->term3_uuid, 'Term 3 was created.'); | ||||
|     $this->assertEqual($node1->uuid, $this->node1_uuid, 'Node 1 was created.'); | ||||
|     $this->assertEqual($node2->uuid, $this->node2_uuid, 'Node 2 was created.'); | ||||
|     $this->assertEqual($user1->uuid, $this->user1_uuid, 'User 1 was created.'); | ||||
|  | ||||
|     // Check the features state. | ||||
|     $this->assertFeatureState('uuid_default_entities_example', FEATURES_DEFAULT); | ||||
|  | ||||
|     // New property. | ||||
|     $new = 'foo bar'; | ||||
|     // Change a term. | ||||
|     $term1->name = $new; | ||||
|     $status = taxonomy_term_save($term1); | ||||
|     $this->assertEqual($status, SAVED_UPDATED, 'Updated term 1.'); | ||||
|     // Change a node. | ||||
|     $node1->title = $new; | ||||
|     node_save($node1); | ||||
|     $this->assertEqual($node1->title, $new, 'Updated node 1.'); | ||||
|     // Change a user. | ||||
|     $user1->name = $new; | ||||
|     $updated_user = user_save($user1); | ||||
|     $this->assertEqual($user1->name, $updated_user->name, 'Updated user 1.'); | ||||
|  | ||||
|     // Check the features state. | ||||
|     $this->assertFeatureState('uuid_default_entities_example', FEATURES_OVERRIDDEN); | ||||
|  | ||||
|     // Revert the feature. | ||||
|     $this->revertFeature('uuid_default_entities_example'); | ||||
|  | ||||
|     // Check the features state. | ||||
|     $this->assertFeatureState('uuid_default_entities_example', FEATURES_DEFAULT); | ||||
|   } | ||||
| } | ||||
|  | ||||
| class UUIDImportEntitiesWithDeploy extends UUIDImportEntitiesTestCase { | ||||
|  | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'Import UUID entities, with Deploy', | ||||
|       'description' => 'Test importing UUID entities with Features and Deploy.', | ||||
|       'group' => 'UUID', | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   function setUp() { | ||||
|     parent::setUp('taxonomy', 'uuid', 'entity', 'features', 'deploy', 'deploy_example'); | ||||
|   } | ||||
| } | ||||
|  | ||||
| class UUIDImportEntitiesWithoutDeploy extends UUIDImportEntitiesTestCase { | ||||
|  | ||||
|   public static function getInfo() { | ||||
|     return array( | ||||
|       'name' => 'Import UUID entities, without Deploy', | ||||
|       'description' => 'Test importing UUID entities with Features only.', | ||||
|       'group' => 'UUID', | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   function setUp() { | ||||
|     parent::setUp('taxonomy', 'uuid', 'entity', 'features'); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -29,7 +29,7 @@ function uuid_token_info() { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements hook_token_info_alter() | ||||
|  * Implements hook_token_info_alter(). | ||||
|  */ | ||||
| function uuid_token_info_alter(&$data) { | ||||
|   foreach (entity_get_info() as $entity_type => $info) { | ||||
|   | ||||
| @@ -1,402 +0,0 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @file | ||||
|  * uuid_default_entities_example.features.uuid_entities.inc | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Implements hook_uuid_default_entities(). | ||||
|  */ | ||||
| function uuid_default_entities_example_uuid_default_entities() { | ||||
|   $entities = array(); | ||||
|  | ||||
|   $entities['deploy_example_plan'][] = (object) array( | ||||
|     '__metadata' => array( | ||||
|       'type' => 'taxonomy_term', | ||||
|       'uri' => 'taxonomy_term/bcb92ce8-2236-e264-65c8-0c163ae716d1', | ||||
|       'cause' => 'node/b0558664-c94b-3674-d9df-3e1696b2e471', | ||||
|     ), | ||||
|     'description' => NULL, | ||||
|     'format' => NULL, | ||||
|     'name' => 'Foo', | ||||
|     'path' => array( | ||||
|       'alias' => 'term/foo', | ||||
|     ), | ||||
|     'rdf_mapping' => array( | ||||
|       'rdftype' => array( | ||||
|         0 => 'skos:Concept', | ||||
|       ), | ||||
|       'name' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'rdfs:label', | ||||
|           1 => 'skos:prefLabel', | ||||
|         ), | ||||
|       ), | ||||
|       'description' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:definition', | ||||
|         ), | ||||
|       ), | ||||
|       'vid' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:inScheme', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'parent' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:broader', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|     ), | ||||
|     'uuid' => 'bcb92ce8-2236-e264-65c8-0c163ae716d1', | ||||
|     'vocabulary_machine_name' => 'tags', | ||||
|     'weight' => '0', | ||||
|   ); | ||||
|   $entities['deploy_example_plan'][] = (object) array( | ||||
|     '__metadata' => array( | ||||
|       'type' => 'taxonomy_term', | ||||
|       'uri' => 'taxonomy_term/4293a15c-531a-6164-7d1b-668ed019a6bd', | ||||
|       'cause' => 'node/b0558664-c94b-3674-d9df-3e1696b2e471', | ||||
|     ), | ||||
|     'description' => NULL, | ||||
|     'format' => NULL, | ||||
|     'name' => 'Bar', | ||||
|     'rdf_mapping' => array( | ||||
|       'rdftype' => array( | ||||
|         0 => 'skos:Concept', | ||||
|       ), | ||||
|       'name' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'rdfs:label', | ||||
|           1 => 'skos:prefLabel', | ||||
|         ), | ||||
|       ), | ||||
|       'description' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:definition', | ||||
|         ), | ||||
|       ), | ||||
|       'vid' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:inScheme', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'parent' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:broader', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|     ), | ||||
|     'uuid' => '4293a15c-531a-6164-7d1b-668ed019a6bd', | ||||
|     'vocabulary_machine_name' => 'tags', | ||||
|     'weight' => '0', | ||||
|   ); | ||||
|   $entities['deploy_example_plan'][] = (object) array( | ||||
|     '__metadata' => array( | ||||
|       'type' => 'node', | ||||
|       'uri' => 'node/b0558664-c94b-3674-d9df-3e1696b2e471', | ||||
|       'cause' => FALSE, | ||||
|     ), | ||||
|     'body' => array( | ||||
|       'und' => array( | ||||
|         0 => array( | ||||
|           'format' => 'filtered_html', | ||||
|           'summary' => '', | ||||
|           'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', | ||||
|         ), | ||||
|       ), | ||||
|     ), | ||||
|     'cid' => '0', | ||||
|     'comment' => '2', | ||||
|     'comment_count' => '0', | ||||
|     'field_image' => array(), | ||||
|     'field_tags' => array( | ||||
|       'und' => array( | ||||
|         0 => array( | ||||
|           'tid' => 'bcb92ce8-2236-e264-65c8-0c163ae716d1', | ||||
|         ), | ||||
|         1 => array( | ||||
|           'tid' => '4293a15c-531a-6164-7d1b-668ed019a6bd', | ||||
|         ), | ||||
|       ), | ||||
|     ), | ||||
|     'language' => 'und', | ||||
|     'last_comment_name' => NULL, | ||||
|     'last_comment_uid' => '1', | ||||
|     'log' => '', | ||||
|     'path' => array( | ||||
|       'alias' => 'lorem-ipsum', | ||||
|     ), | ||||
|     'promote' => '1', | ||||
|     'rdf_mapping' => array( | ||||
|       'field_image' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'og:image', | ||||
|           1 => 'rdfs:seeAlso', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'field_tags' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'dc:subject', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'rdftype' => array( | ||||
|         0 => 'sioc:Item', | ||||
|         1 => 'foaf:Document', | ||||
|       ), | ||||
|       'title' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'dc:title', | ||||
|         ), | ||||
|       ), | ||||
|       'created' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'dc:date', | ||||
|           1 => 'dc:created', | ||||
|         ), | ||||
|         'datatype' => 'xsd:dateTime', | ||||
|         'callback' => 'date_iso8601', | ||||
|       ), | ||||
|       'changed' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'dc:modified', | ||||
|         ), | ||||
|         'datatype' => 'xsd:dateTime', | ||||
|         'callback' => 'date_iso8601', | ||||
|       ), | ||||
|       'body' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'content:encoded', | ||||
|         ), | ||||
|       ), | ||||
|       'uid' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'sioc:has_creator', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'name' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'foaf:name', | ||||
|         ), | ||||
|       ), | ||||
|       'comment_count' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'sioc:num_replies', | ||||
|         ), | ||||
|         'datatype' => 'xsd:integer', | ||||
|       ), | ||||
|       'last_activity' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'sioc:last_activity_date', | ||||
|         ), | ||||
|         'datatype' => 'xsd:dateTime', | ||||
|         'callback' => 'date_iso8601', | ||||
|       ), | ||||
|     ), | ||||
|     'status' => '1', | ||||
|     'sticky' => '0', | ||||
|     'title' => 'Lorem ipsum', | ||||
|     'tnid' => '0', | ||||
|     'translate' => '0', | ||||
|     'type' => 'article', | ||||
|     'uid' => '1', | ||||
|     'uuid' => 'b0558664-c94b-3674-d9df-3e1696b2e471', | ||||
|   ); | ||||
|   $entities['deploy_example_plan'][] = (object) array( | ||||
|     '__metadata' => array( | ||||
|       'type' => 'taxonomy_term', | ||||
|       'uri' => 'taxonomy_term/af738a46-f278-cf84-d94d-9e03879fd71e', | ||||
|       'cause' => 'node/5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837', | ||||
|     ), | ||||
|     'description' => NULL, | ||||
|     'format' => NULL, | ||||
|     'name' => 'Baz', | ||||
|     'rdf_mapping' => array( | ||||
|       'rdftype' => array( | ||||
|         0 => 'skos:Concept', | ||||
|       ), | ||||
|       'name' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'rdfs:label', | ||||
|           1 => 'skos:prefLabel', | ||||
|         ), | ||||
|       ), | ||||
|       'description' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:definition', | ||||
|         ), | ||||
|       ), | ||||
|       'vid' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:inScheme', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'parent' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'skos:broader', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|     ), | ||||
|     'uuid' => 'af738a46-f278-cf84-d94d-9e03879fd71e', | ||||
|     'vocabulary_machine_name' => 'tags', | ||||
|     'weight' => '0', | ||||
|   ); | ||||
|   $entities['deploy_example_plan'][] = (object) array( | ||||
|     '__metadata' => array( | ||||
|       'type' => 'user', | ||||
|       'uri' => 'user/7cf875e6-dc15-4404-f190-5a7c3e91d14c', | ||||
|       'cause' => 'node/5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837', | ||||
|     ), | ||||
|     'init' => 'no@example.com', | ||||
|     'language' => '', | ||||
|     'mail' => 'no@example.com', | ||||
|     'name' => 'mohamed', | ||||
|     'pass' => '$S$DtyVr4YQkvCpofZdLT4.L23Xb6E8HUkmEgZikN919RTZXZSePwso', | ||||
|     'picture' => NULL, | ||||
|     'rdf_mapping' => array( | ||||
|       'rdftype' => array( | ||||
|         0 => 'sioc:UserAccount', | ||||
|       ), | ||||
|       'name' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'foaf:name', | ||||
|         ), | ||||
|       ), | ||||
|       'homepage' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'foaf:page', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|     ), | ||||
|     'roles' => array( | ||||
|       2 => 'authenticated user', | ||||
|       3 => 'administrator', | ||||
|     ), | ||||
|     'signature' => '', | ||||
|     'signature_format' => 'filtered_html', | ||||
|     'status' => '1', | ||||
|     'theme' => '', | ||||
|     'timezone' => 'Asia/Riyadh', | ||||
|     'uuid' => '7cf875e6-dc15-4404-f190-5a7c3e91d14c', | ||||
|   ); | ||||
|   $entities['deploy_example_plan'][] = (object) array( | ||||
|     '__metadata' => array( | ||||
|       'type' => 'node', | ||||
|       'uri' => 'node/5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837', | ||||
|       'cause' => FALSE, | ||||
|     ), | ||||
|     'body' => array( | ||||
|       'und' => array( | ||||
|         0 => array( | ||||
|           'format' => 'filtered_html', | ||||
|           'summary' => '', | ||||
|           'value' => 'Nunc sollicitudin justo ut augue egestas et varius quam consectetur.', | ||||
|         ), | ||||
|       ), | ||||
|     ), | ||||
|     'cid' => '0', | ||||
|     'comment' => '2', | ||||
|     'comment_count' => '0', | ||||
|     'field_image' => array(), | ||||
|     'field_tags' => array( | ||||
|       'und' => array( | ||||
|         0 => array( | ||||
|           'tid' => 'af738a46-f278-cf84-d94d-9e03879fd71e', | ||||
|         ), | ||||
|       ), | ||||
|     ), | ||||
|     'language' => 'und', | ||||
|     'last_comment_name' => NULL, | ||||
|     'last_comment_uid' => '7cf875e6-dc15-4404-f190-5a7c3e91d14c', | ||||
|     'log' => '', | ||||
|     'promote' => '1', | ||||
|     'rdf_mapping' => array( | ||||
|       'field_image' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'og:image', | ||||
|           1 => 'rdfs:seeAlso', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'field_tags' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'dc:subject', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'rdftype' => array( | ||||
|         0 => 'sioc:Item', | ||||
|         1 => 'foaf:Document', | ||||
|       ), | ||||
|       'title' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'dc:title', | ||||
|         ), | ||||
|       ), | ||||
|       'created' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'dc:date', | ||||
|           1 => 'dc:created', | ||||
|         ), | ||||
|         'datatype' => 'xsd:dateTime', | ||||
|         'callback' => 'date_iso8601', | ||||
|       ), | ||||
|       'changed' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'dc:modified', | ||||
|         ), | ||||
|         'datatype' => 'xsd:dateTime', | ||||
|         'callback' => 'date_iso8601', | ||||
|       ), | ||||
|       'body' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'content:encoded', | ||||
|         ), | ||||
|       ), | ||||
|       'uid' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'sioc:has_creator', | ||||
|         ), | ||||
|         'type' => 'rel', | ||||
|       ), | ||||
|       'name' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'foaf:name', | ||||
|         ), | ||||
|       ), | ||||
|       'comment_count' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'sioc:num_replies', | ||||
|         ), | ||||
|         'datatype' => 'xsd:integer', | ||||
|       ), | ||||
|       'last_activity' => array( | ||||
|         'predicates' => array( | ||||
|           0 => 'sioc:last_activity_date', | ||||
|         ), | ||||
|         'datatype' => 'xsd:dateTime', | ||||
|         'callback' => 'date_iso8601', | ||||
|       ), | ||||
|     ), | ||||
|     'status' => '1', | ||||
|     'sticky' => '0', | ||||
|     'title' => 'Nunc sollicitudin', | ||||
|     'tnid' => '0', | ||||
|     'translate' => '0', | ||||
|     'type' => 'article', | ||||
|     'uid' => '7cf875e6-dc15-4404-f190-5a7c3e91d14c', | ||||
|     'uuid' => '5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837', | ||||
|   ); | ||||
|  | ||||
|   return $entities; | ||||
| } | ||||
| @@ -1,15 +0,0 @@ | ||||
| core = "7.x" | ||||
| dependencies[] = "entity" | ||||
| dependencies[] = "features" | ||||
| dependencies[] = "uuid" | ||||
| description = "Example feature mainly used for testing." | ||||
| features[uuid_entities][] = "deploy_example_plan" | ||||
| name = "UUID default entities example" | ||||
| package = "Features" | ||||
|  | ||||
| ; Information added by drupal.org packaging script on 2013-09-11 | ||||
| version = "7.x-1.0-alpha5+0-dev" | ||||
| core = "7.x" | ||||
| project = "uuid" | ||||
| datestamp = "1378899072" | ||||
|  | ||||
| @@ -1,6 +0,0 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @file | ||||
|  */ | ||||
|  | ||||
| // Drupal needs this blank file. | ||||
| @@ -5,9 +5,9 @@ package = UUID | ||||
| dependencies[] = uuid | ||||
|  | ||||
|  | ||||
| ; Information added by drupal.org packaging script on 2013-09-11 | ||||
| version = "7.x-1.0-alpha5+0-dev" | ||||
| ; Information added by Drupal.org packaging script on 2014-09-23 | ||||
| version = "7.x-1.0-alpha6" | ||||
| core = "7.x" | ||||
| project = "uuid" | ||||
| datestamp = "1378899072" | ||||
| datestamp = "1411455150" | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,13 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @file | ||||
|  * Field Collection services definition functions. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Define a services resource for field_collections. | ||||
|  */ | ||||
| function _field_collection_resource_definition() { | ||||
|   if (module_exists('field_collection')) { | ||||
|     // We will allow uuid_services_services_resources_alter() to add the | ||||
|   | ||||
| @@ -7,9 +7,9 @@ dependencies[] = services | ||||
| dependencies[] = uuid | ||||
| dependencies[] = entity | ||||
|  | ||||
| ; Information added by drupal.org packaging script on 2013-09-11 | ||||
| version = "7.x-1.0-alpha5+0-dev" | ||||
| ; Information added by Drupal.org packaging script on 2014-09-23 | ||||
| version = "7.x-1.0-alpha6" | ||||
| core = "7.x" | ||||
| project = "uuid" | ||||
| datestamp = "1378899072" | ||||
| datestamp = "1411455150" | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,20 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Implementation of hook_menu(). | ||||
|  */ | ||||
| function uuid_services_menu() { | ||||
|   $items['admin/config/services/uuid-services'] = array( | ||||
|     'title' => 'UUID Services', | ||||
|     'description' => 'Configure settings for Module Filter.', | ||||
|     'access arguments' => array('administer services'), | ||||
|     'page callback' => 'drupal_get_form', | ||||
|     'page arguments' => array('uuid_services_settings'), | ||||
|     'file' => 'uuid_services.admin.inc' | ||||
|   ); | ||||
|   return $items; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements hook_services_resources_alter(). | ||||
|  * | ||||
| @@ -14,7 +29,7 @@ | ||||
|  */ | ||||
| function uuid_services_services_resources_alter(&$resources, &$endpoint) { | ||||
|   foreach (entity_get_info() as $entity_type => $entity_info) { | ||||
|     if (isset($entity_info['uuid']) && $entity_info['uuid'] == TRUE && isset($resources[$entity_type])) { | ||||
|     if (isset($entity_info['uuid']) && $entity_info['uuid'] == TRUE && (isset($resources[$entity_type]) || variable_get('uuid_services_support_all_entity_types', FALSE))) { | ||||
|       unset($resources[$entity_type]['operations']['create']); | ||||
|  | ||||
|       // Alter 'retrieve' method to use UUID enabled functions and arguments. | ||||
| @@ -126,6 +141,7 @@ function _uuid_services_entity_update($entity_type, $uuid, $entity) { | ||||
|     else { | ||||
|       $entity = (object) $entity; | ||||
|     } | ||||
|     $entity->uuid_services = TRUE; | ||||
|     entity_uuid_save($entity_type, $entity); | ||||
|     return $entity; | ||||
|   } | ||||
|   | ||||
| @@ -11,9 +11,9 @@ features[ctools][] = services:services:3 | ||||
| features[features_api][] = api:2 | ||||
| features[services_endpoint][] = uuid_services_example | ||||
|  | ||||
| ; Information added by drupal.org packaging script on 2013-09-11 | ||||
| version = "7.x-1.0-alpha5+0-dev" | ||||
| ; Information added by Drupal.org packaging script on 2014-09-23 | ||||
| version = "7.x-1.0-alpha6" | ||||
| core = "7.x" | ||||
| project = "uuid" | ||||
| datestamp = "1378899072" | ||||
| datestamp = "1411455150" | ||||
|  | ||||
|   | ||||
| @@ -6,9 +6,9 @@ files[] = session_limit.module | ||||
| files[] = session_limit.tokens.inc | ||||
| files[] = tests/session_limit.test | ||||
|  | ||||
| ; Information added by drupal.org packaging script on 2013-07-06 | ||||
| version = "7.x-2.0-rc2" | ||||
| ; Information added by Drupal.org packaging script on 2014-03-04 | ||||
| version = "7.x-2.0" | ||||
| core = "7.x" | ||||
| project = "session_limit" | ||||
| datestamp = "1373115956" | ||||
| datestamp = "1393949919" | ||||
|  | ||||
|   | ||||
| @@ -24,9 +24,9 @@ files[] = views/views_handler_sort_ip_user_count.inc | ||||
| files[] = views/views_handler_sort_is_online.inc | ||||
| files[] = views/views_handler_sort_user_ip_count.inc | ||||
|  | ||||
| ; Information added by drupal.org packaging script on 2013-09-11 | ||||
| ; Information added by drupal.org packaging script on 2013-10-19 | ||||
| version = "7.x-1.x-dev" | ||||
| core = "7.x" | ||||
| project = "user_stats" | ||||
| datestamp = "1378898964" | ||||
| datestamp = "1382151011" | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Bachir Soussi Chiadmi
					Bachir Soussi Chiadmi