質問編集履歴
5
phpunit.batの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,12 +52,6 @@
|
|
52
52
|
|
53
53
|
C:\MyPhpUnit\phpunit_chap13\test\RestaurantCheckTest.php
|
54
54
|
|
55
|
-
C:\MyPhpUnit\phpunit_chap13\vendor
|
56
|
-
|
57
|
-
C:\MyPhpUnit\phpunit_chap13\composer.json
|
58
|
-
|
59
|
-
C:\MyPhpUnit\phpunit_chap13\composer.lock
|
60
|
-
|
61
55
|
C:\MyPhpUnit\phpunit_chap13\phpunit.phar
|
62
56
|
|
63
57
|
C:\MyPhpUnit\phpunit_chap13\phpunit.cmd
|
@@ -152,6 +146,16 @@
|
|
152
146
|
|
153
147
|
|
154
148
|
|
149
|
+
```.bat
|
150
|
+
|
151
|
+
// phpunit.cmd
|
152
|
+
|
153
|
+
@php "%~dp0phpunit.phar" %*
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
|
158
|
+
|
155
159
|
```エラー
|
156
160
|
|
157
161
|
|
4
修正する。
test
CHANGED
File without changes
|
test
CHANGED
@@ -108,13 +108,13 @@
|
|
108
108
|
|
109
109
|
//RestaurantCheckTest.php
|
110
110
|
|
111
|
-
include '
|
111
|
+
include 'restaurant_check.php';
|
112
112
|
|
113
113
|
|
114
114
|
|
115
115
|
// 引数値の変更
|
116
116
|
|
117
|
-
class RestaurantCheckTest extends PHPUnit
|
117
|
+
class RestaurantCheckTest extends PHPUnit_Framework_TestCase{
|
118
118
|
|
119
119
|
|
120
120
|
|
3
コード、質問の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,8 +9,6 @@
|
|
9
9
|
約1ケ月ぐらいPHPUnitをネットで調べて初歩のテストができるようになったので、
|
10
10
|
|
11
11
|
参考書に戻ってやってみたのですが、
|
12
|
-
|
13
|
-
CalculateTest.phpはうまくいったので、見比べながらやってみたのですが
|
14
12
|
|
15
13
|
どうしても以下のエラーが解決できません。
|
16
14
|
|
@@ -48,43 +46,23 @@
|
|
48
46
|
|
49
47
|
ファイルは以下のようになっています。
|
50
48
|
|
51
|
-
C:\MyPhpUnit\
|
49
|
+
C:\MyPhpUnit\phpunit_chap13\srcrestaurant_check.php
|
52
|
-
|
53
|
-
C:\MyPhpUnit\OreillyPhpunit\chap13\src\Calculate.php
|
54
|
-
|
55
|
-
C:\MyPhpUnit\OreillyPhpunit\chap13\test\RestaurantCheckTest.php
|
56
|
-
|
57
|
-
C:\MyPhpUnit\OreillyPhpunit\chap13\test\CalculateTest.php
|
58
50
|
|
59
51
|
|
60
52
|
|
61
|
-
C:\MyPhpUnit\
|
53
|
+
C:\MyPhpUnit\phpunit_chap13\test\RestaurantCheckTest.php
|
62
54
|
|
55
|
+
C:\MyPhpUnit\phpunit_chap13\vendor
|
56
|
+
|
57
|
+
C:\MyPhpUnit\phpunit_chap13\composer.json
|
58
|
+
|
59
|
+
C:\MyPhpUnit\phpunit_chap13\composer.lock
|
60
|
+
|
61
|
+
C:\MyPhpUnit\phpunit_chap13\phpunit.phar
|
62
|
+
|
63
|
-
C:\MyPhpUnit\
|
63
|
+
C:\MyPhpUnit\phpunit_chap13\phpunit.cmd
|
64
64
|
|
65
65
|
|
66
|
-
|
67
|
-
ちなみに同じフォルダにあるCalculateTest.phpは以下のようにテスト結果が正常に表示されます。
|
68
|
-
|
69
|
-
hiroko@HIROKO711 C:\MyPhpUnit\OreillyPhpunit\chap13
|
70
|
-
|
71
|
-
& phpunit test/CalculateTest.php
|
72
|
-
|
73
|
-
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
.
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
Time: 00:00.003, Memory: 12.00 MB
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
OK (1 test, 2 assertions)
|
88
66
|
|
89
67
|
よろしくお願いいたします。
|
90
68
|
|
@@ -156,7 +134,7 @@
|
|
156
134
|
|
157
135
|
|
158
136
|
|
159
|
-
$result = rest
|
137
|
+
$result = resturant_check($meal,$tax,$tip);
|
160
138
|
|
161
139
|
|
162
140
|
|
@@ -172,125 +150,27 @@
|
|
172
150
|
|
173
151
|
```
|
174
152
|
|
175
|
-
```
|
176
|
-
|
177
|
-
//Calculate.php
|
178
|
-
|
179
|
-
<?php
|
180
|
-
|
181
|
-
// http://refirio.org/view/364
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
function multiplication($x, $y) {
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
return $x * $y;
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
}
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
function division($x, $y) {
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
return $x / $y;
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
```
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
```php
|
212
|
-
|
213
|
-
//CalculateTest.php
|
214
|
-
|
215
|
-
<?php
|
216
|
-
|
217
|
-
//http://refirio.org/view/364
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
require_once './src/calculate.php';
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
class CalculateTest extends PHPUnit\Framework\TestCase
|
226
|
-
|
227
|
-
{
|
228
|
-
|
229
|
-
public function testCalculate()
|
230
|
-
|
231
|
-
{
|
232
|
-
|
233
|
-
$this->assertEquals(8, multiplication(4, 2));
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
$this->assertEquals(2, division(4, 2));
|
238
|
-
|
239
|
-
}
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
```
|
244
|
-
|
245
153
|
|
246
154
|
|
247
155
|
```エラー
|
248
156
|
|
249
157
|
|
250
158
|
|
251
|
-
hiroko@HIROKO711 C:\MyPhpUnit\
|
159
|
+
hiroko@HIROKO711 C:\MyPhpUnit\phpunit_chap13
|
252
160
|
|
253
|
-
#
|
161
|
+
# phpunit test\RestaurantCheckTest.php
|
254
|
-
|
255
|
-
PHP Warning: include(./src/restaurant_check.php): failed to open stream:
|
256
|
-
|
257
|
-
h file or directory in C:\MyPhpUnit\OreillyPhpunit\chap13\test\RestaurantC
|
258
|
-
|
259
|
-
st.php on line 2
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
Warning: include(./src/restaurant_check.php): failed to open stream: No su
|
264
|
-
|
265
|
-
e or directory in C:\MyPhpUnit\OreillyPhpunit\chap13\test\RestaurantCheckT
|
266
|
-
|
267
|
-
p on line 2
|
268
|
-
|
269
|
-
PHP Warning: include(): Failed opening './src/restaurant_check.php' for i
|
270
|
-
|
271
|
-
on (include_path='C:\xampp\php\PEAR') in C:\MyPhpUnit\OreillyPhpunit\chap1
|
272
|
-
|
273
|
-
\RestaurantCheckTest.php on line 2
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
Warning: include(): Failed opening './src/restaurant_check.php' for inclus
|
278
|
-
|
279
|
-
nclude_path='C:\xampp\php\PEAR') in C:\MyPhpUnit\OreillyPhpunit\chap13\tes
|
280
|
-
|
281
|
-
aurantCheckTest.php on line 2
|
282
162
|
|
283
163
|
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.
|
284
164
|
|
285
165
|
|
286
166
|
|
287
|
-
E
|
167
|
+
E
|
288
168
|
|
289
169
|
|
290
170
|
|
291
171
|
|
292
172
|
|
293
|
-
Time: 00:00.00
|
173
|
+
Time: 00:00.001, Memory: 12.00 MB
|
294
174
|
|
295
175
|
|
296
176
|
|
@@ -300,11 +180,11 @@
|
|
300
180
|
|
301
181
|
1) RestaurantCheckTest::testWithTaxAndTip
|
302
182
|
|
303
|
-
Error: Call to undefined function rest
|
183
|
+
Error: Call to undefined function resturant_check()
|
304
184
|
|
305
185
|
|
306
186
|
|
307
|
-
C:\MyPhpUnit\
|
187
|
+
C:\MyPhpUnit\phpunit_chap13\test\RestaurantCheckTest.php:15
|
308
188
|
|
309
189
|
|
310
190
|
|
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -68,7 +68,7 @@
|
|
68
68
|
|
69
69
|
hiroko@HIROKO711 C:\MyPhpUnit\OreillyPhpunit\chap13
|
70
70
|
|
71
|
-
|
71
|
+
& phpunit test/CalculateTest.php
|
72
72
|
|
73
73
|
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.
|
74
74
|
|
1
コードの修正と追加、エラーの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,15 +6,23 @@
|
|
6
6
|
|
7
7
|
RestaurantCheckTest()関数は、restaurant_check()関数をテストする関数です。
|
8
8
|
|
9
|
-
|
9
|
+
約1ケ月ぐらいPHPUnitをネットで調べて初歩のテストができるようになったので、
|
10
|
+
|
10
|
-
|
11
|
+
参考書に戻ってやってみたのですが、
|
12
|
+
|
13
|
+
CalculateTest.phpはうまくいったので、見比べながらやってみたのですが
|
14
|
+
|
15
|
+
どうしても以下のエラーが解決できません。
|
16
|
+
|
17
|
+
|
18
|
+
|
11
|
-
XAMPP for Windows 7.4.
|
19
|
+
XAMPP for Windows 7.4.7
|
12
20
|
|
13
21
|
|
14
22
|
|
15
23
|
> php -v
|
16
24
|
|
17
|
-
PHP 7.4.
|
25
|
+
PHP 7.4.7 (cli) (built: May 12 2020 11:38:54) ( ZTS Visual C++ 2017 x64 )
|
18
26
|
|
19
27
|
Copyright (c) The PHP Group
|
20
28
|
|
@@ -32,7 +40,7 @@
|
|
32
40
|
|
33
41
|
>phpunit -v
|
34
42
|
|
35
|
-
PHPUnit 9.2.
|
43
|
+
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.
|
36
44
|
|
37
45
|
|
38
46
|
|
@@ -40,23 +48,29 @@
|
|
40
48
|
|
41
49
|
ファイルは以下のようになっています。
|
42
50
|
|
43
|
-
C:\xampp\php\phpunit.phar
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
C:\
|
51
|
+
C:\MyPhpUnit\OreillyPhpunit\chap13\ restaurant_check.php
|
52
|
+
|
48
|
-
|
53
|
+
C:\MyPhpUnit\OreillyPhpunit\chap13\src\Calculate.php
|
54
|
+
|
49
|
-
C:\
|
55
|
+
C:\MyPhpUnit\OreillyPhpunit\chap13\test\RestaurantCheckTest.php
|
56
|
+
|
50
|
-
|
57
|
+
C:\MyPhpUnit\OreillyPhpunit\chap13\test\CalculateTest.php
|
58
|
+
|
59
|
+
|
60
|
+
|
51
|
-
|
61
|
+
C:\MyPhpUnit\OreillyPhpunit\chap13\phpunit.phar
|
62
|
+
|
52
|
-
|
63
|
+
C:\MyPhpUnit\OreillyPhpunit\chap13\phpunit.cmd
|
64
|
+
|
65
|
+
|
66
|
+
|
53
|
-
ちなみに同じフォルダにある
|
67
|
+
ちなみに同じフォルダにあるCalculateTest.phpは以下のようにテスト結果が正常に表示されます。
|
54
|
-
|
68
|
+
|
55
|
-
hiroko@HIROKO711
|
69
|
+
hiroko@HIROKO711 C:\MyPhpUnit\OreillyPhpunit\chap13
|
56
|
-
|
70
|
+
|
57
|
-
|
71
|
+
# phpunit test/CalculateTest.php
|
58
|
-
|
72
|
+
|
59
|
-
PHPUnit 9.2.
|
73
|
+
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.
|
60
74
|
|
61
75
|
|
62
76
|
|
@@ -70,7 +84,7 @@
|
|
70
84
|
|
71
85
|
|
72
86
|
|
73
|
-
OK (1 test,
|
87
|
+
OK (1 test, 2 assertions)
|
74
88
|
|
75
89
|
よろしくお願いいたします。
|
76
90
|
|
@@ -116,75 +130,115 @@
|
|
116
130
|
|
117
131
|
//RestaurantCheckTest.php
|
118
132
|
|
133
|
+
include './src/restaurant_check.php';
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
// 引数値の変更
|
138
|
+
|
139
|
+
class RestaurantCheckTest extends PHPUnit\Framework\TestCase{
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
public function testWithTaxAndTip() {
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
$meal =100;
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
$tax = 10;
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
$tip = 20 ;
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
$result = restaurant_check($meal,$tax,$tip);
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
$this->assertEquals(130,$result);
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
//Calculate.php
|
178
|
+
|
119
179
|
<?php
|
120
180
|
|
121
|
-
|
181
|
+
// http://refirio.org/view/364
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
182
|
+
|
126
|
-
|
127
|
-
|
183
|
+
|
128
|
-
|
129
|
-
|
130
|
-
|
184
|
+
|
131
|
-
|
185
|
+
function multiplication($x, $y) {
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
186
|
+
|
136
|
-
|
137
|
-
|
138
|
-
|
187
|
+
|
188
|
+
|
139
|
-
|
189
|
+
return $x * $y;
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
190
|
+
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
191
|
+
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
192
|
+
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
156
|
-
|
197
|
+
function division($x, $y) {
|
198
|
+
|
199
|
+
|
200
|
+
|
157
|
-
|
201
|
+
return $x / $y;
|
158
|
-
|
202
|
+
|
203
|
+
|
204
|
+
|
159
|
-
|
205
|
+
}
|
160
|
-
|
161
|
-
|
206
|
+
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
```
|
207
|
+
```
|
208
|
+
|
209
|
+
|
166
210
|
|
167
211
|
```php
|
168
212
|
|
169
|
-
//
|
213
|
+
//CalculateTest.php
|
170
214
|
|
171
215
|
<?php
|
172
216
|
|
217
|
+
//http://refirio.org/view/364
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
require_once './src/calculate.php';
|
222
|
+
|
223
|
+
|
224
|
+
|
173
|
-
|
225
|
+
class CalculateTest extends PHPUnit\Framework\TestCase
|
226
|
+
|
174
|
-
|
227
|
+
{
|
175
|
-
|
176
|
-
|
228
|
+
|
177
|
-
|
229
|
+
public function testCalculate()
|
230
|
+
|
178
|
-
|
231
|
+
{
|
232
|
+
|
179
|
-
|
233
|
+
$this->assertEquals(8, multiplication(4, 2));
|
180
|
-
|
234
|
+
|
235
|
+
|
236
|
+
|
181
|
-
|
237
|
+
$this->assertEquals(2, division(4, 2));
|
182
|
-
|
238
|
+
|
183
|
-
|
239
|
+
}
|
184
|
-
|
240
|
+
|
185
|
-
|
241
|
+
}
|
186
|
-
|
187
|
-
?>
|
188
242
|
|
189
243
|
```
|
190
244
|
|
@@ -194,39 +248,39 @@
|
|
194
248
|
|
195
249
|
|
196
250
|
|
197
|
-
hiroko@HIROKO711
|
251
|
+
hiroko@HIROKO711 C:\MyPhpUnit\OreillyPhpunit\chap13
|
198
|
-
|
252
|
+
|
199
|
-
# phpunit
|
253
|
+
# phpunit test/RestaurantCheckTest.php
|
200
|
-
|
254
|
+
|
201
|
-
PHP Warning: include(
|
255
|
+
PHP Warning: include(./src/restaurant_check.php): failed to open stream:
|
202
|
-
|
203
|
-
|
256
|
+
|
204
|
-
|
205
|
-
heckTest.php on line 2
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
Warning: include(C:\xampp\php\phpunit_test\restaurant_check.php): failed
|
210
|
-
|
211
|
-
|
257
|
+
h file or directory in C:\MyPhpUnit\OreillyPhpunit\chap13\test\RestaurantC
|
212
|
-
|
258
|
+
|
213
|
-
|
259
|
+
st.php on line 2
|
260
|
+
|
261
|
+
|
262
|
+
|
214
|
-
|
263
|
+
Warning: include(./src/restaurant_check.php): failed to open stream: No su
|
264
|
+
|
265
|
+
e or directory in C:\MyPhpUnit\OreillyPhpunit\chap13\test\RestaurantCheckT
|
266
|
+
|
267
|
+
p on line 2
|
268
|
+
|
215
|
-
PHP Warning: include(): Failed opening '
|
269
|
+
PHP Warning: include(): Failed opening './src/restaurant_check.php' for i
|
216
|
-
|
217
|
-
|
270
|
+
|
218
|
-
|
219
|
-
t_test\RestaurantCheckTest.php on line 2
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
Warning: include(): Failed opening 'C:\xampp\php\phpunit_test\restaurant_
|
224
|
-
|
225
|
-
|
271
|
+
on (include_path='C:\xampp\php\PEAR') in C:\MyPhpUnit\OreillyPhpunit\chap1
|
226
|
-
|
272
|
+
|
227
|
-
|
273
|
+
\RestaurantCheckTest.php on line 2
|
274
|
+
|
275
|
+
|
276
|
+
|
228
|
-
|
277
|
+
Warning: include(): Failed opening './src/restaurant_check.php' for inclus
|
278
|
+
|
279
|
+
nclude_path='C:\xampp\php\PEAR') in C:\MyPhpUnit\OreillyPhpunit\chap13\tes
|
280
|
+
|
281
|
+
aurantCheckTest.php on line 2
|
282
|
+
|
229
|
-
PHPUnit 9.2.
|
283
|
+
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.
|
230
284
|
|
231
285
|
|
232
286
|
|
@@ -236,7 +290,7 @@
|
|
236
290
|
|
237
291
|
|
238
292
|
|
239
|
-
Time: 00:00.00
|
293
|
+
Time: 00:00.003, Memory: 12.00 MB
|
240
294
|
|
241
295
|
|
242
296
|
|
@@ -250,7 +304,7 @@
|
|
250
304
|
|
251
305
|
|
252
306
|
|
253
|
-
C:\
|
307
|
+
C:\MyPhpUnit\OreillyPhpunit\chap13\test\RestaurantCheckTest.php:15
|
254
308
|
|
255
309
|
|
256
310
|
|