commit | author | age
|
2207d6
|
1 |
|
W |
2 |
## Codeception\InitTemplate |
|
3 |
|
|
4 |
|
|
5 |
* *Uses* `Codeception\Command\Shared\FileSystem`, `Codeception\Command\Shared\Style` |
|
6 |
|
|
7 |
Codeception templates allow creating a customized setup and configuration for your project. |
|
8 |
An abstract class for installation template. Each init template should extend it and implement a `setup` method. |
|
9 |
Use it to build a custom setup class which can be started with `codecept init` command. |
|
10 |
|
|
11 |
|
|
12 |
```php |
|
13 |
<?php |
|
14 |
namespace Codeception\Template; // it is important to use this namespace so codecept init could locate this template |
|
15 |
class CustomInstall extends \Codeception\InitTemplate |
|
16 |
{ |
|
17 |
public function setup() |
|
18 |
{ |
|
19 |
// implement this |
|
20 |
} |
|
21 |
} |
|
22 |
``` |
|
23 |
This class provides various helper methods for building customized setup |
|
24 |
|
|
25 |
|
|
26 |
#### __construct() |
|
27 |
|
|
28 |
*public* __construct($input, $output) |
|
29 |
|
|
30 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L65) |
|
31 |
|
|
32 |
#### addStyles() |
|
33 |
|
|
34 |
*public* addStyles($output) |
|
35 |
|
|
36 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Command/Shared/Style.php#L9) |
|
37 |
|
|
38 |
#### ask() |
|
39 |
|
|
40 |
*protected* ask($question, $answer = null) |
|
41 |
|
|
42 |
```php |
|
43 |
<?php |
|
44 |
// propose firefox as default browser |
|
45 |
$this->ask('select the browser of your choice', 'firefox'); |
|
46 |
|
|
47 |
// propose firefox or chrome possible options |
|
48 |
$this->ask('select the browser of your choice', ['firefox', 'chrome']); |
|
49 |
|
|
50 |
// ask true/false question |
|
51 |
$this->ask('do you want to proceed (y/n)', true); |
|
52 |
``` |
|
53 |
|
|
54 |
* `param` $question |
|
55 |
* `param null` $answer |
|
56 |
* `return` mixed|string |
|
57 |
|
|
58 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L107) |
|
59 |
|
|
60 |
#### breakParts() |
|
61 |
|
|
62 |
*protected* breakParts($class) |
|
63 |
|
|
64 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Util/Shared/Namespaces.php#L6) |
|
65 |
|
|
66 |
#### checkInstalled() |
|
67 |
|
|
68 |
*protected* checkInstalled($dir = null) |
|
69 |
|
|
70 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L208) |
|
71 |
|
|
72 |
#### completeSuffix() |
|
73 |
|
|
74 |
*protected* completeSuffix($filename, $suffix) |
|
75 |
|
|
76 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Command/Shared/FileSystem.php#L25) |
|
77 |
|
|
78 |
#### createActor() |
|
79 |
|
|
80 |
*protected* createActor($name, $directory, $suiteConfig) |
|
81 |
|
|
82 |
Create an Actor class and generate actions for it. |
|
83 |
Requires a suite config as array in 3rd parameter. |
|
84 |
|
|
85 |
* `param` $name |
|
86 |
* `param` $directory |
|
87 |
* `param` $suiteConfig |
|
88 |
|
|
89 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L223) |
|
90 |
|
|
91 |
#### createDirectoryFor() |
|
92 |
|
|
93 |
*protected* createDirectoryFor($basePath, $className = null) |
|
94 |
|
|
95 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Command/Shared/FileSystem.php#L10) |
|
96 |
|
|
97 |
#### createEmptyDirectory() |
|
98 |
|
|
99 |
*protected* createEmptyDirectory($dir) |
|
100 |
|
|
101 |
Create an empty directory and add a placeholder file into it |
|
102 |
* `param` $dir |
|
103 |
|
|
104 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L195) |
|
105 |
|
|
106 |
#### createFile() |
|
107 |
|
|
108 |
*protected* createFile($filename, $contents, $force = null, $flags = null) |
|
109 |
|
|
110 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Command/Shared/FileSystem.php#L46) |
|
111 |
|
|
112 |
#### createHelper() |
|
113 |
|
|
114 |
*protected* createHelper($name, $directory) |
|
115 |
|
|
116 |
Create a helper class inside a directory |
|
117 |
|
|
118 |
* `param` $name |
|
119 |
* `param` $directory |
|
120 |
|
|
121 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L174) |
|
122 |
|
|
123 |
#### getNamespaceHeader() |
|
124 |
|
|
125 |
*protected* getNamespaceHeader($class) |
|
126 |
|
|
127 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Util/Shared/Namespaces.php#L31) |
|
128 |
|
|
129 |
#### getNamespaceString() |
|
130 |
|
|
131 |
*protected* getNamespaceString($class) |
|
132 |
|
|
133 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Util/Shared/Namespaces.php#L25) |
|
134 |
|
|
135 |
#### getNamespaces() |
|
136 |
|
|
137 |
*protected* getNamespaces($class) |
|
138 |
|
|
139 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Util/Shared/Namespaces.php#L40) |
|
140 |
|
|
141 |
#### getShortClassName() |
|
142 |
|
|
143 |
*protected* getShortClassName($class) |
|
144 |
|
|
145 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Util/Shared/Namespaces.php#L19) |
|
146 |
|
|
147 |
#### gitIgnore() |
|
148 |
|
|
149 |
*protected* gitIgnore($path) |
|
150 |
|
|
151 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L201) |
|
152 |
|
|
153 |
#### initDir() |
|
154 |
|
|
155 |
*public* initDir($workDir) |
|
156 |
|
|
157 |
Change the directory where Codeception should be installed. |
|
158 |
|
|
159 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L75) |
|
160 |
|
|
161 |
#### removeSuffix() |
|
162 |
|
|
163 |
*protected* removeSuffix($classname, $suffix) |
|
164 |
|
|
165 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Command/Shared/FileSystem.php#L40) |
|
166 |
|
|
167 |
#### say() |
|
168 |
|
|
169 |
*protected* say($message = null) |
|
170 |
|
|
171 |
Print a message to console. |
|
172 |
|
|
173 |
```php |
|
174 |
<?php |
|
175 |
$this->say('Welcome to Setup'); |
|
176 |
``` |
|
177 |
|
|
178 |
|
|
179 |
* `param string` $message |
|
180 |
|
|
181 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L136) |
|
182 |
|
|
183 |
#### sayInfo() |
|
184 |
|
|
185 |
*protected* sayInfo($message) |
|
186 |
|
|
187 |
Print info message |
|
188 |
* `param` $message |
|
189 |
|
|
190 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L163) |
|
191 |
|
|
192 |
#### saySuccess() |
|
193 |
|
|
194 |
*protected* saySuccess($message) |
|
195 |
|
|
196 |
Print a successful message |
|
197 |
* `param` $message |
|
198 |
|
|
199 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L145) |
|
200 |
|
|
201 |
#### sayWarning() |
|
202 |
|
|
203 |
*protected* sayWarning($message) |
|
204 |
|
|
205 |
Print warning message |
|
206 |
* `param` $message |
|
207 |
|
|
208 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L154) |
|
209 |
|
|
210 |
#### setup() |
|
211 |
|
|
212 |
*abstract public* setup() |
|
213 |
|
|
214 |
Override this class to create customized setup. |
|
215 |
* `return` mixed |
|
216 |
|
|
217 |
[See source](https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php#L88) |
|
218 |
|
|
219 |
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/InitTemplate.php">Help us to improve documentation. Edit module reference</a></div> |