metatag.with_me.test 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @file
  4. * Tests for the Metatag module for Me module integration.
  5. */
  6. /**
  7. * Tests for the Metatag module for Me module integration.
  8. */
  9. class MetatagCoreWithMeTest extends MetatagTestHelper {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Metatag core tests with Me',
  16. 'description' => 'Test Metatag integration with the Me module.',
  17. 'group' => 'Metatag',
  18. 'dependencies' => array('ctools', 'token', 'me'),
  19. );
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. function setUp(array $modules = array()) {
  25. $modules[] = 'me';
  26. parent::setUp($modules);
  27. }
  28. /**
  29. * Make sure the /user/me path doesn't load any meta tags.
  30. */
  31. public function testMePath() {
  32. // Create an admin user and log them in.
  33. if (!isset($this->adminUser)) {
  34. $this->adminUser = $this->createAdminUser();
  35. }
  36. $this->drupalLogin($this->adminUser);
  37. // Load the user's profile page.
  38. // Load the 'me' page.
  39. $this->drupalGet('user/' . $this->adminUser->uid);
  40. $this->assertResponse(200);
  41. // Look for some meta tags that should exist.
  42. $xpath = $this->xpath("//meta[@name='generator']");
  43. $this->assertEqual(count($xpath), 1, 'Exactly one generator meta tag found.');
  44. $this->assertEqual($xpath[0]['content'], 'Drupal 7 (https://www.drupal.org)');
  45. $xpath = $this->xpath("//link[@rel='canonical']");
  46. $this->assertEqual(count($xpath), 1, 'Exactly one canonical meta tag found.');
  47. $this->assertEqual($xpath[0]['href'], url('user/' . $this->adminUser->uid, array('absolute' => TRUE)));
  48. $xpath = $this->xpath("//link[@rel='shortlink']");
  49. $this->assertEqual(count($xpath), 1, 'Exactly one shortlink meta tag found.');
  50. $this->assertEqual($xpath[0]['href'], url('user/' . $this->adminUser->uid, array('absolute' => TRUE)));
  51. // Load the 'me' page.
  52. $this->drupalGet('user/me');
  53. $this->assertResponse(200);
  54. // Confirm the meta tags defined above don't exist.
  55. $xpath = $this->xpath("//meta[@name='generator']");
  56. $this->assertEqual(count($xpath), 0, 'Did not find the generator meta tag.');
  57. $xpath = $this->xpath("//link[@rel='canonical']");
  58. $this->assertEqual(count($xpath), 0, 'Did not find the canonical meta tag.');
  59. $xpath = $this->xpath("//link[@rel='shortlink']");
  60. $this->assertEqual(count($xpath), 0, 'Did not find the shortlink meta tag.');
  61. }
  62. }