metatag.with_workbench_moderation.test 3.5 KB

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