Projet

Général

Profil

Paste
Télécharger (1,82 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / page_manager / tests / head_links.test @ 7e72b748

1
<?php
2
/**
3
 * @file
4
 * Tests the head links for page manager pages.
5
 */
6

    
7
/**
8
 * Test the head links.
9
 */
10
class HeadLinksTestCase extends DrupalWebTestCase {
11
  /**
12
   * {@inheritdoc}
13
   */
14
  public static function getInfo() {
15
    return array(
16
      'name' => 'Head links test',
17
      'description' => 'Checks that the shortlink and canonical links are present on a node page overriden by Page manager',
18
      'group' => 'ctools',
19
    );
20
  }
21

    
22
  /**
23
   * {@inheritdoc}
24
   */
25
  public function setUp() {
26
    parent::setUp('page_manager');
27

    
28
    // First add an override for "node/%node".
29
    variable_set('page_manager_node_view_disabled', FALSE);
30

    
31
    $record = (object) array(
32
      'name' => 'node_view__http_response_707659df-062d-4252-8c2a-22a8e0289cd4',
33
      'task' => 'node_view',
34
      'subtask' => '',
35
      'handler' => 'http_response',
36
      'weight' => '1',
37
      'conf' => array(
38
        'title' => 'Test',
39
        'contexts' => array(
40
          0 => array(
41
            'identifier' => 'String',
42
            'keyword' => 'string',
43
            'name' => 'string',
44
            'string' => 'Test',
45
            'id' => 1,
46
          ),
47
        ),
48
        'relationships' => array(),
49
        'code' => '404',
50
        'destination' => '',
51
        'name' => '',
52
      ),
53
    );
54

    
55
    page_manager_save_task_handler($record);
56

    
57
    menu_rebuild();
58
  }
59

    
60
  /**
61
   * Test the presence of the head links.
62
   */
63
  public function testHeadLinks() {
64
    $node = $this->drupalCreateNode();
65
    $url = 'node/' . $node->nid;
66
    $this->drupalGet($url);
67

    
68
    $shortlink = $this->xpath('//head//link[@rel="shortlink"]');
69
    $this->assertEqual(url($url), (string) $shortlink[0]['href'], 'shortlink url found');
70

    
71
    $canonical = $this->xpath('//head//link[@rel="canonical"]');
72
    $this->assertEqual(url($url), (string) $canonical[0]['href'], 'canonical url found');
73
  }
74
}