BmTestBasics.test 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * @file
  4. * Tests for different parts of the Backup Migrate system.
  5. */
  6. /**
  7. * Test that the front page still loads.
  8. */
  9. class BmTestBasics extends BmTestBase {
  10. /**
  11. * Define this test class.
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Basic tests',
  16. 'description' => 'Run through basic scenarios and functionality.',
  17. 'group' => 'backup_migrate',
  18. );
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function setUp(array $modules = array()) {
  24. parent::setUp($modules);
  25. // Log in as user 1, so that permissions are irrelevant.
  26. $this->loginUser1();
  27. }
  28. /**
  29. * Verify the main page has the expected functionality available.
  30. */
  31. public function testMainPage() {
  32. // Load the main B&M page.
  33. $this->drupalGet(BACKUP_MIGRATE_MENU_PATH);
  34. $this->assertResponse(200);
  35. // @todo Confirm each of the tabs are present.
  36. // @todo Confirm each of the local tasks are present.
  37. // Confirm the form has the expected fields.
  38. $this->assertFieldByName('source_id');
  39. $this->assertFieldByName('destination_id');
  40. $this->assertFieldByName('profile_id');
  41. $this->assertFieldByName('copy');
  42. $this->assertFieldByName('copy_destination_id');
  43. $this->assertFieldByName('description_enabled');
  44. // This item should not have a value "selected", it just defaults to the
  45. // first item being the active item.
  46. $items = array('db', 'files', 'archive');
  47. $this->assertSelectOptions('edit-source-id', $items);
  48. $this->assertNoOptionsSelected('edit-source-id');
  49. // This item should have a value "selected", not just the first item.
  50. $items = array('manual', 'download', 'nodesquirrel');
  51. $this->assertSelectOptions('edit-destination-id', $items);
  52. $this->assertOptionSelected('edit-destination-id', 'download');
  53. // This item should not have a value "selected", it just defaults to the
  54. // first item being the active item.
  55. $items = array('default');
  56. $this->assertSelectOptions('edit-profile-id', $items);
  57. $this->assertNoOptionsSelected('edit-profile-id');
  58. // This item should not have a value "selected", it just defaults to the
  59. // first item being the active item.
  60. $items = array('manual', 'download', 'nodesquirrel');
  61. $this->assertSelectOptions('edit-copy-destination-id', $items);
  62. $this->assertNoOptionsSelected('edit-copy-destination-id');
  63. }
  64. /**
  65. * Confirm the initial backup process works.
  66. */
  67. public function testFirstBackup() {
  68. // Load the main B&M page.
  69. $this->drupalGet(BACKUP_MIGRATE_MENU_PATH);
  70. $this->assertResponse(200);
  71. // Generate a backup and confirm it was created correctly.
  72. $edit = array(
  73. 'destination_id' => 'manual',
  74. );
  75. $this->drupalPost(NULL, $edit, 'Backup now');
  76. $this->assertResponse(200);
  77. // Confirm the response is as expected. This is split up into separate
  78. // pieces because it'd be more effort than is necessary right now to confirm
  79. // what the exact filename is.
  80. $this->assertText('Default Database backed up successfully');
  81. $this->assertText('in destination Manual Backups Directory');
  82. $this->assertLink('download');
  83. $this->assertLink('restore');
  84. $this->assertLink('delete');
  85. // Try requesting the backup file.
  86. $xpath = $this
  87. ->xpath('//a[normalize-space(text())=:label]', array(
  88. ':label' => 'download',
  89. ));
  90. $this->verbose($xpath);
  91. $this->assertTrue(isset($xpath[0]['href']));
  92. $this->assertNotNull($xpath[0]['href']);
  93. // @todo This doesn't work on drupalci, so work out how to fix it.
  94. // $this->drupalGet($xpath[0]['href']);
  95. $this->assertResponse(200);
  96. }
  97. }
  98. // @todo Test permissions.
  99. // @todo Test admin forms.