AuthorizationManagerTest extends TestCase Uses TestDatabase, RefreshDatabase, withTestUser
Integration tests for the built-in Sprunje classes.
Table of Contents
$migrated | bool | |
---|---|---|
setUp() | Setup the test database. | void |
tearDown() | void | |
testConstructor() | AuthorizationManager | |
testAddCallback() | mixed | |
testService() | Test the service. Will have the predefined callbacks | mixed |
testCheckAccess_withOutUser() | mixed | |
testCheckAccess_withNullUser() | mixed | |
testCheckAccess_withBadUserType() | mixed | |
testCheckAccess_withNullCurrentUser() | By default, `checkAccess` is null. Test to make sure we don't break the "current user is guest" thing | mixed |
testCheckAccess_withNormalUser() | mixed | |
testCheckAccess_withCurrentUser() | Once logged in, `currentUser` will not be null | mixed |
testCheckAccess_withMasterUser() | mixed | |
testCheckAccess_withNormalUserWithPermission() | mixed | |
testCheckAccess_withNormalUserWithFailedPermission() | mixed | |
getManager() | AuthorizationManager | |
getMockAuthLogger() | We'll test using the `debug.auth` on and a mock authLogger to not get our dirty test into the real log | Logger |
setupTestDatabase() | Define the test_integration database connection the default one | mixed |
refreshDatabase() | Define hooks to migrate the database before and after each test. | mixed |
usingInMemoryDatabase() | Determine if an in-memory database is being used. | bool |
refreshInMemoryDatabase() | Refresh the in-memory database. | mixed |
refreshTestDatabase() | Refresh a conventional test database. | mixed |
beginDatabaseTransaction() | Handle database transactions on the specified connections. | mixed |
connectionsToTransact() | The database connections that should have transactions. | array |
loginUser() | mixed | |
logoutCurrentUser() | Logout | mixed |
createTestUser() | Create a test user with no settings/permissions for a controller test | User |
getRandomUserId() | Returns a random user id, exclusing th master id | int |
giveUserTestPermission() | Gives a user a new test permission | Permission |
giveUserPermission() | Add the test permission to a Role, then the role to the user | Role |
Properties
$migrated
public
static bool
$migrated
= false
Methods
setUp()
Setup the test database.
public
setUp(
)
: void
tearDown()
public
tearDown(
)
: void
testConstructor()
public
testConstructor(
)
: AuthorizationManager
Return values
AuthorizationManagertestAddCallback()
public
testAddCallback(
$manager :
AuthorizationManager
)
: mixed
Parameters
- $manager : AuthorizationManager
Tags
Return values
mixedtestService()
Test the service. Will have the predefined callbacks
public
testService(
)
: mixed
Return values
mixedtestCheckAccess_withOutUser()
public
testCheckAccess_withOutUser(
$manager :
AuthorizationManager
)
: mixed
Parameters
- $manager : AuthorizationManager
Tags
Return values
mixedtestCheckAccess_withNullUser()
public
testCheckAccess_withNullUser(
)
: mixed
Tags
Return values
mixedtestCheckAccess_withBadUserType()
public
testCheckAccess_withBadUserType(
)
: mixed
Tags
Return values
mixedtestCheckAccess_withNullCurrentUser()
By default, `checkAccess` is null. Test to make sure we don't break the "current user is guest" thing
public
testCheckAccess_withNullCurrentUser(
)
: mixed
Tags
Return values
mixedtestCheckAccess_withNormalUser()
public
testCheckAccess_withNormalUser(
)
: mixed
Tags
Return values
mixedtestCheckAccess_withCurrentUser()
Once logged in, `currentUser` will not be null
public
testCheckAccess_withCurrentUser(
)
: mixed
Tags
Return values
mixedtestCheckAccess_withMasterUser()
public
testCheckAccess_withMasterUser(
)
: mixed
Tags
Return values
mixedtestCheckAccess_withNormalUserWithPermission()
public
testCheckAccess_withNormalUserWithPermission(
)
: mixed
Tags
Return values
mixedtestCheckAccess_withNormalUserWithFailedPermission()
public
testCheckAccess_withNormalUserWithFailedPermission(
)
: mixed
Tags
Return values
mixedgetManager()
protected
getManager(
)
: AuthorizationManager
Return values
AuthorizationManagergetMockAuthLogger()
We'll test using the `debug.auth` on and a mock authLogger to not get our dirty test into the real log
protected
getMockAuthLogger(
)
: Logger
Return values
LoggersetupTestDatabase()
Define the test_integration database connection the default one
public
setupTestDatabase(
)
: mixed
Return values
mixedrefreshDatabase()
Define hooks to migrate the database before and after each test.
public
refreshDatabase(
)
: mixed
Return values
mixedusingInMemoryDatabase()
Determine if an in-memory database is being used.
public
usingInMemoryDatabase(
)
: bool
Return values
boolrefreshInMemoryDatabase()
Refresh the in-memory database.
protected
refreshInMemoryDatabase(
)
: mixed
Return values
mixedrefreshTestDatabase()
Refresh a conventional test database.
protected
refreshTestDatabase(
)
: mixed
Return values
mixedbeginDatabaseTransaction()
Handle database transactions on the specified connections.
protected
beginDatabaseTransaction(
)
: mixed
Return values
mixedconnectionsToTransact()
The database connections that should have transactions.
protected
connectionsToTransact(
)
: array
Return values
arrayloginUser()
protected
loginUser(
$user :
UserInterface
)
: mixed
Parameters
- $user : UserInterface
Return values
mixedlogoutCurrentUser()
Logout
protected
logoutCurrentUser(
)
: mixed
Return values
mixedcreateTestUser()
Create a test user with no settings/permissions for a controller test
protected
createTestUser(
[ $isMaster :
bool
= false ]
[, $login :
bool
= false ]
[, $params :
array
= [] ]
)
: User
Parameters
- $isMaster : bool = false
Does this user have root access? Will bypass all permissions
- $login : bool = false
Login this user, setting him as the currentUser
- $params : array = []
User account params
Return values
UsergetRandomUserId()
Returns a random user id, exclusing th master id
protected
getRandomUserId(
$masterId :
int
)
: int
Parameters
- $masterId : int
Return values
intgiveUserTestPermission()
Gives a user a new test permission
protected
giveUserTestPermission(
$user :
UserInterface
, $slug :
string
[, $conditions :
string
= 'always()' ]
)
: Permission
Parameters
- $user : UserInterface
- $slug : string
- $conditions : string = 'always()'
Return values
PermissiongiveUserPermission()
Add the test permission to a Role, then the role to the user
protected
giveUserPermission(
$user :
UserInterface
, $permission :
Permission
)
: Role
Parameters
- $user : UserInterface
- $permission : Permission
Return values
Role —The intermidiate role