-
Notifications
You must be signed in to change notification settings - Fork 1
/
UseInPhpUnitTest.php
53 lines (47 loc) · 1.34 KB
/
UseInPhpUnitTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace Macocci7\PhpCombination;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/UseInPhpUnit.class.php';
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Macocci7\PhpCombination\Examples\UseInPhpUnit;
use Macocci7\PhpCombination\Combination;
final class UseInPhpUnitTest extends TestCase
{
public static function provide_order_can_order_correctly(): array
{
$products = [ 1101, 1102, ];
$sizes = [ 'S', 'M', 'L', ];
$colors = [ 'White', 'Black', ];
$amount = [ 1, 2, ];
$c = new Combination();
$data = [];
foreach (
$c->fromArrays([$products, $sizes, $colors, $amount]) as $e
) {
$data[implode(', ', $e)] = $e;
}
return $data;
}
/**
* PHPDoc for PHPUnit 9.x
* @dataProvider provide_order_can_order_correctly
*/
// Attribute for PHPUnit 10.x or later
#[DataProvider('provide_order_can_order_correctly')]
public function test_order_can_order_correctly(
int $productId,
string $size,
string $color,
int $amount
): void {
$u = new UseInPhpUnit();
$this->assertTrue($u->order(
$productId,
$size,
$color,
$amount
));
}
}