Trait luya\testsuite\traits\AdminDatabaseTableTrait

Uses Traitsluya\testsuite\traits\DatabaseTableTrait
Implemented byluya\testsuite\cases\NgRestTestCase, luya\testsuite\scopes\PermissionScope
Available since version1.0.20

A trait to make it easier to work with database tables and LUYA admin permission.

Public Methods

Hide inherited methods

Method Description Defined By
addPermissionApi() Add permission api entry luya\testsuite\traits\AdminDatabaseTableTrait
addPermissionRoute() Add permission route. luya\testsuite\traits\AdminDatabaseTableTrait
assignGroupAuth() Assigne a group to an auth entry. luya\testsuite\traits\AdminDatabaseTableTrait
createAdminAuthTable() Create the admin auth table. luya\testsuite\traits\AdminDatabaseTableTrait
createAdminGroupAuthTable() Create the admin group auth table. luya\testsuite\traits\AdminDatabaseTableTrait
createAdminGroupFixture() Create the Group Fixture with given ID. luya\testsuite\traits\AdminDatabaseTableTrait
createAdminLangFixture() Create admin language fixture luya\testsuite\traits\AdminDatabaseTableTrait
createAdminNgRestLogFixture() Create the NgRest Log Fixture. luya\testsuite\traits\AdminDatabaseTableTrait
createAdminQueueLogErrorFixture() Queue Log Error luya\testsuite\traits\AdminDatabaseTableTrait
createAdminQueueLogFixture() Queue Log luya\testsuite\traits\AdminDatabaseTableTrait
createAdminQueueTable() Create the Admin Queue Table luya\testsuite\traits\AdminDatabaseTableTrait
createAdminStorageFileFixture() Storage File luya\testsuite\traits\AdminDatabaseTableTrait
createAdminStorageFilterChainFixture() Storage Filter Chain luya\testsuite\traits\AdminDatabaseTableTrait
createAdminStorageFilterFixture() Storage Filter luya\testsuite\traits\AdminDatabaseTableTrait
createAdminStorageImageFixture() Storage Image luya\testsuite\traits\AdminDatabaseTableTrait
createAdminTagFixture() Create admin tag fixture luya\testsuite\traits\AdminDatabaseTableTrait
createAdminTagRelationFixture() Create admin tag relation fixture luya\testsuite\traits\AdminDatabaseTableTrait
createAdminUserAuthNotificationTable() Create the admin user auth notification table. luya\testsuite\traits\AdminDatabaseTableTrait
createAdminUserDeviceFixture() User Device luya\testsuite\traits\AdminDatabaseTableTrait
createAdminUserFixture() Create the User Fixture with given fixture Data. luya\testsuite\traits\AdminDatabaseTableTrait
createAdminUserGroupTable() Create the admin user group table. luya\testsuite\traits\AdminDatabaseTableTrait
createAdminUserLoginFixture() Admin User Fixture luya\testsuite\traits\AdminDatabaseTableTrait
createAdminUserLoginLockoutFixture() User Login Lockout luya\testsuite\traits\AdminDatabaseTableTrait
createAdminUserOnlineFixture() Create the User Online Fixture. luya\testsuite\traits\AdminDatabaseTableTrait
createGroupFixture() Create the Group Fixture with given ID. luya\testsuite\traits\AdminDatabaseTableTrait
createNgRestLogFixture() Create the NgRest Log Fixture. luya\testsuite\traits\AdminDatabaseTableTrait
createUserFixture() Create the User Fixture with given fixture Data. luya\testsuite\traits\AdminDatabaseTableTrait
createUserOnlineFixture() Create the User Online Fixture. luya\testsuite\traits\AdminDatabaseTableTrait
dropAdminAuthTable() Drop the admin auth table. luya\testsuite\traits\AdminDatabaseTableTrait
dropAdminGroupAuthTable() Drop the admin group auth table. luya\testsuite\traits\AdminDatabaseTableTrait
dropAdminUserAuthNotificationTable() Drop the admin user auth notification table. luya\testsuite\traits\AdminDatabaseTableTrait
dropAdminUserGroupTable() Drop the admin user group table. luya\testsuite\traits\AdminDatabaseTableTrait
removePermissionApi() Remove permission api entry. luya\testsuite\traits\AdminDatabaseTableTrait
removePermissionRoute() Remove permission route luya\testsuite\traits\AdminDatabaseTableTrait
unAssignGroupAuth() Unassigne a group from auth luya\testsuite\traits\AdminDatabaseTableTrait

Method Details

Hide inherited methods

addPermissionApi() public method

Add permission api entry

public integer addPermissionApi ( $id, $api, $isCrud true )
$id
$api string
$isCrud boolean
return integer

Returns the "fake" id fro the given api

                public function addPermissionApi($id, $api, $isCrud = true)
{
    $this->insertRow('admin_auth', [
        'id' => $id,
        'module_name' => '@app',
        'alias_name' => $api,
        'is_crud' => (int) $isCrud,
        'api' => $api,
    ]);
    return $id;
}

            
addPermissionRoute() public method

Add permission route.

public integer addPermissionRoute ( $id, $route, $moduleName '@app' )
$id
$route string
$moduleName
return integer

Returns the fake id for the auth entry.

                public function addPermissionRoute($id, $route, $moduleName = '@app')
{
    $this->insertRow('admin_auth', [
        'id' => $id,
        'module_name' => $moduleName,
        'alias_name' => $route,
        'route' => $route,
    ]);
    return $id;
}

            
assignGroupAuth() public method

Assigne a group to an auth entry.

public integer assignGroupAuth ( $groupId, $authId, $canCreate true, $canUpdate true, $canDelete true )
$groupId integer
$authId integer
$canCreate boolean
$canUpdate boolean
$canDelete boolean
return integer

The number of affected rows.

                public function assignGroupAuth($groupId, $authId, $canCreate = true, $canUpdate = true, $canDelete = true)
{
    return $this->insertRow('admin_group_auth', [
        'group_id' => $groupId,
        'auth_id' => $authId,
        'crud_create' => (int) $canCreate,
        'crud_update' => (int) $canUpdate,
        'crud_delete' => (int) $canDelete,
    ]);
}

            
createAdminAuthTable() public method

Create the admin auth table.

public void createAdminAuthTable ( )

                public function createAdminAuthTable()
{
    $this->createTableIfNotExists('admin_auth', [
        'id' => 'INT(11) PRIMARY KEY',
        'alias_name' => 'text',
        'module_name' => 'text',
        'is_crud' => 'int(11)',
        'route' => 'text',
        'api' => 'text',
        'pool' => 'text',
    ]);
}

            
createAdminGroupAuthTable() public method

Create the admin group auth table.

public void createAdminGroupAuthTable ( )

                public function createAdminGroupAuthTable()
{
    $this->createTableIfNotExists('admin_group_auth', [
        'id' => 'INT(11) PRIMARY KEY',
        'group_id' => 'int(11)',
        'auth_id' => 'int(11)',
        'crud_create' => 'int(11)',
        'crud_update' => 'int(11)',
        'crud_delete' => 'int(11)',
    ]);
}

            
createAdminGroupFixture() public method

Create the Group Fixture with given ID.

public luya\testsuite\fixtures\NgRestModelFixture createAdminGroupFixture ( $id )
$id integer

                public function createAdminGroupFixture($id)
{
    return new NgRestModelFixture([
        'modelClass' => Group::class,
        'fixtureData' => [
            'tester' => [
                'id' => $id,
                'name' => 'Test Group',
            ],
        ],
    ]);
}

            
createAdminLangFixture() public method (available since version 1.0.21)

Create admin language fixture

public luya\testsuite\fixtures\NgRestModelFixture createAdminLangFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminLangFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => Lang::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminNgRestLogFixture() public method

Create the NgRest Log Fixture.

public luya\testsuite\fixtures\ActiveRecordFixture createAdminNgRestLogFixture ( array $fixtureData = [] )
$fixtureData

                public function createAdminNgRestLogFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => NgrestLog::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminQueueLogErrorFixture() public method

Queue Log Error

public luya\testsuite\fixtures\ActiveRecordFixture createAdminQueueLogErrorFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminQueueLogErrorFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => QueueLogError::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminQueueLogFixture() public method

Queue Log

public luya\testsuite\fixtures\ActiveRecordFixture createAdminQueueLogFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminQueueLogFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => QueueLog::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminQueueTable() public method (available since version 1.1.1)

Create the Admin Queue Table

public void createAdminQueueTable ( )

                public function createAdminQueueTable()
{
    return $this->createTableIfNotExists('admin_queue', [
        'id' => 'INT(11) PRIMARY KEY',
        'channel' => 'text',
        'job' => 'blog',
        'pushed_at' => 'int(11)',
        'ttr' => 'int(11)',
        'delay' => 'int(11)',
        'priority' => 'int(11)',
        'reserved_at' => 'int(11)',
        'attempt' => 'int(11)',
        'done_at' => 'int(11)',
    ]);
}

            
createAdminStorageFileFixture() public method (available since version 1.2.0)

Storage File

public luya\testsuite\fixtures\ActiveRecordFixture createAdminStorageFileFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminStorageFileFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => StorageFile::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminStorageFilterChainFixture() public method (available since version 1.2.0)

Storage Filter Chain

public luya\testsuite\fixtures\ActiveRecordFixture createAdminStorageFilterChainFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminStorageFilterChainFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => StorageFilterChain::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminStorageFilterFixture() public method (available since version 1.2.0)

Storage Filter

public luya\testsuite\fixtures\ActiveRecordFixture createAdminStorageFilterFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminStorageFilterFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => StorageFilter::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminStorageImageFixture() public method (available since version 1.2.0)

Storage Image

public luya\testsuite\fixtures\ActiveRecordFixture createAdminStorageImageFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminStorageImageFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => StorageImage::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminTagFixture() public method (available since version 1.0.22)

Create admin tag fixture

public luya\testsuite\fixtures\NgRestModelFixture createAdminTagFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminTagFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => Tag::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminTagRelationFixture() public method (available since version 1.0.22)

Create admin tag relation fixture

public luya\testsuite\fixtures\ActiveRecordFixture createAdminTagRelationFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminTagRelationFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => TagRelation::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminUserAuthNotificationTable() public method

Create the admin user auth notification table.

public void createAdminUserAuthNotificationTable ( )

                public function createAdminUserAuthNotificationTable()
{
    $this->createTableIfNotExists('admin_user_auth_notification', [
        'id' => 'INT(11) PRIMARY KEY',
        'user_id' => 'int(11)',
        'auth_id' => 'int(11)',
        'is_muted' => 'int(11)',
        'model_latest_pk_value' => 'text',
        'model_class' => 'text',
        'created_at' => 'int(11)',
        'updated_at' => 'int(11)',
    ]);
}

            
createAdminUserDeviceFixture() public method (available since version 1.0.27)

User Device

public luya\testsuite\fixtures\ActiveRecordFixture createAdminUserDeviceFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminUserDeviceFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => UserDevice::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminUserFixture() public method

Create the User Fixture with given fixture Data.

public luya\testsuite\fixtures\NgRestModelFixture createAdminUserFixture ( array $fixtureData = [], $defaultSchema true )
$fixtureData array
$defaultSchema

                public function createAdminUserFixture(array $fixtureData = [], $defaultSchema = true)
{
    return new NgRestModelFixture([
        'modelClass' => User::class,
        'schema' => $defaultSchema ? [
            'title' => 'int(11)',
            'firstname' => 'text',
            'lastname' => 'text',
            'email' => 'text',
            'is_deleted' => 'int(11)',
            'is_api_user' => 'boolean',
            'api_last_activity' => 'int(11)',
            'auth_token' => 'text',
            'is_request_logger_enabled' => 'boolean',
            'email_verification_token_timestamp' => 'int(11)',
            'login_attempt_lock_expiration' => 'int(11)',
            'login_attempt' => 'int(11)',
            'email_verification_token' => 'text',
            'api_allowed_ips' => 'text',
            'api_rate_limit' => 'int(11)',
            'cookie_token' => 'text',
            'settings' => 'text',
            'force_reload' => 'int(11)',
            'secure_token_timestamp' => 'int(11)',
            'secure_token' => 'text',
            'password' => 'text',
            'password_salt' => 'text',
            'login_2fa_enabled' => 'int(11)',
            'login_2fa_secret' => 'text',
            'login_2fa_backup_key' => 'text',
            'password_verification_token' => 'text',
            'password_verification_token_timestamp' => 'int(11)',
        ] : null,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminUserGroupTable() public method

Create the admin user group table.

public void createAdminUserGroupTable ( )

                public function createAdminUserGroupTable()
{
    $this->createTableIfNotExists('admin_user_group', [
        'id' => 'INT(11) PRIMARY KEY',
        'user_id' => 'int(11)',
        'group_id' => 'int(11)',
    ]);
}

            
createAdminUserLoginFixture() public method (available since version 1.0.27)

Admin User Fixture

public luya\testsuite\fixtures\NgRestModelFixture createAdminUserLoginFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminUserLoginFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => UserLogin::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminUserLoginLockoutFixture() public method (available since version 1.0.27)

User Login Lockout

public luya\testsuite\fixtures\ActiveRecordFixture createAdminUserLoginLockoutFixture ( array $fixtureData = [] )
$fixtureData array

                public function createAdminUserLoginLockoutFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => UserLoginLockout::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createAdminUserOnlineFixture() public method

Create the User Online Fixture.

public luya\testsuite\fixtures\ActiveRecordFixture createAdminUserOnlineFixture ( array $fixtureData = [] )
$fixtureData

                public function createAdminUserOnlineFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => UserOnline::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createGroupFixture() public method
Deprecated since version 1.0.27:

Create the Group Fixture with given ID.

public luya\testsuite\fixtures\NgRestModelFixture createGroupFixture ( $id )
$id integer

                public function createGroupFixture($id)
{
    trigger_error('use createAdminGroupFixture() instead', E_USER_DEPRECATED);
    return $this->createAdminGroupFixture($id);
}

            
createNgRestLogFixture() public method
Deprecated since version 1.0.27:

Create the NgRest Log Fixture.

public luya\testsuite\fixtures\ActiveRecordFixture createNgRestLogFixture ( array $fixtureData = [] )
$fixtureData

                public function createNgRestLogFixture(array $fixtureData = [])
{
    trigger_error('use createAdminNgRestLogFixture() instead', E_USER_DEPRECATED);
    return $this->createAdminNgRestLogFixture($fixtureData);
}

            
createUserFixture() public method
Deprecated since version 1.0.27:

Create the User Fixture with given fixture Data.

public luya\testsuite\fixtures\NgRestModelFixture createUserFixture ( array $fixtureData = [] )
$fixtureData array

                public function createUserFixture(array $fixtureData = [])
{
    trigger_error('use createAdminUserFixture() instead', E_USER_DEPRECATED);
    return $this->createAdminUserFixture($fixtureData);
}

            
createUserOnlineFixture() public method
Deprecated since version 1.0.27:

Create the User Online Fixture.

public luya\testsuite\fixtures\ActiveRecordFixture createUserOnlineFixture ( array $fixtureData = [] )
$fixtureData

                public function createUserOnlineFixture(array $fixtureData = [])
{
    trigger_error('use createAdminUserOnlineFixture() instead', E_USER_DEPRECATED);
    return $this->createAdminUserOnlineFixture($fixtureData);
}

            
dropAdminAuthTable() public method

Drop the admin auth table.

public void dropAdminAuthTable ( )

                public function dropAdminAuthTable()
{
    $this->dropTableIfExists('admin_auth');
}

            
dropAdminGroupAuthTable() public method

Drop the admin group auth table.

public void dropAdminGroupAuthTable ( )

                public function dropAdminGroupAuthTable()
{
    $this->dropTableIfExists('admin_group_auth');
}    

            
dropAdminUserAuthNotificationTable() public method

Drop the admin user auth notification table.

public void dropAdminUserAuthNotificationTable ( )

                public function dropAdminUserAuthNotificationTable()
{
    $this->dropTableIfExists('admin_user_auth_notification');
}

            
dropAdminUserGroupTable() public method

Drop the admin user group table.

public void dropAdminUserGroupTable ( )

                public function dropAdminUserGroupTable()
{
    $this->dropTableIfExists('admin_user_group');   
}

            
removePermissionApi() public method

Remove permission api entry.

public integer removePermissionApi ( $api )
$api string
return integer

The number of affected rows.

                public function removePermissionApi($api)
{
    return $this->deleteRow('admin_auth', [
        'api' => $api,
    ]);
}

            
removePermissionRoute() public method

Remove permission route

public integer removePermissionRoute ( $route )
$route string
return integer

The number of affected rows.

                public function removePermissionRoute($route)
{
    return $this->deleteRow('admin_auth', [
        'route' => $route,
    ]);
}

            
unAssignGroupAuth() public method

Unassigne a group from auth

public integer unAssignGroupAuth ( $groupId, $authId )
$groupId integer
$authId integer
return integer

The number of affected rows.

                public function unAssignGroupAuth($groupId, $authId)
{
    return $this->deleteRow('admin_group_auth', [
        'group_id' => $groupId,
        'auth_id' => $authId,
    ]);
}