metatag.with_media.test 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @file
  4. * Tests for the Metatag module for Media integration.
  5. */
  6. /**
  7. * Tests for the Metatag module for Media integration.
  8. */
  9. class MetatagCoreWithMediaTest extends MetatagTestHelper {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Metatag core tests with Media',
  16. 'description' => 'Test Metatag integration with the Media module.',
  17. 'group' => 'Metatag',
  18. 'dependencies' => array('ctools', 'token', 'file_entity', 'media'),
  19. );
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. function setUp(array $modules = array()) {
  25. $modules[] = 'file_entity';
  26. $modules[] = 'media';
  27. // The filter is in the WYSIWYG submodule.
  28. $modules[] = 'media_wysiwyg';
  29. parent::setUp($modules);
  30. }
  31. /**
  32. * Make sure the media filter is enabled.
  33. */
  34. public function testMediaFilter() {
  35. $desc = 'The description.';
  36. // Create a node and check how the meta tag is displayed.
  37. $node = $this->drupalCreateNode(array(
  38. 'body' => array(
  39. LANGUAGE_NONE => array(
  40. array(
  41. 'value' => $desc . '[[{"fid":"1","view_mode":"default","type":"media","attributes":{"height":"100","width":"100","class":"media-element file-default"}}]]',
  42. 'format' => filter_default_format(),
  43. ),
  44. ),
  45. ),
  46. ));
  47. // Load the node page.
  48. $this->drupalGet('node/' . $node->nid);
  49. $this->assertResponse(200);
  50. // Check the 'description' tag to make sure the Media string was filtered.
  51. $xpath = $this->xpath("//meta[@name='description']");
  52. $this->assertEqual($xpath[0]['content'], $desc);
  53. }
  54. }