-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAbstractStringMapTestCase.php
More file actions
56 lines (48 loc) · 1.31 KB
/
AbstractStringMapTestCase.php
File metadata and controls
56 lines (48 loc) · 1.31 KB
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
54
55
56
<?php
/**
* This file is part of the Noctud Collection.
* Copyright (c) Noctud.dev
*/
declare(strict_types=1);
namespace Noctud\Collection\Tests\Map\StringMap\Case;
use Closure;
use Noctud\Collection\Collection;
use Noctud\Collection\Map\Map;
use Noctud\Collection\Tests\EnumerableCopyOnWrite;
use PHPUnit\Framework\TestCase;
use Noctud\Collection\Tests\Map\StringMap\StringMapConvert;
use Noctud\Collection\Tests\Map\StringMap\StringMapCopyOnWrite;
use Noctud\Collection\Tests\Map\StringMap\StringMapKeyEnforcement;
use Noctud\Collection\Tests\Map\StringMap\StringMapBasics;
/**
* Base test case for StringMap tests.
* Uses only string-keyed associative arrays in test data.
*/
abstract class AbstractStringMapTestCase extends TestCase implements StringMapTestCase
{
use EnumerableCopyOnWrite;
use StringMapBasics;
use StringMapConvert;
use StringMapCopyOnWrite;
use StringMapKeyEnforcement;
/**
* @template V
* @param iterable<string,V>|Closure():iterable<string,V> $data
* @return Map<string,V>
*/
public function enumerableOf(iterable|Closure $data): Collection|Map
{
return $this->mapOf($data);
}
/**
* @return array<string, string>
*/
protected function generateSampleData(int $size): array
{
$data = [];
for ($i = 0; $i < $size; $i++) {
$data["key_$i"] = "value_$i";
}
return $data;
}
}