Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/SettingsTest.php
T
oleibman 77815d2dcc Remove Previously Announced Deprecations
Remove
- Worksheet::getHashCode
- Worksheet::getProtectecCells
- Worksheet::getStyles
- Drawing::setIsUrl
- IReader::SKIP_EMPTY_CELLS
- Settings:setLibXmlLoaderOptions and getLibXmlLoaderOptions
- Writer/Html::isMpdf
2025-02-04 19:30:57 -08:00

50 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests;
use PhpOffice\PhpSpreadsheet\Exception as SpException;
use PhpOffice\PhpSpreadsheet\Settings;
use PHPUnit\Framework\TestCase;
class SettingsTest extends TestCase
{
protected function tearDown(): void
{
Settings::setCache(null);
}
public function testInvalidChartRenderer(): void
{
$this->expectException(SpException::class);
$this->expectExceptionMessage('Chart renderer must implement');
// @phpstan-ignore-next-line
Settings::setChartRenderer(self::class);
}
public function testInvalidRequestFactory(): void
{
$this->expectException(SpException::class);
$this->expectExceptionMessage('HTTP client must be configured');
Settings::getRequestFactory();
}
public function testCache(): void
{
$cache1 = Settings::getCache();
self::assertNotNull($cache1);
Settings::setCache(null);
$cache2 = Settings::getCache();
self::assertEquals($cache1, $cache2);
self::assertNotSame($cache1, $cache2);
$array = ['A1' => 10, 'B2' => 20];
$cache2->setMultiple($array);
self::assertSame($array, $cache2->getMultiple(array_keys($array)));
self::assertNull($cache2->get('C3'));
$cache2->clear();
self::assertNull($cache2->get('A1'));
self::assertNull($cache2->get('B2'));
}
}