fe_block.test 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * @file
  4. * Tests for the Features Extra Block module.
  5. */
  6. /**
  7. * Tests the functionality of FE Block.
  8. */
  9. class FeaturesExtraBlockTestCase extends FeaturesExtraTestCase {
  10. // The installation profile that will be used to run the tests.
  11. protected $profile = 'testing';
  12. // Stores a test block.
  13. protected $block;
  14. public static function getInfo() {
  15. return array(
  16. 'name' => 'FE Block',
  17. 'description' => 'Tests Features integration for blocks and block settings.',
  18. 'group' => 'Features Extra',
  19. );
  20. }
  21. /**
  22. * Check that all modules that are required for the test suite are available.
  23. */
  24. public function testRequiredModules() {
  25. $required_modules = array(
  26. 'block',
  27. 'block_class',
  28. 'blockcache_alter',
  29. 'ctools',
  30. 'features',
  31. 'fe_block',
  32. 'features_extra_test',
  33. );
  34. foreach ($required_modules as $module) {
  35. $this->assertTrue(module_exists($module), format_string('The required module @module exists.', array('@module' => $module)));
  36. }
  37. }
  38. /**
  39. * Test if custom blocks can be reverted and that overrides are detected.
  40. */
  41. public function testBlockRevert() {
  42. // Ensure that the exported custom block is properly available.
  43. $bid = fe_block_get_bid('features_extra_test_block');
  44. $this->block = block_load('block', $bid);
  45. $this->assertTrue(!empty($this->block), 'The reverted block is present.');
  46. $components = array(
  47. 'fe_block_boxes',
  48. 'fe_block_settings',
  49. );
  50. $this->revertComponents($components);
  51. }
  52. /**
  53. * Change the content of the test block so the component becomes overridden.
  54. */
  55. protected function override_fe_block_boxes() {
  56. db_update('block_custom')
  57. ->fields(array('body' => 'overridden'))
  58. ->condition('bid', $this->block->bid)
  59. ->execute();
  60. }
  61. /**
  62. * Change a setting of the test block so the component becomes overridden.
  63. */
  64. protected function override_fe_block_settings() {
  65. db_update('block')
  66. ->fields(array('region' => 'footer'))
  67. ->condition('bid', $this->block->bid)
  68. ->condition('theme', 'bartik')
  69. ->execute();
  70. }
  71. /**
  72. * Tests the integration with the Block Class module.
  73. *
  74. * @see http://www.drupal.org/node/1342996
  75. */
  76. public function testBlockClass() {
  77. $this->drupalGet('<front>');
  78. $this->assertRaw('test-class', 'The class set by the Block Class module has been found.');
  79. }
  80. /**
  81. * Tests the integration with the Block Cache Alter module.
  82. *
  83. * @see http://www.drupal.org/node/1973926
  84. */
  85. public function testBlockCacheAlter() {
  86. $bid = fe_block_get_bid('features_extra_test_block');
  87. $this->block = block_load('block', $bid);
  88. $this->assertEqual($this->block->cache, DRUPAL_CACHE_GLOBAL, 'The test block uses the caching method set by the Block Cache Alter module.');
  89. }
  90. }