diff --git modules/simpletest/tests/update.test modules/simpletest/tests/update.test new file mode 100644 index 0000000..f1ef2f3 --- /dev/null +++ modules/simpletest/tests/update.test @@ -0,0 +1,102 @@ + t('Update Single'), + 'description' => t('Tests the execute of a single update step which is successful'), + 'group' => t('Update'), + ); + } + + function setUp() { + parent::setUp('update_test_single'); + } + + function testSingleUpdate() { + drupal_set_installed_schema_version('update_test_single', 0); + + variable_set('simpletest_update', TRUE); + $this->drupalPost('update.php', array(), t('Continue')); + $this->drupalPost(NULL, array(), t('apply pending updates')); + + $this->assertNoPattern('/class="failure">.*Failed:.*Update Successful/i', 'Update successful'); + } +} + +class UpdateFailTestCase extends DrupalWebTestCase { + function getInfo() { + return array( + 'name' => t('Update Fail'), + 'description' => t('Tests the execute of a single update step which has failed'), + 'group' => t('Update'), + ); + } + + function setUp() { + parent::setUp('update_test_fail'); + } + + function testFailUpdate() { + drupal_set_installed_schema_version('update_test_fail', 0); + + variable_set('simpletest_update', TRUE); + $this->drupalPost('update.php', array(), t('Continue')); + $this->drupalPost(NULL, array(), t('apply pending updates')); + + $this->assertPattern('/class="failure">.*Failed:.*Update Successful/i', 'Update failed'); + } +} + +class UpdateAbortTestCase extends DrupalWebTestCase { + function getInfo() { + return array( + 'name' => t('Update Abort'), + 'description' => t('Tests an update being told to abort by the update function'), + 'group' => t('Update'), + ); + } + + function setUp() { + parent::setUp('update_test_abort'); + } + + function testFailUpdate() { + drupal_set_installed_schema_version('update_test_abort', 0); + + variable_set('simpletest_update', TRUE); + $this->drupalPost('update.php', array(), t('Continue')); + $this->drupalPost(NULL, array(), t('apply pending updates')); + + $this->assertPattern('/class="failure">.*Failed:.*operation aborted/i', 'Update aborted'); + } +} + +class UpdateMultipleTestCase extends DrupalWebTestCase { + function getInfo() { + return array( + 'name' => t('Update Multiple'), + 'description' => t('Tests an update which has to call the update mutiple times'), + 'group' => t('Update'), + ); + } + + function setUp() { + parent::setUp('update_test_multiple'); + } + + function testFailUpdate() { + drupal_set_installed_schema_version('update_test_multiple', 0); + + variable_set('simpletest_update', TRUE); + $this->drupalPost('update.php', array(), t('Continue')); + $this->drupalPost(NULL, array(), t('apply pending updates')); + + for ($i = 1; $i < 11; $i++) { + $this->assertText('Update Pass '. $i, 'Update '. $i .' found'); + } + $this->assertText('Update Finished', 'Update Finished found'); + } +} + diff --git modules/simpletest/tests/update_test_abort.info modules/simpletest/tests/update_test_abort.info new file mode 100644 index 0000000..e2cf3af --- /dev/null +++ modules/simpletest/tests/update_test_abort.info @@ -0,0 +1,8 @@ +; $Id$ +name = Update Single Test +description = Test a Successful run of a single call update +package = Testing +version = VERSION +core = 7.x +files[] = update_test_single.module +hidden = TRUE diff --git modules/simpletest/tests/update_test_abort.install modules/simpletest/tests/update_test_abort.install new file mode 100644 index 0000000..2ab2805 --- /dev/null +++ modules/simpletest/tests/update_test_abort.install @@ -0,0 +1,12 @@ + array('success' => FALSE, 'query' => 'operation aborted')); + + return $ret; +} + diff --git modules/simpletest/tests/update_test_abort.module modules/simpletest/tests/update_test_abort.module new file mode 100644 index 0000000..13bb990 --- /dev/null +++ modules/simpletest/tests/update_test_abort.module @@ -0,0 +1,2 @@ + FALSE, 'query' => 'Update Successful')); + + return $ret; +} + diff --git modules/simpletest/tests/update_test_fail.module modules/simpletest/tests/update_test_fail.module new file mode 100644 index 0000000..13bb990 --- /dev/null +++ modules/simpletest/tests/update_test_fail.module @@ -0,0 +1,2 @@ + 10) { + $ret = array(array('success' => TRUE, 'query' => 'Update Finished')); + $ret['#finished'] = 1; + } + else { + $ret = array(array('success' => TRUE, 'query' => 'Update Pass '. $sandbox['count'])); + $ret['#finished'] = $sandbox['count']/11; + } + + $sandbox['count']++; + + return $ret; +} + diff --git modules/simpletest/tests/update_test_multiple.module modules/simpletest/tests/update_test_multiple.module new file mode 100644 index 0000000..13bb990 --- /dev/null +++ modules/simpletest/tests/update_test_multiple.module @@ -0,0 +1,2 @@ + TRUE, 'query' => 'Update Successful')); + + return $ret; +} + diff --git modules/simpletest/tests/update_test_single.module modules/simpletest/tests/update_test_single.module new file mode 100644 index 0000000..13bb990 --- /dev/null +++ modules/simpletest/tests/update_test_single.module @@ -0,0 +1,2 @@ +uid == 1) { +if (!empty($update_free_access) || $user->uid == 1 || variable_get('simpletest_update', FALSE)) { include_once DRUPAL_ROOT . '/includes/install.inc'; include_once DRUPAL_ROOT . '/includes/batch.inc';