feature-ninja / testing-matrix
Easily test multiple scenarios by creating a testing matrix
0.1.1
2024-09-11 15:52 UTC
Requires
- php: ^8.3
Requires (Dev)
- laravel/pint: ^1.10
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^11.3
This package is auto-updated.
Last update: 2024-11-20 16:08:54 UTC
README
Easily test multiple scenarios by creating a testing matrix
Installation
You can install the package via composer:
composer require feature-ninja/testing-matrix
Usage
Create a testing matrix from an array:
use FeatureNinja\TestingMatrix\Matrix; $matrix = Matrix::create([ 'a' => [1, 2], 'b' => [3, 4], ]); assert(iterator_to_array($matrix) === [ 'a=1 b=3' => [1, 3], 'a=1 b=4' => [1, 4], 'a=2 b=3' => [2, 3], 'a=2 b=4' => [2, 4], ]);
Usage in PHPUnit:
use FeatureNinja\TestingMatrix\Matrix; use PHPUnit\Framework\Attributes\DataProvider;use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; final class ExampleTest extends TestCase { public static function example_data_provider(): Generator { yield from Matrix::create([ 'a' => [1, 2], 'b' => [3, 4], ]); } #[Test] #[DataProvider('examples')] public function example(int $a, int $b): void { // ... } }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.