Codeception\InitTemplate
-
Uses
Codeception\Command\Shared\FileSystem
,Codeception\Command\Shared\Style
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
__construct()
public __construct($input, $output)
addModulesToComposer()
protected addModulesToComposer($modules)
addStyles()
public addStyles($output)
ask()
protected ask($question, $answer = null)
<?php // propose firefox as default browser $this->ask('select the browser of your choice', 'firefox'); // 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);
-
param string
$question -
param mixed
$answer -
return
mixedstring
breakParts()
protected breakParts($class)
checkInstalled()
protected checkInstalled($dir = null)
completeSuffix()
protected completeSuffix($filename, $suffix)
createActor()
protected createActor($name, $directory, $suiteConfig)
Create an Actor class and generate actions for it. Requires a suite config as array in 3rd parameter.
-
param
$name -
param
$directory -
param
$suiteConfig
createDirectoryFor()
protected createDirectoryFor($basePath, $className = null)
createEmptyDirectory()
protected createEmptyDirectory($dir)
Create an empty directory and add a placeholder file into it
-
param
$dir
createFile()
protected createFile($filename, $contents, $force = null, $flags = null)
createHelper()
protected createHelper($name, $directory)
Create a helper class inside a directory
-
param
$name -
param
$directory
getNamespaceHeader()
protected getNamespaceHeader($class)
getNamespaceString()
protected getNamespaceString($class)
getNamespaces()
protected getNamespaces($class)
getShortClassName()
protected getShortClassName($class)
gitIgnore()
protected gitIgnore($path)
initDir()
public initDir($workDir)
Change the directory where Codeception should be installed.
removeSuffix()
protected removeSuffix($classname, $suffix)
say()
protected say($message = null)
Print a message to console.
<?php $this->say('Welcome to Setup');
-
param string
$message
sayError()
protected sayError($message)
Print error message
-
param string
$message
sayInfo()
protected sayInfo($message)
Print info message
-
param string
$message
saySuccess()
protected saySuccess($message)
Print a successful message
-
param string
$message
sayWarning()
protected sayWarning($message)
Print warning message
-
param
$message
setup()
abstract public setup()
Override this class to create customized setup.
-
return
mixed
updateComposerClassMap()
private updateComposerClassMap($vendorDir = null)
© 2011 Michael Bodnarchuk and contributors
Licensed under the MIT License.
https://codeception.com/docs/reference/InitTemplate