metatag.with_workbench_moderation.test 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * @file
  4. * Tests for the Metatag module for Workbench Moderation integration.
  5. */
  6. /**
  7. * Tests for the Metatag module for Workbench Moderation integration.
  8. */
  9. class MetatagCoreWithWorkbenchModerationTest extends MetatagTestHelper {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Metatag core tests with Workbench Moderation v3',
  16. 'description' => 'Test Metatag integration with the Workbench Moderation module (v3).',
  17. 'group' => 'Metatag',
  18. 'dependencies' => array('ctools', 'token', 'workbench_moderation'),
  19. );
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. function setUp(array $modules = array()) {
  25. $modules[] = 'workbench_moderation';
  26. parent::setUp($modules);
  27. }
  28. /**
  29. * Confirm that WM-based node edit workflows work properly.
  30. */
  31. public function testNodeEdit() {
  32. // Create a new content type and enable moderation on it.
  33. $content_type = 'metatag_test';
  34. $content_type_path = str_replace('_', '-', $content_type);
  35. $label = 'Test';
  36. $this->createContentType($content_type, $label);
  37. variable_set('node_options_' . $content_type, array('revision', 'moderation'));
  38. // Create a brand new unpublished node programmatically.
  39. $settings = array(
  40. 'title' => 'Who likes magic',
  41. 'type' => $content_type,
  42. 'metatags' => array(
  43. LANGUAGE_NONE => array(
  44. 'abstract' => array('value' => '[node:title] ponies'),
  45. ),
  46. ),
  47. 'status' => NODE_NOT_PUBLISHED,
  48. );
  49. $node = $this->drupalCreateNode($settings);
  50. // Check that page is not published.
  51. $this->drupalGet('node/' . $node->nid);
  52. $this->assertResponse(403);
  53. // Create and login user.
  54. $moderator_user = $this->drupalCreateUser(array(
  55. 'access content',
  56. 'view revisions',
  57. 'view all unpublished content',
  58. 'view moderation history',
  59. 'view moderation messages',
  60. 'bypass workbench moderation',
  61. "create {$content_type} content",
  62. "edit any {$content_type} content",
  63. ));
  64. $this->drupalLogin($moderator_user);
  65. // Publish the node via the moderation form.
  66. $moderate = array('state' => workbench_moderation_state_published());
  67. $this->drupalPost("node/{$node->nid}/moderation", $moderate, t('Apply'));
  68. // Create draft with different node title.
  69. $edit = array(
  70. 'title' => 'I like magic',
  71. );
  72. $this->drupalPost("node/{$node->nid}/edit", $edit, t('Save'));
  73. // Logout user.
  74. $this->drupalLogout();
  75. // Check that page is already published.
  76. $this->drupalGet('node/' . $node->nid);
  77. $this->assertResponse(200);
  78. // Verify the title is using the custom default for this content type.
  79. $xpath = $this->xpath("//meta[@name='abstract']");
  80. $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.');
  81. $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies');
  82. // Login user again.
  83. $this->drupalLogin($moderator_user);
  84. // Publish draft via the moderation form.
  85. $moderate = array('state' => workbench_moderation_state_published());
  86. $this->drupalPost("node/{$node->nid}/moderation", $moderate, t('Apply'));
  87. // Logout user.
  88. $this->drupalLogout();
  89. // Check that page is already published.
  90. $this->drupalGet('node/' . $node->nid);
  91. $this->assertResponse(200);
  92. // Verify the title is using the custom default for this content type.
  93. $xpath = $this->xpath("//meta[@name='abstract']");
  94. $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.');
  95. $this->assertEqual($xpath[0]['content'], 'I like magic ponies');
  96. }
  97. }