BmTestCtools.test 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * @file
  4. * Test extended functionality as provided by Ctools.
  5. */
  6. /**
  7. * Class for testing CTools' extended functionality.
  8. */
  9. class BmTestCtools extends BmTestBase {
  10. /**
  11. * Define this test class.
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'CTools tests',
  16. 'description' => 'Test integration with the CTools module.',
  17. 'group' => 'backup_migrate',
  18. 'dependencies' => array('ctools'),
  19. );
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function setUp(array $modules = array()) {
  25. $modules[] = 'bm_test';
  26. $modules[] = 'ctools';
  27. parent::setUp($modules);
  28. // Log in as user 1, so that permissions are irrelevant.
  29. $this->loginUser1();
  30. }
  31. /**
  32. * Confirm automated settings exist.
  33. */
  34. public function testSettingsPage() {
  35. // Load the B&M Settings page.
  36. $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings');
  37. $this->assertResponse(200);
  38. // Does the mock schedule exist?
  39. $this->assertText('Mock weekly database schedule');
  40. // Does the mock source exist?
  41. $this->assertText('Mock file directory');
  42. // Does the mock destination exist?
  43. $this->assertText('Mock e-mail destination');
  44. // Load the B&M Schedule page.
  45. $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/schedule');
  46. $this->assertResponse(200);
  47. // Does the mock schedule exist?
  48. $this->assertText('Mock weekly database schedule');
  49. // Does the mock schedule contain the appropriate values?
  50. $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/schedule/edit/mock_db_weekly');
  51. $this->assertResponse(200);
  52. $fields = _bm_test_get_mock_schedule();
  53. // @todo Deal with periods, but now I need sleep.
  54. // See the get_frequency_period() method in includes/schedules.inc.
  55. unset($fields['period']);
  56. // Test the destination selection with its own assertion.
  57. $this->assertOptionSelected('edit-destination-id', $fields['destination_id']);
  58. unset($fields['destination_id']);
  59. foreach ($fields as $key => $field) {
  60. $id = 'edit-' . str_replace('_', '-', $key);
  61. $this->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
  62. }
  63. // Does the mock source contain the appropriate values?
  64. $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/source/edit/mock_file_directory');
  65. $this->assertResponse(200);
  66. $fields = _bm_test_get_mock_source();
  67. unset($fields['subtype']);
  68. foreach ($fields as $key => $field) {
  69. $id = 'edit-' . str_replace('_', '-', $key);
  70. $this->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
  71. }
  72. // Does the mock destination contain the appropriate values?
  73. $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/edit/mock_email');
  74. $this->assertResponse(200);
  75. $fields = _bm_test_get_mock_destination();
  76. unset($fields['subtype']);
  77. foreach ($fields as $key => $field) {
  78. $id = 'edit-' . str_replace('_', '-', $key);
  79. $this->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
  80. }
  81. }
  82. }