upgrade.test

  1. drupal
    1. 7 modules/simpletest/tests/upgrade/upgrade.test
    2. 8 core/modules/system/tests/upgrade/upgrade.test

Classes

NameDescription
BasicMinimalUpdatePathPerforms point release update tests on a bare database.
BasicStandardUpdatePathPerforms point release update tests on a bare database.
BasicUpgradePathPerform basic upgrade tests.
FilledMinimalUpdatePathPerforms point release update tests on a populated database.
FilledStandardUpdatePathPerforms point release update tests on a 'filled' database.
UpdatePathTestCasePerforms end-to-end point test of the release update path.
UpgradePathTestCasePerform end-to-end tests of the upgrade path.

File

modules/simpletest/tests/upgrade/upgrade.test
View source
  1. <?php
  2. /**
  3. * Perform end-to-end tests of the upgrade path.
  4. */
  5. abstract class UpgradePathTestCase extends DrupalWebTestCase {
  6. /**
  7. * The file path(s) to the dumped database(s) to load into the child site.
  8. *
  9. * @var array
  10. */
  11. var $databaseDumpFiles = array();
  12. /**
  13. * Flag that indicates whether the child site has been upgraded.
  14. */
  15. var $upgradedSite = FALSE;
  16. /**
  17. * Array of errors triggered during the upgrade process.
  18. */
  19. var $upgradeErrors = array();
  20. /**
  21. * Array of modules loaded when the test starts.
  22. */
  23. var $loadedModules = array();
  24. /**
  25. * Flag to indicate whether zlib is installed or not.
  26. */
  27. var $zlibInstalled = TRUE;
  28. /**
  29. * Flag to indicate whether there are pending updates or not.
  30. */
  31. var $pendingUpdates = TRUE;
  32. /**
  33. * Constructs an UpgradePathTestCase object.
  34. *
  35. * @param $test_id
  36. * (optional) The ID of the test. Tests with the same id are reported
  37. * together.
  38. */
  39. function __construct($test_id = NULL) {
  40. parent::__construct($test_id);
  41. $this->zlibInstalled = function_exists('gzopen');
  42. }
  43. /**
  44. * Prepares the appropriate session for the release of Drupal being upgraded.
  45. */
  46. protected function prepareD7Session() {
  47. // Generate and set a D6-compatible session cookie.
  48. $this->curlInitialize();
  49. $sid = drupal_hash_base64(uniqid(mt_rand(), TRUE) . drupal_random_bytes(55));
  50. $session_name = update_get_d6_session_name();
  51. curl_setopt($this->curlHandle, CURLOPT_COOKIE, rawurlencode($session_name) . '=' . rawurlencode($sid));
  52. // Force our way into the session of the child site.
  53. drupal_save_session(TRUE);
  54. // A session cannot be written without the ssid column which is missing on
  55. // Drupal 6 sites.
  56. db_add_field('sessions', 'ssid', array('description' => "Secure session ID. The value is generated by Drupal's session handlers.", 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
  57. _drupal_session_write($sid, '');
  58. // Remove the temporarily added ssid column.
  59. db_drop_field('sessions', 'ssid');
  60. drupal_save_session(FALSE);
  61. }
  62. /**
  63. * Override of DrupalWebTestCase::setUp() specialized for upgrade testing.
  64. */
  65. protected function setUp() {
  66. // We are going to set a missing zlib requirement property for usage
  67. // during the performUpgrade() and tearDown() methods. Also set that the
  68. // tests failed.
  69. if (!$this->zlibInstalled) {
  70. parent::setUp();
  71. return;
  72. }
  73. global $user, $language, $conf;
  74. // Load the Update API.
  75. require_once DRUPAL_ROOT . '/includes/update.inc';
  76. // Reset flags.
  77. $this->upgradedSite = FALSE;
  78. $this->upgradeErrors = array();
  79. $this->loadedModules = module_list();
  80. // Generate a temporary prefixed database to ensure that tests have a clean starting point.
  81. $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
  82. db_update('simpletest_test_id')
  83. ->fields(array('last_prefix' => $this->databasePrefix))
  84. ->condition('test_id', $this->testId)
  85. ->execute();
  86. // Clone the current connection and replace the current prefix.
  87. $connection_info = Database::getConnectionInfo('default');
  88. Database::renameConnection('default', 'simpletest_original_default');
  89. foreach ($connection_info as $target => $value) {
  90. $connection_info[$target]['prefix'] = array(
  91. 'default' => $value['prefix']['default'] . $this->databasePrefix,
  92. );
  93. }
  94. Database::addConnectionInfo('default', 'default', $connection_info['default']);
  95. // Store necessary current values before switching to prefixed database.
  96. $this->originalLanguage = $language;
  97. $this->originalLanguageDefault = variable_get('language_default');
  98. $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
  99. $this->originalProfile = drupal_get_profile();
  100. $clean_url_original = variable_get('clean_url', 0);
  101. // Unregister the registry.
  102. // This is required to make sure that the database layer works properly.
  103. spl_autoload_unregister('drupal_autoload_class');
  104. spl_autoload_unregister('drupal_autoload_interface');
  105. // Create test directories ahead of installation so fatal errors and debug
  106. // information can be logged during installation process.
  107. // Use mock files directories with the same prefix as the database.
  108. $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
  109. $private_files_directory = $public_files_directory . '/private';
  110. $temp_files_directory = $private_files_directory . '/temp';
  111. // Create the directories.
  112. file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  113. file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
  114. file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY);
  115. $this->generatedTestFiles = FALSE;
  116. // Log fatal errors.
  117. ini_set('log_errors', 1);
  118. ini_set('error_log', $public_files_directory . '/error.log');
  119. // Reset all statics and variables to perform tests in a clean environment.
  120. $conf = array();
  121. // Load the database from the portable PHP dump.
  122. // The files may be gzipped.
  123. foreach ($this->databaseDumpFiles as $file) {
  124. if (substr($file, -3) == '.gz') {
  125. $file = "compress.zlib://$file";
  126. }
  127. require $file;
  128. }
  129. // Set path variables.
  130. $this->variable_set('file_public_path', $public_files_directory);
  131. $this->variable_set('file_private_path', $private_files_directory);
  132. $this->variable_set('file_temporary_path', $temp_files_directory);
  133. $this->pass('Finished loading the dump.');
  134. // Load user 1.
  135. $this->originalUser = $user;
  136. drupal_save_session(FALSE);
  137. $user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchObject();
  138. // Generate and set a D6-compatible session cookie.
  139. $this->prepareD7Session();
  140. // Restore necessary variables.
  141. $this->variable_set('clean_url', $clean_url_original);
  142. $this->variable_set('site_mail', 'simpletest@example.com');
  143. drupal_set_time_limit($this->timeLimit);
  144. $this->setup = TRUE;
  145. }
  146. /**
  147. * Override of DrupalWebTestCase::tearDown() specialized for upgrade testing.
  148. */
  149. protected function tearDown() {
  150. global $user, $language;
  151. if (!$this->zlibInstalled) {
  152. parent::tearDown();
  153. return;
  154. }
  155. // In case a fatal error occurred that was not in the test process read the
  156. // log to pick up any fatal errors.
  157. simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
  158. // Delete temporary files directory.
  159. file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
  160. // Get back to the original connection.
  161. Database::removeConnection('default');
  162. Database::renameConnection('simpletest_original_default', 'default');
  163. // Remove all prefixed tables.
  164. $tables = db_find_tables($this->databasePrefix . '%');
  165. foreach ($tables as $table) {
  166. db_drop_table($table);
  167. }
  168. // Return the user to the original one.
  169. $user = $this->originalUser;
  170. drupal_save_session(TRUE);
  171. // Ensure that internal logged in variable and cURL options are reset.
  172. $this->loggedInUser = FALSE;
  173. $this->additionalCurlOptions = array();
  174. // Reload module list and implementations to ensure that test module hooks
  175. // aren't called after tests.
  176. module_list(TRUE);
  177. module_implements('', FALSE, TRUE);
  178. // Reset the Field API.
  179. field_cache_clear();
  180. // Rebuild caches.
  181. parent::refreshVariables();
  182. // Reset language.
  183. $language = $this->originalLanguage;
  184. if ($this->originalLanguageDefault) {
  185. $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
  186. }
  187. // Close the CURL handler.
  188. $this->curlClose();
  189. }
  190. /**
  191. * Specialized variable_set() that works even if the child site is not upgraded.
  192. *
  193. * @param $name
  194. * The name of the variable to set.
  195. * @param $value
  196. * The value to set. This can be any PHP data type; these functions take care
  197. * of serialization as necessary.
  198. */
  199. protected function variable_set($name, $value) {
  200. db_delete('variable')
  201. ->condition('name', $name)
  202. ->execute();
  203. db_insert('variable')
  204. ->fields(array(
  205. 'name' => $name,
  206. 'value' => serialize($value),
  207. ))
  208. ->execute();
  209. try {
  210. cache_clear_all('variables', 'cache');
  211. cache_clear_all('variables', 'cache_bootstrap');
  212. }
  213. // Since cache_bootstrap won't exist in a Drupal 6 site, ignore the
  214. // exception if the above fails.
  215. catch (Exception $e) {}
  216. }
  217. /**
  218. * Specialized refreshVariables().
  219. */
  220. protected function refreshVariables() {
  221. // No operation if the child has not been upgraded yet.
  222. if (!$this->upgradedSite) {
  223. return parent::refreshVariables();
  224. }
  225. }
  226. /**
  227. * Perform the upgrade.
  228. *
  229. * @param $register_errors
  230. * Register the errors during the upgrade process as failures.
  231. * @return
  232. * TRUE if the upgrade succeeded, FALSE otherwise.
  233. */
  234. protected function performUpgrade($register_errors = TRUE) {
  235. if (!$this->zlibInstalled) {
  236. $this->fail(t('Missing zlib requirement for upgrade tests.'));
  237. return FALSE;
  238. }
  239. $update_url = $GLOBALS['base_url'] . '/update.php';
  240. // Load the first update screen.
  241. $this->drupalGet($update_url, array('external' => TRUE));
  242. if (!$this->assertResponse(200)) {
  243. return FALSE;
  244. }
  245. // Continue.
  246. $this->drupalPost(NULL, array(), t('Continue'));
  247. if (!$this->assertResponse(200)) {
  248. return FALSE;
  249. }
  250. // The test should pass if there are no pending updates.
  251. $content = $this->drupalGetContent();
  252. if (strpos($content, t('No pending updates.')) !== FALSE) {
  253. $this->pass(t('No pending updates and therefore no upgrade process to test.'));
  254. $this->pendingUpdates = FALSE;
  255. return TRUE;
  256. }
  257. // Go!
  258. $this->drupalPost(NULL, array(), t('Apply pending updates'));
  259. if (!$this->assertResponse(200)) {
  260. return FALSE;
  261. }
  262. // Check for errors during the update process.
  263. foreach ($this->xpath('//li[@class=:class]', array(':class' => 'failure')) as $element) {
  264. $message = strip_tags($element->asXML());
  265. $this->upgradeErrors[] = $message;
  266. if ($register_errors) {
  267. $this->fail($message);
  268. }
  269. }
  270. if (!empty($this->upgradeErrors)) {
  271. // Upgrade failed, the installation might be in an inconsistent state,
  272. // don't process.
  273. return FALSE;
  274. }
  275. // Check if there still are pending updates.
  276. $this->drupalGet($update_url, array('external' => TRUE));
  277. $this->drupalPost(NULL, array(), t('Continue'));
  278. if (!$this->assertText(t('No pending updates.'), t('No pending updates at the end of the update process.'))) {
  279. return FALSE;
  280. }
  281. // Upgrade succeed, rebuild the environment so that we can call the API
  282. // of the child site directly from this request.
  283. $this->upgradedSite = TRUE;
  284. // Reload module list. For modules that are enabled in the test database,
  285. // but not on the test client, we need to load the code here.
  286. $new_modules = array_diff(module_list(TRUE), $this->loadedModules);
  287. foreach ($new_modules as $module) {
  288. drupal_load('module', $module);
  289. }
  290. // Reload hook implementations
  291. module_implements('', FALSE, TRUE);
  292. // Rebuild caches.
  293. drupal_static_reset();
  294. drupal_flush_all_caches();
  295. // Reload global $conf array and permissions.
  296. $this->refreshVariables();
  297. $this->checkPermissions(array(), TRUE);
  298. return TRUE;
  299. }
  300. /**
  301. * Force uninstall all modules from a test database, except those listed.
  302. *
  303. * @param $modules
  304. * The list of modules to keep installed. Required core modules will
  305. * always be kept.
  306. */
  307. protected function uninstallModulesExcept(array $modules) {
  308. $required_modules = array('block', 'dblog', 'filter', 'node', 'system', 'update', 'user');
  309. $modules = array_merge($required_modules, $modules);
  310. db_delete('system')
  311. ->condition('type', 'module')
  312. ->condition('name', $modules, 'NOT IN')
  313. ->execute();
  314. }
  315. }
  316. /**
  317. * Performs end-to-end point test of the release update path.
  318. */
  319. abstract class UpdatePathTestCase extends UpgradePathTestCase {
  320. /**
  321. * Overrides UpgradePathTestCase::prepareD7Session().
  322. */
  323. protected function prepareD7Session() {
  324. // Generate and set a D7-compatible session cookie.
  325. $this->curlInitialize();
  326. $sid = drupal_hash_base64(uniqid(mt_rand(), TRUE) . drupal_random_bytes(55));
  327. curl_setopt($this->curlHandle, CURLOPT_COOKIE, rawurlencode(session_name()) . '=' . rawurlencode($sid));
  328. // Force our way into the session of the child site.
  329. drupal_save_session(TRUE);
  330. _drupal_session_write($sid, '');
  331. drupal_save_session(FALSE);
  332. }
  333. }
  334. /**
  335. * Perform basic upgrade tests.
  336. *
  337. * Load a bare installation of Drupal 6 and run the upgrade process on it.
  338. *
  339. * The install only contains dblog (although it's optional, it's only so that
  340. * another hook_watchdog module can take its place, the site is not functional
  341. * without watchdog) and update.
  342. */
  343. class BasicUpgradePath extends UpgradePathTestCase {
  344. public static function getInfo() {
  345. return array(
  346. 'name' => 'Basic upgrade path',
  347. 'description' => 'Basic upgrade path tests.',
  348. 'group' => 'Upgrade path',
  349. );
  350. }
  351. public function setUp() {
  352. // Path to the database dump files.
  353. $this->databaseDumpFiles = array(
  354. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
  355. );
  356. parent::setUp();
  357. }
  358. /**
  359. * Test a failed upgrade, and verify that the failure is reported.
  360. */
  361. public function testFailedUpgrade() {
  362. // Destroy a table that the upgrade process needs.
  363. db_drop_table('access');
  364. // Assert that the upgrade fails.
  365. $this->assertFalse($this->performUpgrade(FALSE) && $this->pendingUpdates, t('A failed upgrade should return messages.'));
  366. }
  367. /**
  368. * Test a successful upgrade.
  369. */
  370. public function testBasicUpgrade() {
  371. $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
  372. // Hit the frontpage.
  373. $this->drupalGet('');
  374. $this->assertResponse(200);
  375. // Verify that we are still logged in.
  376. $this->drupalGet('user');
  377. $this->clickLink(t('Edit'));
  378. $this->assertEqual($this->getUrl(), url('user/1/edit', array('absolute' => TRUE)), t('We are still logged in as admin at the end of the upgrade.'));
  379. // Logout and verify that we can login back in with our initial password.
  380. $this->drupalLogout();
  381. $this->drupalLogin((object) array(
  382. 'uid' => 1,
  383. 'name' => 'admin',
  384. 'pass_raw' => 'admin',
  385. ));
  386. // The previous login should've triggered a password rehash, so login one
  387. // more time to make sure the new hash is readable.
  388. $this->drupalLogout();
  389. $this->drupalLogin((object) array(
  390. 'uid' => 1,
  391. 'name' => 'admin',
  392. 'pass_raw' => 'admin',
  393. ));
  394. // Test that the site name is correctly displayed.
  395. $this->assertText('Drupal 6', t('The site name is correctly displayed.'));
  396. // Verify that the main admin sections are available.
  397. $this->drupalGet('admin');
  398. $this->assertText(t('Content'));
  399. $this->assertText(t('Appearance'));
  400. $this->assertText(t('People'));
  401. $this->assertText(t('Configuration'));
  402. $this->assertText(t('Reports'));
  403. $this->assertText(t('Structure'));
  404. $this->assertText(t('Modules'));
  405. // Confirm that no {menu_links} entry exists for user/autocomplete.
  406. $result = db_query('SELECT COUNT(*) FROM {menu_links} WHERE link_path = :user_autocomplete', array(':user_autocomplete' => 'user/autocomplete'))->fetchField();
  407. $this->assertFalse($result, t('No {menu_links} entry exists for user/autocomplete'));
  408. // Test that the environment after the upgrade is in a consistent status.
  409. $update_d6 = variable_get('update_d6', FALSE);
  410. $this->assertFalse($update_d6, t('The D6 upgrade flag variable has been correctly disabled.'));
  411. }
  412. }
  413. /**
  414. * Performs point release update tests on a bare database.
  415. *
  416. * Loads an installation of Drupal 7.0 and runs the update process on it.
  417. *
  418. * The install contains the standard profile (plus all optional) modules
  419. * without any content so that an update from any of the modules under this
  420. * profile installation can be wholly tested.
  421. */
  422. class BasicStandardUpdatePath extends UpdatePathTestCase {
  423. public static function getInfo() {
  424. return array(
  425. 'name' => 'Basic standard + all profile update path',
  426. 'description' => 'Basic update path tests for a standard profile install with all enabled modules.',
  427. 'group' => 'Upgrade path',
  428. );
  429. }
  430. public function setUp() {
  431. // Path to the database dump files.
  432. $this->databaseDumpFiles = array(
  433. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz',
  434. );
  435. parent::setUp();
  436. }
  437. /**
  438. * Tests a successful point release update.
  439. */
  440. public function testBasicStandardUpdate() {
  441. $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
  442. // Hit the frontpage.
  443. $this->drupalGet('');
  444. $this->assertResponse(200);
  445. // Verify that we are still logged in.
  446. $this->drupalGet('user');
  447. $this->clickLink(t('Edit'));
  448. $this->assertEqual($this->getUrl(), url('user/1/edit', array('absolute' => TRUE)), t('We are still logged in as admin at the end of the upgrade.'));
  449. // Logout and verify that we can login back in with our initial password.
  450. $this->drupalLogout();
  451. $this->drupalLogin((object) array(
  452. 'uid' => 1,
  453. 'name' => 'admin',
  454. 'pass_raw' => 'admin',
  455. ));
  456. // The previous login should've triggered a password rehash, so login one
  457. // more time to make sure the new hash is readable.
  458. $this->drupalLogout();
  459. $this->drupalLogin((object) array(
  460. 'uid' => 1,
  461. 'name' => 'admin',
  462. 'pass_raw' => 'admin',
  463. ));
  464. // Test that the site name is correctly displayed.
  465. $this->assertText('Drupal', t('The site name is correctly displayed.'));
  466. // Verify that the main admin sections are available.
  467. $this->drupalGet('admin');
  468. $this->assertText(t('Content'));
  469. $this->assertText(t('Appearance'));
  470. $this->assertText(t('People'));
  471. $this->assertText(t('Configuration'));
  472. $this->assertText(t('Reports'));
  473. $this->assertText(t('Structure'));
  474. $this->assertText(t('Modules'));
  475. // Confirm that no {menu_links} entry exists for user/autocomplete.
  476. $result = db_query('SELECT COUNT(*) FROM {menu_links} WHERE link_path = :user_autocomplete', array(':user_autocomplete' => 'user/autocomplete'))->fetchField();
  477. $this->assertFalse($result, t('No {menu_links} entry exists for user/autocomplete'));
  478. }
  479. }
  480. /**
  481. * Performs point release update tests on a bare database.
  482. *
  483. * Loads an installation of Drupal 7.0 and runs the update process on it.
  484. *
  485. * The install contains the minimal profile modules (without any generated
  486. * content) so that an update from of a site under this profile may be tested.
  487. */
  488. class BasicMinimalUpdatePath extends UpdatePathTestCase {
  489. public static function getInfo() {
  490. return array(
  491. 'name' => 'Basic minimal profile update path',
  492. 'description' => 'Basic update path tests for a minimal profile install.',
  493. 'group' => 'Upgrade path',
  494. );
  495. }
  496. public function setUp() {
  497. // Path to the database dump files.
  498. $this->databaseDumpFiles = array(
  499. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.bare.minimal.database.php.gz',
  500. );
  501. parent::setUp();
  502. }
  503. /**
  504. * Tests a successful point release update.
  505. */
  506. public function testBasicMinimalUpdate() {
  507. $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
  508. // Hit the frontpage.
  509. $this->drupalGet('');
  510. $this->assertResponse(200);
  511. // Verify that we are still logged in.
  512. $this->drupalGet('user');
  513. $this->clickLink(t('Edit'));
  514. $this->assertEqual($this->getUrl(), url('user/1/edit', array('absolute' => TRUE)), t('We are still logged in as admin at the end of the upgrade.'));
  515. // Logout and verify that we can login back in with our initial password.
  516. $this->drupalLogout();
  517. $this->drupalLogin((object) array(
  518. 'uid' => 1,
  519. 'name' => 'admin',
  520. 'pass_raw' => 'admin',
  521. ));
  522. // The previous login should've triggered a password rehash, so login one
  523. // more time to make sure the new hash is readable.
  524. $this->drupalLogout();
  525. $this->drupalLogin((object) array(
  526. 'uid' => 1,
  527. 'name' => 'admin',
  528. 'pass_raw' => 'admin',
  529. ));
  530. // Test that the site name is correctly displayed.
  531. $this->assertText('Drupal', t('The site name is correctly displayed.'));
  532. // Verify that the main admin sections are available.
  533. $this->drupalGet('admin');
  534. $this->assertText(t('Content'));
  535. $this->assertText(t('Appearance'));
  536. $this->assertText(t('People'));
  537. $this->assertText(t('Configuration'));
  538. $this->assertText(t('Reports'));
  539. $this->assertText(t('Structure'));
  540. $this->assertText(t('Modules'));
  541. // Confirm that no {menu_links} entry exists for user/autocomplete.
  542. $result = db_query('SELECT COUNT(*) FROM {menu_links} WHERE link_path = :user_autocomplete', array(':user_autocomplete' => 'user/autocomplete'))->fetchField();
  543. $this->assertFalse($result, t('No {menu_links} entry exists for user/autocomplete'));
  544. }
  545. }
  546. /**
  547. * Performs point release update tests on a 'filled' database.
  548. *
  549. * Loads an installation of Drupal 7.0 and runs the update process on it.
  550. *
  551. * The install contains the standard profile (plus all optional) modules
  552. * with generated content so that an update from any of the modules under this
  553. * profile installation can be wholly tested.
  554. */
  555. class FilledStandardUpdatePath extends UpdatePathTestCase {
  556. public static function getInfo() {
  557. return array(
  558. 'name' => 'Basic standard + all profile update path, populated database',
  559. 'description' => 'Basic update path tests for a standard profile install with all enabled modules and a populated database.',
  560. 'group' => 'Upgrade path',
  561. );
  562. }
  563. public function setUp() {
  564. // Path to the database dump files.
  565. $this->databaseDumpFiles = array(
  566. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.filled.standard_all.database.php.gz',
  567. );
  568. parent::setUp();
  569. }
  570. /**
  571. * Tests a successful point release update.
  572. */
  573. public function testFilledStandardUpdate() {
  574. $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
  575. // Hit the frontpage.
  576. $this->drupalGet('');
  577. $this->assertResponse(200);
  578. // Verify that we are still logged in.
  579. $this->drupalGet('user');
  580. $this->clickLink(t('Edit'));
  581. $this->assertEqual($this->getUrl(), url('user/1/edit', array('absolute' => TRUE)), t('We are still logged in as admin at the end of the upgrade.'));
  582. // Logout and verify that we can login back in with our initial password.
  583. $this->drupalLogout();
  584. $this->drupalLogin((object) array(
  585. 'uid' => 1,
  586. 'name' => 'admin',
  587. 'pass_raw' => 'admin',
  588. ));
  589. // The previous login should've triggered a password rehash, so login one
  590. // more time to make sure the new hash is readable.
  591. $this->drupalLogout();
  592. $this->drupalLogin((object) array(
  593. 'uid' => 1,
  594. 'name' => 'admin',
  595. 'pass_raw' => 'admin',
  596. ));
  597. // Test that the site name is correctly displayed.
  598. $this->assertText('Drupal', t('The site name is correctly displayed.'));
  599. // Verify that the main admin sections are available.
  600. $this->drupalGet('admin');
  601. $this->assertText(t('Content'));
  602. $this->assertText(t('Appearance'));
  603. $this->assertText(t('People'));
  604. $this->assertText(t('Configuration'));
  605. $this->assertText(t('Reports'));
  606. $this->assertText(t('Structure'));
  607. $this->assertText(t('Modules'));
  608. // Confirm that no {menu_links} entry exists for user/autocomplete.
  609. $result = db_query('SELECT COUNT(*) FROM {menu_links} WHERE link_path = :user_autocomplete', array(':user_autocomplete' => 'user/autocomplete'))->fetchField();
  610. $this->assertFalse($result, t('No {menu_links} entry exists for user/autocomplete'));
  611. }
  612. }
  613. /**
  614. * Performs point release update tests on a populated database.
  615. *
  616. * Loads an installation of Drupal 7.0 and runs the update process on it.
  617. *
  618. * The install contains the minimal profile modules (along with generated
  619. * content) so that an update from of a site under this profile may be tested.
  620. */
  621. class FilledMinimalUpdatePath extends UpdatePathTestCase {
  622. public static function getInfo() {
  623. return array(
  624. 'name' => 'Basic minimal profile update path, populated database',
  625. 'description' => 'Basic update path tests for a minimal profile install with a populated database.',
  626. 'group' => 'Upgrade path',
  627. );
  628. }
  629. public function setUp() {
  630. // Path to the database dump files.
  631. $this->databaseDumpFiles = array(
  632. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-7.filled.minimal.database.php.gz',
  633. );
  634. parent::setUp();
  635. }
  636. /**
  637. * Tests a successful point release update.
  638. */
  639. public function testFilledStandardUpdate() {
  640. $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
  641. // Hit the frontpage.
  642. $this->drupalGet('');
  643. $this->assertResponse(200);
  644. // Verify that we are still logged in.
  645. $this->drupalGet('user');
  646. $this->clickLink(t('Edit'));
  647. $this->assertEqual($this->getUrl(), url('user/1/edit', array('absolute' => TRUE)), t('We are still logged in as admin at the end of the upgrade.'));
  648. // Logout and verify that we can login back in with our initial password.
  649. $this->drupalLogout();
  650. $this->drupalLogin((object) array(
  651. 'uid' => 1,
  652. 'name' => 'admin',
  653. 'pass_raw' => 'admin',
  654. ));
  655. // The previous login should've triggered a password rehash, so login one
  656. // more time to make sure the new hash is readable.
  657. $this->drupalLogout();
  658. $this->drupalLogin((object) array(
  659. 'uid' => 1,
  660. 'name' => 'admin',
  661. 'pass_raw' => 'admin',
  662. ));
  663. // Test that the site name is correctly displayed.
  664. $this->assertText('Drupal', t('The site name is correctly displayed.'));
  665. // Verify that the main admin sections are available.
  666. $this->drupalGet('admin');
  667. $this->assertText(t('Content'));
  668. $this->assertText(t('Appearance'));
  669. $this->assertText(t('People'));
  670. $this->assertText(t('Configuration'));
  671. $this->assertText(t('Reports'));
  672. $this->assertText(t('Structure'));
  673. $this->assertText(t('Modules'));
  674. // Confirm that no {menu_links} entry exists for user/autocomplete.
  675. $result = db_query('SELECT COUNT(*) FROM {menu_links} WHERE link_path = :user_autocomplete', array(':user_autocomplete' => 'user/autocomplete'))->fetchField();
  676. $this->assertFalse($result, t('No {menu_links} entry exists for user/autocomplete'));
  677. }
  678. }
Login or register to post comments