Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Reader/Html/HtmlLibxmlTest.php
T
oleibman 2c8177a319 Eliminate Unneeded Separate Process Tests
The tests stay; they just no longer run in separate processes. I think that only 2 tests still require separate processes - Helper/SampleTest and Tcpdf/NoDieTest. Aside from a new internal method in IOFactory, all the changes here are to test members.
2025-12-07 23:15:01 -08:00

44 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
use PhpOffice\PhpSpreadsheet\Reader\Html;
use PHPUnit\Framework\TestCase;
/**
* Dom loadHtml usually succeeds even with invalid Html,
* although it will generate warning messages.
* This member demonstrates a method less intrusive than
* set_error_handler to detect if there has been a problem.
*/
class HtmlLibxmlTest extends TestCase
{
private bool $useErrors;
protected function setUp(): void
{
$this->useErrors = libxml_use_internal_errors(true);
}
protected function tearDown(): void
{
libxml_use_internal_errors($this->useErrors);
}
public function testLoadInvalidString(): void
{
$html = '<table<>';
(new Html())->loadFromString($html);
self::assertNotEmpty(libxml_get_errors());
}
public function testLoadValidString(): void
{
$html = '<table>';
(new Html())->loadFromString($html);
self::assertEmpty(libxml_get_errors());
}
}