'Update 7310', 'description' => 'Confirm update 7310 works as intended.', 'group' => 'backup_migrate', ); } /** * {@inheritdoc} */ public function setUp(array $modules = array()) { parent::setUp($modules); // Log in as user 1, so that permissions are irrelevant. $this->loginUser1(); } /** * Test update 7310. */ public function testUpdate7310() { require_once dirname(__FILE__) . '/../includes/destinations.inc'; require_once dirname(__FILE__) . '/../includes/schedules.inc'; $this->assertEqual(function_exists('backup_migrate_update_7310'), TRUE, 'Update 7310 exists.'); // First test what happens when there are no e-mail destinations. // Execute the update function. $result = backup_migrate_update_7310(); // We should be getting a notice as a result. $message = "The following notice was displayed: "$result""; $expected = 'No destinations were affected by this change.'; $this->assertEqual($expected, $result, $message); // Next, add e-mail destinations and see what happens then. // Create two mock e-mail destinations. $address = strtolower($this->randomName(10)) . '@example.com'; $email_destination_id = strtolower($this->randomName(16)); $this->submitDestinationEmail('Mock e-mail destination', $email_destination_id, $address); $address = strtolower($this->randomName(10)) . '@example.com'; $email_destination_id = strtolower($this->randomName(16)); $this->submitDestinationEmail('Mock e-mail destination', $email_destination_id, $address); $this->assertText(t('Your destination was saved')); // Create mock schedules with different types of destinations. $mock_schedule_1 = $this->randomName(10); $mock_schedule_2 = $this->randomName(10); $mock_schedule_3 = $this->randomName(10); $this->submitSchedule($mock_schedule_1, 'test_1', 'scheduled', ''); $this->assertText(t('Your schedule was saved')); $this->submitSchedule($mock_schedule_2, 'test_2', $email_destination_id, ''); $this->assertText(t('Your schedule was saved')); $this->submitSchedule($mock_schedule_3, 'test_3', 'scheduled', $email_destination_id); $this->assertText(t('Your schedule was saved')); $destinations = db_select('backup_migrate_destinations', 'bmd')->fields('bmd', array('machine_name'))->condition('subtype', 'email', '=')->execute()->fetchAllAssoc('machine_name', PDO::FETCH_ASSOC); $destinations = array_keys($destinations); // Execute the update function. $result = backup_migrate_update_7310(); // We should be getting a notice as a result. $expected = htmlspecialchars("Schedules that back up to e-mail destinations have been disabled. Check that you are using the correct e-mail addresses, then re-enable manually. The following schedules have been disabled: