File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -467,6 +467,18 @@ public function toBeArray(string $message = ''): self
467
467
return $ this ;
468
468
}
469
469
470
+ /**
471
+ * Asserts that the value is a list.
472
+ *
473
+ * @return self<TValue>
474
+ */
475
+ public function toBeList (string $ message = '' ): self
476
+ {
477
+ Assert::assertIsList ($ this ->value , $ message );
478
+
479
+ return $ this ;
480
+ }
481
+
470
482
/**
471
483
* Asserts that the value is of type bool.
472
484
*
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use PHPUnit \Framework \ExpectationFailedException ;
4
+
5
+ test ('pass ' , function () {
6
+ expect ([1 , 2 , 3 ])->toBeList ();
7
+ expect (['a ' => 1 , 'b ' => 2 , 'c ' => 3 ])->not ->toBeList ();
8
+ expect ('1, 2, 3 ' )->not ->toBeList ();
9
+ });
10
+
11
+ test ('failures ' , function () {
12
+ expect (null )->toBeList ();
13
+ })->throws (ExpectationFailedException::class);
14
+
15
+ test ('failures with custom message ' , function () {
16
+ expect (null )->toBeList ('oh no! ' );
17
+ })->throws (ExpectationFailedException::class, 'oh no! ' );
18
+
19
+ test ('not failures ' , function () {
20
+ expect (['a ' , 'b ' , 'c ' ])->not ->toBeList ();
21
+ })->throws (ExpectationFailedException::class);
You can’t perform that action at this time.
0 commit comments