roleTest.php

  1. 8.0.x tests/roleTest.php
  2. 6.x tests/roleTest.php
  3. 7.x tests/roleTest.php
  4. master tests/roleTest.php

Tests for role.drush.inc

Namespace

Unish

Classes

Namesort ascending Description
roleCase @group slow @group commands

File

tests/roleTest.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Tests for role.drush.inc
  5. */
  6. namespace Unish;
  7. /**
  8. * @group slow
  9. * @group commands
  10. */
  11. class roleCase extends CommandUnishTestCase {
  12. /**
  13. * Create, edit, block, and cancel users.
  14. */
  15. public function testRole() {
  16. // In D8+, the testing profile has no perms.
  17. $sites = $this->setUpDrupal(1, TRUE, UNISH_DRUPAL_MAJOR_VERSION, UNISH_DRUPAL_MAJOR_VERSION == 6 ? 'default' : 'standard');
  18. $root = $this->webroot();
  19. $name = "example";
  20. $options = array(
  21. 'root' => $root,
  22. 'uri' => key($sites),
  23. 'yes' => NULL,
  24. );
  25. $anonymous = 'anonymous';
  26. $authenticated = 'authenticated';
  27. if (UNISH_DRUPAL_MAJOR_VERSION < 8) {
  28. $anonymous .= ' user';
  29. $authenticated .= ' user';
  30. }
  31. $this->drush('role-list', array($anonymous), $options + array('pipe' => NULL) );
  32. $output = $this->getOutput();
  33. $this->assertContains('access content', $output);
  34. $this->drush('role-list', array($authenticated), $options + array('pipe' => NULL) );
  35. $output = $this->getOutput();
  36. $this->assertContains('access content', $output);
  37. $this->drush('role-add-perm', array($anonymous, 'administer nodes'), $options );
  38. $this->drush('role-list', array($anonymous), $options + array('pipe' => NULL) );
  39. $output = $this->getOutput();
  40. $this->assertContains('administer nodes', $output);
  41. $this->drush('role-remove-perm', array($anonymous, 'administer nodes'), $options );
  42. $this->drush('role-list', array($anonymous), $options + array('pipe' => NULL) );
  43. $output = $this->getOutput();
  44. $this->assertNotContains('administer nodes', $output);
  45. }
  46. }