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

Enhancement: Implement NullProvider #327

Merged
merged 1 commit into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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).
Expand Down
115 changes: 115 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\\>\\|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
Expand Down
5 changes: 5 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<code>true === $value</code>
</RedundantIdentityWithTrue>
</file>
<file src="src/DataProvider/NullProvider.php">
<MoreSpecificReturnType occurrences="1">
<code>\Generator&lt;string, array{0: null}&gt;</code>
</MoreSpecificReturnType>
</file>
<file src="src/Helper.php">
<MissingClosureParamType occurrences="2">
<code>$excludeClassyName</code>
Expand Down
31 changes: 31 additions & 0 deletions src/DataProvider/NullProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2017-2020 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/test-util
*/

namespace Ergebnis\Test\Util\DataProvider;

use Ergebnis\Test\Util;

final class NullProvider
{
use Util\Helper;

/**
* @return \Generator<string, array{0: null}>
*/
public static function null(): \Generator
{
yield from self::provide([
'null' => null,
]);
}
}
34 changes: 34 additions & 0 deletions test/Unit/DataProvider/NullProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2017-2020 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/test-util
*/

namespace Ergebnis\Test\Util\Test\Unit\DataProvider;

use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Test\Util\DataProvider\NullProvider
*/
final class NullProviderTest extends Framework\TestCase
{
/**
* @dataProvider \Ergebnis\Test\Util\DataProvider\NullProvider::null()
*
* @param mixed $value
*/
public function testNullProvidesNull($value): void
{
self::assertNull($value);
}
}