Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3464Test.php
T
Adrien Crivelli ec4098c8fd Strict mode for all tests
While we might never be able to have 100% of our code strict, we can at
the very least do it for all of our tests. This ensures that our tests
are using our API with the types as intended by the test author, and not
silently be cast to what our API requires.
2023-09-07 17:44:56 +08:00

43 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\RichText\RichText;
class Issue3464Test extends \PHPUnit\Framework\TestCase
{
/**
* @var string
*/
private static $testbook = 'tests/data/Reader/XLSX/issue.3464.xlsx';
public function testReadFontColor(): void
{
$inputFileType = IOFactory::identify(self::$testbook);
$objReader = IOFactory::createReader($inputFileType);
$objReader->setReadEmptyCells(false);
$spreadsheet = $objReader->load(self::$testbook);
$sheet = $spreadsheet->getActiveSheet();
$rickText = $sheet->getCell([1, 1])->getValue();
self::assertInstanceOf(RichText::class, $rickText);
$elements = $rickText->getRichTextElements();
self::assertCount(2, $elements);
self::assertEquals("产品介绍\n", $elements[0]->getText());
$font = $elements[0]->getFont();
self::assertNotNull($font);
self::assertEquals('7f7f7f', $font->getColor()->getRGB());
self::assertEquals('(这是一行示例数据,在导入时需要删除该行)', $elements[1]->getText());
$font = $elements[1]->getFont();
self::assertNotNull($font);
self::assertEquals('ff2600', $font->getColor()->getRGB());
$spreadsheet->disconnectWorksheets();
}
}