X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Ftests%2FRoleTest.php;fp=vendor%2Fdrush%2Fdrush%2Ftests%2FRoleTest.php;h=6fc9de603209e09d54bfe0d6076a1a0ae22ba920;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/drush/drush/tests/RoleTest.php b/vendor/drush/drush/tests/RoleTest.php new file mode 100644 index 000000000..6fc9de603 --- /dev/null +++ b/vendor/drush/drush/tests/RoleTest.php @@ -0,0 +1,65 @@ +setUpDrupal(1, true); + + // In D8+, the testing profile has no perms. + // Copy the module to where Drupal expects it. + $this->setupModulesForTests(['user_form_test'], Path::join($this->webroot(), 'core/modules/user/tests/modules')); + $this->drush('pm-enable', ['user_form_test']); + + $this->drush('role-list'); + $output = $this->getOutput(); + $this->assertNotContains('cancel other accounts', $output); + + $this->drush('role-list', [], ['filter' => 'cancel other accounts']); + $output = $this->getOutput(); + $this->assertNotContains('authenticated', $output); + $this->assertNotContains('anonymous', $output); + + // Create the role foo. + $rid = 'foo'; + $this->drush('role-create', [$rid]); + $this->drush('role-list'); + $this->assertContains($rid, $this->getOutput()); + + // Assert that anon user starts without 'cancel other accounts' perm. + $perm = 'cancel other accounts'; + $this->drush('role-list', [], ['format' => 'json']); + $role = $this->getOutputFromJSON($rid); + $this->assertFalse(in_array($perm, $role->perms)); + + // Now grant that perm to foo. + $this->drush('role-add-perm', [$rid, 'cancel other accounts']); + $this->drush('role-list', [], ['format' => 'json']); + $role = $this->getOutputFromJSON($rid); + $this->assertTrue(in_array($perm, $role->perms)); + + // Now remove the perm from foo. + $this->drush('role-remove-perm', [$rid, 'cancel other accounts']); + $this->drush('role-list', [], ['format' => 'json']); + $role = $this->getOutputFromJSON($rid); + $this->assertFalse(in_array($perm, $role->perms)); + + // Delete the foo role + $this->drush('role-delete', [$rid]); + $this->drush('role-list'); + $this->assertNotContains($rid, $this->getOutput()); + } +}