1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace PhpOffice\PhpSpreadsheetTests; |
6
|
|
|
|
7
|
|
|
use PhpOffice\PhpSpreadsheet\Exception as SpException; |
8
|
|
|
use PhpOffice\PhpSpreadsheet\Settings; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
|
11
|
|
|
class SettingsTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
protected function tearDown(): void |
14
|
|
|
{ |
15
|
|
|
Settings::setCache(null); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testInvalidChartRenderer(): void |
19
|
|
|
{ |
20
|
|
|
$this->expectException(SpException::class); |
21
|
|
|
$this->expectExceptionMessage('Chart renderer must implement'); |
22
|
|
|
// @phpstan-ignore-next-line |
23
|
|
|
Settings::setChartRenderer(self::class); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testInvalidRequestFactory(): void |
27
|
|
|
{ |
28
|
|
|
$this->expectException(SpException::class); |
29
|
|
|
$this->expectExceptionMessage('HTTP client must be configured'); |
30
|
|
|
Settings::getRequestFactory(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testCache(): void |
34
|
|
|
{ |
35
|
|
|
$cache1 = Settings::getCache(); |
36
|
|
|
self::assertNotNull($cache1); |
37
|
|
|
Settings::setCache(null); |
38
|
|
|
$cache2 = Settings::getCache(); |
39
|
|
|
self::assertEquals($cache1, $cache2); |
40
|
|
|
self::assertNotSame($cache1, $cache2); |
41
|
|
|
$array = ['A1' => 10, 'B2' => 20]; |
42
|
|
|
$cache2->setMultiple($array); |
43
|
|
|
self::assertSame($array, $cache2->getMultiple(array_keys($array))); |
44
|
|
|
self::assertNull($cache2->get('C3')); |
45
|
|
|
$cache2->clear(); |
46
|
|
|
self::assertNull($cache2->get('A1')); |
47
|
|
|
self::assertNull($cache2->get('B2')); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|