context_ui.test 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Functional Test for Context UI
  4. *
  5. * TODO Test if menu and blocks respond.
  6. */
  7. class ContextUiTestCase extends DrupalWebTestCase {
  8. protected $profile = 'testing';
  9. public static function getInfo() {
  10. return array(
  11. 'name' => 'Context UI functional tests',
  12. 'description' => 'Create and save a context.',
  13. 'group' => 'Context UI',
  14. );
  15. }
  16. function setUp() {
  17. parent::setUp('ctools', 'context', 'context_ui', 'blog', 'menu');
  18. // Create and login user
  19. $admin_user = $this->drupalCreateUser(array(
  20. 'access administration pages',
  21. 'administer site configuration',
  22. 'access content',
  23. 'create blog content'
  24. ));
  25. $this->drupalLogin($admin_user);
  26. }
  27. function testCreateContext() {
  28. // Create context
  29. $context = new stdClass();
  30. $context->name = strtolower($this->randomName(15));
  31. $context->description = strtolower($this->randomName(15));
  32. $context->tag = strtolower($this->randomName(15));
  33. $this->context = $context;
  34. $this->drupalGet('admin');
  35. $this->drupalGet('admin/structure');
  36. $this->drupalGet('admin/structure/context');
  37. $edit = array(
  38. 'name' => $context->name,
  39. 'description' => $context->description,
  40. 'tag' => $context->tag,
  41. 'conditions[plugins][node][values][blog]' => 'blog',
  42. 'reactions[plugins][menu]' => 'node/add/blog',
  43. );
  44. $this->drupalPost('admin/structure/context/add', $edit, 'Save');
  45. $this->assertText($context->name . ' has been created.', 'Context saved.');
  46. $edit = array();
  47. // export_ui confirm delete
  48. $this->drupalPost('admin/structure/context/list/' . $context->name . '/edit', $edit, 'Delete');
  49. $this->assertTrue(strpos($this->getUrl(), 'admin/structure/context/list/' . $context->name . '/delete') !== FALSE, 'Context deletion confirmation page displayed');
  50. }
  51. }