head_links.test 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @file
  4. * Tests the head links for page manager pages.
  5. */
  6. /**
  7. * Test the head links.
  8. */
  9. class HeadLinksTestCase extends DrupalWebTestCase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Head links test',
  16. 'description' => 'Checks that the shortlink and canonical links are present on a node page overriden by Page manager',
  17. 'group' => 'ctools',
  18. );
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function setUp() {
  24. parent::setUp('page_manager');
  25. // First add an override for "node/%node".
  26. variable_set('page_manager_node_view_disabled', FALSE);
  27. $record = (object) array(
  28. 'name' => 'node_view__http_response_707659df-062d-4252-8c2a-22a8e0289cd4',
  29. 'task' => 'node_view',
  30. 'subtask' => '',
  31. 'handler' => 'http_response',
  32. 'weight' => '1',
  33. 'conf' => array(
  34. 'title' => 'Test',
  35. 'contexts' => array(
  36. 0 => array(
  37. 'identifier' => 'String',
  38. 'keyword' => 'string',
  39. 'name' => 'string',
  40. 'string' => 'Test',
  41. 'id' => 1,
  42. ),
  43. ),
  44. 'relationships' => array(),
  45. 'code' => '404',
  46. 'destination' => '',
  47. 'name' => '',
  48. ),
  49. );
  50. page_manager_save_task_handler($record);
  51. menu_rebuild();
  52. }
  53. /**
  54. * Test the presence of the head links.
  55. */
  56. public function testHeadLinks() {
  57. $node = $this->drupalCreateNode();
  58. $url = 'node/' . $node->nid;
  59. $this->drupalGet($url);
  60. $shortlink = $this->xpath('//head//link[@rel="shortlink"]');
  61. $this->assertEqual(url($url), (string) $shortlink[0]['href'], 'shortlink url found');
  62. $canonical = $this->xpath('//head//link[@rel="canonical"]');
  63. $this->assertEqual(url($url), (string) $canonical[0]['href'], 'canonical url found');
  64. }
  65. }