From eacc4dc60eca15a22830a51239e8a3f7ea7426df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Sat, 3 Oct 2020 11:43:51 +0200 Subject: [PATCH] Enhancement: Implement NullProvider --- .github/workflows/integrate.yaml | 2 +- CHANGELOG.md | 2 + Makefile | 2 +- README.md | 7 ++ phpstan-baseline.neon | 115 ++++++++++++++++++++ psalm-baseline.xml | 5 + src/DataProvider/NullProvider.php | 31 ++++++ test/Unit/DataProvider/NullProviderTest.php | 34 ++++++ 8 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 src/DataProvider/NullProvider.php create mode 100644 test/Unit/DataProvider/NullProviderTest.php diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 89f98cea..dead2799 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -11,7 +11,7 @@ on: # yamllint disable-line rule:truthy env: ERGEBNIS_BOT_NAME: "ergebnis-bot" MIN_COVERED_MSI: 95 - MIN_MSI: 91 + MIN_MSI: 90 PHP_EXTENSIONS: "mbstring" jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index bfa5b471..22c64907 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ For a full diff see [`1.1.0...main`][1.1.0...main]. ### Added * Added `DataProvider\BooleanProvider` ([#326]), by [@localheinz] +* Added `DataProvider\NullProvider` ([#327]), by [@localheinz] ## [`1.1.0`][1.1.0] @@ -113,6 +114,7 @@ For a full diff see [`0.7.0...0.8.0`][0.7.0...0.8.0]. [#295]: https://github.com/ergebnis/test-util/pull/295 [#302]: https://github.com/ergebnis/test-util/pull/302 [#326]: https://github.com/ergebnis/test-util/pull/326 +[#327]: https://github.com/ergebnis/test-util/pull/327 [@ergebnis]: https://github.com/ergebnis [@localheinz]: https://github.com/localheinz diff --git a/Makefile b/Makefile index 48bff840..176bd679 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ MIN_COVERED_MSI:=95 -MIN_MSI:=91 +MIN_MSI:=90 .PHONY: it it: coding-standards static-code-analysis tests ## Runs the coding-standards, static-code-analysis, and tests targets diff --git a/README.md b/README.md index d81078cb..545c53f5 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ In addition to the assertions made available by extending from `PHPUnit\Framewor This package provides the following generic data providers: * [`Ergebnis\Test\Util\DataProvider\BooleanProvider`](https://github.com/ergebnis/test-util#dataproviderbooleanprovider) +* [`Ergebnis\Test\Util\DataProvider\NullProvider`](https://github.com/ergebnis/test-util#dataprovidernullprovider) #### `DataProvider\BooleanProvider` @@ -111,6 +112,12 @@ This package provides the following generic data providers: For examples, see [`Ergebnis\Test\Util\Test\Unit\DataProvider\BooleanProviderTest`](test/Unit/DataProvider/BooleanProviderTest.php). +#### `DataProvider\NullProvider` + +* `null()` provides `null` + +For examples, see [`Ergebnis\Test\Util\Test\Unit\DataProvider\NullProviderTest`](test/Unit/DataProvider/NullProviderTest.php). + ## Changelog Please have a look at [`CHANGELOG.md`](CHANGELOG.md). diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c249a33a..43ec6b45 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -115,6 +115,121 @@ parameters: count: 1 path: src/DataProvider/BooleanProvider.php + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:faker\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassesAreAbstractOrFinal\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Parameter \\#1 \\$argument of class ReflectionClass constructor expects class\\-string\\\\|T of object, string given\\.$#" + count: 2 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassesHaveTests\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Call to an undefined static method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertEmpty\\(\\)\\.$#" + count: 2 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassyConstructsSatisfySpecification\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassExists\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Call to an undefined static method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertTrue\\(\\)\\.$#" + count: 11 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassExtends\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassImplementsInterface\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassIsAbstract\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassIsFinal\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassSatisfiesSpecification\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertClassUsesTrait\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Call to an undefined static method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertContains\\(\\)\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertInterfaceExists\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertInterfaceExtends\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertInterfaceSatisfiesSpecification\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertTraitExists\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:assertTraitSatisfiesSpecification\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:provide\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:provideWhere\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + + - + message: "#^Method Ergebnis\\\\Test\\\\Util\\\\DataProvider\\\\NullProvider\\:\\:provideWhereNot\\(\\) is protected, but since the containing class is final, it can be private\\.$#" + count: 1 + path: src/DataProvider/NullProvider.php + - message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\AutoReview\\\\SrcCodeTest\\:\\:faker\\(\\) is protected, but since the containing class is final, it can be private\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a423155f..e2ca2fe0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -10,6 +10,11 @@ true === $value + + + \Generator<string, array{0: null}> + + $excludeClassyName diff --git a/src/DataProvider/NullProvider.php b/src/DataProvider/NullProvider.php new file mode 100644 index 00000000..3c9475a8 --- /dev/null +++ b/src/DataProvider/NullProvider.php @@ -0,0 +1,31 @@ + + */ + public static function null(): \Generator + { + yield from self::provide([ + 'null' => null, + ]); + } +} diff --git a/test/Unit/DataProvider/NullProviderTest.php b/test/Unit/DataProvider/NullProviderTest.php new file mode 100644 index 00000000..463fdbe4 --- /dev/null +++ b/test/Unit/DataProvider/NullProviderTest.php @@ -0,0 +1,34 @@ +