mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 01:31:45 +01:00
Exception - InvalidHtmlAttributesException - an exception used while html attributes are invalid
This commit is contained in:
29
src/Exception/Regex/InvalidHtmlAttributesException.php
Normal file
29
src/Exception/Regex/InvalidHtmlAttributesException.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\Common\Exception\Regex;
|
||||
|
||||
/**
|
||||
* An exception used while html attributes are invalid
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class InvalidHtmlAttributesException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $htmlAttributes Invalid html attributes
|
||||
*/
|
||||
public function __construct($htmlAttributes)
|
||||
{
|
||||
$message = sprintf('HTML attributes \'%s\' are invalid. Is there everything ok?', $htmlAttributes);
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace Meritoo\Common\Test\Exception\Regex;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
|
||||
use Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
|
||||
@@ -21,6 +22,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*/
|
||||
class InvalidColorHexValueExceptionTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* @throws UnknownOopVisibilityTypeException
|
||||
*/
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(InvalidColorHexValueException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
|
||||
69
tests/Exception/Regex/InvalidHtmlAttributesExceptionTest.php
Normal file
69
tests/Exception/Regex/InvalidHtmlAttributesExceptionTest.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\Common\Test\Exception\Regex;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Exception\Regex\InvalidHtmlAttributesException;
|
||||
use Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
|
||||
/**
|
||||
* Test case of an exception used while html attributes are invalid
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class InvalidHtmlAttributesExceptionTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* @throws UnknownOopVisibilityTypeException
|
||||
*/
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(InvalidHtmlAttributesException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $htmlAttributes Invalid html attributes
|
||||
* @param string $expectedMessage Expected exception's message
|
||||
*
|
||||
* @dataProvider provideHtmlAttributes
|
||||
*/
|
||||
public function testConstructorMessage($htmlAttributes, $expectedMessage)
|
||||
{
|
||||
$exception = new InvalidHtmlAttributesException($htmlAttributes);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides html attributes
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideHtmlAttributes()
|
||||
{
|
||||
$template = 'HTML attributes \'%s\' are invalid. Is there everything ok?';
|
||||
|
||||
yield[
|
||||
'abc = def',
|
||||
sprintf($template, 'abc = def'),
|
||||
];
|
||||
|
||||
yield[
|
||||
'abc = def ghi = jkl',
|
||||
sprintf($template, 'abc = def ghi = jkl'),
|
||||
];
|
||||
|
||||
yield[
|
||||
'abc=def ghi=jkl',
|
||||
sprintf($template, 'abc=def ghi=jkl'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user