context_ui.test 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. 'administer contexts',
  23. 'access content',
  24. 'create blog content'
  25. ));
  26. $this->drupalLogin($admin_user);
  27. }
  28. function testCreateContext() {
  29. // Create context
  30. $context = new stdClass();
  31. $context->name = strtolower($this->randomName(15));
  32. $context->description = strtolower($this->randomName(15));
  33. $context->tag = strtolower($this->randomName(15));
  34. $this->context = $context;
  35. $this->drupalGet('admin');
  36. $this->drupalGet('admin/structure');
  37. $this->drupalGet('admin/structure/context');
  38. $edit = array(
  39. 'name' => $context->name,
  40. 'description' => $context->description,
  41. 'tag' => $context->tag,
  42. 'conditions[plugins][node][values][blog]' => 'blog',
  43. 'reactions[plugins][menu][]' => 'navigation:node/add/blog',
  44. );
  45. $this->drupalPost('admin/structure/context/add', $edit, 'Save');
  46. $this->assertText($context->name . ' has been created.', 'Context saved.');
  47. $edit = array();
  48. // export_ui confirm delete
  49. $this->drupalPost('admin/structure/context/list/' . $context->name . '/edit', $edit, 'Delete');
  50. $this->assertTrue(strpos($this->getUrl(), 'admin/structure/context/list/' . $context->name . '/delete') !== FALSE, 'Context deletion confirmation page displayed');
  51. }
  52. }