Modern DOM library written in PHP for HTML documents
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

<?php
/**
* @license MIT
* Copyright 2017, Dustin Wilson, J. King et al.
* See LICENSE and AUTHORS files for details
*/
declare(strict_types=1);
namespace MensBeam\HTML\DOM\TestCase;
use MensBeam\HTML\DOM\{
DOMException,
Exception
};
/**
* @covers \MensBeam\HTML\DOM\DOMException
* @covers \MensBeam\HTML\DOM\Exception
*/
class TestException extends \PHPUnit\Framework\TestCase {
public function provideConstructorFailures(): iterable {
return [
[ function() {
$d = new DOMException(2112);
}, Exception::INVALID_CODE ],
[ function() {
$d = new Exception(2112);
}, Exception::INVALID_CODE ],
[ function() {
throw new DOMException(DOMException::NOT_FOUND, 'FAIL');
}, Exception::INCORRECT_PARAMETERS_FOR_MESSAGE ],
[ function() {
throw new Exception(Exception::UNKNOWN_ERROR, 'FAIL');
}, Exception::INCORRECT_PARAMETERS_FOR_MESSAGE ],
];
}
/**
* @dataProvider provideConstructorFailures
* @covers \MensBeam\HTML\DOM\DOMException::__construct
* @covers \MensBeam\HTML\DOM\Exception::__construct
*/
public function testConstructorFailures(\Closure $closure, int $errorCode): void {
$this->expectException(Exception::class);
$this->expectExceptionCode($errorCode);
$closure();
}
}