public function roleCase::testRole

8.0.x roleTest.php public roleCase::testRole()
6.x roleTest.php public roleCase::testRole()
7.x roleTest.php public roleCase::testRole()
master roleTest.php public roleCase::testRole()

Create, edit, block, and cancel users.

File

tests/roleTest.php, line 19
Tests for role.drush.inc

Namespace

Unish

Class

roleCase
@group slow @group commands

Code

public function testRole() {
  // In D8+, the testing profile has no perms.
  $sites = $this->setUpDrupal(1, TRUE, UNISH_DRUPAL_MAJOR_VERSION, 'standard');
  $root = $this->webroot();
  $name = "example";
  $options = array(
    'root' => $root,
    'uri' => key($sites),
    'yes' => NULL,
  );
  $anonymous = 'anonymous';
  $authenticated = 'authenticated';
  if (UNISH_DRUPAL_MAJOR_VERSION < 8) {
    $anonymous .= ' user';
    $authenticated .= ' user';
  }
  $this->drush('role-list', array($anonymous), $options + array('pipe' => NULL));
  $output = $this->getOutput();
  $this->assertContains('access content', $output);
  $this->drush('role-list', array($authenticated), $options + array('pipe' => NULL));
  $output = $this->getOutput();
  $this->assertContains('access content', $output);
  $this->drush('role-add-perm', array($anonymous, 'administer nodes'), $options);
  $this->drush('role-list', array($anonymous), $options + array('pipe' => NULL));
  $output = $this->getOutput();
  $this->assertContains('administer nodes', $output);
  $this->drush('role-remove-perm', array($anonymous, 'administer nodes'), $options);
  $this->drush('role-list', array($anonymous), $options + array('pipe' => NULL));
  $output = $this->getOutput();
  $this->assertNotContains('administer nodes', $output);
}