Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Reader/Html/HtmlLibxmlTest.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

49 lines
1.2 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.
* I want it run in a separate
* process because I am nervous about libxml_use_internal_errors.
*
* @runTestsInSeparateProcesses
*/
class HtmlLibxmlTest extends TestCase
{
/** @var bool */
private $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());
}
}