commit e329e0dcc93748d6148f3856917926a5c0ec4dea Author: Matthew Radcliffe Date: Wed Feb 27 14:40:41 2013 -0500 Issue #1258026 by mradcliffe: Add a basic 7200 update path test. This should help with development, but needs to be flushed out more. diff --git a/userpoints-7.x-1.x.filled.database.php b/userpoints-7.x-1.x.filled.database.php new file mode 100644 index 0000000..3911665 --- /dev/null +++ b/userpoints-7.x-1.x.filled.database.php @@ -0,0 +1,427 @@ + array( + 'pid' => array( + 'type' => 'serial', + 'not null' => TRUE, + ), + 'uid' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'points' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'max_points' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'last_update' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'tid' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array( + 'pid', + ), + 'indexes' => array( + 'last_update' => array( + 'last_update', + ), + 'points' => array( + 'points', + ), + ), + 'unique keys' => array( + 'uid_tid' => array( + 'uid', + 'tid', + ), + ), + 'module' => 'userpoints', + 'name' => 'userpoints', +)); +db_insert('userpoints')->fields(array( + 'pid', + 'uid', + 'points', + 'max_points', + 'last_update', + 'tid', +)) +->values(array( + 'pid' => '1', + 'uid' => '1', + 'points' => '4', + 'max_points' => '5', + 'last_update' => '1361395354', + 'tid' => '0', +)) +->values(array( + 'pid' => '2', + 'uid' => '1', + 'points' => '-1', + 'max_points' => '8', + 'last_update' => '1361395411', + 'tid' => '2', +)) +->values(array( + 'pid' => '3', + 'uid' => '1', + 'points' => '7', + 'max_points' => '7', + 'last_update' => '1361395402', + 'tid' => '1', +)) +->execute(); + +db_create_table('userpoints_total', array( + 'fields' => array( + 'uid' => array( + 'type' => 'int', + 'not null' => TRUE, + ), + 'points' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'max_points' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'last_update' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array( + 'uid', + ), + 'indexes' => array( + 'last_update' => array( + 'last_update', + ), + 'points' => array( + 'points', + ), + ), + 'module' => 'userpoints', + 'name' => 'userpoints_total', +)); +db_insert('userpoints_total')->fields(array( + 'uid', + 'points', + 'max_points', + 'last_update', +)) +->values(array( + 'uid' => '1', + 'points' => '10', + 'max_points' => '19', + 'last_update' => '1361395411', +)) +->execute(); + +db_create_table('userpoints_txn', array( + 'fields' => array( + 'txn_id' => array( + 'type' => 'serial', + 'not null' => TRUE, + ), + 'uid' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'approver_uid' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'points' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'time_stamp' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'changed' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'status' => array( + 'type' => 'int', + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + ), + 'description' => array( + 'type' => 'text', + ), + 'reference' => array( + 'type' => 'varchar', + 'length' => 128, + ), + 'expirydate' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'expired' => array( + 'type' => 'int', + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + ), + 'parent_txn_id' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'tid' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'entity_id' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'entity_type' => array( + 'type' => 'varchar', + 'length' => 128, + ), + 'operation' => array( + 'type' => 'varchar', + 'length' => 48, + ), + ), + 'primary key' => array( + 'txn_id', + ), + 'indexes' => array( + 'operation' => array( + 'operation', + ), + 'reference' => array( + 'reference', + ), + 'status_expired_expiry' => array( + 'status', + 'expired', + 'expirydate', + ), + 'changed' => array( + 'changed', + ), + 'uid' => array( + 'uid', + ), + 'approver_uid' => array( + 'approver_uid', + ), + 'points' => array( + 'points', + ), + ), + 'module' => 'userpoints', + 'name' => 'userpoints_txn', +)); +db_insert('userpoints_txn')->fields(array( + 'txn_id', + 'uid', + 'approver_uid', + 'points', + 'time_stamp', + 'changed', + 'status', + 'description', + 'reference', + 'expirydate', + 'expired', + 'parent_txn_id', + 'tid', + 'entity_id', + 'entity_type', + 'operation', +)) +->values(array( + 'txn_id' => '1', + 'uid' => '1', + 'approver_uid' => '1', + 'points' => '5', + 'time_stamp' => '1361395345', + 'changed' => '1361395345', + 'status' => '0', + 'description' => '', + 'reference' => '', + 'expirydate' => '0', + 'expired' => '0', + 'parent_txn_id' => '0', + 'tid' => '0', + 'entity_id' => '0', + 'entity_type' => NULL, + 'operation' => 'admin', +)) +->values(array( + 'txn_id' => '2', + 'uid' => '1', + 'approver_uid' => '1', + 'points' => '-1', + 'time_stamp' => '1361395354', + 'changed' => '1361395354', + 'status' => '0', + 'description' => '', + 'reference' => '', + 'expirydate' => '0', + 'expired' => '0', + 'parent_txn_id' => '0', + 'tid' => '0', + 'entity_id' => '0', + 'entity_type' => NULL, + 'operation' => 'admin', +)) +->values(array( + 'txn_id' => '3', + 'uid' => '1', + 'approver_uid' => '1', + 'points' => '-3', + 'time_stamp' => '1361395364', + 'changed' => '1361395364', + 'status' => '0', + 'description' => '', + 'reference' => '', + 'expirydate' => '0', + 'expired' => '0', + 'parent_txn_id' => '0', + 'tid' => '2', + 'entity_id' => '0', + 'entity_type' => NULL, + 'operation' => 'admin', +)) +->values(array( + 'txn_id' => '4', + 'uid' => '1', + 'approver_uid' => '1', + 'points' => '1', + 'time_stamp' => '1361395371', + 'changed' => '1361395371', + 'status' => '0', + 'description' => '', + 'reference' => '', + 'expirydate' => '0', + 'expired' => '0', + 'parent_txn_id' => '0', + 'tid' => '2', + 'entity_id' => '0', + 'entity_type' => NULL, + 'operation' => 'admin', +)) +->values(array( + 'txn_id' => '5', + 'uid' => '1', + 'approver_uid' => '1', + 'points' => '5', + 'time_stamp' => '1361395380', + 'changed' => '1361395380', + 'status' => '0', + 'description' => '', + 'reference' => '', + 'expirydate' => '0', + 'expired' => '0', + 'parent_txn_id' => '0', + 'tid' => '1', + 'entity_id' => '0', + 'entity_type' => NULL, + 'operation' => 'admin', +)) +->values(array( + 'txn_id' => '6', + 'uid' => '1', + 'approver_uid' => '1', + 'points' => '10', + 'time_stamp' => '1361395390', + 'changed' => '1361395390', + 'status' => '0', + 'description' => '', + 'reference' => '', + 'expirydate' => '0', + 'expired' => '0', + 'parent_txn_id' => '0', + 'tid' => '2', + 'entity_id' => '0', + 'entity_type' => NULL, + 'operation' => 'admin', +)) +->values(array( + 'txn_id' => '7', + 'uid' => '1', + 'approver_uid' => '1', + 'points' => '2', + 'time_stamp' => '1361395402', + 'changed' => '1361395402', + 'status' => '0', + 'description' => '', + 'reference' => '', + 'expirydate' => '0', + 'expired' => '0', + 'parent_txn_id' => '0', + 'tid' => '1', + 'entity_id' => '0', + 'entity_type' => NULL, + 'operation' => 'admin', +)) +->values(array( + 'txn_id' => '8', + 'uid' => '1', + 'approver_uid' => '1', + 'points' => '-9', + 'time_stamp' => '1361395411', + 'changed' => '1361395411', + 'status' => '0', + 'description' => '', + 'reference' => '', + 'expirydate' => '0', + 'expired' => '0', + 'parent_txn_id' => '0', + 'tid' => '2', + 'entity_id' => '0', + 'entity_type' => NULL, + 'operation' => 'admin', +)) +->execute(); +db_update('system')->fields(array( + 'schema_version' => '7199', + 'status' => 1, +)) +->condition('name', 'userpoints') +->execute(); diff --git a/userpoints.test b/userpoints.test index d06d9e3..963a728 100644 --- a/userpoints.test +++ b/userpoints.test @@ -706,3 +706,45 @@ class UserpointsFieldsTestCase extends UserpointsBaseTestCase { $this->assertText($message['field_' . $name . '[' . LANGUAGE_NONE . '][0][value]'], t('Content of new field is displayed.')); } } + +/** + * Tests for update 7200: bundles. + */ +class UserpointsUpdate7200TestCase extends UpdatePathTestCase { + /** + * Implements getInfo(). + */ + public static function getInfo() { + return array( + 'name' => 'Userpoints update 7200', + 'description' => 'Assert that database update 7200 works', + 'group' => 'Userpoints', + ); + } + + /** + * Implements setUp(). + */ + public function setUp() { + + $this->databaseDumpFiles = array( + drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz', + drupal_get_path('module', 'userpoints') . '/userpoints.filled.database.php', + ); + + parent::setUp(); + } + + /** + * Assert successful update. + */ + public function testUpdate() { + $update = $this->performUpgrade(); + + $this->assertTrue($update); + + $this->drupalGet('admin/config/people/points/types'); + $this->assertRaw(t('Default')); + } + +}