Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #554 from ergebnis/fix/provide
Browse files Browse the repository at this point in the history
Fix: Remove provide methods
  • Loading branch information
localheinz committed Jan 3, 2022
2 parents 94d28a4 + 32b333d commit 03810a3
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 353 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,18 @@ For a full diff see [`1.6.0...2.0.0`][1.6.0...2.0.0].

If you use any of the assertions, stop. Most of them are useless, some of them could be replaced with static code analysis. I do not use them anymore and I would not recommend to use these kinds of assertions.

- Removed all provide methods ([#554]), by [@localheinz]

If you use any of the provide methods in an external data provider, run

```shell
composer require --dev ergebnis/data-provider
```

and extend `Ergebnis\DataProvider\AbstractProvider`.

If you use any of the provide methods in data provider declared as an instance method on a test case, extract your own `Helper` trait and move the functionality there.

## [`1.6.0`][1.6.0]

For a full diff see [`1.5.0...1.6.0`][1.5.0...1.6.0].
Expand Down
4 changes: 2 additions & 2 deletions infection.json
Expand Up @@ -3,8 +3,8 @@
"logs": {
"text": ".build/infection/infection-log.txt"
},
"minCoveredMsi": 73,
"minMsi": 73,
"minCoveredMsi": 25,
"minMsi": 25,
"phpUnit": {
"configDir": "test\/Unit"
},
Expand Down
42 changes: 0 additions & 42 deletions phpstan-baseline.neon
@@ -1,49 +1,7 @@
parameters:
ignoreErrors:
-
message:
"""
#^Call to deprecated method provideDataForValues\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
use ergebnis/data\\-provider instead$#
"""
count: 2
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method provideDataForValuesWhere\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
use ergebnis/data\\-provider instead$#
"""
count: 3
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method provideDataForValuesWhereNot\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
use ergebnis/data\\-provider instead$#
"""
count: 3
path: test/Unit/HelperTest.php

-
message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:\\:faker\\(\\) is protected, but since the containing class is final, it can be private\\.$#"
count: 1
path: test/Unit/HelperTest.php

-
message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:\\:provideDataForValues\\(\\) is protected, but since the containing class is final, it can be private\\.$#"
count: 1
path: test/Unit/HelperTest.php

-
message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:\\:provideDataForValuesWhere\\(\\) is protected, but since the containing class is final, it can be private\\.$#"
count: 1
path: test/Unit/HelperTest.php

-
message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:\\:provideDataForValuesWhereNot\\(\\) is protected, but since the containing class is final, it can be private\\.$#"
count: 1
path: test/Unit/HelperTest.php

18 changes: 1 addition & 17 deletions psalm-baseline.xml
@@ -1,18 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.17.0@6f4707aa41c9174353a6434bba3fc8840f981d9c">
<file src="src/Helper.php">
<DeprecatedMethod occurrences="2">
<code>self::provideDataForValues($filtered)</code>
<code>self::provideDataForValues($filtered)</code>
</DeprecatedMethod>
<MixedAssignment occurrences="1">
<code>$value</code>
</MixedAssignment>
</file>
<file src="test/Unit/HelperTest.php">
<DeprecatedMethod occurrences="8">
<code>self::provideDataForValues($values)</code>
<code>self::provideDataForValues($values)</code>
</DeprecatedMethod>
</file>
</files>
<files psalm-version="4.17.0@6f4707aa41c9174353a6434bba3fc8840f981d9c"/>
27 changes: 0 additions & 27 deletions src/Exception/EmptyValues.php

This file was deleted.

77 changes: 0 additions & 77 deletions src/Helper.php
Expand Up @@ -42,81 +42,4 @@ final protected static function faker(string $locale = 'en_US'): Generator

return $fakers[$locale];
}

/**
* @deprecated use ergebnis/data-provider instead
* @see https://github.com/ergebnis/data-provider
*
* @param array<string, mixed> $values
*
* @throws Exception\EmptyValues
*
* @return \Generator<string, array{0: mixed}>
*/
final protected static function provideDataForValues(array $values): \Generator
{
if ([] === $values) {
throw Exception\EmptyValues::create();
}

foreach ($values as $key => $value) {
yield $key => [
$value,
];
}
}

/**
* @deprecated use ergebnis/data-provider instead
* @see https://github.com/ergebnis/data-provider
*
* @param array<string, mixed> $values
*
* @throws Exception\EmptyValues
*
* @return \Generator<string, array{0: mixed}>
*/
final protected static function provideDataForValuesWhere(array $values, \Closure $test): \Generator
{
if ([] === $values) {
throw Exception\EmptyValues::create();
}

$filtered = \array_filter($values, static function ($value) use ($test): bool {
return true === $test($value);
});

if ([] === $filtered) {
throw Exception\EmptyValues::filtered();
}

yield from self::provideDataForValues($filtered);
}

/**
* @deprecated use ergebnis/data-provider instead
* @see https://github.com/ergebnis/data-provider
*
* @param array<string, mixed> $values
*
* @throws Exception\EmptyValues
*
* @return \Generator<string, array{0: mixed}>
*/
final protected static function provideDataForValuesWhereNot(array $values, \Closure $test): \Generator
{
if ([] === $values) {
throw Exception\EmptyValues::create();
}

$filtered = \array_filter($values, static function ($value) use ($test): bool {
return false === $test($value);
});

if ([] === $filtered) {
throw Exception\EmptyValues::filtered();
}

yield from self::provideDataForValues($filtered);
}
}
39 changes: 0 additions & 39 deletions test/Unit/Exception/EmptyValuesTest.php

This file was deleted.

0 comments on commit 03810a3

Please sign in to comment.