PHP code example of feature-ninja / testing-matrix

1. Go to this page and download the library: Download feature-ninja/testing-matrix library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

feature-ninja / testing-matrix example snippets


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],
]);

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
    {
        // ...
    }
}