2e86c939
xu
“首次提交”
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
## 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
<?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)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L65)
#### addStyles()
*public* addStyles($output)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Command/Shared/Style.php#L9)
#### ask()
*protected* ask($question, $answer = null)
```php
<?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` $question
* `param null` $answer
* `return` mixed|string
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L107)
#### breakParts()
*protected* breakParts($class)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Util/Shared/Namespaces.php#L6)
#### checkInstalled()
*protected* checkInstalled($dir = null)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L208)
#### completeSuffix()
*protected* completeSuffix($filename, $suffix)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Command/Shared/FileSystem.php#L25)
#### 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
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L223)
#### createDirectoryFor()
*protected* createDirectoryFor($basePath, $className = null)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Command/Shared/FileSystem.php#L10)
#### createEmptyDirectory()
*protected* createEmptyDirectory($dir)
Create an empty directory and add a placeholder file into it
* `param` $dir
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L195)
#### createFile()
*protected* createFile($filename, $contents, $force = null, $flags = null)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Command/Shared/FileSystem.php#L46)
#### createHelper()
*protected* createHelper($name, $directory)
Create a helper class inside a directory
* `param` $name
* `param` $directory
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L174)
#### getNamespaceHeader()
*protected* getNamespaceHeader($class)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Util/Shared/Namespaces.php#L31)
#### getNamespaceString()
*protected* getNamespaceString($class)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Util/Shared/Namespaces.php#L25)
#### getNamespaces()
*protected* getNamespaces($class)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Util/Shared/Namespaces.php#L40)
#### getShortClassName()
*protected* getShortClassName($class)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Util/Shared/Namespaces.php#L19)
#### gitIgnore()
*protected* gitIgnore($path)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L201)
#### initDir()
*public* initDir($workDir)
Change the directory where Codeception should be installed.
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L75)
#### removeSuffix()
*protected* removeSuffix($classname, $suffix)
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Command/Shared/FileSystem.php#L40)
#### say()
*protected* say($message = null)
Print a message to console.
```php
<?php
$this->say('Welcome to Setup');
```
* `param string` $message
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L136)
#### sayInfo()
*protected* sayInfo($message)
Print info message
* `param` $message
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L163)
#### saySuccess()
*protected* saySuccess($message)
Print a successful message
* `param` $message
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L145)
#### sayWarning()
*protected* sayWarning($message)
Print warning message
* `param` $message
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L154)
#### setup()
*abstract public* setup()
Override this class to create customized setup.
* `return` mixed
[See source](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php#L88)
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/InitTemplate.php">Help us to improve documentation. Edit module reference</a></div>
|