boxes_spaces.test 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. class BoxesSpacesTestCase extends BoxesAjaxTestCase {
  3. /**
  4. * Implementation of getInfo().
  5. */
  6. public static function getInfo() {
  7. return array(
  8. 'name' => t('Boxes Spaces functionality'),
  9. 'description' => t('Add custom boxes in Spaces.'),
  10. 'group' => t('Boxes'),
  11. );
  12. }
  13. /**
  14. * Implementation of setUp().
  15. */
  16. function setUp() {
  17. parent::setUp('ctools', 'boxes', 'features', 'purl', 'spaces', 'spaces_ui', 'spaces_user', 'taxonomy', 'spaces_taxonomy');
  18. // Create and login user
  19. $admin_user = $this->drupalCreateUser(array(
  20. 'administer blocks',
  21. 'administer boxes',
  22. 'administer spaces',
  23. 'administer site configuration',
  24. 'administer taxonomy',
  25. ));
  26. $this->drupalLogin($admin_user);
  27. }
  28. function runTest($path) {
  29. $this->ajaxLoadBoxesBlock('boxes_add__simple', $path);
  30. $this->assertResponse('200', 'Response code 200');
  31. $this->assertText(t('Add custom box'), 'Found box add form');
  32. $edit = array(
  33. 'description' => $this->randomName(),
  34. 'title' => $this->randomName(),
  35. 'body' => $this->randomName(32),
  36. );
  37. $this->drupalPost(NULL, $edit, t('Save'));
  38. $response = $this->parseJSON();
  39. $delta = null;
  40. foreach ($response as $command) {
  41. if ($command->command == 'getBlock') {
  42. $delta = $command->delta;
  43. break;
  44. }
  45. }
  46. if (!$delta) {
  47. $this->fail('AJAX block submission failed');
  48. }
  49. $this->ajaxLoadBoxesBlock($delta, $path);
  50. $this->assertResponse('200', 'Response code 200');
  51. $this->assertText($edit['title'], 'Found box');
  52. $this->ajaxLoadBoxesBlock($delta, 'node');
  53. $this->assertNoText($edit['title'], "Block not available outside spaces.");
  54. return $delta;
  55. }
  56. function testUserSpace() {
  57. $delta = $this->runTest('user/3');
  58. // Before this final check we make sure that user/%uid/features/override
  59. // path is actually available. Some of our caches are over exuberant.
  60. $this->drupalPost('admin/config/development/performance', array(), t('Clear cached data'));
  61. $this->drupalGet('user/3/features/overrides');
  62. $this->assertResponse('200', 'Response code 200');
  63. $this->assertText($delta, 'Found overridden box: ' . $delta);
  64. }
  65. function testTermSpace() {
  66. // Setup; set the purl type to path.
  67. $edit = array('purl_types[path]' => 'path');
  68. $this->drupalPost('admin/config/purl/types', $edit, t('Save configuration'));
  69. // Setup; enable path prefixing for taxonomy spaces.
  70. $edit = array('purl_method_spaces_taxonomy' => 'path');
  71. $this->drupalPost('admin/config/purl', $edit, t('Save configuration'));
  72. // Setup; create a vocabulary.
  73. $edit = array(
  74. 'name' => $this->randomName(),
  75. 'module' => strtolower($this->randomName()),
  76. );
  77. $this->drupalPost('admin/structure/taxonomy/add/vocabulary', $edit, t('Save'));
  78. // Setup; Enable this vocab for spaces_taxonomy.
  79. $edit = array('spaces_taxonomy_vid' => '1');
  80. $this->drupalPost('admin/structure/spaces/taxonomy', $edit, t('Save configuration'));
  81. // Setup; Create our term space.
  82. $edit = array(
  83. 'name' => $this->randomName(),
  84. 'purl[value]' => strtolower($this->randomName()),
  85. );
  86. $this->drupalPost('admin/structure/taxonomy/1/add/term', $edit, t('Save'));
  87. // Testing!
  88. $prefix = $edit['purl[value]'];
  89. $this->drupalGet($prefix . '/node');
  90. $this->assertResponse('200', 'Response code 200');
  91. $delta = $this->runTest($prefix . '/node');
  92. // Before this final check we make sure that user/%uid/features/override
  93. // path is actually available. Some of our caches are over exuberant.
  94. $this->drupalPost('admin/config/development/performance', array(), t('Clear cached data'));
  95. $this->drupalGet('taxonomy/term/1/features/overrides');
  96. $this->assertResponse('200', 'Response code 200');
  97. $this->assertText($delta, 'Found overridden box: ' . $delta);
  98. }
  99. }