File: contextual.test

package info (click to toggle)
drupal7 7.14-2%2Bdeb7u12
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 24,516 kB
  • sloc: php: 42,979; pascal: 39,064; sh: 1,622; xml: 441; makefile: 14; sql: 1
file content (49 lines) | stat: -rw-r--r-- 1,926 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

/**
 * @file
 * Tests for contextual.module.
 */

/**
 * Tests accessible links after inaccessible links on dynamic context.
 */
class ContextualDynamicContextTestCase extends DrupalWebTestCase {
  protected $profile = 'testing';

  public static function getInfo() {
    return array(
      'name' => 'Contextual links on node lists',
      'description' => 'Tests if contextual links are showing on the front page depending on permissions.',
      'group' => 'Contextual',
    );
  }

  function setUp() {
    parent::setUp(array('contextual', 'node'));
    $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
    $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
    $web_user = $this->drupalCreateUser(array('access content', 'access contextual links', 'edit any article content'));
    $this->drupalLogin($web_user);
  }

  /**
   * Tests contextual links on node lists with different permissions.
   */
  function testNodeLinks() {
    // Create three nodes in the following order:
    // - An article, which should be user-editable.
    // - A page, which should not be user-editable.
    // - A second article, which should also be user-editable.
    $node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
    $node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
    $node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));

    // Now, on the front page, all article nodes should have contextual edit
    // links. The page node in between should not.
    $this->drupalGet('node');
    $this->assertRaw('node/' . $node1->nid . '/edit', 'Edit link for oldest article node showing.');
    $this->assertNoRaw('node/' . $node2->nid . '/edit', 'No edit link for page nodes.');
    $this->assertRaw('node/' . $node3->nid . '/edit', 'Edit link for most recent article node showing.');
  }
}