Skip to content

Commit

Permalink
Merge pull request #244 from ergebnis/fix/uuid
Browse files Browse the repository at this point in the history
Fix: Remove `StringProvider::uuid()`
  • Loading branch information
localheinz committed Jul 16, 2023
2 parents 7d24a3e + cfe3c6a commit 59f3d88
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 34 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

For a full diff see [`2.0.0...main`][2.0.0...main].

### Removed

- Removed `StringProvider::uuid()` ([#244]), by [@localheinz]

## [`2.0.0`][2.0.0]

For a full diff see [`1.3.0...2.0.0`][1.3.0...2.0.0].
Expand Down Expand Up @@ -77,5 +81,6 @@ For a full diff see [`a5f2657...1.0.0`][a5f2657...1.0.0].
[#119]: https://github.com/ergebnis/data-provider/pull/119
[#226]: https://github.com/ergebnis/data-provider/pull/226
[#230]: https://github.com/ergebnis/data-provider/pull/230
[#244]: https://github.com/ergebnis/data-provider/pull/244

[@localheinz]: https://github.com/localheinz
3 changes: 1 addition & 2 deletions psalm-baseline.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.13.0@a0a9c27630bcf8301ee78cb06741d2907d8c9fef">
<files psalm-version="5.13.1@086b94371304750d1c673315321a55d15fc59015">
<file src="src/AbstractProvider.php">
<MixedAssignment>
<code>$value</code>
Expand Down Expand Up @@ -60,7 +60,6 @@
<code><![CDATA[\Generator<string, array{0: string}>]]></code>
<code><![CDATA[\Generator<string, array{0: string}>]]></code>
<code><![CDATA[\Generator<string, array{0: string}>]]></code>
<code><![CDATA[\Generator<string, array{0: string}>]]></code>
</MixedReturnTypeCoercion>
</file>
<file src="src/UuidProvider.php">
Expand Down
16 changes: 0 additions & 16 deletions src/StringProvider.php
Expand Up @@ -66,16 +66,6 @@ public static function untrimmed(): \Generator
});
}

/**
* @return \Generator<string, array{0: string}>
*/
public static function uuid(): \Generator
{
yield from self::provideDataForValuesWhere(self::values(), static function (string $value): bool {
return 1 === \preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $value);
});
}

/**
* @return \Generator<string, array{0: string}>
*/
Expand Down Expand Up @@ -115,11 +105,6 @@ private static function values(): array
'string-empty' => '',
];

$uuidValues = [
'string-uuid-case-lower' => \strtolower($faker->uuid()),
'string-uuid-case-upper' => \strtoupper($faker->uuid()),
];

$untrimmedValues = \array_combine(
\array_map(static function (string $key): string {
return \sprintf(
Expand Down Expand Up @@ -166,7 +151,6 @@ private static function values(): array
$blankValues,
$emptyValues,
$untrimmedValues,
$uuidValues,
$withWhitespaceValues,
);
}
Expand Down
16 changes: 0 additions & 16 deletions test/Unit/StringProviderTest.php
Expand Up @@ -46,8 +46,6 @@ public function testArbitraryReturnsGeneratorThatProvidesArbitraryStrings(): voi
'string-untrimmed-line-feed' => Test\Util\Specification\Pattern::create('/^\n{1,5}\w+\n{1,5}$/'),
'string-untrimmed-space' => Test\Util\Specification\Pattern::create('/^\s{1,5}\w+\s{1,5}$/'),
'string-untrimmed-tab' => Test\Util\Specification\Pattern::create('/^\t{1,5}\w+\t{1,5}$/'),
'string-uuid-case-lower' => Test\Util\Specification\Pattern::create('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/'),
'string-uuid-case-upper' => Test\Util\Specification\Pattern::create('/^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$/'),
'string-with-whitespace-carriage-return' => Test\Util\Specification\Pattern::create('/^\w+(\r+\w+){1,4}$/'),
'string-with-whitespace-line-feed' => Test\Util\Specification\Pattern::create('/^\w+(\n+\w+){1,4}$/'),
'string-with-whitespace-space' => Test\Util\Specification\Pattern::create('/^\w+(\s+\w+){1,4}$/'),
Expand Down Expand Up @@ -120,8 +118,6 @@ public function testTrimmedReturnsGeneratorThatProvidesStringsThatAreTrimmed():
'string-arbitrary-word' => Test\Util\Specification\Closure::create(static function (string $value): bool {
return '' !== $value && '' !== \trim($value);
}),
'string-uuid-case-lower' => Test\Util\Specification\Pattern::create('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/'),
'string-uuid-case-upper' => Test\Util\Specification\Pattern::create('/^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$/'),
'string-with-whitespace-carriage-return' => Test\Util\Specification\Pattern::create('/^\w+(\r+\w+){1,4}$/'),
'string-with-whitespace-line-feed' => Test\Util\Specification\Pattern::create('/^\w+(\n+\w+){1,4}$/'),
'string-with-whitespace-space' => Test\Util\Specification\Pattern::create('/^\w+(\s+\w+){1,4}$/'),
Expand All @@ -147,18 +143,6 @@ public function testUntrimmedReturnsGeneratorThatProvidesUntrimmedStrings(): voi
self::assertProvidesDataSetsForValuesSatisfyingSpecifications($specifications, $provider);
}

public function testUuidReturnsGeneratorThatProvidesUuidStrings(): void
{
$specifications = [
'string-uuid-case-lower' => Test\Util\Specification\Pattern::create('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/'),
'string-uuid-case-upper' => Test\Util\Specification\Pattern::create('/^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$/'),
];

$provider = StringProvider::uuid();

self::assertProvidesDataSetsForValuesSatisfyingSpecifications($specifications, $provider);
}

public function testWithWhitespaceReturnsGeneratorThatProvidesTrimmedStringsWithWhitespace(): void
{
$specifications = [
Expand Down

0 comments on commit 59f3d88

Please sign in to comment.