HumHub Documentation (unofficial)

Filesystem extends Module
in package

Module for testing local filesystem.

Fork it to extend the module for FTP, Amazon S3, others.

Status

  • Maintainer: davert
  • Stability: stable
  • Contact: codecept@davert.mail.ua

Module was developed to test Codeception itself.

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
$file  : mixed
$filepath  : mixed
$moduleContainer  : ModuleContainer
$path  : mixed
$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.
amInPath()  : mixed
Enters a directory In local filesystem.
cleanDir()  : mixed
Erases directory contents
copyDir()  : mixed
Copies directory with all contents
deleteDir()  : mixed
Deletes directory with all subdirectories
deleteFile()  : mixed
Deletes a file
deleteThisFile()  : mixed
Deletes a file
dontSeeFileFound()  : mixed
Checks if file does not exist in path
dontSeeInThisFile()  : mixed
Checks If opened file doesn't contain `text` in it
openFile()  : mixed
Opens a file and stores it's content.
seeFileContentsEqual()  : mixed
Checks the strict matching of file contents.
seeFileFound()  : mixed
Checks if file exists in path.
seeInThisFile()  : mixed
Checks If opened file has `text` in it.
seeNumberNewLines()  : mixed
Checks If opened file has the `number` of new lines.
seeThisFileMatches()  : mixed
Checks that contents of currently opened file matches $regex
writeToFile()  : mixed
Saves contents to file
absolutizePath()  : string
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.
findFileInPath()  : string|false
Finds the first matching file

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

amInPath()

Enters a directory In local filesystem.

public amInPath(string $path) : mixed

Project root directory is used by default

Parameters
$path : string

cleanDir()

Erases directory contents

public cleanDir(string $dirname) : mixed
<?php
$I->cleanDir('logs');
?>
Parameters
$dirname : string

copyDir()

Copies directory with all contents

public copyDir(string $src, string $dst) : mixed
<?php
$I->copyDir('vendor','old_vendor');
?>
Parameters
$src : string
$dst : string

deleteDir()

Deletes directory with all subdirectories

public deleteDir(string $dirname) : mixed
<?php
$I->deleteDir('vendor');
?>
Parameters
$dirname : string

deleteFile()

Deletes a file

public deleteFile(string $filename) : mixed
<?php
$I->deleteFile('composer.lock');
?>
Parameters
$filename : string

deleteThisFile()

Deletes a file

public deleteThisFile() : mixed

dontSeeFileFound()

Checks if file does not exist in path

public dontSeeFileFound(string $filename[, string $path = '' ]) : mixed
Parameters
$filename : string
$path : string = ''

dontSeeInThisFile()

Checks If opened file doesn't contain `text` in it

public dontSeeInThisFile(string $text) : mixed
<?php
$I->openFile('composer.json');
$I->dontSeeInThisFile('codeception/codeception');
?>
Parameters
$text : string

openFile()

Opens a file and stores it's content.

public openFile(string $filename) : mixed

Usage:

<?php
$I->openFile('composer.json');
$I->seeInThisFile('codeception/codeception');
?>
Parameters
$filename : string

seeFileContentsEqual()

Checks the strict matching of file contents.

public seeFileContentsEqual(string $text) : mixed

Unlike seeInThisFile will fail if file has something more than expected lines. Better to use with HEREDOC strings. Matching is done after removing "\r" chars from file content.

<?php
$I->openFile('process.pid');
$I->seeFileContentsEqual('3192');
?>
Parameters
$text : string

seeFileFound()

Checks if file exists in path.

public seeFileFound(string $filename[, string $path = '' ]) : mixed

Opens a file when it's exists

<?php
$I->seeFileFound('UserModel.php','app/models');
?>
Parameters
$filename : string
$path : string = ''

seeInThisFile()

Checks If opened file has `text` in it.

public seeInThisFile(string $text) : mixed

Usage:

<?php
$I->openFile('composer.json');
$I->seeInThisFile('codeception/codeception');
?>
Parameters
$text : string

seeNumberNewLines()

Checks If opened file has the `number` of new lines.

public seeNumberNewLines(int $number) : mixed

Usage:

<?php
$I->openFile('composer.json');
$I->seeNumberNewLines(5);
?>
Parameters
$number : int

New lines

seeThisFileMatches()

Checks that contents of currently opened file matches $regex

public seeThisFileMatches(string $regex) : mixed
Parameters
$regex : string

writeToFile()

Saves contents to file

public writeToFile(string $filename, string $contents) : mixed
Parameters
$filename : string
$contents : string

absolutizePath()

protected absolutizePath(string $path) : string
Parameters
$path : string
Return values
string

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

findFileInPath()

Finds the first matching file

private findFileInPath(string $filename, string $path) : string|false
Parameters
$filename : string
$path : string
Tags
throws
AssertionFailedError

When path does not exist

Return values
string|false

Path to the first matching file


        
On this page

Search results