From 84357664a37df98ec2b78d3338fa79ec1eca56c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Sun, 4 Oct 2020 10:23:32 +0200 Subject: [PATCH 1/2] Enhancement: Assert that StringProvider::arbitrary() provides all kinds of values --- test/Unit/DataProvider/StringProviderTest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/Unit/DataProvider/StringProviderTest.php b/test/Unit/DataProvider/StringProviderTest.php index a7ca1fd1..3977ac0d 100644 --- a/test/Unit/DataProvider/StringProviderTest.php +++ b/test/Unit/DataProvider/StringProviderTest.php @@ -26,11 +26,11 @@ final class StringProviderTest extends AbstractProviderTestCase /** * @dataProvider \Ergebnis\Test\Util\DataProvider\StringProvider::arbitrary() * - * @param string $value + * @param mixed $value */ - public function testArbitraryProvidesString(string $value): void + public function testArbitraryProvidesString($value): void { - self::assertNotSame('', \trim($value)); + self::assertIsString($value); } public function testArbitraryReturnsGeneratorThatProvidesStringsThatAreNeitherEmptyNorBlank(): void @@ -42,6 +42,11 @@ public function testArbitraryReturnsGeneratorThatProvidesStringsThatAreNeitherEm 'string-arbitrary-word' => Util\DataProvider\Specification\Closure::create(static function (string $value): bool { return '' !== $value && '' !== \trim($value); }), + 'string-blank-carriage-return' => Util\DataProvider\Specification\Identical::create("\r"), + 'string-blank-line-feed' => Util\DataProvider\Specification\Identical::create("\n"), + 'string-blank-space' => Util\DataProvider\Specification\Identical::create(' '), + 'string-blank-tab' => Util\DataProvider\Specification\Identical::create("\t"), + 'string-empty' => Util\DataProvider\Specification\Identical::create(''), 'string-untrimmed-carriage-return' => Util\DataProvider\Specification\Pattern::create('/^\r{1,5}\w+\r{1,5}$/'), 'string-untrimmed-line-feed' => Util\DataProvider\Specification\Pattern::create('/^\n{1,5}\w+\n{1,5}$/'), 'string-untrimmed-space' => Util\DataProvider\Specification\Pattern::create('/^\s{1,5}\w+\s{1,5}$/'), From e2cb8cf509f4fbd8f76124cfa5ef2bfd5be79b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Sun, 4 Oct 2020 10:33:12 +0200 Subject: [PATCH 2/2] Fix: Provide all kinds of string values --- README.md | 2 +- src/DataProvider/StringProvider.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index daef7534..1f5a09a9 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ For examples, see [`Ergebnis\Test\Util\Test\Unit\DataProvider\NullProviderTest`] #### `DataProvider\StringProvider` -* `arbitrary()` provides non-empty `string`s without leading and trailing whitespade +* `arbitrary()` provides arbitrary `string`s * `blank()` provides `string`s consisting of whitespace characters only * `empty()` provides an empty `string` * `untrimmed()` provides `string`s with leading and trailing whitespace diff --git a/src/DataProvider/StringProvider.php b/src/DataProvider/StringProvider.php index fe26154b..c16009af 100644 --- a/src/DataProvider/StringProvider.php +++ b/src/DataProvider/StringProvider.php @@ -24,9 +24,7 @@ final class StringProvider */ public static function arbitrary(): \Generator { - yield from self::provideDataForValuesWhereNot(self::values(), static function (string $value): bool { - return '' === \trim($value); - }); + yield from self::provideDataForValues(self::values()); } /**