Exceptions > create instance of exception using static "create()" method (instead of constructor)

This commit is contained in:
Meritoo
2018-07-02 08:52:01 +02:00
parent 9342f0e87e
commit 834b24f348
35 changed files with 139 additions and 105 deletions

View File

@@ -23,7 +23,7 @@ class IncorrectColorHexLengthExceptionTest extends BaseTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(IncorrectColorHexLengthException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
static::assertConstructorVisibilityAndArguments(IncorrectColorHexLengthException::class, OopVisibilityType::IS_PUBLIC, 3);
}
/**
@@ -34,7 +34,7 @@ class IncorrectColorHexLengthExceptionTest extends BaseTestCase
*/
public function testConstructorMessage($color, $expectedMessage)
{
$exception = new IncorrectColorHexLengthException($color);
$exception = IncorrectColorHexLengthException::create($color);
static::assertEquals($expectedMessage, $exception->getMessage());
}

View File

@@ -10,7 +10,6 @@ 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;
@@ -22,12 +21,9 @@ use Meritoo\Common\Type\OopVisibilityType;
*/
class InvalidColorHexValueExceptionTest extends BaseTestCase
{
/**
* @throws UnknownOopVisibilityTypeException
*/
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(InvalidColorHexValueException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
static::assertConstructorVisibilityAndArguments(InvalidColorHexValueException::class, OopVisibilityType::IS_PUBLIC, 3);
}
/**
@@ -38,7 +34,7 @@ class InvalidColorHexValueExceptionTest extends BaseTestCase
*/
public function testConstructorMessage($color, $expectedMessage)
{
$exception = new InvalidColorHexValueException($color);
$exception = InvalidColorHexValueException::create($color);
static::assertEquals($expectedMessage, $exception->getMessage());
}

View File

@@ -10,7 +10,6 @@ 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;
@@ -22,12 +21,9 @@ use Meritoo\Common\Type\OopVisibilityType;
*/
class InvalidHtmlAttributesExceptionTest extends BaseTestCase
{
/**
* @throws UnknownOopVisibilityTypeException
*/
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(InvalidHtmlAttributesException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
static::assertConstructorVisibilityAndArguments(InvalidHtmlAttributesException::class, OopVisibilityType::IS_PUBLIC, 3);
}
/**
@@ -38,7 +34,7 @@ class InvalidHtmlAttributesExceptionTest extends BaseTestCase
*/
public function testConstructorMessage($htmlAttributes, $expectedMessage)
{
$exception = new InvalidHtmlAttributesException($htmlAttributes);
$exception = InvalidHtmlAttributesException::create($htmlAttributes);
static::assertEquals($expectedMessage, $exception->getMessage());
}

View File

@@ -23,7 +23,7 @@ class InvalidUrlExceptionTest extends BaseTestCase
{
public function testConstructorVisibilityAndArguments()
{
static::assertConstructorVisibilityAndArguments(InvalidUrlException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
static::assertConstructorVisibilityAndArguments(InvalidUrlException::class, OopVisibilityType::IS_PUBLIC, 3);
}
/**
@@ -34,7 +34,7 @@ class InvalidUrlExceptionTest extends BaseTestCase
*/
public function testConstructorMessage($url, $expectedMessage)
{
$exception = new InvalidUrlException($url);
$exception = InvalidUrlException::create($url);
static::assertEquals($expectedMessage, $exception->getMessage());
}