HumHub Documentation (unofficial)

AbstractAsserts extends Module
in package
uses Asserts

AbstractYes

Basic class for Modules and Helpers.

You must extend from it while implementing own helpers.

Public methods of this class start with _ prefix in order to ignore them in actor classes. Module contains HOOKS which allow to handle test execution routine.

Table of Contents

Properties

$aliases  : array<string|int, mixed>
Allows to rename actions
$excludeActions  : array<string|int, mixed>
Allows to explicitly exclude actions from module.
$includeInheritedActions  : bool
By setting it to false module wan't inherit methods of parent class.
$onlyActions  : array<string|int, mixed>
Allows to explicitly set what methods have this class.
$backupConfig  : mixed
$config  : mixed
$moduleContainer  : ModuleContainer
$requiredFields  : mixed
$storage  : mixed

Methods

__construct()  : mixed
Module constructor.
_after()  : mixed
**HOOK** executed after test
_afterStep()  : mixed
**HOOK** executed after step
_afterSuite()  : mixed
**HOOK** executed after suite
_before()  : mixed
**HOOK** executed before test
_beforeStep()  : mixed
**HOOK** executed before step
_beforeSuite()  : mixed
**HOOK** executed before suite
_failed()  : mixed
**HOOK** executed when test fails but before `_after`
_getConfig()  : mixed
Get config values or specific config item.
_getName()  : string
Returns a module name for a Module, a class name for Helper
_hasRequiredFields()  : bool
Checks if a module has required fields
_initialize()  : mixed
**HOOK** triggered after module is created and configuration is loaded
_reconfigure()  : mixed
Allows to redefine config for a specific test.
_resetConfig()  : mixed
Reverts config changed by `_reconfigure`
_setConfig()  : mixed
Allows to define initial module config.
assert()  : mixed
assertFileNotExists()  : mixed
Asserts that a file does not exist.
assertGreaterOrEquals()  : mixed
Asserts that a value is greater than or equal to another value.
assertIsEmpty()  : mixed
Asserts that a variable is empty.
assertLessOrEquals()  : mixed
Asserts that a value is smaller than or equal to another value.
assertNot()  : mixed
assertNotRegExp()  : mixed
Asserts that a string does not match a given regular expression.
assertRegExp()  : mixed
Asserts that a string matches a given regular expression.
assertThatItsNot()  : mixed
Evaluates a PHPUnit\Framework\Constraint matcher object.
debug()  : mixed
Print debug message to the screen.
debugSection()  : mixed
Print debug message with a title
getModule()  : Module
Get another module by its name:
getModules()  : array<string|int, mixed>
Get all enabled modules
hasModule()  : bool
Checks that module is enabled.
onReconfigure()  : mixed
HOOK to be executed when config changes with `_reconfigure`.
scalarizeArray()  : mixed
shortenMessage()  : string
Short text message to an amount of chars
validateConfig()  : mixed
Validates current config for required fields and required packages.

Properties

$aliases

Allows to rename actions

public static array<string|int, mixed> $aliases = []

$excludeActions

Allows to explicitly exclude actions from module.

public static array<string|int, mixed> $excludeActions = []

$includeInheritedActions

By setting it to false module wan't inherit methods of parent class.

public static bool $includeInheritedActions = true

$onlyActions

Allows to explicitly set what methods have this class.

public static array<string|int, mixed> $onlyActions = []

$backupConfig

protected mixed $backupConfig = []

$config

protected mixed $config = []

$requiredFields

protected mixed $requiredFields = []

$storage

protected mixed $storage = []

Methods

__construct()

Module constructor.

public __construct(ModuleContainer $moduleContainer[, array<string|int, mixed>|null $config = null ]) : mixed

Requires module container (to provide access between modules of suite) and config.

Parameters
$moduleContainer : ModuleContainer
$config : array<string|int, mixed>|null = null

_afterStep()

**HOOK** executed after step

public _afterStep(Step $step) : mixed
Parameters
$step : Step

_afterSuite()

**HOOK** executed after suite

public _afterSuite() : mixed

_beforeStep()

**HOOK** executed before step

public _beforeStep(Step $step) : mixed
Parameters
$step : Step

_beforeSuite()

**HOOK** executed before suite

public _beforeSuite([array<string|int, mixed> $settings = [] ]) : mixed
Parameters
$settings : array<string|int, mixed> = []

_failed()

**HOOK** executed when test fails but before `_after`

public _failed(TestInterface $test, Exception $fail) : mixed
Parameters
$test : TestInterface
$fail : Exception

_getConfig()

Get config values or specific config item.

public _getConfig([mixed $key = null ]) : mixed
Parameters
$key : mixed = null
Return values
mixed

the config item's value or null if it doesn't exist

_getName()

Returns a module name for a Module, a class name for Helper

public _getName() : string
Return values
string

_hasRequiredFields()

Checks if a module has required fields

public _hasRequiredFields() : bool
Return values
bool

_initialize()

**HOOK** triggered after module is created and configuration is loaded

public _initialize() : mixed

_reconfigure()

Allows to redefine config for a specific test.

public _reconfigure(mixed $config) : mixed

Config is restored at the end of a test.

<?php
// cleanup DB only for specific group of tests
public function _before(Test $test) {
    if (in_array('cleanup', $test->getMetadata()->getGroups()) {
        $this->getModule('Db')->_reconfigure(['cleanup' => true]);
    }
}
Parameters
$config : mixed
Tags
throws
ModuleConfigException
throws
ModuleException

_resetConfig()

Reverts config changed by `_reconfigure`

public _resetConfig() : mixed

_setConfig()

Allows to define initial module config.

public _setConfig(mixed $config) : mixed

Can be used in _beforeSuite hook of Helpers or Extensions

<?php
public function _beforeSuite($settings = []) {
    $this->getModule('otherModule')->_setConfig($this->myOtherConfig);
}
Parameters
$config : mixed
Tags
throws
ModuleConfigException
throws
ModuleException

assert()

protected assert(mixed $arguments[, bool $not = false ]) : mixed
Parameters
$arguments : mixed
$not : bool = false

assertFileNotExists()

Asserts that a file does not exist.

protected assertFileNotExists(string $filename[, string $message = '' ]) : mixed
Parameters
$filename : string
$message : string = ''

assertGreaterOrEquals()

Asserts that a value is greater than or equal to another value.

protected assertGreaterOrEquals(mixed $expected, mixed $actual[, string $message = '' ]) : mixed
Parameters
$expected : mixed
$actual : mixed
$message : string = ''

assertIsEmpty()

Asserts that a variable is empty.

protected assertIsEmpty(mixed $actual[, string $message = '' ]) : mixed
Parameters
$actual : mixed
$message : string = ''

assertLessOrEquals()

Asserts that a value is smaller than or equal to another value.

protected assertLessOrEquals(mixed $expected, mixed $actual[, string $message = '' ]) : mixed
Parameters
$expected : mixed
$actual : mixed
$message : string = ''

assertNot()

protected assertNot(mixed $arguments) : mixed
Parameters
$arguments : mixed

assertNotRegExp()

Asserts that a string does not match a given regular expression.

protected assertNotRegExp(string $pattern, string $string[, string $message = '' ]) : mixed
Parameters
$pattern : string
$string : string
$message : string = ''

assertRegExp()

Asserts that a string matches a given regular expression.

protected assertRegExp(string $pattern, string $string[, string $message = '' ]) : mixed
Parameters
$pattern : string
$string : string
$message : string = ''

assertThatItsNot()

Evaluates a PHPUnit\Framework\Constraint matcher object.

protected assertThatItsNot(mixed $value, Constraint $constraint[, string $message = '' ]) : mixed
Parameters
$value : mixed
$constraint : Constraint
$message : string = ''

debug()

Print debug message to the screen.

protected debug(mixed $message) : mixed
Parameters
$message : mixed

debugSection()

Print debug message with a title

protected debugSection(mixed $title, mixed $message) : mixed
Parameters
$title : mixed
$message : mixed

getModule()

Get another module by its name:

protected getModule(mixed $name) : Module
<?php
$this->getModule('WebDriver')->_findElements('.items');
Parameters
$name : mixed
Tags
throws
ModuleException
Return values
Module

getModules()

Get all enabled modules

protected getModules() : array<string|int, mixed>
Return values
array<string|int, mixed>

hasModule()

Checks that module is enabled.

protected hasModule(mixed $name) : bool
Parameters
$name : mixed
Return values
bool

onReconfigure()

HOOK to be executed when config changes with `_reconfigure`.

protected onReconfigure() : mixed

scalarizeArray()

protected scalarizeArray(mixed $array) : mixed
Parameters
$array : mixed

shortenMessage()

Short text message to an amount of chars

protected shortenMessage(mixed $message[, mixed $chars = 150 ]) : string
Parameters
$message : mixed
$chars : mixed = 150
Return values
string

        
On this page

Search results