質問編集履歴

2

自己解決を書く場所を間違えました。

2017/06/13 05:53

投稿

hotta
hotta

スコア1613

test CHANGED
File without changes
test CHANGED
@@ -245,75 +245,3 @@
245
245
 
246
246
 
247
247
  ```
248
-
249
-
250
-
251
- ----
252
-
253
- 【自己解決しました】
254
-
255
- PHPUnit だけではできなかったのですが、
256
-
257
- [https://github.com/VladaHejda/PhpUnitAssertException](https://github.com/VladaHejda/PhpUnitAssertException)
258
-
259
- というのを見つけました。これを入れて、テストコードを以下のようにしたら通りました。
260
-
261
- ```php
262
-
263
- <?php
264
-
265
-
266
-
267
- use PHPUnit\Framework\TestCase;
268
-
269
- require_once '/home/vagrant/PhpUnitAssertException/src/AssertException.php';
270
-
271
-
272
-
273
- function my_app_takes_two_args(int $a, int $b): int {
274
-
275
- return a + b;
276
-
277
- }
278
-
279
-
280
-
281
- class MyAddReturnIntTest extends TestCase
282
-
283
- {
284
-
285
- use VladaHejda\AssertException;
286
-
287
-
288
-
289
- public function testLackOfParameter()
290
-
291
- {
292
-
293
- $test = function () {
294
-
295
- my_app_takes_two_args(3);
296
-
297
- };
298
-
299
-
300
-
301
- $this->assertError($test, ArgumentCountError::class);
302
-
303
- }
304
-
305
- }
306
-
307
-
308
-
309
- ```
310
-
311
- 注意事項として、当該 trait は mbstring に依存します。mbstring が入ってないと、
312
-
313
- ```bash
314
-
315
- Error: Call to undefined function mb_strpos()
316
-
317
- ```
318
-
319
- というエラーになりました。

1

自己解決しました。

2017/06/13 05:53

投稿

hotta
hotta

スコア1613

test CHANGED
File without changes
test CHANGED
@@ -245,3 +245,75 @@
245
245
 
246
246
 
247
247
  ```
248
+
249
+
250
+
251
+ ----
252
+
253
+ 【自己解決しました】
254
+
255
+ PHPUnit だけではできなかったのですが、
256
+
257
+ [https://github.com/VladaHejda/PhpUnitAssertException](https://github.com/VladaHejda/PhpUnitAssertException)
258
+
259
+ というのを見つけました。これを入れて、テストコードを以下のようにしたら通りました。
260
+
261
+ ```php
262
+
263
+ <?php
264
+
265
+
266
+
267
+ use PHPUnit\Framework\TestCase;
268
+
269
+ require_once '/home/vagrant/PhpUnitAssertException/src/AssertException.php';
270
+
271
+
272
+
273
+ function my_app_takes_two_args(int $a, int $b): int {
274
+
275
+ return a + b;
276
+
277
+ }
278
+
279
+
280
+
281
+ class MyAddReturnIntTest extends TestCase
282
+
283
+ {
284
+
285
+ use VladaHejda\AssertException;
286
+
287
+
288
+
289
+ public function testLackOfParameter()
290
+
291
+ {
292
+
293
+ $test = function () {
294
+
295
+ my_app_takes_two_args(3);
296
+
297
+ };
298
+
299
+
300
+
301
+ $this->assertError($test, ArgumentCountError::class);
302
+
303
+ }
304
+
305
+ }
306
+
307
+
308
+
309
+ ```
310
+
311
+ 注意事項として、当該 trait は mbstring に依存します。mbstring が入ってないと、
312
+
313
+ ```bash
314
+
315
+ Error: Call to undefined function mb_strpos()
316
+
317
+ ```
318
+
319
+ というエラーになりました。