Files
oleibman 898fa0bf60 Phpstan Bleeding Edge Part 1 of Many
We currently use Phpstan Release 1. Release 2 has been available for some time, and we would like to stay current if possible. In order to get to Release 2, we first have to pass the "bleeding edge" tests for Release 1. I will do this by generating a new baseline using bleeding edge, then fix the baseline errors over several different PR's. This is the first of those.
2025-02-12 07:48:32 -08:00

34 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Writer\Xls;
use PhpOffice\PhpSpreadsheet\Shared\File;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xls;
use PHPUnit\Framework\TestCase;
class Issue642Test extends TestCase
{
public function testCharOutsideBMP(): void
{
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$stringUtf8 = "Hello\u{1f600}goodbye";
$stringUtf16 = (string) iconv('UTF-8', 'UTF-16LE', $stringUtf8);
self::assertSame(28, strlen($stringUtf16)); // each character requires 2 bytes except for non-BMP which requires 4
$sheet->getCell('A1')->setValue($stringUtf8);
$outputFilename = File::temporaryFilename();
$writer = new Xls($spreadsheet);
$writer->save($outputFilename);
$spreadsheet->disconnectWorksheets();
$contents = (string) file_get_contents($outputFilename);
unlink($outputFilename);
$expected = "\x00\x0e\x00\x01" . $stringUtf16; // length is 14 (0e), not 13
self::assertStringContainsString($expected, $contents);
$unexpected = "\x00\x0d\x00\x01" . $stringUtf16; // length is 14 (0e), not 13
self::assertStringNotContainsString($unexpected, $contents);
}
}