metatag.with_me.test 2.3 KB

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