File tree 2 files changed +32
-0
lines changed
2 files changed +32
-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
+ });
9
+
10
+ test ('failures ' , function () {
11
+ expect (null )->toBeList ();
12
+ })->throws (ExpectationFailedException::class);
13
+
14
+ test ('failures with custom message ' , function () {
15
+ expect (null )->toBeList ('oh no! ' );
16
+ })->throws (ExpectationFailedException::class, 'oh no! ' );
17
+
18
+ test ('not failures ' , function () {
19
+ expect (['a ' , 'b ' , 'c ' ])->not ->toBeList ();
20
+ })->throws (ExpectationFailedException::class);
You can’t perform that action at this time.
0 commit comments