Skip to content

Commit ba4a79a

Browse files
herndlmondrejmirtes
authored andcommitted
Add more impossible-check tests for stringNotEmpty
1 parent 9424683 commit ba4a79a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ public function testExtension(): void
4444
'Call to static method Webmozart\Assert\Assert::notInstanceOf() with WebmozartAssertImpossibleCheck\Bar and \'WebmozartAssertImpossibleCheck\\\Bar\' will always evaluate to false.',
4545
32,
4646
],
47+
[
48+
'Call to static method Webmozart\Assert\Assert::stringNotEmpty() with non-empty-string will always evaluate to true.',
49+
44,
50+
],
51+
[
52+
'Call to static method Webmozart\Assert\Assert::stringNotEmpty() with non-empty-string will always evaluate to true.',
53+
46,
54+
],
55+
[
56+
'Call to static method Webmozart\Assert\Assert::nullOrStringNotEmpty() with non-empty-string will always evaluate to true.',
57+
49,
58+
],
59+
[
60+
'Call to static method Webmozart\Assert\Assert::nullOrStringNotEmpty() with non-empty-string|null will always evaluate to true.',
61+
53,
62+
],
4763
]);
4864
}
4965

tests/Type/WebMozartAssert/data/impossible-check.php

+21
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,27 @@ public function notInstanceOf(Bar $a): void
3232
Assert::notInstanceOf($a, Bar::class);
3333
}
3434

35+
/**
36+
* @param non-empty-string $b
37+
* @param non-empty-string|null $e
38+
*/
39+
public function stringNotEmpty(string $a, string $b, string $c, ?string $d, ?string $e): void
40+
{
41+
Assert::stringNotEmpty(null); // maybe this should report, similar as '' does too
42+
43+
Assert::stringNotEmpty($a);
44+
Assert::stringNotEmpty($a);
45+
46+
Assert::stringNotEmpty($b);
47+
48+
Assert::nullOrStringNotEmpty($c);
49+
Assert::nullOrStringNotEmpty($c);
50+
51+
Assert::nullOrStringNotEmpty($d);
52+
53+
Assert::nullOrStringNotEmpty($e);
54+
}
55+
3556
}
3657

3758
interface Bar {};

0 commit comments

Comments
 (0)