Skip to content

Commit 9426c42

Browse files
committed
Refactor the tests.
1 parent 1c1c432 commit 9426c42

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

tests/unit/AnytimeTest.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace drupol\phpartition\Tests\unit;
6+
7+
use Codeception\Test\Unit;
8+
use drupol\phpartition\Anytime;
9+
10+
/**
11+
* @internal
12+
*
13+
* @covers \drupol\phpartition\Anytime
14+
* @covers \drupol\phpartition\Partitioner
15+
*/
16+
final class AnytimeTest extends Unit
17+
{
18+
/**
19+
* @var \UnitTester
20+
*/
21+
protected $tester;
22+
23+
public function anytimeTestProvider()
24+
{
25+
yield [
26+
[1, 2, 3, 4, 5, 6],
27+
1,
28+
[[1, 2, 3, 4, 5, 6]],
29+
];
30+
31+
yield [
32+
[1, 2, 3, 4, 5, 6],
33+
2,
34+
[[4, 6], [1, 2, 3, 5]],
35+
];
36+
37+
yield [
38+
[1, 2, 3, 4, 5, 6],
39+
3,
40+
[[1, 6], [2, 5], [3, 4]],
41+
];
42+
43+
yield [
44+
[1, 2, 3, 4, 5, 6],
45+
4,
46+
[[5, 6], [1, 4], [2], [3]],
47+
];
48+
49+
yield [
50+
[1, 2, 3, 4, 5, 6],
51+
5,
52+
[[4], [5], [3], [6], [1, 2]],
53+
];
54+
55+
yield [
56+
[1, 2, 3, 4, 5, 6],
57+
6,
58+
[[3], [4], [2], [5], [1], [6]],
59+
];
60+
61+
yield [
62+
[1, 2, 3, 4, 5, 6],
63+
7,
64+
[[1, 2, 3, 4, 5, 6], [], [], [], [], [], []],
65+
];
66+
}
67+
68+
/**
69+
* @param $dataset
70+
* @param $chunks
71+
* @param $expected
72+
*
73+
* @dataProvider anytimeTestProvider
74+
*/
75+
public function testAnytime($dataset, $chunks, $expected)
76+
{
77+
$anytime = new Anytime();
78+
79+
$anytime->setDataset($dataset);
80+
81+
static::assertSame($expected, $anytime->export($chunks));
82+
}
83+
}

0 commit comments

Comments
 (0)