1
1
<?php
2
2
namespace webfiori \framework \test \cli ;
3
3
4
- use webfiori \framework \App ;
4
+ use webfiori \framework \cli \CLITestCase ;
5
+ use webfiori \framework \cli \commands \CreateCommand ;
5
6
use webfiori \framework \scheduler \webServices \TasksServicesManager ;
6
7
use webfiori \http \WebServicesManager ;
7
8
/**
8
9
* @author Ibrahim
9
10
*/
10
- class CreateAPITestCaseTest extends CreateTestCase {
11
+ class CreateAPITestCaseTest extends CLITestCase {
11
12
/**
12
13
* @test
13
14
*/
14
15
public function testCreateAPITestCase00 () {
15
- $ runner = App:: getRunner ();
16
- $ runner -> setArgsVector ([
17
- ' webfiori ' ,
18
- ' create ' ,
16
+ $ this -> assertEquals ([
17
+ " Error: The argument --manager has invalid value. \n" ,
18
+ ], $ this -> executeMultiCommand ([
19
+ CreateCommand::class ,
19
20
'--c ' => 'api-test ' ,
20
21
'--manager ' => 'A ' ,
21
22
'--service ' => 'c '
22
- ]);
23
- $ runner ->setInputs ([
24
-
25
- ]);
26
- $ exitCode = $ runner ->start ();
27
- $ this ->assertEquals (-1 , $ exitCode );
28
- $ this ->assertEquals ([
29
- "Error: The argument --manager has invalid value. \n" ,
30
-
31
- ], $ runner ->getOutput ());
32
- // $this->assertTrue(class_exists('\\app\\commands\\NewCLICommand'));
33
- // $this->removeClass('\\app\\commands\\NewCLICommand');
23
+ ]));
24
+ $ this ->assertEquals (-1 , $ this ->getExitCode ());
34
25
}
35
26
/**
36
27
* @test
37
28
*/
38
29
public function testCreateAPITestCase01 () {
39
- $ runner = App::getRunner ();
40
- $ runner ->setArgsVector ([
41
- 'webfiori ' ,
42
- 'create ' ,
43
- '--c ' => 'api-test ' ,
44
- '--manager ' => TasksServicesManager::class,
45
- '--service ' => 'c '
46
- ]);
47
- $ runner ->setInputs ([
48
- "0 " ,
49
- "y "
50
- ]);
51
- $ exitCode = $ runner ->start ();
52
- $ this ->assertEquals (0 , $ exitCode );
53
30
$ path = ROOT_PATH .DS ."tests " .DS ."webfiori " .DS ."framework " .DS ."scheduler " .DS ."webServices " ;
54
31
$ this ->assertEquals ([
55
32
"Info: Selected services manager has no service with name 'c'. \n" ,
@@ -65,57 +42,44 @@ public function testCreateAPITestCase01() {
65
42
"Path: " .$ path ."\n" ,
66
43
"Would you like to use default parameters?(Y/n) \n" ,
67
44
"Info: New class was created at \"" .$ path ."\". \n"
68
- ], $ runner ->getOutput ());
69
- $ clazz = '\tests\webfiori \\framework\scheduler\webServices \\TasksLoginServiceTest ' ;
45
+ ], $ this ->executeMultiCommand ([
46
+ CreateCommand::class,
47
+ '--c ' => 'api-test ' ,
48
+ '--manager ' => TasksServicesManager::class,
49
+ '--service ' => 'c '
50
+ ], [
51
+ "0 " ,
52
+ "y "
53
+ ]));
54
+
55
+ $ this ->assertEquals (0 , $ this ->getExitCode ());
56
+ $ clazz = '\\tests\webfiori \\framework\scheduler\webServices \\TasksLoginServiceTest ' ;
70
57
$ this ->assertTrue (class_exists ($ clazz ));
71
58
$ this ->removeClass ($ clazz );
72
59
}
73
60
/**
74
61
* @test
75
62
*/
76
63
public function testCreateAPITestCase02 () {
77
- $ runner = App::getRunner ();
78
- $ runner ->setArgsVector ([
79
- 'webfiori ' ,
80
- 'create ' ,
64
+ $ path = ROOT_PATH .DS ."tests " .DS ."webfiori " .DS ."framework " .DS ."scheduler " .DS ."webServices " ;
65
+ $ this ->assertEquals ([
66
+ "Info: New class was created at \"" .$ path ."\". \n"
67
+ ], $ this ->executeMultiCommand ([
68
+ CreateCommand::class,
81
69
'--c ' => 'api-test ' ,
82
70
'--manager ' => TasksServicesManager::class,
83
71
'--service ' => 'get-tasks ' ,
84
72
'--defaults '
85
- ]);
86
- $ runner ->setInputs ([
87
- ]);
88
- $ exitCode = $ runner ->start ();
89
- $ this ->assertEquals (0 , $ exitCode );
90
- $ path = ROOT_PATH .DS ."tests " .DS ."webfiori " .DS ."framework " .DS ."scheduler " .DS ."webServices " ;
91
- $ this ->assertEquals ([
92
- "Info: New class was created at \"" .$ path ."\". \n"
93
- ], $ runner ->getOutput ());
94
- $ clazz = '\tests\webfiori \\framework\scheduler\webServices \\GetTasksServiceTest ' ;
73
+ ]));
74
+ $ this ->assertEquals (0 , $ this ->getExitCode ());
75
+ $ clazz = '\\tests\webfiori \\framework\scheduler\webServices \\GetTasksServiceTest ' ;
95
76
$ this ->assertTrue (class_exists ($ clazz ));
96
77
$ this ->removeClass ($ clazz );
97
78
}
98
79
/**
99
80
* @test
100
81
*/
101
82
public function testCreateAPITestCase03 () {
102
- $ runner = App::getRunner ();
103
- $ runner ->setArgsVector ([
104
- 'webfiori ' ,
105
- 'create ' ,
106
- '--c ' => 'api-test ' ,
107
- '--service ' => 'get-tasks ' ,
108
- ]);
109
- $ runner ->setInputs ([
110
- '\webfiori \\framework\scheduler\webServices \\TasksServicesManager ' ,
111
- 'n ' ,
112
- '10 ' ,
113
- '' ,
114
- '' ,
115
-
116
- ]);
117
- $ exitCode = $ runner ->start ();
118
- $ this ->assertEquals (0 , $ exitCode );
119
83
$ path = ROOT_PATH .DS ."tests " .DS ."webfiori " .DS ."framework " .DS ."scheduler " .DS ."webServices " ;
120
84
$ this ->assertEquals ([
121
85
"Please enter services manager information: \n" ,
@@ -128,34 +92,27 @@ public function testCreateAPITestCase03() {
128
92
"Enter a name for the new class: \n" ,
129
93
"Enter an optional namespace for the class: Enter = 'tests\webfiori \\framework\scheduler\webServices' \n" ,
130
94
"Info: New class was created at \"" .$ path ."\". \n"
131
- ], $ runner ->getOutput ());
132
- $ clazz = '\tests\webfiori \\framework\scheduler\webServices \\GetTasksServiceTest ' ;
95
+ ], $ this ->executeMultiCommand ([
96
+ CreateCommand::class,
97
+ '--c ' => 'api-test ' ,
98
+ '--service ' => 'get-tasks ' ,
99
+ ], [
100
+ '\webfiori \\framework\scheduler\webServices \\TasksServicesManager ' ,
101
+ 'n ' ,
102
+ '10 ' ,
103
+ '' ,
104
+ '' ,
105
+ ]));
106
+ $ this ->assertEquals (0 , $ this ->getExitCode ());
107
+
108
+ $ clazz = '\\tests\webfiori \\framework\scheduler\webServices \\GetTasksServiceTest ' ;
133
109
$ this ->assertTrue (class_exists ($ clazz ));
134
110
$ this ->removeClass ($ clazz );
135
111
}
136
112
/**
137
113
* @test
138
114
*/
139
115
public function testCreateAPITestCase04 () {
140
- $ runner = App::getRunner ();
141
-
142
-
143
- $ runner ->setArgsVector ([
144
- 'webfiori ' ,
145
- 'create ' ,
146
- '--c ' => 'api-test ' ,
147
- '--service ' => 'say-hi-service ' ,
148
- ]);
149
- $ runner ->setInputs ([
150
- '\\tests \\apis \\multiple \\ServicesManager00 ' ,
151
- 'n ' ,
152
- '10 ' ,
153
- '' ,
154
- '' ,
155
-
156
- ]);
157
- $ exitCode = $ runner ->start ();
158
- $ this ->assertEquals (0 , $ exitCode );
159
116
$ path = ROOT_PATH .DS ."tests " .DS ."tests " .DS ."apis " .DS ."multiple " ;
160
117
$ this ->assertEquals ([
161
118
"Please enter services manager information: \n" ,
@@ -168,7 +125,19 @@ public function testCreateAPITestCase04() {
168
125
"Enter a name for the new class: \n" ,
169
126
"Enter an optional namespace for the class: Enter = 'tests \\tests\apis\multiple' \n" ,
170
127
"Info: New class was created at \"" .$ path ."\". \n"
171
- ], $ runner ->getOutput ());
128
+ ], $ this ->executeMultiCommand ([
129
+ CreateCommand::class,
130
+ '--c ' => 'api-test ' ,
131
+ '--service ' => 'say-hi-service ' ,
132
+ ], [
133
+ '\\tests \\apis \\multiple \\ServicesManager00 ' ,
134
+ 'n ' ,
135
+ '10 ' ,
136
+ '' ,
137
+ '' ,
138
+ ]));
139
+ $ this ->assertEquals (0 , $ this ->getExitCode ());
140
+
172
141
$ clazz = '\\tests \\tests \\apis \\multiple \\WebService00Test ' ;
173
142
$ this ->assertTrue (class_exists ($ clazz ));
174
143
$ this ->removeClass ($ clazz );
@@ -178,46 +147,19 @@ public function testCreateAPITestCase04() {
178
147
* @test
179
148
*/
180
149
public function testCreateAPITestCase05 () {
181
- $ runner = App::getRunner ();
182
- $ runner ->setArgsVector ([
183
- 'webfiori ' ,
184
- 'create ' ,
185
- '--c ' => 'api-test ' ,
186
- '--manager ' => '\\tests \\apis \\emptyService \\EmptyServicesManager ' ,
187
- ]);
188
- $ runner ->setInputs ();
189
-
190
- $ exitCode = $ runner ->start ();
191
- $ this ->assertEquals (-1 , $ exitCode );
192
-
193
150
$ this ->assertEquals ([
194
151
"Info: Provided services manager has 0 registered services. \n" ,
195
- ], $ runner ->getOutput ());
152
+ ], $ this ->executeMultiCommand ([
153
+ CreateCommand::class,
154
+ '--c ' => 'api-test ' ,
155
+ '--manager ' => '\\tests \\apis \\emptyService \\EmptyServicesManager ' ,
156
+ ]));
157
+ $ this ->assertEquals (-1 , $ this ->getExitCode ());
196
158
}
197
159
/**
198
160
* @test
199
161
*/
200
162
public function testCreateAPITestCase06 () {
201
- $ runner = App::getRunner ();
202
-
203
-
204
- $ runner ->setArgsVector ([
205
- 'webfiori ' ,
206
- 'create ' ,
207
- '--c ' => 'api-test ' ,
208
- '--service ' => 'say-hi-service ' ,
209
- ]);
210
- $ runner ->setInputs ([
211
- '\\tests \\apis \\multiple \\WebService00 ' ,
212
- '\\tests \\apis \\multiple \\ServicesManager00 ' ,
213
- 'n ' ,
214
- '10 ' ,
215
- '' ,
216
- '' ,
217
-
218
- ]);
219
- $ exitCode = $ runner ->start ();
220
- $ this ->assertEquals (0 , $ exitCode );
221
163
$ path = ROOT_PATH .DS ."tests " .DS ."tests " .DS ."apis " .DS ."multiple " ;
222
164
$ this ->assertEquals ([
223
165
"Please enter services manager information: \n" ,
@@ -232,7 +174,19 @@ public function testCreateAPITestCase06() {
232
174
"Enter a name for the new class: \n" ,
233
175
"Enter an optional namespace for the class: Enter = 'tests \\tests\apis\multiple' \n" ,
234
176
"Info: New class was created at \"" .$ path ."\". \n"
235
- ], $ runner ->getOutput ());
177
+ ], $ this ->executeMultiCommand ([
178
+ CreateCommand::class,
179
+ '--c ' => 'api-test ' ,
180
+ '--service ' => 'say-hi-service ' ,
181
+ ], [
182
+ '\\tests \\apis \\multiple \\WebService00 ' ,
183
+ '\\tests \\apis \\multiple \\ServicesManager00 ' ,
184
+ 'n ' ,
185
+ '10 ' ,
186
+ '' ,
187
+ '' ,
188
+ ]));
189
+ $ this ->assertEquals (0 , $ this ->getExitCode ());
236
190
$ clazz = '\\tests \\tests \\apis \\multiple \\WebService00Test ' ;
237
191
$ this ->assertTrue (class_exists ($ clazz ));
238
192
$ this ->removeClass ($ clazz );
@@ -241,42 +195,30 @@ public function testCreateAPITestCase06() {
241
195
* @test
242
196
*/
243
197
public function testCreateAPITestCase07 () {
244
- $ runner = App::getRunner ();
245
- $ runner ->setArgsVector ([
246
- 'webfiori ' ,
247
- 'create ' ,
248
- '--c ' => 'api-test ' ,
249
- '--manager ' => '\\tests \\apis \\emptyService \\Xyz ' ,
250
- ]);
251
- $ runner ->setInputs ();
252
-
253
- $ exitCode = $ runner ->start ();
254
- $ this ->assertEquals (-1 , $ exitCode );
255
-
256
198
$ this ->assertEquals ([
257
199
"Error: The argument --manager has invalid value. \n" ,
258
- ], $ runner ->getOutput ());
200
+ ], $ this ->executeMultiCommand ([
201
+ CreateCommand::class,
202
+ '--c ' => 'api-test ' ,
203
+ '--manager ' => '\\tests \\apis \\emptyService \\Xyz ' ,
204
+ ]));
205
+ $ this ->assertEquals (-1 , $ this ->getExitCode ());
259
206
}
260
207
/**
261
208
* @test
262
209
*/
263
210
public function testCreateAPITestCase08 () {
264
- $ runner = App::getRunner ();
265
- $ runner ->setArgsVector ([
266
- 'webfiori ' ,
267
- 'create ' ,
211
+ $ path = ROOT_PATH .DS ."tests " .DS ."tests " .DS ."apis " .DS ."multiple " ;
212
+ $ this ->assertEquals ([
213
+ "Info: New class was created at \"" .$ path ."\". \n"
214
+ ], $ this ->executeMultiCommand ([
215
+ CreateCommand::class,
268
216
'--c ' => 'api-test ' ,
269
217
'--service ' => 'say-hi-service-2 ' ,
270
218
'--manager ' => '\\tests \\apis \\multiple \\ServicesManager00 ' ,
271
219
'--defaults '
272
- ]);
273
- $ runner ->setInputs ();
274
- $ exitCode = $ runner ->start ();
275
- $ this ->assertEquals (0 , $ exitCode );
276
- $ path = ROOT_PATH .DS ."tests " .DS ."tests " .DS ."apis " .DS ."multiple " ;
277
- $ this ->assertEquals ([
278
- "Info: New class was created at \"" .$ path ."\". \n"
279
- ], $ runner ->getOutput ());
220
+ ]));
221
+ $ this ->assertEquals (0 , $ this ->getExitCode ());
280
222
$ clazz = '\\tests \\tests \\apis \\multiple \\WebService01Test ' ;
281
223
$ this ->assertTrue (class_exists ($ clazz ));
282
224
$ this ->removeClass ($ clazz );
0 commit comments