mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Exceptions > create instance of exception using static "create()" method (instead of constructor)
This commit is contained in:
@@ -6,6 +6,7 @@ Common and useful classes, methods, exceptions etc.
|
||||
|
||||
1. Composer > support/require PHP 5.6+ (instead of 5.5.9+)
|
||||
2. Docker > rename `php-cli` service to `php`
|
||||
3. Exceptions > create instance of exception using static `create()` method (instead of constructor)
|
||||
|
||||
# 0.0.21
|
||||
|
||||
|
||||
@@ -21,21 +21,22 @@ use Meritoo\Common\Utilities\Arrays;
|
||||
abstract class UnknownTypeException extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string|int $unknownType The unknown type of something (value of constant)
|
||||
* @param BaseType $typeInstance An instance of class that contains type of the something
|
||||
* @param string $typeName Name of the something
|
||||
* @return UnknownTypeException
|
||||
*/
|
||||
public function __construct($unknownType, BaseType $typeInstance, $typeName)
|
||||
public static function create($unknownType, BaseType $typeInstance, $typeName)
|
||||
{
|
||||
$allTypes = $typeInstance->getAll();
|
||||
$types = Arrays::values2string($allTypes, '', ', ');
|
||||
|
||||
$template = 'The \'%s\' type of %s is unknown. Probably doesn\'t exist or there is a typo. You should use one'
|
||||
. ' of these types: %s.';
|
||||
|
||||
$allTypes = $typeInstance->getAll();
|
||||
$types = Arrays::values2string($allTypes, '', ', ');
|
||||
$message = sprintf(sprintf($template, $unknownType, $typeName, $types));
|
||||
parent::__construct($message);
|
||||
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,18 @@ use Exception;
|
||||
class IncorrectBundleNameException extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $bundleName Incorrect name of bundle
|
||||
* @return IncorrectBundleNameException
|
||||
*/
|
||||
public function __construct($bundleName)
|
||||
public static function create($bundleName)
|
||||
{
|
||||
$template = 'Name of bundle \'%s\' is incorrect. It should start with big letter and end with "Bundle". Is'
|
||||
. ' there everything ok?';
|
||||
|
||||
$message = sprintf($template, $bundleName);
|
||||
parent::__construct($message);
|
||||
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,16 @@ namespace Meritoo\Common\Exception\File;
|
||||
class EmptyFileException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $emptyFilePath Path of the empty file
|
||||
* @return EmptyFileException
|
||||
*/
|
||||
public function __construct($emptyFilePath)
|
||||
public static function create($emptyFilePath)
|
||||
{
|
||||
$template = 'File with path \'%s\' is empty (has no content). Did you provide path of proper file?';
|
||||
$message = sprintf($template, $emptyFilePath);
|
||||
|
||||
parent::__construct($message);
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ namespace Meritoo\Common\Exception\File;
|
||||
class EmptyFilePathException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*/
|
||||
public function __construct()
|
||||
public static function create()
|
||||
{
|
||||
parent::__construct('Path of the file is empty. Did you provide path of proper file?');
|
||||
return new static('Path of the file is empty. Did you provide path of proper file?');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,16 @@ namespace Meritoo\Common\Exception\File;
|
||||
class NotExistingFileException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $notExistingFilePath Path of not existing (or not readable) file
|
||||
* @return NotExistingFileException
|
||||
*/
|
||||
public function __construct($notExistingFilePath)
|
||||
public static function create($notExistingFilePath)
|
||||
{
|
||||
$template = 'File with path \'%s\' does not exist (or is not readable). Did you provide path of proper file?';
|
||||
$message = sprintf($template, $notExistingFilePath);
|
||||
|
||||
parent::__construct($message);
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,13 @@ use Exception;
|
||||
class DisabledMethodException extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $disabledMethod Name of the disabled method
|
||||
* @param string $alternativeMethod (optional) Name of the alternative method
|
||||
* @return DisabledMethodException
|
||||
*/
|
||||
public function __construct($disabledMethod, $alternativeMethod = '')
|
||||
public static function create($disabledMethod, $alternativeMethod = '')
|
||||
{
|
||||
$template = 'Method %s() cannot be called, because is disabled.';
|
||||
|
||||
@@ -33,6 +34,7 @@ class DisabledMethodException extends Exception
|
||||
}
|
||||
|
||||
$message = sprintf($template, $disabledMethod, $alternativeMethod);
|
||||
parent::__construct($message);
|
||||
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,15 @@ use Exception;
|
||||
class CannotResolveClassNameException extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param array|object|string $source Source of the class's / trait's name. It can be an array of objects,
|
||||
* namespaces, object or namespace.
|
||||
* @param bool $forClass (optional) If is set to true, message of this exception for class is
|
||||
* prepared. Otherwise - for trait.
|
||||
* @return CannotResolveClassNameException
|
||||
*/
|
||||
public function __construct($source, $forClass = true)
|
||||
public static function create($source, $forClass = true)
|
||||
{
|
||||
$forWho = 'trait';
|
||||
$value = '';
|
||||
@@ -42,6 +43,6 @@ class CannotResolveClassNameException extends Exception
|
||||
$template = 'Name of %s from given \'%s\'%s cannot be resolved. Is there everything ok?';
|
||||
$message = sprintf($template, $forWho, gettype($source), $value);
|
||||
|
||||
parent::__construct($message);
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@ use Meritoo\Common\Utilities\Reflection;
|
||||
class MissingChildClassesException extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param array|object|string $parentClass Class that hasn't child classes, but it should. An array of objects,
|
||||
* strings, object or string.
|
||||
* @return MissingChildClassesException
|
||||
*/
|
||||
public function __construct($parentClass)
|
||||
public static function create($parentClass)
|
||||
{
|
||||
$template = 'The \'%s\' class requires one child class at least who will extend her (maybe is an abstract'
|
||||
. ' class), but the child classes are missing. Did you forget to extend this class?';
|
||||
@@ -33,6 +34,6 @@ class MissingChildClassesException extends Exception
|
||||
$parentClassName = Reflection::getClassName($parentClass);
|
||||
$message = sprintf($template, $parentClassName);
|
||||
|
||||
parent::__construct($message);
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,14 @@ use Meritoo\Common\Utilities\Reflection;
|
||||
class TooManyChildClassesException extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param array|object|string $parentClass Class that has more than one child class, but it shouldn't. An array
|
||||
* of objects, strings, object or string.
|
||||
* @param array $childClasses Child classes
|
||||
* @return TooManyChildClassesException
|
||||
*/
|
||||
public function __construct($parentClass, array $childClasses)
|
||||
public static function create($parentClass, array $childClasses)
|
||||
{
|
||||
$template = "The '%s' class requires one child class at most who will extend her, but more than one child"
|
||||
. " class was found:\n- %s\n\nWhy did you create more than one classes that extend '%s' class?";
|
||||
@@ -34,6 +35,6 @@ class TooManyChildClassesException extends Exception
|
||||
$parentClassName = Reflection::getClassName($parentClass);
|
||||
$message = sprintf($template, $parentClassName, implode("\n- ", $childClasses), $parentClassName);
|
||||
|
||||
parent::__construct($message);
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,18 @@ namespace Meritoo\Common\Exception\Regex;
|
||||
class IncorrectColorHexLengthException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $color Incorrect hexadecimal value of color
|
||||
* @return IncorrectColorHexLengthException
|
||||
*/
|
||||
public function __construct($color)
|
||||
public static function create($color)
|
||||
{
|
||||
$template = 'Length of hexadecimal value of color \'%s\' is incorrect. It\'s %d, but it should be 3 or 6.'
|
||||
. ' Is there everything ok?';
|
||||
|
||||
$message = sprintf($template, $color, strlen($color));
|
||||
parent::__construct($message);
|
||||
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,15 @@ namespace Meritoo\Common\Exception\Regex;
|
||||
class InvalidColorHexValueException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $color Invalid hexadecimal value of color
|
||||
* @return InvalidColorHexValueException
|
||||
*/
|
||||
public function __construct($color)
|
||||
public static function create($color)
|
||||
{
|
||||
$message = sprintf('Hexadecimal value of color \'%s\' is invalid. Is there everything ok?', $color);
|
||||
parent::__construct($message);
|
||||
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,15 @@ namespace Meritoo\Common\Exception\Regex;
|
||||
class InvalidHtmlAttributesException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $htmlAttributes Invalid html attributes
|
||||
* @return InvalidHtmlAttributesException
|
||||
*/
|
||||
public function __construct($htmlAttributes)
|
||||
public static function create($htmlAttributes)
|
||||
{
|
||||
$message = sprintf('HTML attributes \'%s\' are invalid. Is there everything ok?', $htmlAttributes);
|
||||
parent::__construct($message);
|
||||
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
@@ -11,13 +17,15 @@ namespace Meritoo\Common\Exception\Regex;
|
||||
class InvalidUrlException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $url Invalid url
|
||||
* @return InvalidUrlException
|
||||
*/
|
||||
public function __construct($url)
|
||||
public static function create($url)
|
||||
{
|
||||
$message = sprintf('Url \'%s\' is invalid. Is there everything ok?', $url);
|
||||
parent::__construct($message);
|
||||
|
||||
return new static($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\Common\Exception\Date;
|
||||
namespace Meritoo\Common\Exception\Type;
|
||||
|
||||
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
||||
use Meritoo\Common\Type\DatePartType;
|
||||
@@ -20,13 +20,17 @@ use Meritoo\Common\Type\DatePartType;
|
||||
class UnknownDatePartTypeException extends UnknownTypeException
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $unknownDatePart Type of date part, e.g. "year". One of DatePartType class constants.
|
||||
* @param string $unknownDatePart Unknown type of date part
|
||||
* @param string $value Incorrect value
|
||||
* @return UnknownDatePartTypeException
|
||||
*/
|
||||
public function __construct($unknownDatePart, $value)
|
||||
public static function createException($unknownDatePart, $value)
|
||||
{
|
||||
parent::__construct($unknownDatePart, new DatePartType(), sprintf('date part (with value %s)', $value));
|
||||
/* @var UnknownDatePartTypeException $exception */
|
||||
$exception = parent::create($unknownDatePart, new DatePartType(), sprintf('date part (with value %s)', $value));
|
||||
|
||||
return $exception;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
<?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\Type;
|
||||
|
||||
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
||||
@@ -14,10 +20,16 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
class UnknownOopVisibilityTypeException extends UnknownTypeException
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Creates exception
|
||||
*
|
||||
* @param string $unknownType Unknown visibility of a property, a method or (as of PHP 7.1.0) a constant
|
||||
* @return UnknownOopVisibilityTypeException
|
||||
*/
|
||||
public function __construct($unknownType)
|
||||
public static function createException($unknownType)
|
||||
{
|
||||
parent::__construct($unknownType, new OopVisibilityType(), 'OOP-related visibility');
|
||||
/* @var UnknownOopVisibilityTypeException $exception */
|
||||
$exception = parent::create($unknownType, new OopVisibilityType(), 'OOP-related visibility');
|
||||
|
||||
return $exception;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class Bundle
|
||||
* Given name of bundle is invalid?
|
||||
*/
|
||||
if (!Regex::isValidBundleName($bundleName)) {
|
||||
throw new IncorrectBundleNameException($bundleName);
|
||||
throw IncorrectBundleNameException::create($bundleName);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Meritoo\Common\Utilities;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use Meritoo\Common\Exception\Date\UnknownDatePartTypeException;
|
||||
use Meritoo\Common\Exception\Type\UnknownDatePartTypeException;
|
||||
use Meritoo\Common\Type\DatePartType;
|
||||
use Meritoo\Common\Type\DatePeriod;
|
||||
|
||||
@@ -255,21 +255,21 @@ class Date
|
||||
* Oops, incorrect year
|
||||
*/
|
||||
if ($year <= 0) {
|
||||
throw new UnknownDatePartTypeException(DatePartType::YEAR, $year);
|
||||
throw UnknownDatePartTypeException::createException(DatePartType::YEAR, $year);
|
||||
}
|
||||
|
||||
/*
|
||||
* Oops, incorrect month
|
||||
*/
|
||||
if ($month < 1 || $month > 12) {
|
||||
throw new UnknownDatePartTypeException(DatePartType::MONTH, $month);
|
||||
throw UnknownDatePartTypeException::createException(DatePartType::MONTH, $month);
|
||||
}
|
||||
|
||||
/*
|
||||
* Oops, incorrect day
|
||||
*/
|
||||
if ($day < 1 || $day > 31) {
|
||||
throw new UnknownDatePartTypeException(DatePartType::DAY, $day);
|
||||
throw UnknownDatePartTypeException::createException(DatePartType::DAY, $day);
|
||||
}
|
||||
|
||||
if ($month < 3) {
|
||||
|
||||
@@ -524,7 +524,7 @@ class Reflection
|
||||
* Oops, cannot resolve class
|
||||
*/
|
||||
if (null === $className) {
|
||||
throw new CannotResolveClassNameException($class);
|
||||
throw CannotResolveClassNameException::create($class);
|
||||
}
|
||||
|
||||
$childClasses = [];
|
||||
@@ -558,7 +558,6 @@ class Reflection
|
||||
*
|
||||
* @param array|object|string $parentClass Class who child class should be returned. An array of objects,
|
||||
* namespaces, object or namespace.
|
||||
* @throws CannotResolveClassNameException
|
||||
* @throws MissingChildClassesException
|
||||
* @throws TooManyChildClassesException
|
||||
* @return mixed
|
||||
@@ -572,7 +571,7 @@ class Reflection
|
||||
* Oops, the base / parent class hasn't child class
|
||||
*/
|
||||
if (empty($childClasses)) {
|
||||
throw new MissingChildClassesException($parentClass);
|
||||
throw MissingChildClassesException::create($parentClass);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -580,7 +579,7 @@ class Reflection
|
||||
* Oops, the base / parent class has too many child classes
|
||||
*/
|
||||
if (count($childClasses) > 1) {
|
||||
throw new TooManyChildClassesException($parentClass, $childClasses);
|
||||
throw TooManyChildClassesException::create($parentClass, $childClasses);
|
||||
}
|
||||
|
||||
return trim($childClasses[0]);
|
||||
@@ -621,7 +620,6 @@ class Reflection
|
||||
* @param bool $verifyParents If is set to true, parent classes are verified if they use given
|
||||
* trait. Otherwise - not.
|
||||
* @throws CannotResolveClassNameException
|
||||
* @throws ReflectionException
|
||||
* @return bool|null
|
||||
*/
|
||||
public static function usesTrait($class, $trait, $verifyParents = false)
|
||||
@@ -633,7 +631,7 @@ class Reflection
|
||||
* Oops, cannot resolve class
|
||||
*/
|
||||
if (empty($className)) {
|
||||
throw new CannotResolveClassNameException($class);
|
||||
throw CannotResolveClassNameException::create($class);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,7 +23,7 @@ class UnknownTypeExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(UnknownTestTypeException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(UnknownTestTypeException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
public function testWithoutException()
|
||||
@@ -60,13 +60,17 @@ class TestType extends BaseType
|
||||
class UnknownTestTypeException extends UnknownTypeException
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
* Creates exception
|
||||
*
|
||||
* @param int|string $unknownType The unknown type of something (for testing purposes)
|
||||
* @param string $unknownType The unknown type of something (for testing purposes)
|
||||
* @return UnknownTestTypeException
|
||||
*/
|
||||
public function __construct($unknownType)
|
||||
public static function createException($unknownType)
|
||||
{
|
||||
parent::__construct($unknownType, new TestType(), 'type of something used for testing');
|
||||
/* @var UnknownTestTypeException $exception */
|
||||
$exception = parent::create($unknownType, new TestType(), 'type of something used for testing');
|
||||
|
||||
return $exception;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace Meritoo\Common\Test\Exception\Date;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Exception\Date\UnknownDatePartTypeException;
|
||||
use Meritoo\Common\Exception\Type\UnknownDatePartTypeException;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\DatePartType;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
@@ -24,7 +24,7 @@ class UnknownDatePartTypeExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(UnknownDatePartTypeException::class, OopVisibilityType::IS_PUBLIC, 2, 2);
|
||||
static::assertConstructorVisibilityAndArguments(UnknownDatePartTypeException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,9 +34,9 @@ class UnknownDatePartTypeExceptionTest extends BaseTestCase
|
||||
*
|
||||
* @dataProvider provideDatePartAndValue
|
||||
*/
|
||||
public function testConstructorMessage($unknownDatePart, $value, $expectedMessage)
|
||||
public function testMessage($unknownDatePart, $value, $expectedMessage)
|
||||
{
|
||||
$exception = new UnknownDatePartTypeException($unknownDatePart, $value);
|
||||
$exception = UnknownDatePartTypeException::createException($unknownDatePart, $value);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class EmptyFileExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(EmptyFileException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(EmptyFileException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,9 +32,9 @@ class EmptyFileExceptionTest extends BaseTestCase
|
||||
*
|
||||
* @dataProvider providePathOfFile
|
||||
*/
|
||||
public function testConstructorMessage($emptyFilePath, $expectedMessage)
|
||||
public function testMessage($emptyFilePath, $expectedMessage)
|
||||
{
|
||||
$exception = new EmptyFileException($emptyFilePath);
|
||||
$exception = EmptyFileException::create($emptyFilePath);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@ class EmptyFilePathExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(EmptyFilePathException::class, OopVisibilityType::IS_PUBLIC);
|
||||
static::assertConstructorVisibilityAndArguments(EmptyFilePathException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
public function testConstructorMessage()
|
||||
{
|
||||
$exception = new EmptyFilePathException();
|
||||
$exception = EmptyFilePathException::create();
|
||||
static::assertEquals('Path of the file is empty. Did you provide path of proper file?', $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class NotExistingFileExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(NotExistingFileException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(NotExistingFileException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ class NotExistingFileExceptionTest extends BaseTestCase
|
||||
*/
|
||||
public function testConstructorMessage($notExistingFilePath, $expectedMessage)
|
||||
{
|
||||
$exception = new NotExistingFileException($notExistingFilePath);
|
||||
$exception = NotExistingFileException::create($notExistingFilePath);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class DisabledMethodExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(DisabledMethodException::class, OopVisibilityType::IS_PUBLIC, 2, 1);
|
||||
static::assertConstructorVisibilityAndArguments(DisabledMethodException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ class DisabledMethodExceptionTest extends BaseTestCase
|
||||
*/
|
||||
public function testConstructorMessage($disabledMethod, $alternativeMethod, $expectedMessage)
|
||||
{
|
||||
$exception = new DisabledMethodException($disabledMethod, $alternativeMethod);
|
||||
$exception = DisabledMethodException::create($disabledMethod, $alternativeMethod);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class CannotResolveClassNameExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(CannotResolveClassNameException::class, OopVisibilityType::IS_PUBLIC, 2, 1);
|
||||
static::assertConstructorVisibilityAndArguments(CannotResolveClassNameException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ class CannotResolveClassNameExceptionTest extends BaseTestCase
|
||||
*/
|
||||
public function testConstructorMessage($source, $forClass, $expectedMessage)
|
||||
{
|
||||
$exception = new CannotResolveClassNameException($source, $forClass);
|
||||
$exception = CannotResolveClassNameException::create($source, $forClass);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class MissingChildClassesExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(MissingChildClassesException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(MissingChildClassesException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ class MissingChildClassesExceptionTest extends BaseTestCase
|
||||
*/
|
||||
public function testConstructorMessage($parentClass, $expectedMessage)
|
||||
{
|
||||
$exception = new MissingChildClassesException($parentClass);
|
||||
$exception = MissingChildClassesException::create($parentClass);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class TooManyChildClassesExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(TooManyChildClassesException::class, OopVisibilityType::IS_PUBLIC, 2, 2);
|
||||
static::assertConstructorVisibilityAndArguments(TooManyChildClassesException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ class TooManyChildClassesExceptionTest extends BaseTestCase
|
||||
*/
|
||||
public function testConstructorMessage($parentClass, array $childClasses, $expectedMessage)
|
||||
{
|
||||
$exception = new TooManyChildClassesException($parentClass, $childClasses);
|
||||
$exception = TooManyChildClassesException::create($parentClass, $childClasses);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class UnknownOopVisibilityTypeExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(UnknownOopVisibilityTypeException::class, OopVisibilityType::IS_PUBLIC, 1, 1);
|
||||
static::assertConstructorVisibilityAndArguments(UnknownOopVisibilityTypeException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ class UnknownOopVisibilityTypeExceptionTest extends BaseTestCase
|
||||
*/
|
||||
public function testConstructorMessage($unknownType, $expectedMessage)
|
||||
{
|
||||
$exception = new UnknownOopVisibilityTypeException($unknownType);
|
||||
$exception = UnknownOopVisibilityTypeException::createException($unknownType);
|
||||
static::assertEquals($expectedMessage, $exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ class BundleTest extends BaseTestCase
|
||||
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
*
|
||||
* @throws IncorrectBundleNameException
|
||||
* @dataProvider provideViewPathAndIncorrectBundleName
|
||||
*/
|
||||
public function testGetBundleViewPathUsingIncorrectBundleName($viewPath, $bundleName)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Meritoo\Common\Test\Utilities;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use Generator;
|
||||
use Meritoo\Common\Exception\Date\UnknownDatePartTypeException;
|
||||
use Meritoo\Common\Exception\Type\UnknownDatePartTypeException;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\DatePeriod;
|
||||
use Meritoo\Common\Utilities\Date;
|
||||
|
||||
Reference in New Issue
Block a user