diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info index 6b5f34d..a07e29a 100644 --- a/modules/simpletest/simpletest.info +++ b/modules/simpletest/simpletest.info @@ -46,5 +46,6 @@ files[] = tests/upgrade/upgrade.menu.test files[] = tests/upgrade/upgrade.node.test files[] = tests/upgrade/upgrade.taxonomy.test files[] = tests/upgrade/upgrade.translatable.test +files[] = tests/upgrade/update.trigger.test files[] = tests/upgrade/upgrade.upload.test files[] = tests/upgrade/upgrade.user.test diff --git a/modules/simpletest/tests/upgrade/drupal-7.trigger.database.php b/modules/simpletest/tests/upgrade/drupal-7.trigger.database.php new file mode 100644 index 0000000..996f711 --- /dev/null +++ b/modules/simpletest/tests/upgrade/drupal-7.trigger.database.php @@ -0,0 +1,28 @@ +fields(array( + 'hook', + 'aid', + 'weight', +)) +->values(array( + 'hook' => 'node_presave', + 'aid' => 'node_publish_action', + 'weight' => '1', +)) +->values(array( + 'hook' => 'comment_presave', + 'aid' => 'comment_publish_action', + 'weight' => '1', +)) +->values(array( + 'hook' => 'comment_delete', + 'aid' => 'node_save_action', + 'weight' => '1', +)) +->execute(); diff --git a/modules/simpletest/tests/upgrade/update.trigger.test b/modules/simpletest/tests/upgrade/update.trigger.test new file mode 100644 index 0000000..a91f7b9 --- /dev/null +++ b/modules/simpletest/tests/upgrade/update.trigger.test @@ -0,0 +1,37 @@ + 7.x upgrade path. + */ +class TriggerUpdatePathTestCase extends UpdatePathTestCase { + public static function getInfo() { + return array( + 'name' => 'Trigger update path', + 'description' => 'Trigger update path tests.', + 'group' => 'Upgrade path', + ); + } + + public function setUp() { + // Use the filled upgrade path and our trigger data. + $this->databaseDumpFiles = array( + drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.filled.standard_all.database.php.gz', + drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.trigger.database.php', + ); + parent::setUp(); + + // Our test data includes node and comment trigger assignments. + $this->uninstallModulesExcept(array('comment', 'trigger')); + } + + /** + * Tests that the upgrade is successful. + */ + public function testFilledUpgrade() { + $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.')); + } +} diff --git a/modules/trigger/tests/trigger_test.module b/modules/trigger/tests/trigger_test.module index 0e3f3f8..72fe352 100644 --- a/modules/trigger/tests/trigger_test.module +++ b/modules/trigger/tests/trigger_test.module @@ -57,7 +57,7 @@ function trigger_test_action_info() { function trigger_test_trigger_info() { // Register triggers that this module provides. The first is an additional // node trigger and the second is our own, which should create a new tab - // on the trigger assignment page. + // on the trigger assignment page. The last tests long trigger names. return array( 'node' => array( 'node_triggertest' => array( @@ -68,6 +68,9 @@ function trigger_test_trigger_info() { 'trigger_test_triggertest' => array( 'label' => t('Another test trigger is fired'), ), + 'trigger_test_we_sweat_it_out_in_the_streets_of_a_runaway_american_dream' => array( + 'label' => t('A test trigger with a name over 64 characters'), + ), ), ); } diff --git a/modules/trigger/trigger.install b/modules/trigger/trigger.install index 9a172a2..5ed4077 100644 --- a/modules/trigger/trigger.install +++ b/modules/trigger/trigger.install @@ -9,12 +9,14 @@ * Implements hook_schema(). */ function trigger_schema() { + // The total index length (hook and aid) must be less than 333. Since the aid + // field is 255 characters, the hook field can have a maximum length of 78. $schema['trigger_assignments'] = array( 'description' => 'Maps trigger to hook and operation assignments from trigger.module.', 'fields' => array( 'hook' => array( 'type' => 'varchar', - 'length' => 32, + 'length' => 78, 'not null' => TRUE, 'default' => '', 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.', @@ -68,3 +70,11 @@ function trigger_update_7000() { } db_drop_field('trigger_assignments', 'op'); } + +/** + * Increase length of hook name field to 78 characters. + */ +function trigger_update_7001() { + db_drop_primary_key('trigger_assignments'); + db_change_field('trigger_assignments', 'hook', 'hook', array('type' => 'varchar', 'length' => 78, 'not null' => TRUE, 'default' => '', 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.', ), array('primary key' => array('hook', 'aid'))); +}