1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace EasyDictionary; |
6
|
|
|
|
7
|
|
|
use EasyDictionary\DataProvider\Simple as SimpleDataProvider; |
8
|
|
|
use EasyDictionary\Dictionary\Simple as SimpleDictionary; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
use Psr\SimpleCache\CacheInterface; |
11
|
|
|
|
12
|
|
|
/** |
|
|
|
|
13
|
|
|
* @coversDefaultClass \EasyDictionary\BasicConfig |
14
|
|
|
*/ |
|
|
|
|
15
|
|
|
class BasicConfigTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
/** |
|
|
|
|
18
|
|
|
* @covers \EasyDictionary\BasicConfig |
19
|
|
|
*/ |
|
|
|
|
20
|
|
|
public function testClassExistence() |
21
|
|
|
{ |
22
|
|
|
self::assertTrue(class_exists('\EasyDictionary\BasicConfig')); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
|
|
|
|
26
|
|
|
* @covers ::getDefaultDataProviderClass |
27
|
|
|
*/ |
|
|
|
|
28
|
|
|
public function testDefaultDataProviderClass() |
29
|
|
|
{ |
30
|
|
|
$config = new BasicConfig(); |
31
|
|
|
|
32
|
|
|
self::assertEquals( |
33
|
|
|
SimpleDataProvider::class, |
34
|
|
|
$config->getDefaultDataProviderClass() |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
|
|
|
|
39
|
|
|
* @covers ::getDefaultDictionaryClass |
40
|
|
|
*/ |
|
|
|
|
41
|
|
|
public function testDefaultDictionaryClass() |
42
|
|
|
{ |
43
|
|
|
$config = new BasicConfig(); |
44
|
|
|
|
45
|
|
|
self::assertEquals( |
46
|
|
|
SimpleDictionary::class, |
47
|
|
|
$config->getDefaultDictionaryClass() |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
|
|
|
|
52
|
|
|
* @covers ::setDictionaryConfig |
53
|
|
|
* @covers ::getDictionaryConfig |
54
|
|
|
*/ |
|
|
|
|
55
|
|
|
public function testSetGetConfig() |
56
|
|
|
{ |
57
|
|
|
$dictionary = [ |
58
|
|
|
'test' => [] |
59
|
|
|
]; |
60
|
|
|
|
61
|
|
|
$config = new BasicConfig(); |
62
|
|
|
$config->setDictionaryConfig($dictionary); |
63
|
|
|
|
64
|
|
|
self::assertEquals($dictionary, $config->getDictionaryConfig()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
|
|
|
|
68
|
|
|
* @covers ::setDefaultView |
69
|
|
|
* @covers ::getDefaultView |
70
|
|
|
*/ |
|
|
|
|
71
|
|
|
public function testSetGetDefaultView() |
72
|
|
|
{ |
73
|
|
|
$callable = function ($test) { |
|
|
|
|
74
|
|
|
}; |
75
|
|
|
|
76
|
|
|
$config = new BasicConfig(); |
77
|
|
|
self::assertNull($config->getDefaultView()); |
78
|
|
|
|
79
|
|
|
$config->setDefaultView($callable); |
80
|
|
|
self::assertEquals($callable, $config->getDefaultView()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
|
|
|
|
84
|
|
|
* @covers ::addCache |
85
|
|
|
* @covers ::getCache |
86
|
|
|
*/ |
|
|
|
|
87
|
|
|
public function testAddGetCache() |
88
|
|
|
{ |
89
|
|
|
$cache = self::createMock(CacheInterface::class); |
90
|
|
|
|
91
|
|
|
$config = new BasicConfig(); |
92
|
|
|
$config->addCache($cache, 'testCache'); |
|
|
|
|
93
|
|
|
|
94
|
|
|
self::assertEquals($cache, $config->getCache('testCache')); |
95
|
|
|
self::assertNull($config->getCache('noCache')); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|