This repository has been archived by the owner on Jan 4, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #335 from ergebnis/feature/int-provider
Enhancement: Implement IntProvider
- Loading branch information
Showing
8 changed files
with
415 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?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 IntProvider | ||
{ | ||
use Util\Helper; | ||
|
||
/** | ||
* @return \Generator<string, array{0: int}> | ||
*/ | ||
public static function arbitrary(): \Generator | ||
{ | ||
yield from self::provideDataForValues(self::values()); | ||
} | ||
|
||
/** | ||
* @return \Generator<string, array{0: int}> | ||
*/ | ||
public static function lessThanZero(): \Generator | ||
{ | ||
yield from self::provideDataForValuesWhere(self::values(), static function (int $value): bool { | ||
return 0 > $value; | ||
}); | ||
} | ||
|
||
/** | ||
* @return \Generator<string, array{0: int}> | ||
*/ | ||
public static function zero(): \Generator | ||
{ | ||
yield from self::provideDataForValuesWhere(self::values(), static function (int $value): bool { | ||
return 0 === $value; | ||
}); | ||
} | ||
|
||
/** | ||
* @return \Generator<string, array{0: int}> | ||
*/ | ||
public static function greaterThanZero(): \Generator | ||
{ | ||
yield from self::provideDataForValuesWhere(self::values(), static function (int $value): bool { | ||
return 0 < $value; | ||
}); | ||
} | ||
|
||
/** | ||
* @return \Generator<string, array{0: int}> | ||
*/ | ||
public static function lessThanOne(): \Generator | ||
{ | ||
yield from self::provideDataForValuesWhere(self::values(), static function (int $value): bool { | ||
return 1 > $value; | ||
}); | ||
} | ||
|
||
/** | ||
* @return \Generator<string, array{0: int}> | ||
*/ | ||
public static function one(): \Generator | ||
{ | ||
yield from self::provideDataForValuesWhere(self::values(), static function (int $value): bool { | ||
return 1 === $value; | ||
}); | ||
} | ||
|
||
/** | ||
* @return \Generator<string, array{0: int}> | ||
*/ | ||
public static function greaterThanOne(): \Generator | ||
{ | ||
yield from self::provideDataForValuesWhere(self::values(), static function (int $value): bool { | ||
return 1 < $value; | ||
}); | ||
} | ||
|
||
/** | ||
* @return array<string, int> | ||
*/ | ||
private static function values(): array | ||
{ | ||
$faker = self::faker(); | ||
|
||
return [ | ||
'int-less-than-minus-one' => -1 * $faker->numberBetween(1), | ||
'int-minus-one' => -1, | ||
'int-zero' => 0, | ||
'int-plus-one' => 1, | ||
'int-greater-than-plus-one' => $faker->numberBetween(1), | ||
]; | ||
} | ||
} |
Oops, something went wrong.