metatag.with_media.test 1.5 KB

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