File tree Expand file tree Collapse file tree 3 files changed +73
-0
lines changed
tests/FluentAssertions/Asserts/IsNotEmptyString Expand file tree Collapse file tree 3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,9 @@ fact('abcd')->hasLength(3); // Fails
166166
167167fact('')->isEmptyString(); // Passes
168168fact('hello')->isEmptyString(); // Fails
169+
170+ fact('hello')->isNotEmptyString(); // Passes
171+ fact('')->isNotEmptyString(); // Fails
169172```
170173
171174### Type Checking assertions
Original file line number Diff line number Diff line change @@ -273,5 +273,25 @@ public function isEmptyString(string $message = ''): self
273273 return $ this ;
274274 }
275275
276+ /**
277+ * Asserts that a string is not empty.
278+ *
279+ * This method checks if the actual value is not an empty string.
280+ *
281+ * Example usage:
282+ * fact('hello')->isNotEmptyString(); // Passes
283+ * fact('')->isNotEmptyString(); // Fails
284+ *
285+ * @param string $message Optional custom error message.
286+ *
287+ * @return self Enables fluent chaining of assertion methods.
288+ */
289+ public function isNotEmptyString (string $ message = '' ): self
290+ {
291+ Assert::assertNotEmpty ($ this ->variable , $ message );
292+
293+ return $ this ;
294+ }
295+
276296 // endregion Length Methods
277297}
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace K2gl \PHPUnitFluentAssertions \Tests \FluentAssertions \Asserts \IsNotEmptyString ;
4+
5+ use K2gl \PHPUnitFluentAssertions \Tests \FluentAssertions \FluentAssertionsTestCase ;
6+ use K2gl \PHPUnitFluentAssertions \FluentAssertions ;
7+ use PHPUnit \Framework \Attributes \CoversMethod ;
8+ use PHPUnit \Framework \Attributes \DataProvider ;
9+
10+ use function K2gl \PHPUnitFluentAssertions \fact ;
11+
12+ #[CoversMethod(className: FluentAssertions::class, methodName: 'isNotEmptyString ' )]
13+ final class IsNotEmptyStringTest extends FluentAssertionsTestCase
14+ {
15+ #[DataProvider('isNotEmptyStringDataProvider ' )]
16+ public function testIsNotEmptyString (mixed $ variable ): void
17+ {
18+ // act
19+ fact ($ variable )->isNotEmptyString ();
20+
21+ // assert
22+ $ this ->correctAssertionExecuted ();
23+ }
24+
25+ #[DataProvider('notIsNotEmptyStringDataProvider ' )]
26+ public function testNotIsNotEmptyString (mixed $ variable ): void
27+ {
28+ // assert
29+ $ this ->incorrectAssertionExpected ();
30+
31+ // act
32+ fact ($ variable )->isNotEmptyString ();
33+ }
34+
35+ public static function isNotEmptyStringDataProvider (): array
36+ {
37+ return [
38+ ['a ' ],
39+ ['hello ' ],
40+ [' ' ],
41+ ];
42+ }
43+
44+ public static function notIsNotEmptyStringDataProvider (): array
45+ {
46+ return [
47+ ['' ],
48+ ];
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments