contextual.test 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * Tests for contextual.module.
  5. */
  6. /**
  7. * Tests accessible links after inaccessible links on dynamic context.
  8. */
  9. class ContextualDynamicContextTestCase extends DrupalWebTestCase {
  10. protected $profile = 'testing';
  11. public static function getInfo() {
  12. return array(
  13. 'name' => 'Contextual links on node lists',
  14. 'description' => 'Tests if contextual links are showing on the front page depending on permissions.',
  15. 'group' => 'Contextual',
  16. );
  17. }
  18. function setUp() {
  19. parent::setUp(array('contextual', 'node'));
  20. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
  21. $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
  22. $web_user = $this->drupalCreateUser(array('access content', 'access contextual links', 'edit any article content'));
  23. $this->drupalLogin($web_user);
  24. }
  25. /**
  26. * Tests contextual links on node lists with different permissions.
  27. */
  28. function testNodeLinks() {
  29. // Create three nodes in the following order:
  30. // - An article, which should be user-editable.
  31. // - A page, which should not be user-editable.
  32. // - A second article, which should also be user-editable.
  33. $node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
  34. $node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
  35. $node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
  36. // Now, on the front page, all article nodes should have contextual edit
  37. // links. The page node in between should not.
  38. $this->drupalGet('node');
  39. $this->assertRaw('node/' . $node1->nid . '/edit', 'Edit link for oldest article node showing.');
  40. $this->assertNoRaw('node/' . $node2->nid . '/edit', 'No edit link for page nodes.');
  41. $this->assertRaw('node/' . $node3->nid . '/edit', 'Edit link for most recent article node showing.');
  42. }
  43. }