Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Reader\Html; use..
Decoded Output download
<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
use PhpOffice\PhpSpreadsheet\Reader\Html;
use PHPUnit\Framework\TestCase;
class Issue2942Test extends TestCase
{
public function testLoadFromString(): void
{
$content = '<table><tbody><tr><td></td></tr></tbody></table>';
$reader = new Html();
$spreadsheet = $reader->loadFromString($content);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame('', $sheet->getCell('A1')->getValue());
$spreadsheet->disconnectWorksheets();
}
public function testLoadFromFile(): void
{
$file = 'tests/data/Reader/HTML/utf8chars.html';
$reader = new Html();
$spreadsheet = $reader->loadSpreadsheetFromFile($file);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame('Test Utf-8 characters voil', $sheet->getTitle());
self::assertSame('', $sheet->getCell('A1')->getValue());
self::assertSame('', $sheet->getCell('B1')->getValue());
self::assertSame(' & ', $sheet->getCell('A2')->getValue());
self::assertSame('', $sheet->getCell('B2')->getValue());
self::assertSame('', $sheet->getCell('C2')->getValue());
self::assertSame('', $sheet->getCell('A3')->getValue());
self::assertSame('', $sheet->getCell('B3')->getValue());
self::assertSame('', $sheet->getCell('C3')->getValue());
self::assertSame('', $sheet->getCell('D3')->getValue());
$spreadsheet->disconnectWorksheets();
}
public function testInfo(): void
{
$file = 'tests/data/Reader/HTML/utf8chars.charset.html';
$reader = new Html();
$info = $reader->listWorksheetInfo($file);
self::assertCount(1, $info);
$info0 = $info[0];
self::assertSame('Test Utf-8 characters voil', $info0['worksheetName']);
self::assertSame('D', $info0['lastColumnLetter']);
self::assertSame(3, $info0['lastColumnIndex']);
self::assertSame(7, $info0['totalRows']);
self::assertSame(4, $info0['totalColumns']);
$names = $reader->listWorksheetNames($file);
self::assertCount(1, $names);
self::assertSame('Test Utf-8 characters voil', $names[0]);
// Following ignored, just make sure it's executable.
$reader->setLoadSheetsOnly([$names[0]]);
$spreadsheet = $reader->load($file);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame('', $sheet->getCell('D3')->getValue());
$spreadsheet->disconnectWorksheets();
}
}
?>
Did this file decode correctly?
Original Code
<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
use PhpOffice\PhpSpreadsheet\Reader\Html;
use PHPUnit\Framework\TestCase;
class Issue2942Test extends TestCase
{
public function testLoadFromString(): void
{
$content = '<table><tbody><tr><td></td></tr></tbody></table>';
$reader = new Html();
$spreadsheet = $reader->loadFromString($content);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame('', $sheet->getCell('A1')->getValue());
$spreadsheet->disconnectWorksheets();
}
public function testLoadFromFile(): void
{
$file = 'tests/data/Reader/HTML/utf8chars.html';
$reader = new Html();
$spreadsheet = $reader->loadSpreadsheetFromFile($file);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame('Test Utf-8 characters voil', $sheet->getTitle());
self::assertSame('', $sheet->getCell('A1')->getValue());
self::assertSame('', $sheet->getCell('B1')->getValue());
self::assertSame(' & ', $sheet->getCell('A2')->getValue());
self::assertSame('', $sheet->getCell('B2')->getValue());
self::assertSame('', $sheet->getCell('C2')->getValue());
self::assertSame('', $sheet->getCell('A3')->getValue());
self::assertSame('', $sheet->getCell('B3')->getValue());
self::assertSame('', $sheet->getCell('C3')->getValue());
self::assertSame('', $sheet->getCell('D3')->getValue());
$spreadsheet->disconnectWorksheets();
}
public function testInfo(): void
{
$file = 'tests/data/Reader/HTML/utf8chars.charset.html';
$reader = new Html();
$info = $reader->listWorksheetInfo($file);
self::assertCount(1, $info);
$info0 = $info[0];
self::assertSame('Test Utf-8 characters voil', $info0['worksheetName']);
self::assertSame('D', $info0['lastColumnLetter']);
self::assertSame(3, $info0['lastColumnIndex']);
self::assertSame(7, $info0['totalRows']);
self::assertSame(4, $info0['totalColumns']);
$names = $reader->listWorksheetNames($file);
self::assertCount(1, $names);
self::assertSame('Test Utf-8 characters voil', $names[0]);
// Following ignored, just make sure it's executable.
$reader->setLoadSheetsOnly([$names[0]]);
$spreadsheet = $reader->load($file);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame('', $sheet->getCell('D3')->getValue());
$spreadsheet->disconnectWorksheets();
}
}
Function Calls
None |
Stats
MD5 | 2093fda6e85fcaa735dd478d812f6c57 |
Eval Count | 0 |
Decode Time | 84 ms |