Api
extends InitTemplate
in package
Codeception templates allow creating a customized setup and configuration for your project.
An abstract class for installation template. Each init template should extend it and implement a setup
method.
Use it to build a custom setup class which can be started with codecept init
command.
<?php
namespace Codeception\Template; // it is important to use this namespace so codecept init could locate this template
class CustomInstall extends \Codeception\InitTemplate
{
public function setup()
{
// implement this
}
}
This class provides various helper methods for building customized setup
Table of Contents
Constants
- GIT_IGNORE = '.gitignore'
Properties
- $actorSuffix : string
- $configTemplate : mixed
- $firstTest : mixed
- $input : InputInterface
- $namespace : string
- $output : OutputInterface
- $workDir : string
Methods
- __construct() : mixed
- addStyles() : mixed
- initDir() : mixed
- Change the directory where Codeception should be installed.
- setup() : mixed
- Override this class to create customized setup.
- addModulesToComposer() : mixed
- ask() : mixed|string
- ```php <?php // propose firefox as default browser $this->ask('select the browser of your choice', 'firefox');
- checkInstalled() : mixed
- completeSuffix() : mixed
- createActor() : mixed
- Create an Actor class and generate actions for it.
- createDirectoryFor() : mixed
- createEmptyDirectory() : mixed
- Create an empty directory and add a placeholder file into it
- createFile() : mixed
- createHelper() : mixed
- Create a helper class inside a directory
- gitIgnore() : mixed
- removeSuffix() : mixed
- say() : mixed
- Print a message to console.
- sayError() : mixed
- Print error message
- sayInfo() : mixed
- Print info message
- saySuccess() : mixed
- Print a successful message
- sayWarning() : mixed
- Print warning message
- updateComposerClassMap() : mixed
Constants
GIT_IGNORE
public
mixed
GIT_IGNORE
= '.gitignore'
Properties
$actorSuffix
protected
string
$actorSuffix
= 'Tester'
$configTemplate
protected
mixed
$configTemplate
= <<<EOF
# suite config
suites:
api:
actor: ApiTester
path: .
modules:
enabled:
- REST:
url: {{url}}
depends: PhpBrowser
step_decorators:
- \\Codeception\\Step\\AsJson
paths:
tests: {{baseDir}}
output: {{baseDir}}/_output
data: {{baseDir}}/_data
support: {{baseDir}}/_support
settings:
shuffle: false
lint: true
EOF
$firstTest
protected
mixed
$firstTest
= <<<EOF
<?php
class ApiCest
{
public function tryApi(ApiTester \$I)
{
\$I->sendGet('/');
\$I->seeResponseCodeIs(200);
\$I->seeResponseIsJson();
}
}
EOF
$input
protected
InputInterface
$input
$namespace
protected
string
$namespace
= ''
$output
protected
OutputInterface
$output
$workDir
protected
string
$workDir
= '.'
Methods
__construct()
public
__construct(InputInterface $input, OutputInterface $output) : mixed
Parameters
- $input : InputInterface
- $output : OutputInterface
addStyles()
public
addStyles(OutputInterface $output) : mixed
Parameters
- $output : OutputInterface
initDir()
Change the directory where Codeception should be installed.
public
initDir(mixed $workDir) : mixed
Parameters
- $workDir : mixed
setup()
Override this class to create customized setup.
public
setup() : mixed
addModulesToComposer()
protected
addModulesToComposer(mixed $modules) : mixed
Parameters
- $modules : mixed
ask()
```php <?php // propose firefox as default browser $this->ask('select the browser of your choice', 'firefox');
protected
ask(string $question[, mixed $answer = null ]) : mixed|string
// propose firefox or chrome possible options $this->ask('select the browser of your choice', ['firefox', 'chrome']);
// ask true/false question $this->ask('do you want to proceed (y/n)', true);
Parameters
- $question : string
- $answer : mixed = null
Return values
mixed|stringcheckInstalled()
protected
checkInstalled([mixed $dir = '.' ]) : mixed
Parameters
- $dir : mixed = '.'
completeSuffix()
protected
completeSuffix(mixed $filename, mixed $suffix) : mixed
Parameters
- $filename : mixed
- $suffix : mixed
createActor()
Create an Actor class and generate actions for it.
protected
createActor(mixed $name, mixed $directory, mixed $suiteConfig) : mixed
Requires a suite config as array in 3rd parameter.
Parameters
- $name : mixed
- $directory : mixed
- $suiteConfig : mixed
createDirectoryFor()
protected
createDirectoryFor(mixed $basePath[, mixed $className = '' ]) : mixed
Parameters
- $basePath : mixed
- $className : mixed = ''
createEmptyDirectory()
Create an empty directory and add a placeholder file into it
protected
createEmptyDirectory(mixed $dir) : mixed
Parameters
- $dir : mixed
createFile()
protected
createFile(mixed $filename, mixed $contents[, mixed $force = false ][, mixed $flags = 0 ]) : mixed
Parameters
- $filename : mixed
- $contents : mixed
- $force : mixed = false
- $flags : mixed = 0
createHelper()
Create a helper class inside a directory
protected
createHelper(mixed $name, mixed $directory) : mixed
Parameters
- $name : mixed
- $directory : mixed
gitIgnore()
protected
gitIgnore(mixed $path) : mixed
Parameters
- $path : mixed
removeSuffix()
protected
removeSuffix(mixed $classname, mixed $suffix) : mixed
Parameters
- $classname : mixed
- $suffix : mixed
say()
Print a message to console.
protected
say([string $message = '' ]) : mixed
<?php
$this->say('Welcome to Setup');
Parameters
- $message : string = ''
sayError()
Print error message
protected
sayError(string $message) : mixed
Parameters
- $message : string
sayInfo()
Print info message
protected
sayInfo(string $message) : mixed
Parameters
- $message : string
saySuccess()
Print a successful message
protected
saySuccess(string $message) : mixed
Parameters
- $message : string
sayWarning()
Print warning message
protected
sayWarning(mixed $message) : mixed
Parameters
- $message : mixed
updateComposerClassMap()
private
updateComposerClassMap([mixed $vendorDir = 'vendor' ]) : mixed
Parameters
- $vendorDir : mixed = 'vendor'