Documentation

UserTest extends TestCase
in package
implements EndToEndInterface, TransactionalInterface

Test the Standaloneusers User Api4 actions

Tips:

  • With HookInterface, you may implement CiviCRM hooks directly in the test class. Simply create corresponding functions (e.g. "hook_civicrm_post(...)" or similar).
  • With TransactionalInterface, any data changes made by setUp() or test****() functions will rollback automatically -- as long as you don't manipulate schema or truncate tables. If this test needs to manipulate schema or truncate tables, then either: a. Do all that using setupHeadless() and Civi\Test. b. Disable TransactionalInterface, and handle all setup/teardown yourself.

Fun fact: Running E2E tests with TransactionalInterface is usually prohibitive because of the split DB. However, with Standalone, there's a single DB, so it may work some of the time. (It only becomes prohibitive if you actually use HTTP.)

Tags
group

e2e

Table of Contents

Interfaces

EndToEndInterface
Interface EndToEndInterface
TransactionalInterface
Interface HeadlessInterface

Constants

ADMIN_ROLE_ID  = 1

Properties

$adminContactID  : int
$adminUserID  : int
$contactID  : int
$nonAdminContactID  : int
$nonAdminRoleID  : int
$nonAdminUserID  : int
$otherUserIDs  : array<string|int, mixed>
$userID  : int

Methods

dumpUFMatch()  : mixed
Temporary debugging function
ensureLoggedOut()  : mixed
setUp()  : void
setUpBeforeClass()  : void
tearDown()  : void
testAdminCanChangeRoles()  : mixed
testAdminDeletes()  : mixed
testAdminRoleProtections()  : mixed
testAdminsCanCreate()  : mixed
testAnonymousUserHasNoAccess()  : mixed
Superflous test but here for completeness' sake since it would be bad if anon users could access the User API!
testEveryoneRoleProtections()  : mixed
testGetIsLimited()  : mixed
testNonAdminCannotChangeRoles()  : mixed
testNonAdminDeletes()  : mixed
testNonAdminsCantCreate()  : mixed
testNonPermissionedPasswordChanging()  : mixed
Check non-permissioned password changing.
testOtherApiAccess()  : mixed
Important that roles, permissions, sessions can't be messed about with or inspected by non-admins.
testPermissionedPasswordChangingAsAdmin()  : mixed
Check non-permissioned password changing.
testPermissionedPasswordChangingAsNonAdmin()  : mixed
Check non-permissioned password changing.
testPermissionedSaveAsAdmin()  : mixed
testPermissionedSaveAsNonAdmin()  : mixed
assertRoleCannotBeDeleted()  : mixed
assertRoleUpdateFails()  : mixed
createFixture()  : void
createNonadminRole()  : int
deleteStuffWeMade()  : mixed
loginUser()  : mixed

Constants

ADMIN_ROLE_ID

public mixed ADMIN_ROLE_ID = 1

Properties

$adminContactID

protected int $adminContactID

$nonAdminContactID

protected int $nonAdminContactID

$nonAdminRoleID

protected int $nonAdminRoleID

$nonAdminUserID

protected int $nonAdminUserID

$otherUserIDs

protected array<string|int, mixed> $otherUserIDs = []

Methods

dumpUFMatch()

Temporary debugging function

public dumpUFMatch([string $s = '' ]) : mixed
Parameters
$s : string = ''

ensureLoggedOut()

public ensureLoggedOut() : mixed

setUpBeforeClass()

public static setUpBeforeClass() : void

testAdminCanChangeRoles()

public testAdminCanChangeRoles() : mixed

testAdminDeletes()

public testAdminDeletes() : mixed

testAdminRoleProtections()

public testAdminRoleProtections() : mixed

testAdminsCanCreate()

public testAdminsCanCreate() : mixed

testAnonymousUserHasNoAccess()

Superflous test but here for completeness' sake since it would be bad if anon users could access the User API!

public testAnonymousUserHasNoAccess() : mixed

testEveryoneRoleProtections()

public testEveryoneRoleProtections() : mixed

testGetIsLimited()

public testGetIsLimited() : mixed

testNonAdminCannotChangeRoles()

public testNonAdminCannotChangeRoles() : mixed

testNonAdminDeletes()

public testNonAdminDeletes() : mixed

testNonAdminsCantCreate()

public testNonAdminsCantCreate() : mixed

testNonPermissionedPasswordChanging()

Check non-permissioned password changing.

public testNonPermissionedPasswordChanging() : mixed

testOtherApiAccess()

Important that roles, permissions, sessions can't be messed about with or inspected by non-admins.

public testOtherApiAccess() : mixed

testPermissionedPasswordChangingAsAdmin()

Check non-permissioned password changing.

public testPermissionedPasswordChangingAsAdmin() : mixed

testPermissionedPasswordChangingAsNonAdmin()

Check non-permissioned password changing.

public testPermissionedPasswordChangingAsNonAdmin() : mixed

testPermissionedSaveAsAdmin()

public testPermissionedSaveAsAdmin() : mixed

testPermissionedSaveAsNonAdmin()

public testPermissionedSaveAsNonAdmin() : mixed

assertRoleCannotBeDeleted()

protected assertRoleCannotBeDeleted(mixed $roleName) : mixed
Parameters
$roleName : mixed

assertRoleUpdateFails()

protected assertRoleUpdateFails(mixed $roleName, array<string|int, mixed> $updates) : mixed
Parameters
$roleName : mixed
$updates : array<string|int, mixed>

createFixture()

protected createFixture() : void

createNonadminRole()

protected createNonadminRole() : int
Return values
int

deleteStuffWeMade()

protected deleteStuffWeMade() : mixed

loginUser()

protected loginUser(mixed $userID) : mixed
Parameters
$userID : mixed

        
On this page

Search results