mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-24 18:08:18 +00:00
9512f54cca
This change was suggested by issue #2316. There was a problem reading Xlsx comments which appeared with release 18.0 but which was already fixed in master. So no source change was needed to fix the issue, but I thought we should at least add the test case to our unit tests. In developing that case, I discovered that, although comment text was read correctly, there was a problem with comment author. In fact, there were two problems. One was new, with the namespacing changes - as in several other cases, the namespaced attribute `authorId` needed some special handling. However, another problem was much older - the code was checking `!empty($comment['authorId'])`, eliminating consideration of authorId=0, and should instead have been checking `isset`. Both problems are now fixed, and tested.
27 lines
923 B
PHP
27 lines
923 B
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class CommentTest extends TestCase
|
|
{
|
|
public function testIssue2316(): void
|
|
{
|
|
$filename = 'tests/data/Reader/XLSX/issue.2316.xlsx';
|
|
$reader = new Xlsx();
|
|
$spreadsheet = $reader->load($filename);
|
|
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$comment = $sheet->getComment('A1');
|
|
$commentString = (string) $comment;
|
|
self::assertStringContainsString('編號長度限制:', $commentString);
|
|
self::assertSame('jill.chen', $comment->getAuthor());
|
|
$comment = $sheet->getComment('E1');
|
|
$commentString = (string) $comment;
|
|
self::assertStringContainsString('若為宅配物流僅能選「純配送」', $commentString);
|
|
self::assertSame('Anderson Chen 陳宗棠', $comment->getAuthor());
|
|
}
|
|
}
|