File tree Expand file tree Collapse file tree 7 files changed +41
-4
lines changed Expand file tree Collapse file tree 7 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 2020 "illuminate/console" : " ^10.0|^11.0" ,
2121 "illuminate/support" : " ^10.0|^11.0" ,
2222 "spatie/laravel-package-tools" : " ^1.16.2" ,
23- "symfony/polyfill-php83" : " ^1.30"
23+ "symfony/polyfill-php83" : " ^1.30" ,
24+ "webmozart/assert" : " ^1.11"
2425 },
2526 "require-dev" : {
2627 "illuminate/testing" : " ^10.0|^11.0" ,
Original file line number Diff line number Diff line change 55namespace Maartenpaauw \Specifications ;
66
77use Override ;
8+ use Webmozart \Assert \Assert ;
89
910/**
1011 * @template TCandidate
@@ -18,7 +19,9 @@ final class AndSpecification extends CompositeSpecification
1819 */
1920 public function __construct (
2021 private readonly array $ specifications ,
21- ) {}
22+ ) {
23+ Assert::allIsInstanceOf ($ specifications , Specification::class);
24+ }
2225
2326 #[Override]
2427 public function isSatisfiedBy (mixed $ candidate ): bool
Original file line number Diff line number Diff line change 55namespace Maartenpaauw \Specifications ;
66
77use Override ;
8+ use Webmozart \Assert \Assert ;
89
910/**
1011 * @template TCandidate
@@ -18,7 +19,9 @@ final class OrSpecification extends CompositeSpecification
1819 */
1920 public function __construct (
2021 private readonly array $ specifications ,
21- ) {}
22+ ) {
23+ Assert::allIsInstanceOf ($ this ->specifications , Specification::class);
24+ }
2225
2326 #[Override]
2427 public function isSatisfiedBy (mixed $ candidate ): bool
Original file line number Diff line number Diff line change 55namespace Maartenpaauw \Specifications ;
66
77use Override ;
8+ use Webmozart \Assert \Assert ;
89
910/**
1011 * @template TCandidate
@@ -18,7 +19,9 @@ final class XorSpecification extends CompositeSpecification
1819 */
1920 public function __construct (
2021 private readonly array $ specifications ,
21- ) {}
22+ ) {
23+ Assert::allIsInstanceOf ($ specifications , Specification::class);
24+ }
2225
2326 #[Override]
2427 public function isSatisfiedBy (mixed $ candidate ): bool
Original file line number Diff line number Diff line change 44
55namespace Maartenpaauw \Specifications \Tests ;
66
7+ use InvalidArgumentException ;
78use Maartenpaauw \Specifications \AndSpecification ;
89use Workbench \App \LengthSpecification ;
910use Workbench \App \UppercaseSpecification ;
@@ -30,6 +31,14 @@ protected function setUp(): void
3031 ]);
3132 }
3233
34+ public function test_it_should_throw_an_invalid_argument_exception_when_the_specification_array_does_contain_invalid_data (): void
35+ {
36+ self ::expectException (InvalidArgumentException::class);
37+
38+ // @phpstan-ignore-next-line
39+ new AndSpecification (['invalid ' ]);
40+ }
41+
3342 public function test_it_should_return_true_when_the_candidate_matches_all_specifications (): void
3443 {
3544 // Act
Original file line number Diff line number Diff line change 44
55namespace Maartenpaauw \Specifications \Tests ;
66
7+ use InvalidArgumentException ;
78use Maartenpaauw \Specifications \OrSpecification ;
89use Workbench \App \LengthSpecification ;
910use Workbench \App \UppercaseSpecification ;
@@ -30,6 +31,14 @@ protected function setUp(): void
3031 ]);
3132 }
3233
34+ public function test_it_should_throw_an_invalid_argument_exception_when_the_specification_array_does_contain_invalid_data (): void
35+ {
36+ self ::expectException (InvalidArgumentException::class);
37+
38+ // @phpstan-ignore-next-line
39+ new OrSpecification (['invalid ' ]);
40+ }
41+
3342 public function test_it_should_return_true_when_the_candidate_matches_all_specifications (): void
3443 {
3544 // Act
Original file line number Diff line number Diff line change 44
55namespace Maartenpaauw \Specifications \Tests ;
66
7+ use InvalidArgumentException ;
78use Maartenpaauw \Specifications \XorSpecification ;
89use PHPUnit \Framework \TestCase ;
910use Workbench \App \LengthSpecification ;
@@ -31,6 +32,14 @@ protected function setUp(): void
3132 ]);
3233 }
3334
35+ public function test_it_should_throw_an_invalid_argument_exception_when_the_specification_array_does_contain_invalid_data (): void
36+ {
37+ self ::expectException (InvalidArgumentException::class);
38+
39+ // @phpstan-ignore-next-line
40+ new XorSpecification (['invalid ' ]);
41+ }
42+
3443 public function test_it_should_only_return_true_when_one_specification_is_satisfied (): void
3544 {
3645 $ this ->assertTrue ($ this ->specification ->isSatisfiedBy ('HELLO ' ));
You can’t perform that action at this time.
0 commit comments