diff --git a/.github/workflows/verify-stability.yaml b/.github/workflows/verify-stability.yaml index 962035d..9630a3f 100644 --- a/.github/workflows/verify-stability.yaml +++ b/.github/workflows/verify-stability.yaml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ '8.0', '8.1', '8.2' ] + php-versions: [ '8.2', '8.3' ] env: extensions: dom, fileinfo, intl, json, pcre, simplexml key: cache-v1 # can be any string, change to clear the extension cache. @@ -63,7 +63,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ '8.0', '8.1', '8.2' ] + php-versions: [ '8.2', '8.3' ] env: extensions: dom, fileinfo, intl, json, pcre, simplexml key: cache-v1 # can be any string, change to clear the extension cache. @@ -95,7 +95,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ '8.0', '8.1', '8.2' ] + php-versions: [ '8.2', '8.3' ] env: extensions: dom, fileinfo, intl, json, pcre, simplexml key: cache-v1 # can be any string, change to clear the extension cache. diff --git a/CHANGELOG.md b/CHANGELOG.md index 22437a7..872c8db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,20 @@ Common & useful classes, resources, extensions. Based on Symfony framework. translations [using the ICU MessageFormat](https://symfony.com/doc/current/reference/formats/message_format.html#pluralization) 3. Update the `meritoo/common-library` package to `^1.3` 4. Fix PHPStan errors +5. Bump minimum PHP version: `8.0` -> `8.2` + 1. All the `*Type` classes, that extend `Meritoo\Common\Type\Base\BaseType` class, have been replaced by enumerations + + | Before | After | + |-----------------------------------------------------------------------|---------------------------------------------------------| + | `Meritoo\CommonBundle\Type\DependencyInjection\ConfigurationFileType` | `Meritoo\CommonBundle\Enums\Date\ConfigurationFileType` | + | `Meritoo\CommonBundle\Type\Date\DateLength` | `Meritoo\CommonBundle\Enums\Date\DateLength` | + | `Meritoo\Common\Type\OopVisibilityType` | `Meritoo\Common\Enums\OopVisibility` | + + 2. Other than that: + - The following classes have been removed as not needed anymore: + - `Meritoo\CommonBundle\Exception\Type\Date\UnknownDateLengthException` + - `Meritoo\CommonBundle\Exception\Type\DependencyInjection\UnknownConfigurationFileTypeException` + - `Meritoo\Test\CommonBundle\DependencyInjection\Base\BaseExtension\UnknownServicesFileType\Extension` # 0.3.1 diff --git a/composer.json b/composer.json index 57900c9..ab67ce8 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.2", "ext-intl": "*", "doctrine/annotations": "^2.0", "meritoo/common-library": "^1.3", diff --git a/docker-compose.yml b/docker-compose.yml index 7e46507..88f98e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: # Required to run project # php: - image: meritoo/php:8.0 + image: meritoo/php:8.2 container_name: ${DOCKER_CONTAINER_OWNER}-${DOCKER_CONTAINER_PROJECT}-php entrypoint: php command: -S 0.0.0.0:9999 @@ -12,7 +12,7 @@ services: volumes: - .:/var/www/application:cached composer: - image: meritoo/php:8.0 + image: meritoo/php:8.2 container_name: ${DOCKER_CONTAINER_OWNER}-${DOCKER_CONTAINER_PROJECT}-composer entrypoint: php -d memory_limit=-1 /usr/local/bin/composer volumes: @@ -21,7 +21,7 @@ services: # Required to run PHPUnit's tests # phpunit: - image: meritoo/php:8.0 + image: meritoo/php:8.2 container_name: ${DOCKER_CONTAINER_OWNER}-${DOCKER_CONTAINER_PROJECT}-phpunit entrypoint: ./vendor/bin/simple-phpunit command: --version diff --git a/src/Bundle/Descriptor.php b/src/Bundle/Descriptor.php index ba4c745..d038ef6 100644 --- a/src/Bundle/Descriptor.php +++ b/src/Bundle/Descriptor.php @@ -278,10 +278,7 @@ public function getDataFixturesDirectoryPath(): ?string return null; } - return Miscellaneous::concatenatePaths([ - $path, - static::PATH_DATA_FIXTURES, - ]); + return Miscellaneous::concatenatePaths($path, static::PATH_DATA_FIXTURES); } /** diff --git a/src/DependencyInjection/Base/BaseExtension.php b/src/DependencyInjection/Base/BaseExtension.php index f6f4bd0..1be99e1 100644 --- a/src/DependencyInjection/Base/BaseExtension.php +++ b/src/DependencyInjection/Base/BaseExtension.php @@ -13,7 +13,7 @@ use Meritoo\Common\Utilities\Arrays; use Meritoo\Common\Utilities\Miscellaneous; use Meritoo\CommonBundle\DependencyInjection\ConfigurationFile\FileLoaderFactory; -use Meritoo\CommonBundle\Type\DependencyInjection\ConfigurationFileType; +use Meritoo\CommonBundle\Enums\Date\ConfigurationFileType; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -31,7 +31,7 @@ abstract class BaseExtension extends ConfigurableExtension /** * Default extension of configuration files * - * @var string + * @var ConfigurationFileType */ protected const CONFIGURATION_DEFAULT_EXTENSION = ConfigurationFileType::YAML; @@ -123,7 +123,7 @@ protected function getKeysToStopLoadingParametersOn(): array */ protected function getServicesFileName(): string { - return sprintf('%s.%s', static::CONFIGURATION_SERVICES_NAME, static::CONFIGURATION_DEFAULT_EXTENSION); + return sprintf('%s.%s', static::CONFIGURATION_SERVICES_NAME, static::CONFIGURATION_DEFAULT_EXTENSION->value); } /** @@ -151,7 +151,7 @@ private function getConfigurationFileWithExtension(string $fileName): string // Use the default extension, if extension of configuration file is unknown if (empty($fileExtension)) { - return Miscellaneous::includeFileExtension($fileName, static::CONFIGURATION_DEFAULT_EXTENSION); + return Miscellaneous::includeFileExtension($fileName, static::CONFIGURATION_DEFAULT_EXTENSION->value); } return $fileName; @@ -162,12 +162,15 @@ private function getConfigurationFileWithExtension(string $fileName): string * * @param ContainerBuilder $container Container for the Dependency Injection (DI) * @param FileLocator $locator Locator used to find files - * @param string $fileType Type of configuration file + * @param ConfigurationFileType $fileType Type of configuration file * * @return null|FileLoader */ - private function getFileLoader(ContainerBuilder $container, FileLocator $locator, string $fileType): ?FileLoader - { + private function getFileLoader( + ContainerBuilder $container, + FileLocator $locator, + ConfigurationFileType $fileType, + ): ?FileLoader { $loaderFactory = new FileLoaderFactory($container, $locator); if (ConfigurationFileType::YAML === $fileType) { @@ -236,22 +239,15 @@ private function loadConfigurationFile(ContainerBuilder $container, string $file return; } - $resourcesPath = Miscellaneous::concatenatePaths([ - $bundlePath, - static::CONFIGURATION_PATH, - ]); - - $filePath = Miscellaneous::concatenatePaths([ - $resourcesPath, - $fileName, - ]); + $resourcesPath = Miscellaneous::concatenatePaths($bundlePath, static::CONFIGURATION_PATH); + $filePath = Miscellaneous::concatenatePaths($resourcesPath, $fileName); // Configuration file doesn't exist or is not readable? Nothing to do if (!is_readable($filePath)) { return; } - $fileType = (new ConfigurationFileType())->getTypeFromFileName($fileName); + $fileType = ConfigurationFileType::getTypeFromFileName($fileName); $locator = new FileLocator($resourcesPath); // Let's load the configuration file diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index e685bac..cb4c9d5 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -10,8 +10,8 @@ namespace Meritoo\CommonBundle\DependencyInjection; +use Meritoo\CommonBundle\Enums\Date\DateLength; use Meritoo\CommonBundle\Service\ApplicationService; -use Meritoo\CommonBundle\Type\Date\DateLength; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -120,15 +120,15 @@ private function getDateNode(): NodeDefinition ->arrayNode('format') ->addDefaultsIfNotSet() ->children() - ->scalarNode(DateLength::DATE) + ->scalarNode(DateLength::Date->value) ->info('Format of date without time') ->defaultValue('d.m.Y') ->end() - ->scalarNode(DateLength::DATETIME) + ->scalarNode(DateLength::DateTime->value) ->info('Format of date with time') ->defaultValue('d.m.Y H:i') ->end() - ->scalarNode(DateLength::TIME) + ->scalarNode(DateLength::Time->value) ->info('Format of time without date') ->defaultValue('H:i') ->end() diff --git a/src/DependencyInjection/MeritooCommonExtension.php b/src/DependencyInjection/MeritooCommonExtension.php index fa513ae..ca9b330 100644 --- a/src/DependencyInjection/MeritooCommonExtension.php +++ b/src/DependencyInjection/MeritooCommonExtension.php @@ -26,9 +26,6 @@ class MeritooCommonExtension extends BaseExtension */ protected function getBundleDirectoryPath(): string { - return Miscellaneous::concatenatePaths([ - __DIR__, - '..', - ]); + return Miscellaneous::concatenatePaths(__DIR__, '..'); } } diff --git a/src/Enums/Date/ConfigurationFileType.php b/src/Enums/Date/ConfigurationFileType.php new file mode 100644 index 0000000..0e8a4e3 --- /dev/null +++ b/src/Enums/Date/ConfigurationFileType.php @@ -0,0 +1,34 @@ + - * @copyright Meritoo - */ -class UnknownDateLengthException extends UnknownTypeException -{ - /** - * Creates exception - * - * @param string $unknownType Unknown type of date length for date format - * - * @return UnknownDateLengthException - */ - public static function createException(string $unknownType): UnknownDateLengthException - { - $message = static::createMessage($unknownType, new DateLength(), 'date length for date format'); - - return new self($message); - } -} diff --git a/src/Exception/Type/DependencyInjection/UnknownConfigurationFileTypeException.php b/src/Exception/Type/DependencyInjection/UnknownConfigurationFileTypeException.php deleted file mode 100644 index f01a2da..0000000 --- a/src/Exception/Type/DependencyInjection/UnknownConfigurationFileTypeException.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Meritoo - */ -class UnknownConfigurationFileTypeException extends UnknownTypeException -{ - /** - * Creates exception - * - * @param string $unknownType Unknown type of Dependency Injection (DI) configuration file - * - * @return UnknownConfigurationFileTypeException - */ - public static function createException(string $unknownType): UnknownConfigurationFileTypeException - { - $message = static::createMessage( - $unknownType, - new ConfigurationFileType(), - 'Dependency Injection (DI) configuration file', - ); - - return new self($message); - } -} diff --git a/src/Service/DateService.php b/src/Service/DateService.php index 633a475..6218316 100644 --- a/src/Service/DateService.php +++ b/src/Service/DateService.php @@ -13,9 +13,8 @@ use DateTimeInterface; use Exception; use IntlDateFormatter; -use Meritoo\CommonBundle\Exception\Type\Date\UnknownDateLengthException; +use Meritoo\CommonBundle\Enums\Date\DateLength; use Meritoo\CommonBundle\Service\Base\BaseService; -use Meritoo\CommonBundle\Type\Date\DateLength; /** * Serves dates @@ -64,11 +63,11 @@ public function __construct(string $dateFormat, string $dateTimeFormat, string $ * Returns date formatted according to given length of date * * @param DateTimeInterface $dateTime The date to format - * @param string $dateLength Type of date length. One of the DateLength's class constants. + * @param DateLength $dateLength Type of date length * * @return string */ - public function formatDate(DateTimeInterface $dateTime, string $dateLength): string + public function formatDate(DateTimeInterface $dateTime, DateLength $dateLength): string { $format = $this->getFormat($dateLength); @@ -103,30 +102,24 @@ public function formatDateUsingLocale( /** * Returns format of date according to given length of date * - * @param string $dateLength Type of date length. One of the DateLength's class constants. + * @param DateLength $dateLength Type of date length * - * @throws UnknownDateLengthException * @return string */ - public function getFormat(string $dateLength): string + public function getFormat(DateLength $dateLength): string { - // Oops, unknown length of date - if (false === (new DateLength())->isCorrectType($dateLength)) { - throw UnknownDateLengthException::createException($dateLength); - } - $format = ''; switch ($dateLength) { - case DateLength::DATE: + case DateLength::Date: $format = $this->dateFormat; break; - case DateLength::DATETIME: + case DateLength::DateTime: $format = $this->dateTimeFormat; break; - case DateLength::TIME: + case DateLength::Time: $format = $this->timeFormat; break; diff --git a/src/Type/Date/DateLength.php b/src/Type/Date/DateLength.php deleted file mode 100644 index ca1a764..0000000 --- a/src/Type/Date/DateLength.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Meritoo - */ -class DateLength extends BaseType -{ - /** - * The "date" length. - * Date without time. - * - * @var string - */ - public const DATE = 'date'; - - /** - * The "datetime" length. - * Date with time. - * - * @var string - */ - public const DATETIME = 'datetime'; - - /** - * The "time" length. - * Time only, without date. - * - * @var string - */ - public const TIME = 'time'; -} diff --git a/src/Type/DependencyInjection/ConfigurationFileType.php b/src/Type/DependencyInjection/ConfigurationFileType.php deleted file mode 100644 index 10e6eae..0000000 --- a/src/Type/DependencyInjection/ConfigurationFileType.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Meritoo - */ -class ConfigurationFileType extends BaseType -{ - /** - * The PHP configuration file - * - * @var string - */ - public const PHP = 'php'; - - /** - * The XML configuration file - * - * @var string - */ - public const XML = 'xml'; - - /** - * The YAML configuration file - * - * @var string - */ - public const YAML = 'yaml'; - - /** - * Returns type of configuration file based on name of the file - * - * @param string $fileName Name of configuration file - * - * @return string - * @throws UnknownConfigurationFileTypeException - */ - public function getTypeFromFileName(string $fileName): string - { - $fileExtension = strtolower(Miscellaneous::getFileExtension($fileName)); - - // Oops, incorrect type/extension of configuration file - if (false === $this->isCorrectType($fileExtension)) { - throw UnknownConfigurationFileTypeException::createException($fileExtension); - } - - return $fileExtension; - } -} diff --git a/tests/Application/DescriptorTest.php b/tests/Application/DescriptorTest.php index 6caecf5..4967336 100644 --- a/tests/Application/DescriptorTest.php +++ b/tests/Application/DescriptorTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Application; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\Common\ValueObject\Version; use Meritoo\CommonBundle\Application\Descriptor; @@ -127,7 +127,7 @@ public function provideDescriptorAsString(): Generator new Descriptor( 'Ultricies', 'Nullam quis risus eget urna mollis ornare vel eu leo', - new Version(10, 99, 73) + new Version(10, 99, 73), ), 'Ultricies | Nullam quis risus eget urna mollis ornare vel eu leo | 10.99.73', ]; @@ -136,7 +136,7 @@ public function provideDescriptorAsString(): Generator new Descriptor( '', 'Nullam quis risus eget urna mollis ornare vel eu leo', - new Version(10, 99, 73) + new Version(10, 99, 73), ), '- | Nullam quis risus eget urna mollis ornare vel eu leo | 10.99.73', ]; @@ -145,7 +145,7 @@ public function provideDescriptorAsString(): Generator new Descriptor( '', 'Nullam quis risus eget urna mollis ornare vel eu leo', - new Version(10, 99, 73) + new Version(10, 99, 73), ), '- | Nullam quis risus eget urna mollis ornare vel eu leo | 10.99.73', ]; @@ -175,14 +175,14 @@ public function provideEmptyValuesForConstructor(): Generator public function testConstructor(): void { - static::assertConstructorVisibilityAndArguments(Descriptor::class, OopVisibilityType::IS_PUBLIC, 3, 3); + static::assertConstructorVisibilityAndArguments(Descriptor::class, OopVisibility::Public, 3, 3); } /** - * @param string $name Name of application - * @param string $description Description of application - * @param null|Version $version Version of application - * @param Descriptor $expected Expected descriptor of application + * @param string $name Name of application + * @param string $description Description of application + * @param null|Version $version Version of application + * @param Descriptor $expected Expected descriptor of application * * @dataProvider provideEmptyValuesForConstructor */ @@ -190,7 +190,7 @@ public function testConstructorUsingEmptyValues( string $name, string $description, ?Version $version, - Descriptor $expected + Descriptor $expected, ): void { $descriptor = new Descriptor($name, $description, $version); static::assertEquals($expected, $descriptor); @@ -198,7 +198,7 @@ public function testConstructorUsingEmptyValues( /** * @param Descriptor $descriptor Descriptor of application - * @param string $expected Expected description of application + * @param string $expected Expected description of application * * @dataProvider provideDescriptorAndDescription */ @@ -209,7 +209,7 @@ public function testGetDescription(Descriptor $descriptor, string $expected): vo /** * @param Descriptor $descriptor Descriptor of application - * @param string $expected Expected name of application + * @param string $expected Expected name of application * * @dataProvider provideDescriptorAndName */ @@ -219,8 +219,8 @@ public function testGetName(Descriptor $descriptor, string $expected): void } /** - * @param Descriptor $descriptor Descriptor of application - * @param null|Version $expected Expected version of application + * @param Descriptor $descriptor Descriptor of application + * @param null|Version $expected Expected version of application * * @dataProvider provideDescriptorAndVersion */ @@ -231,13 +231,13 @@ public function testGetVersion(Descriptor $descriptor, ?Version $expected): void /** * @param Descriptor $descriptor Descriptor of application - * @param string $expected Expected string representation of descriptor + * @param string $expected Expected string representation of descriptor * * @dataProvider provideDescriptorAsString * @covers \Meritoo\CommonBundle\Application\Descriptor::__toString */ public function testToString(Descriptor $descriptor, string $expected): void { - static::assertSame($expected, (string) $descriptor); + static::assertSame($expected, (string)$descriptor); } } diff --git a/tests/Bundle/DescriptorTest.php b/tests/Bundle/DescriptorTest.php index f18f08f..2efb74e 100644 --- a/tests/Bundle/DescriptorTest.php +++ b/tests/Bundle/DescriptorTest.php @@ -12,8 +12,8 @@ use Generator; use Meritoo\Common\Collection\StringCollection; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Bundle\Descriptor; use Meritoo\Test\CommonBundle\Bundle\Descriptor\SimpleBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -92,8 +92,8 @@ public function provideArrayForDescriptor(): Generator '', new Descriptor( 'Vulputate', - 'Dolor' - ) + 'Dolor', + ), ), ]; @@ -114,8 +114,8 @@ public function provideArrayForDescriptor(): Generator null, new Descriptor( 'Euismod', - 'Quam' - ) + 'Quam', + ), ), ]; @@ -142,13 +142,13 @@ public function provideArrayForDescriptor(): Generator 'pellentesque/tortor/ultricies/quam', new Descriptor( 'Venenatis', - 'Sem' + 'Sem', ), new Descriptor( 'Adipiscing', 'Etiam', - 'Ornare\Malesuada\Venenatis\Consectetur' - ) + 'Ornare\Malesuada\Venenatis\Consectetur', + ), ), ]; } @@ -191,7 +191,7 @@ public function provideArrayFromDescriptor(): Generator 'PortaCommodoBundle', 'Commodo', 'Porta\CommodoBundle', - 'etiam/risus/parturient' + 'etiam/risus/parturient', ), true, [ @@ -209,7 +209,7 @@ public function provideArrayFromDescriptor(): Generator 'PortaCommodoBundle', 'Commodo', 'Porta\CommodoBundle', - 'etiam/risus/parturient' + 'etiam/risus/parturient', ), false, [ @@ -228,7 +228,7 @@ public function provideArrayFromDescriptor(): Generator 'Commodo', 'Porta\CommodoBundle', 'etiam/risus/parturient', - new Descriptor() + new Descriptor(), ), true, [ @@ -255,7 +255,7 @@ public function provideArrayFromDescriptor(): Generator 'Commodo', 'Porta\CommodoBundle', 'etiam/risus/parturient', - new Descriptor() + new Descriptor(), ), false, [ @@ -275,7 +275,7 @@ public function provideArrayFromDescriptor(): Generator 'Porta\CommodoBundle', 'etiam/risus/parturient', null, - new Descriptor() + new Descriptor(), ), true, [ @@ -303,7 +303,7 @@ public function provideArrayFromDescriptor(): Generator 'Porta\CommodoBundle', 'etiam/risus/parturient', null, - new Descriptor() + new Descriptor(), ), false, [ @@ -323,7 +323,7 @@ public function provideArrayFromDescriptor(): Generator 'Porta\CommodoBundle', 'etiam/risus/parturient', new Descriptor(), - new Descriptor() + new Descriptor(), ), true, [ @@ -359,7 +359,7 @@ public function provideArrayFromDescriptor(): Generator 'Porta\CommodoBundle', 'etiam/risus/parturient', new Descriptor(), - new Descriptor() + new Descriptor(), ), false, [ @@ -382,9 +382,9 @@ public function provideArrayFromDescriptor(): Generator 'OrnareEgestasBundle', 'Ornare', 'Ornare\EgestasBundle', - 'condimentum/fusce/risus' + 'condimentum/fusce/risus', ), - new Descriptor() + new Descriptor(), ), true, [ @@ -423,9 +423,9 @@ public function provideArrayFromDescriptor(): Generator 'OrnareEgestasBundle', 'Ornare', 'Ornare\EgestasBundle', - 'condimentum/fusce/risus' + 'condimentum/fusce/risus', ), - new Descriptor() + new Descriptor(), ), false, [ @@ -448,14 +448,14 @@ public function provideArrayFromDescriptor(): Generator 'OrnareEgestasBundle', 'Ornare', 'Ornare\EgestasBundle', - 'condimentum/fusce/risus' + 'condimentum/fusce/risus', ), new Descriptor( 'ParturientPharetraBundle', 'OrnareMattis', 'Parturient\PharetraBundle', - 'tortor/ullamcorper/mattis' - ) + 'tortor/ullamcorper/mattis', + ), ), true, [ @@ -494,14 +494,14 @@ public function provideArrayFromDescriptor(): Generator 'OrnareEgestasBundle', 'Ornare', 'Ornare\EgestasBundle', - 'condimentum/fusce/risus' + 'condimentum/fusce/risus', ), new Descriptor( 'ParturientPharetraBundle', 'OrnareMattis', 'Parturient\PharetraBundle', - 'tortor/ullamcorper/mattis' - ) + 'tortor/ullamcorper/mattis', + ), ), false, [ @@ -541,7 +541,7 @@ public function provideArrayFromDescriptorUsingDefaults(): Generator 'PortaCommodoBundle', 'Commodo', 'Porta\CommodoBundle', - 'etiam/risus/parturient' + 'etiam/risus/parturient', ), [ 'name' => 'PortaCommodoBundle', @@ -561,7 +561,7 @@ public function provideArrayFromDescriptorUsingDefaults(): Generator 'Commodo', 'Porta\CommodoBundle', 'etiam/risus/parturient', - new Descriptor() + new Descriptor(), ), [ 'name' => 'PortaCommodoBundle', @@ -589,7 +589,7 @@ public function provideArrayFromDescriptorUsingDefaults(): Generator 'Porta\CommodoBundle', 'etiam/risus/parturient', new Descriptor(), - new Descriptor() + new Descriptor(), ), [ 'name' => 'PortaCommodoBundle', @@ -627,9 +627,9 @@ public function provideArrayFromDescriptorUsingDefaults(): Generator 'OrnareEgestasBundle', 'Ornare', 'Ornare\EgestasBundle', - 'condimentum/fusce/risus' + 'condimentum/fusce/risus', ), - new Descriptor() + new Descriptor(), ), [ 'name' => 'PortaCommodoBundle', @@ -667,14 +667,14 @@ public function provideArrayFromDescriptorUsingDefaults(): Generator 'OrnareEgestasBundle', 'Ornare', 'Ornare\EgestasBundle', - 'condimentum/fusce/risus' + 'condimentum/fusce/risus', ), new Descriptor( 'ParturientPharetraBundle', 'OrnareMattis', 'Parturient\PharetraBundle', - 'tortor/ullamcorper/mattis' - ) + 'tortor/ullamcorper/mattis', + ), ), [ 'name' => 'PortaCommodoBundle', @@ -716,7 +716,7 @@ public function provideBundle(): Generator 'SimpleBundle', '', 'Meritoo\Test\CommonBundle\Bundle\Descriptor', - '/tests/Bundle/Descriptor' + '/tests/Bundle/Descriptor', ), ]; } @@ -740,7 +740,7 @@ public function provideChildBundleDescriptor(): Generator '', 'path/of/bundle', null, - null + null, ), null, ]; @@ -754,7 +754,7 @@ public function provideChildBundleDescriptor(): Generator '', 'path/of/bundle', null, - $childBundleDescriptor + $childBundleDescriptor, ), $childBundleDescriptor, ]; @@ -762,7 +762,7 @@ public function provideChildBundleDescriptor(): Generator $childBundleDescriptor = new Descriptor( 'Test', '', - 'This/Is/Namespace' + 'This/Is/Namespace', ); yield [ @@ -772,7 +772,7 @@ public function provideChildBundleDescriptor(): Generator '', 'path/of/bundle', null, - $childBundleDescriptor + $childBundleDescriptor, ), $childBundleDescriptor, ]; @@ -977,7 +977,7 @@ public function provideParentBundleDescriptor(): Generator '', 'path/of/bundle', null, - null + null, ), null, ]; @@ -991,7 +991,7 @@ public function provideParentBundleDescriptor(): Generator '', 'path/of/bundle', $parentBundleDescriptor, - null + null, ), $parentBundleDescriptor, ]; @@ -999,7 +999,7 @@ public function provideParentBundleDescriptor(): Generator $parentBundleDescriptor = new Descriptor( 'Test', '', - 'This/Is/Namespace' + 'This/Is/Namespace', ); yield [ @@ -1009,7 +1009,7 @@ public function provideParentBundleDescriptor(): Generator '', 'path/of/bundle', $parentBundleDescriptor, - null + null, ), $parentBundleDescriptor, ]; @@ -1090,10 +1090,9 @@ public function provideShortName(): Generator } /** - * @param Descriptor $descriptor Descriptor of bundle for who names of files with data fixtures should be - * added - * @param array $fixturesPaths Names of files with data fixtures to add - * @param StringCollection $expected Expected names of files with data fixtures after add + * @param Descriptor $descriptor Descriptor of bundle for who names of files with data fixtures should be added + * @param array $fixturesPaths Names of files with data fixtures to add + * @param StringCollection $expected Expected names of files with data fixtures after add * * @dataProvider provideDataFixturesToAdd * @covers \Meritoo\CommonBundle\Bundle\Descriptor::addDataFixtures @@ -1108,7 +1107,7 @@ public function testAddDataFixtures(Descriptor $descriptor, array $fixturesPaths public function testConstructor(): void { - static::assertConstructorVisibilityAndArguments(Descriptor::class, OopVisibilityType::IS_PUBLIC, 6); + static::assertConstructorVisibilityAndArguments(Descriptor::class, OopVisibility::Public, 6); } public function testConstructorUsingDefaults(): void @@ -1124,7 +1123,7 @@ public function testConstructorUsingDefaults(): void } /** - * @param array $array Data of descriptor + * @param array $array Data of descriptor * @param Descriptor $expected Expected descriptor * * @dataProvider provideArrayForDescriptor @@ -1145,20 +1144,20 @@ public function testFromArray(array $array, Descriptor $expected): void if (null !== $expected->getParentBundleDescriptor()) { static::assertSame( $expected->getParentBundleDescriptor()->toArray(), - $descriptor->getParentBundleDescriptor()->toArray() + $descriptor->getParentBundleDescriptor()->toArray(), ); } if (null !== $expected->getChildBundleDescriptor()) { static::assertSame( $expected->getChildBundleDescriptor()->toArray(), - $descriptor->getChildBundleDescriptor()->toArray() + $descriptor->getChildBundleDescriptor()->toArray(), ); } } /** - * @param Bundle $bundle The bundle + * @param Bundle $bundle The bundle * @param Descriptor $expected Expected descriptor * * @dataProvider provideBundle @@ -1176,8 +1175,8 @@ public function testFromBundle(Bundle $bundle, Descriptor $expected): void } /** - * @param Descriptor $descriptor Descriptor of bundle which descriptor of the child bundle should be returned - * @param null|Descriptor $expected Expected descriptor of the child bundle + * @param Descriptor $descriptor Descriptor of bundle which descriptor of the child bundle should be returned + * @param null|Descriptor $expected Expected descriptor of the child bundle * * @dataProvider provideChildBundleDescriptor */ @@ -1189,7 +1188,7 @@ public function testGetChildBundleDescriptor(Descriptor $descriptor, ?Descriptor /** * @param Descriptor $descriptor Descriptor of bundle who name of configuration root node of bundle should be * returned - * @param string $expected Expected name of configuration root node + * @param string $expected Expected name of configuration root node * * @dataProvider provideConfigurationRootName */ @@ -1199,8 +1198,8 @@ public function testGetConfigurationRootName(Descriptor $descriptor, string $exp } /** - * @param Descriptor $descriptor Descriptor of bundle who names of files with data fixtures from bundle - * @param StringCollection $expected Expected names of files with data fixtures + * @param Descriptor $descriptor Descriptor of bundle who names of files with data fixtures from bundle + * @param StringCollection $expected Expected names of files with data fixtures * * @dataProvider provideDataFixtures */ @@ -1211,9 +1210,9 @@ public function testGetDataFixtures(Descriptor $descriptor, StringCollection $ex } /** - * @param Descriptor $descriptor Descriptor of bundle which path of directory with classes for the DataFixtures - * should be returned - * @param null|string $expected Expected path + * @param Descriptor $descriptor Descriptor of bundle which path of directory with classes for the DataFixtures + * should be returned + * @param null|string $expected Expected path * * @dataProvider provideDataFixturesPath */ @@ -1224,7 +1223,7 @@ public function testGetDataFixturesDirectoryPath(Descriptor $descriptor, ?string /** * @param Descriptor $descriptor Descriptor of bundle who name should be returned - * @param string $expected Expected name + * @param string $expected Expected name * * @dataProvider provideName */ @@ -1234,8 +1233,8 @@ public function testGetName(Descriptor $descriptor, string $expected): void } /** - * @param Descriptor $descriptor Descriptor of bundle which descriptor of the parent bundle should be returned - * @param null|Descriptor $expected Expected descriptor of the parent bundle + * @param Descriptor $descriptor Descriptor of bundle which descriptor of the parent bundle should be returned + * @param null|Descriptor $expected Expected descriptor of the parent bundle * * @dataProvider provideParentBundleDescriptor */ @@ -1246,7 +1245,7 @@ public function testGetParentBundleDescriptor(Descriptor $descriptor, ?Descripto /** * @param Descriptor $descriptor Descriptor of bundle which path should be returned - * @param string $expected Expected physical path of the bundle + * @param string $expected Expected physical path of the bundle * * @dataProvider providePath */ @@ -1257,7 +1256,7 @@ public function testGetPath(Descriptor $descriptor, string $expected): void /** * @param Descriptor $descriptor Descriptor of bundle who root namespace of bundle should be returned - * @param string $expected Expected root namespace of bundle + * @param string $expected Expected root namespace of bundle * * @dataProvider provideRootNamespace */ @@ -1268,7 +1267,7 @@ public function testGetRootNamespace(Descriptor $descriptor, string $expected): /** * @param Descriptor $descriptor Descriptor of bundle who short, simple name should be returned - * @param string $expected Expected short, simple name of the bundle + * @param string $expected Expected short, simple name of the bundle * * @dataProvider provideShortName */ @@ -1279,8 +1278,8 @@ public function testGetShortName(Descriptor $descriptor, string $expected): void /** * @param Descriptor $descriptor Descriptor of bundle who should be verified if file belongs to the bundle - * @param string $filePath Path of file to verify - * @param bool $expected Expected result of verification + * @param string $filePath Path of file to verify + * @param bool $expected Expected result of verification * * @dataProvider provideFilePath */ @@ -1348,10 +1347,10 @@ public function testSetRootNamespace(): void } /** - * @param Descriptor $descriptor Descriptor of bundle who an array representation should be returned - * @param bool $withParentAndChild If is set to true, includes descriptor of the parent and child bundle - * (default behaviour). Otherwise - not. - * @param array $expected Expected array + * @param Descriptor $descriptor Descriptor of bundle who an array representation should be returned + * @param bool $withParentAndChild If is set to true, includes descriptor of the parent and child bundle (default + * behaviour). Otherwise - not. + * @param array $expected Expected array * * @dataProvider provideArrayFromDescriptor */ diff --git a/tests/Bundle/DescriptorsTest.php b/tests/Bundle/DescriptorsTest.php index 3cf4071..af0d4a9 100644 --- a/tests/Bundle/DescriptorsTest.php +++ b/tests/Bundle/DescriptorsTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Bundle; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Bundle\Descriptor; use Meritoo\CommonBundle\Bundle\Descriptors; @@ -51,8 +51,8 @@ public function provideArrayForDescriptors(): Generator '', new Descriptor( 'Vulputate', - 'Dolor' - ) + 'Dolor', + ), ), ]); @@ -128,8 +128,8 @@ public function provideArrayForDescriptors(): Generator '', new Descriptor( 'Vulputate', - 'Dolor' - ) + 'Dolor', + ), ), ]), ]; @@ -202,12 +202,12 @@ public function provideArrayFromDescriptors(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]), [ @@ -277,19 +277,19 @@ public function provideDescriptorAndClassNamespace(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]), 'Vestibulum\Amet\Vehicula\Egestas', new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]; @@ -298,12 +298,12 @@ public function provideDescriptorAndClassNamespace(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), new Descriptor( 'SollicitudinBundle', @@ -313,8 +313,8 @@ public function provideDescriptorAndClassNamespace(): Generator new Descriptor( 'SemBundle', '', - 'Fringilla\Quam\Mollis' - ) + 'Fringilla\Quam\Mollis', + ), ), ]), 'Cras\Risus\Amet\Vehicula\Egestas', @@ -326,8 +326,8 @@ public function provideDescriptorAndClassNamespace(): Generator new Descriptor( 'SemBundle', '', - 'Fringilla\Quam\Mollis' - ) + 'Fringilla\Quam\Mollis', + ), ), ]; } @@ -344,19 +344,19 @@ public function provideDescriptorAndName(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]), 'VehiculaBundle', new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]; @@ -365,12 +365,12 @@ public function provideDescriptorAndName(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), new Descriptor( 'SollicitudinBundle', @@ -380,8 +380,8 @@ public function provideDescriptorAndName(): Generator new Descriptor( 'SemBundle', '', - 'Fringilla\Quam\Mollis' - ) + 'Fringilla\Quam\Mollis', + ), ), ]), 'SollicitudinBundle', @@ -393,8 +393,8 @@ public function provideDescriptorAndName(): Generator new Descriptor( 'SemBundle', '', - 'Fringilla\Quam\Mollis' - ) + 'Fringilla\Quam\Mollis', + ), ), ]; } @@ -423,12 +423,12 @@ public function provideNotExistingDescriptorAndClassNamespace(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]), 'Vulputate\Commodo\Egestas', @@ -440,12 +440,12 @@ public function provideNotExistingDescriptorAndClassNamespace(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]), 'Vulputate\Commodo\Egestas', @@ -477,12 +477,12 @@ public function provideNotExistingDescriptorAndName(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]), 'CommodoBundle', @@ -494,12 +494,12 @@ public function provideNotExistingDescriptorAndName(): Generator new Descriptor( 'MattisBundle', '', - 'Euismod\Egestas\Mattis' + 'Euismod\Egestas\Mattis', ), new Descriptor( 'VehiculaBundle', 'ipsummattis', - 'Vestibulum\Amet\Vehicula' + 'Vestibulum\Amet\Vehicula', ), ]), 'EgestasBundle', @@ -509,11 +509,11 @@ public function provideNotExistingDescriptorAndName(): Generator public function testConstructor(): void { - static::assertConstructorVisibilityAndArguments(Descriptors::class, OopVisibilityType::IS_PUBLIC, 1); + static::assertConstructorVisibilityAndArguments(Descriptors::class, OopVisibility::Public, 1); } /** - * @param array $data Data of descriptors + * @param array $data Data of descriptors * @param Descriptors $expected Expected descriptors * * @dataProvider provideArrayForDescriptors @@ -525,9 +525,9 @@ public function testFromArray(array $data, Descriptors $expected): void } /** - * @param Descriptors $descriptors Descriptors of bundles - * @param string $classNamespace Namespace of class for which descriptor of bundle should be returned - * @param Descriptor $expected Expected descriptor + * @param Descriptors $descriptors Descriptors of bundles + * @param string $classNamespace Namespace of class for which descriptor of bundle should be returned + * @param Descriptor $expected Expected descriptor * * @dataProvider provideDescriptorAndClassNamespace */ @@ -546,22 +546,22 @@ public function testGetDescriptor(Descriptors $descriptors, string $classNamespa if (null !== $expected->getParentBundleDescriptor()) { static::assertSame( $expected->getParentBundleDescriptor()->toArray(), - $descriptor->getParentBundleDescriptor()->toArray() + $descriptor->getParentBundleDescriptor()->toArray(), ); } if (null !== $expected->getChildBundleDescriptor()) { static::assertSame( $expected->getChildBundleDescriptor()->toArray(), - $descriptor->getChildBundleDescriptor()->toArray() + $descriptor->getChildBundleDescriptor()->toArray(), ); } } /** * @param Descriptors $descriptors Descriptors of bundles - * @param string $bundleName Name of bundle which descriptor should be returned - * @param Descriptor $expected Expected descriptor + * @param string $bundleName Name of bundle which descriptor should be returned + * @param Descriptor $expected Expected descriptor * * @dataProvider provideDescriptorAndName */ @@ -580,21 +580,21 @@ public function testGetDescriptorByName(Descriptors $descriptors, string $bundle if (null !== $expected->getParentBundleDescriptor()) { static::assertSame( $expected->getParentBundleDescriptor()->toArray(), - $descriptor->getParentBundleDescriptor()->toArray() + $descriptor->getParentBundleDescriptor()->toArray(), ); } if (null !== $expected->getChildBundleDescriptor()) { static::assertSame( $expected->getChildBundleDescriptor()->toArray(), - $descriptor->getChildBundleDescriptor()->toArray() + $descriptor->getChildBundleDescriptor()->toArray(), ); } } /** * @param Descriptors $descriptors Descriptors of bundles - * @param string $bundleName Name of bundle which descriptor should be returned + * @param string $bundleName Name of bundle which descriptor should be returned * * @dataProvider provideNotExistingDescriptorAndName */ @@ -604,8 +604,8 @@ public function testGetDescriptorByNameWhenDoesNotExist(Descriptors $descriptors } /** - * @param Descriptors $descriptors Descriptors of bundles - * @param string $classNamespace Namespace of class for which descriptor of bundle should be returned + * @param Descriptors $descriptors Descriptors of bundles + * @param string $classNamespace Namespace of class for which descriptor of bundle should be returned * * @dataProvider provideNotExistingDescriptorAndClassNamespace */ @@ -616,7 +616,7 @@ public function testGetDescriptorWhenDoesNotExist(Descriptors $descriptors, stri /** * @param Descriptors $descriptors Descriptors of bundles - * @param array $expected Expected array + * @param array $expected Expected array * * @dataProvider provideArrayFromDescriptors */ diff --git a/tests/DependencyInjection/Base/BaseExtensionTest.php b/tests/DependencyInjection/Base/BaseExtensionTest.php index bb1dbe7..706ed19 100644 --- a/tests/DependencyInjection/Base/BaseExtensionTest.php +++ b/tests/DependencyInjection/Base/BaseExtensionTest.php @@ -13,11 +13,9 @@ use Generator; use Meritoo\Common\Test\Base\BaseTestCase; use Meritoo\CommonBundle\DependencyInjection\Base\BaseExtension; -use Meritoo\CommonBundle\Exception\Type\DependencyInjection\UnknownConfigurationFileTypeException; use Meritoo\Test\CommonBundle\DependencyInjection\Base\BaseExtension\EmptyBundlePath\Extension as EmptyBundlePathExtension; use Meritoo\Test\CommonBundle\DependencyInjection\Base\BaseExtension\NotExistingServicesFile\Extension as NotExistingServicesFileExtension; use Meritoo\Test\CommonBundle\DependencyInjection\Base\BaseExtension\PhpServicesFileType\Extension as PhpServicesFileTypeExtension; -use Meritoo\Test\CommonBundle\DependencyInjection\Base\BaseExtension\UnknownServicesFileType\Extension as UnknownServicesFileTypeExtension; use Meritoo\Test\CommonBundle\DependencyInjection\Base\BaseExtension\WithoutParameters\Extension as WithoutParametersExtension; use Meritoo\Test\CommonBundle\DependencyInjection\Base\BaseExtension\XmlServicesFileType\Extension as XmlServicesFileTypeExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -87,19 +85,4 @@ public function testLoadingParametersAndServices(BaseExtension $extension): void */ static::assertCount(1, $container->getServiceIds()); } - - public function testLoadingParametersWithUnknownServicesFileType(): void - { - $message = 'The \'txt\' type of Dependency Injection (DI) configuration file is unknown. Probably doesn\'t' - .' exist or there is a typo. You should use one of these types: php, xml, yaml.'; - - $this->expectException(UnknownConfigurationFileTypeException::class); - $this->expectExceptionMessage($message); - - $container = new ContainerBuilder(); - $extension = new UnknownServicesFileTypeExtension(); - - $configuration = []; - $extension->load($configuration, $container); - } } diff --git a/tests/DependencyInjection/ConfigurationFile/FileLoaderFactoryTest.php b/tests/DependencyInjection/ConfigurationFile/FileLoaderFactoryTest.php index 9c4a504..ce0266e 100644 --- a/tests/DependencyInjection/ConfigurationFile/FileLoaderFactoryTest.php +++ b/tests/DependencyInjection/ConfigurationFile/FileLoaderFactoryTest.php @@ -10,8 +10,8 @@ namespace Meritoo\Test\CommonBundle\DependencyInjection\ConfigurationFile; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\DependencyInjection\ConfigurationFile\FileLoaderFactory; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Config\FileLocator; @@ -37,9 +37,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( FileLoaderFactory::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 2, 2, - 2 ); } diff --git a/tests/Exception/Controller/BaseController/CannotRedirectToEmptyRefererUrlExceptionTest.php b/tests/Exception/Controller/BaseController/CannotRedirectToEmptyRefererUrlExceptionTest.php index 1c76e54..e3b64b4 100644 --- a/tests/Exception/Controller/BaseController/CannotRedirectToEmptyRefererUrlExceptionTest.php +++ b/tests/Exception/Controller/BaseController/CannotRedirectToEmptyRefererUrlExceptionTest.php @@ -10,8 +10,8 @@ namespace Meritoo\Test\CommonBundle\Exception\Controller\BaseController; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Contract\Service\RequestServiceInterface; use Meritoo\CommonBundle\Exception\Controller\BaseController\CannotRedirectToEmptyRefererUrlException; @@ -30,8 +30,8 @@ public function testConstructorVisibilityAndArguments(): void { static::assertConstructorVisibilityAndArguments( CannotRedirectToEmptyRefererUrlException::class, - OopVisibilityType::IS_PUBLIC, - 3 + OopVisibility::Public, + 3, ); } diff --git a/tests/Exception/Pagination/IncorrectCurrentPageExceptionTest.php b/tests/Exception/Pagination/IncorrectCurrentPageExceptionTest.php index a1ca69b..1b41e3f 100644 --- a/tests/Exception/Pagination/IncorrectCurrentPageExceptionTest.php +++ b/tests/Exception/Pagination/IncorrectCurrentPageExceptionTest.php @@ -4,8 +4,8 @@ namespace Meritoo\Test\CommonBundle\Exception\Pagination; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Exception\ValueObject\Pagination\IncorrectCurrentPageException; /** @@ -23,9 +23,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( IncorrectCurrentPageException::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } @@ -36,7 +36,7 @@ public function testCreate(): void static::assertSame( 'The \'current page\' parameter of pagination should be greater than 0, but 0 was provided. Is there' .' everything ok?', - $exception->getMessage() + $exception->getMessage(), ); } } diff --git a/tests/Exception/Pagination/IncorrectPerPageExceptionTest.php b/tests/Exception/Pagination/IncorrectPerPageExceptionTest.php index 118b45e..898e937 100644 --- a/tests/Exception/Pagination/IncorrectPerPageExceptionTest.php +++ b/tests/Exception/Pagination/IncorrectPerPageExceptionTest.php @@ -4,8 +4,8 @@ namespace Meritoo\Test\CommonBundle\Exception\Pagination; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Exception\ValueObject\Pagination\IncorrectPerPageException; /** @@ -23,9 +23,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( IncorrectPerPageException::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } @@ -36,7 +36,7 @@ public function testCreate(): void static::assertSame( 'The \'per page\' parameter of pagination should be greater than 0, but 0 was provided. Is there' .' everything ok?', - $exception->getMessage() + $exception->getMessage(), ); } } diff --git a/tests/Exception/Pagination/IncorrectTotalAmountExceptionTest.php b/tests/Exception/Pagination/IncorrectTotalAmountExceptionTest.php index b886db9..154ef65 100644 --- a/tests/Exception/Pagination/IncorrectTotalAmountExceptionTest.php +++ b/tests/Exception/Pagination/IncorrectTotalAmountExceptionTest.php @@ -4,8 +4,8 @@ namespace Meritoo\Test\CommonBundle\Exception\Pagination; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Exception\ValueObject\Pagination\IncorrectTotalAmountException; /** @@ -23,9 +23,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( IncorrectTotalAmountException::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } @@ -36,7 +36,7 @@ public function testCreate(): void static::assertSame( 'The \'total amount\' parameter of pagination should be greater than or equal 0, but -1 was' .' provided. Is there everything ok?', - $exception->getMessage() + $exception->getMessage(), ); } } diff --git a/tests/Exception/Service/EmptyVersionFilePathExceptionTest.php b/tests/Exception/Service/EmptyVersionFilePathExceptionTest.php index 3e895b1..1719973 100644 --- a/tests/Exception/Service/EmptyVersionFilePathExceptionTest.php +++ b/tests/Exception/Service/EmptyVersionFilePathExceptionTest.php @@ -10,8 +10,8 @@ namespace Meritoo\Test\CommonBundle\Exception\Service; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Exception\Service\ApplicationService\EmptyVersionFilePathException; /** @@ -27,12 +27,15 @@ class EmptyVersionFilePathExceptionTest extends BaseTestCase { public function testConstructorVisibilityAndArguments(): void { - static::assertConstructorVisibilityAndArguments(EmptyVersionFilePathException::class, OopVisibilityType::IS_PUBLIC, 3); + static::assertConstructorVisibilityAndArguments(EmptyVersionFilePathException::class, OopVisibility::Public, 3); } public function testCreate(): void { $exception = EmptyVersionFilePathException::create(); - static::assertSame('Path of a file, who contains version of the application, is empty. Is there everything ok?', $exception->getMessage()); + + static::assertSame('Path of a file, who contains version of the application, is empty. Is there everything ok?', + $exception->getMessage(), + ); } } diff --git a/tests/Exception/Service/UnreadableVersionFileExceptionTest.php b/tests/Exception/Service/UnreadableVersionFileExceptionTest.php index 4c991a1..df2ca95 100644 --- a/tests/Exception/Service/UnreadableVersionFileExceptionTest.php +++ b/tests/Exception/Service/UnreadableVersionFileExceptionTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Exception\Service; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Exception\Service\ApplicationService\UnreadableVersionFileException; /** @@ -53,11 +53,15 @@ public function provideFilePathAndMessage(): Generator public function testConstructorVisibilityAndArguments(): void { - static::assertConstructorVisibilityAndArguments(UnreadableVersionFileException::class, OopVisibilityType::IS_PUBLIC, 3); + static::assertConstructorVisibilityAndArguments( + UnreadableVersionFileException::class, + OopVisibility::Public, + 3, + ); } /** - * @param string $filePath Path of a file who contains version of the application + * @param string $filePath Path of a file who contains version of the application * @param string $expectedMessage Expected message of exception * * @dataProvider provideFilePathAndMessage diff --git a/tests/Exception/Type/Date/UnknownDateLengthExceptionTest.php b/tests/Exception/Type/Date/UnknownDateLengthExceptionTest.php deleted file mode 100644 index 2826e2e..0000000 --- a/tests/Exception/Type/Date/UnknownDateLengthExceptionTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Meritoo - * - * @internal - * @covers \Meritoo\CommonBundle\Exception\Type\Date\UnknownDateLengthException - */ -class UnknownDateLengthExceptionTest extends BaseTestCase -{ - public function provideUnknownTypeAndMessage(): ?Generator - { - $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 = (new DateLength())->getAll(); - $types = Arrays::values2string($allTypes, '', ', '); - - yield [ - 'An empty string', - '', - sprintf($template, '', 'date length for date format', $types), - ]; - - yield [ - 'Strange type 1', - 'xyz ;asdkq28h', - sprintf($template, 'xyz ;asdkq28h', 'date length for date format', $types), - ]; - - yield [ - 'Strange type 2', - ' _ & #---# ++;;...', - sprintf($template, ' _ & #---# ++;;...', 'date length for date format', $types), - ]; - } - - public function testConstructorVisibilityAndArguments(): void - { - static::assertConstructorVisibilityAndArguments( - UnknownConfigurationFileTypeException::class, - OopVisibilityType::IS_PUBLIC, - 3 - ); - } - - /** - * @param string $description Description of test - * @param string $unknownType Unknown type of date length for date format - * @param string $expectedMessage Expected message of exception - * - * @dataProvider provideUnknownTypeAndMessage - */ - public function testCreateException(string $description, string $unknownType, string $expectedMessage): void - { - $exception = UnknownDateLengthException::createException($unknownType); - static::assertSame($expectedMessage, $exception->getMessage(), $description); - } -} diff --git a/tests/Exception/Type/DependencyInjection/UnknownConfigurationFileTypeExceptionTest.php b/tests/Exception/Type/DependencyInjection/UnknownConfigurationFileTypeExceptionTest.php deleted file mode 100644 index 643151e..0000000 --- a/tests/Exception/Type/DependencyInjection/UnknownConfigurationFileTypeExceptionTest.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Meritoo - * - * @internal - * @covers \Meritoo\CommonBundle\Exception\Type\DependencyInjection\UnknownConfigurationFileTypeException - */ -class UnknownConfigurationFileTypeExceptionTest extends BaseTestCase -{ - /** - * Provides unknown type and message of exception - * - * @return Generator - */ - public function provideUnknownTypeAndMessage(): Generator - { - $template = 'The \'%s\' type of Dependency Injection (DI) configuration file is unknown. Probably doesn\'t' - .' exist or there is a typo. You should use one of these types: php, xml, yaml.'; - - yield [ - '', - sprintf($template, ''), - ]; - - yield [ - 'jpg', - sprintf($template, 'jpg'), - ]; - - yield [ - 'txt', - sprintf($template, 'txt'), - ]; - - yield [ - 'yml', - sprintf($template, 'yml'), - ]; - } - - public function testConstructorVisibilityAndArguments(): void - { - static::assertConstructorVisibilityAndArguments(UnknownConfigurationFileTypeException::class, OopVisibilityType::IS_PUBLIC, 3); - } - - /** - * @param string $unknownType Unknown type of Dependency Injection (DI) configuration file - * @param string $expectedMessage Expected message of exception - * - * @dataProvider provideUnknownTypeAndMessage - */ - public function testCreateException(string $unknownType, string $expectedMessage): void - { - $exception = UnknownConfigurationFileTypeException::createException($unknownType); - static::assertSame($expectedMessage, $exception->getMessage()); - } -} diff --git a/tests/Service/ApplicationServiceTest.php b/tests/Service/ApplicationServiceTest.php index a82629d..2fb0be7 100644 --- a/tests/Service/ApplicationServiceTest.php +++ b/tests/Service/ApplicationServiceTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Service; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\Common\ValueObject\Version; use Meritoo\CommonBundle\Application\Descriptor; use Meritoo\CommonBundle\Exception\Service\ApplicationService\EmptyVersionFilePathException; @@ -60,7 +60,7 @@ public function provideConstructorArgumentsAndDescriptor(): Generator new Descriptor( 'Lorem', 'Sed posuere consectetur est at lobortis', - new Version(5, 46, 17) + new Version(5, 46, 17), ), ]; } @@ -69,9 +69,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( ApplicationService::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 3, 3, - 3 ); } @@ -97,10 +97,10 @@ public function testConstructorUsingUnreadableVersionFilePath(): void } /** - * @param string $versionFilePath Path of a file who contains version of the application - * @param null|string $applicationName Name of application. May be displayed near logo. + * @param string $versionFilePath Path of a file who contains version of the application + * @param null|string $applicationName Name of application. May be displayed near logo. * @param null|string $applicationDescription Description of application. May be displayed near logo. - * @param Descriptor $expected Expected descriptor of application + * @param Descriptor $expected Expected descriptor of application * * @dataProvider provideConstructorArgumentsAndDescriptor */ @@ -108,7 +108,7 @@ public function testGetDescriptor( string $versionFilePath, ?string $applicationName, ?string $applicationDescription, - Descriptor $expected + Descriptor $expected, ): void { $service = new ApplicationService($versionFilePath, $applicationName, $applicationDescription); static::assertEquals($expected, $service->getDescriptor()); @@ -119,7 +119,7 @@ public function testGetDescriptorUsingTestEnvironment(): void $expected = new Descriptor( 'This is a Test', 'Just for Testing', - new Version(1, 2, 0) + new Version(1, 2, 0), ); static::assertEquals($expected, $this->applicationService->getDescriptor()); diff --git a/tests/Service/DateServiceTest.php b/tests/Service/DateServiceTest.php index 7680cbf..077bcb5 100644 --- a/tests/Service/DateServiceTest.php +++ b/tests/Service/DateServiceTest.php @@ -15,11 +15,10 @@ use DateTimeZone; use Generator; use IntlDateFormatter; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; -use Meritoo\CommonBundle\Exception\Type\Date\UnknownDateLengthException; +use Meritoo\CommonBundle\Enums\Date\DateLength; use Meritoo\CommonBundle\Service\DateService; -use Meritoo\CommonBundle\Type\Date\DateLength; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; /** @@ -51,17 +50,17 @@ class DateServiceTest extends KernelTestCase public function provideDateFormatUsingDefaults(): Generator { yield [ - DateLength::DATE, + DateLength::Date, 'd.m.Y', ]; yield [ - DateLength::DATETIME, + DateLength::DateTime, 'd.m.Y H:i', ]; yield [ - DateLength::TIME, + DateLength::Time, 'H:i', ]; } @@ -74,17 +73,17 @@ public function provideDateFormatUsingDefaults(): Generator public function provideDateFormatUsingTestEnvironment(): Generator { yield [ - DateLength::DATE, + DateLength::Date, 'Y.m.d', ]; yield [ - DateLength::DATETIME, + DateLength::DateTime, 'Y.m.d H:i:s', ]; yield [ - DateLength::TIME, + DateLength::Time, 'H:i:s', ]; } @@ -103,73 +102,73 @@ public function provideDateFormattedUsingDefaults(): Generator yield [ new DateTime($date1, new DateTimeZone(static::TIMEZONE)), - DateLength::DATE, + DateLength::Date, '01.02.1900', ]; yield [ new DateTime($date2, new DateTimeZone(static::TIMEZONE)), - DateLength::DATE, + DateLength::Date, '15.10.2000', ]; yield [ new DateTime($date3, new DateTimeZone(static::TIMEZONE)), - DateLength::DATE, + DateLength::Date, '01.05.2100', ]; yield [ new DateTime($date4, new DateTimeZone(static::TIMEZONE)), - DateLength::DATE, + DateLength::Date, '01.08.2200', ]; yield [ new DateTime($date1, new DateTimeZone(static::TIMEZONE)), - DateLength::DATETIME, + DateLength::DateTime, '01.02.1900 08:25', ]; yield [ new DateTime($date2, new DateTimeZone(static::TIMEZONE)), - DateLength::DATETIME, + DateLength::DateTime, '15.10.2000 10:05', ]; yield [ new DateTime($date3, new DateTimeZone(static::TIMEZONE)), - DateLength::DATETIME, + DateLength::DateTime, '01.05.2100 00:00', ]; yield [ new DateTime($date4, new DateTimeZone(static::TIMEZONE)), - DateLength::DATETIME, + DateLength::DateTime, '01.08.2200 20:00', ]; yield [ new DateTime($date1, new DateTimeZone(static::TIMEZONE)), - DateLength::TIME, + DateLength::Time, '08:25', ]; yield [ new DateTime($date2, new DateTimeZone(static::TIMEZONE)), - DateLength::TIME, + DateLength::Time, '10:05', ]; yield [ new DateTime($date3, new DateTimeZone(static::TIMEZONE)), - DateLength::TIME, + DateLength::Time, '00:00', ]; yield [ new DateTime($date4, new DateTimeZone(static::TIMEZONE)), - DateLength::TIME, + DateLength::Time, '20:00', ]; } @@ -237,7 +236,7 @@ public function provideDateFormattedUsingLocale(): Generator IntlDateFormatter::SHORT, $locale, new DateTime($dateString, new DateTimeZone(static::TIMEZONE)), - '8:25 AM', + '8:25 AM', ]; yield [ @@ -245,7 +244,7 @@ public function provideDateFormattedUsingLocale(): Generator IntlDateFormatter::MEDIUM, $locale, new DateTime($dateString, new DateTimeZone(static::TIMEZONE)), - '8:25:40 AM', + '8:25:40 AM', ]; // @@ -275,7 +274,7 @@ public function provideDateFormattedUsingLocale(): Generator IntlDateFormatter::SHORT, $locale, new DateTime($dateString, new DateTimeZone(static::TIMEZONE)), - 'Feb 1, 1900, 8:25 AM', + 'Feb 1, 1900, 8:25 AM', ]; yield [ @@ -283,7 +282,7 @@ public function provideDateFormattedUsingLocale(): Generator IntlDateFormatter::MEDIUM, $locale, new DateTime($dateString, new DateTimeZone(static::TIMEZONE)), - 'February 1, 1900 at 8:25:40 AM', + 'February 1, 1900 at 8:25:40 AM', ]; } @@ -300,55 +299,55 @@ public function provideDateFormattedUsingTestEnvironment(): Generator yield [ new DateTime($date1, new DateTimeZone(static::TIMEZONE)), - DateLength::DATE, + DateLength::Date, '1900.02.01', ]; yield [ new DateTime($date2, new DateTimeZone(static::TIMEZONE)), - DateLength::DATE, + DateLength::Date, '2000.10.15', ]; yield [ new DateTime($date3, new DateTimeZone(static::TIMEZONE)), - DateLength::DATE, + DateLength::Date, '2100.05.01', ]; yield [ new DateTime($date1, new DateTimeZone(static::TIMEZONE)), - DateLength::DATETIME, + DateLength::DateTime, '1900.02.01 08:25:40', ]; yield [ new DateTime($date2, new DateTimeZone(static::TIMEZONE)), - DateLength::DATETIME, + DateLength::DateTime, '2000.10.15 10:05:40', ]; yield [ new DateTime($date3, new DateTimeZone(static::TIMEZONE)), - DateLength::DATETIME, + DateLength::DateTime, '2100.05.01 00:00:00', ]; yield [ new DateTime($date1, new DateTimeZone(static::TIMEZONE)), - DateLength::TIME, + DateLength::Time, '08:25:40', ]; yield [ new DateTime($date2, new DateTimeZone(static::TIMEZONE)), - DateLength::TIME, + DateLength::Time, '10:05:40', ]; yield [ new DateTime($date3, new DateTimeZone(static::TIMEZONE)), - DateLength::TIME, + DateLength::Time, '00:00:00', ]; } @@ -385,7 +384,7 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( DateService::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, 3, 3, ); @@ -393,14 +392,14 @@ public function testConstructor(): void /** * @param DateTimeInterface $dateTime The date to format - * @param string $dateLength Type of date length + * @param DateLength $dateLength Type of date length * @param string $expected Expected date * * @dataProvider provideDateFormattedUsingDefaults */ public function testFormatDateUsingDefaults( DateTimeInterface $dateTime, - string $dateLength, + DateLength $dateLength, string $expected, ): void { static::bootKernel([ @@ -483,38 +482,27 @@ public function testFormatDateUsingLocaleAndTestEnvironment( /** * @param DateTimeInterface $dateTime The date to format - * @param string $dateLength Type of date length + * @param DateLength $dateLength Type of date length * @param string $expected Expected date * * @dataProvider provideDateFormattedUsingTestEnvironment */ public function testFormatDateUsingTestEnvironment( DateTimeInterface $dateTime, - string $dateLength, + DateLength $dateLength, string $expected, ): void { static::assertSame($expected, $this->dateService->formatDate($dateTime, $dateLength)); } /** - * @param string $dateLength Unknown type of date length - * - * @dataProvider provideUnknownDateLength - */ - public function testFormatDateUsingUnknownDateLength(string $dateLength): void - { - $this->expectException(UnknownDateLengthException::class); - $this->dateService->formatDate(new DateTime(), $dateLength); - } - - /** - * @param string $dateLength Type of date length + * @param DateLength $dateLength Type of date length * @param string $expected Expected date format * * @dataProvider provideDateFormatUsingDefaults */ public function testGetFormatUsingDefaults( - string $dateLength, + DateLength $dateLength, string $expected, ): void { static::bootKernel([ @@ -530,29 +518,18 @@ public function testGetFormatUsingDefaults( } /** - * @param string $dateLength Type of date length + * @param DateLength $dateLength Type of date length * @param string $expected Expected date format * * @dataProvider provideDateFormatUsingTestEnvironment */ public function testGetFormatUsingTestEnvironment( - string $dateLength, + DateLength $dateLength, string $expected, ): void { static::assertSame($expected, $this->dateService->getFormat($dateLength)); } - /** - * @param string $dateLength Unknown type of date length - * - * @dataProvider provideUnknownDateLength - */ - public function testGetFormatUsingUnknownDateLength(string $dateLength): void - { - $this->expectException(UnknownDateLengthException::class); - $this->dateService->getFormat($dateLength); - } - /** * {@inheritdoc} */ diff --git a/tests/Service/FormServiceTest.php b/tests/Service/FormServiceTest.php index a2435ca..31fecdb 100644 --- a/tests/Service/FormServiceTest.php +++ b/tests/Service/FormServiceTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Service; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Contract\Service\FormServiceInterface; use Meritoo\CommonBundle\Service\FormService; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -94,7 +94,7 @@ public function provideExistingFormOptionsUsingDefaults(): Generator /** * @param array $existingOptions Existing options - * @param array $expected Expected options + * @param array $expected Expected options * * @dataProvider provideExistingFormOptionsCustomConfiguration */ @@ -114,7 +114,7 @@ public function testAddHtml5ValidationOptionsUsingDefaults(array $existingOption /** * @param array $existingOptions Existing options - * @param array $expected Expected options + * @param array $expected Expected options * * @dataProvider provideExistingFormOptionsUsingDefaults */ @@ -128,9 +128,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( FormService::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } diff --git a/tests/Service/PaginationServiceTest.php b/tests/Service/PaginationServiceTest.php index a2ab026..d55fab6 100644 --- a/tests/Service/PaginationServiceTest.php +++ b/tests/Service/PaginationServiceTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Service; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\Common\Utilities\Reflection; use Meritoo\CommonBundle\Contract\Service\PaginationServiceInterface; use Meritoo\CommonBundle\Exception\Pagination\MissingPerPageAmountException; @@ -79,9 +79,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( PaginationService::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, 5, - 2 + 2, ); } diff --git a/tests/Service/RequestServiceTest.php b/tests/Service/RequestServiceTest.php index f7e7bbd..c5d3fbf 100644 --- a/tests/Service/RequestServiceTest.php +++ b/tests/Service/RequestServiceTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Service; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Contract\Service\RequestServiceInterface; use Meritoo\CommonBundle\Exception\Service\Request\UnknownRequestException; use Meritoo\CommonBundle\Service\RequestService; @@ -143,14 +143,15 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( RequestService::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 2, 2, - 2 ); } /** * @param string $expected Expected url of referer + * * @dataProvider provideUrl */ public function testFetchRefererUrl(string $expected): void @@ -333,7 +334,7 @@ public function testGetParameterIfCurrentRequestIsUnknown(): void } /** - * @param Request $request The request (that probably contains referer) + * @param Request $request The request (that probably contains referer) * @param null|string $expected Expected url of referer * * @dataProvider provideRequestAndRefererUrl @@ -383,6 +384,7 @@ public function testIsCurrentRouteIfCurrentRequestIsUnknown(): void /** * @param string $url The referer url to store + * * @dataProvider provideUrl */ public function testStoreRefererUrl(string $url): void @@ -392,7 +394,7 @@ public function testStoreRefererUrl(string $url): void } /** - * @param Request $request The request (that probably contains referer) + * @param Request $request The request (that probably contains referer) * @param null|string $expected Expected url of referer * * @dataProvider provideRequestAndRefererUrlToStore diff --git a/tests/Service/ResponseServiceTest.php b/tests/Service/ResponseServiceTest.php index 35edd5a..53d213b 100644 --- a/tests/Service/ResponseServiceTest.php +++ b/tests/Service/ResponseServiceTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Service; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Service\ResponseService; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -60,17 +60,17 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( ResponseService::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } /** - * @param string $routeName The name of the route. Used to build url used for redirection. - * @param array $routeParameters An array of parameters. Used to build url used for redirection. - * @param string $url Url that should be generated and used for redirection - * @param RedirectResponse $expected Expected instance of RedirectResponse + * @param string $routeName The name of the route. Used to build url used for redirection. + * @param array $routeParameters An array of parameters. Used to build url used for redirection. + * @param string $url Url that should be generated and used for redirection + * @param RedirectResponse $expected Expected instance of RedirectResponse * * @dataProvider provideRouteDetailsForRedirectResponse */ @@ -78,11 +78,12 @@ public function testGetRedirectResponse( string $routeName, array $routeParameters, string $url, - RedirectResponse $expected + RedirectResponse $expected, ): void { $redirectResponse = $this ->getResponseService($routeName, $routeParameters, $url) - ->getRedirectResponse($routeName, $routeParameters); + ->getRedirectResponse($routeName, $routeParameters) + ; static::assertSame($expected->getTargetUrl(), $redirectResponse->getTargetUrl()); static::assertSame($expected->getContent(), $redirectResponse->getContent()); @@ -103,9 +104,10 @@ protected function setUp(): void /** * Returns instance of ResponseService with all related and mocked instances * - * @param string $routeName The name of the route. Used to build url used for redirection. - * @param array $routeParameters An array of parameters. Used to build url used for redirection. - * @param string $url Url that should be generated and used for redirection + * @param string $routeName The name of the route. Used to build url used for redirection. + * @param array $routeParameters An array of parameters. Used to build url used for redirection. + * @param string $url Url that should be generated and used for redirection + * * @return ResponseService */ private function getResponseService(string $routeName, array $routeParameters, string $url): ResponseService diff --git a/tests/Twig/ApplicationRuntimeTest.php b/tests/Twig/ApplicationRuntimeTest.php index 7b97045..f6f9c1e 100644 --- a/tests/Twig/ApplicationRuntimeTest.php +++ b/tests/Twig/ApplicationRuntimeTest.php @@ -10,8 +10,8 @@ namespace Meritoo\Test\CommonBundle\Twig; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\Common\ValueObject\Version; use Meritoo\CommonBundle\Application\Descriptor; use Meritoo\CommonBundle\Exception\Service\ApplicationService\UnreadableVersionFileException; @@ -38,9 +38,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( ApplicationRuntime::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } @@ -63,7 +63,7 @@ public function testGetDescriptorUsingTestEnvironment(): void $expected = new Descriptor( 'This is a Test', 'Just for Testing', - new Version(1, 2, 0) + new Version(1, 2, 0), ); static::assertEquals($expected, $this->applicationRuntime->getDescriptor()); diff --git a/tests/Twig/CommonRuntimeTest.php b/tests/Twig/CommonRuntimeTest.php index 8856455..2246fd2 100644 --- a/tests/Twig/CommonRuntimeTest.php +++ b/tests/Twig/CommonRuntimeTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\Twig; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Twig\CommonRuntime; use stdClass; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -225,9 +225,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( CommonRuntime::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } @@ -237,23 +237,23 @@ public function testIsInstanceOfRuntimeExtensionInterface(): void } /** - * @param mixed $value The value to check + * @param mixed $value The value to check * @param null|string $emptyValueReplacement Custom replacement of empty value. If is set to null, the - * replacement is retrieved from configuration (default behaviour). - * @param mixed $expected Expected value + * replacement is retrieved from configuration (default behaviour). + * @param mixed $expected Expected value * * @dataProvider provideValueAndValueReplacementToVerifyEmptyValue */ public function testVerifyEmptyValueUsingCustomValueReplacement( $value, ?string $emptyValueReplacement, - $expected + $expected, ): void { static::assertSame($expected, $this->commonRuntime->verifyEmptyValue($value, $emptyValueReplacement)); } /** - * @param mixed $value The value to check + * @param mixed $value The value to check * @param mixed $expected Expected value * * @dataProvider provideValueToVerifyEmptyValueUsingDefaults @@ -273,7 +273,7 @@ public function testVerifyEmptyValueUsingDefaults($value, $expected): void } /** - * @param mixed $value The value to check + * @param mixed $value The value to check * @param mixed $expected Expected value * * @dataProvider provideValueToVerifyEmptyValue diff --git a/tests/Twig/FormRuntimeTest.php b/tests/Twig/FormRuntimeTest.php index 74564d2..f778169 100644 --- a/tests/Twig/FormRuntimeTest.php +++ b/tests/Twig/FormRuntimeTest.php @@ -10,8 +10,8 @@ namespace Meritoo\Test\CommonBundle\Twig; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Twig\FormRuntime; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Twig\Extension\RuntimeExtensionInterface; @@ -35,9 +35,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( FormRuntime::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } diff --git a/tests/Twig/MenuRuntimeTest.php b/tests/Twig/MenuRuntimeTest.php index a2a10a7..a9a1a0d 100644 --- a/tests/Twig/MenuRuntimeTest.php +++ b/tests/Twig/MenuRuntimeTest.php @@ -10,8 +10,8 @@ namespace Meritoo\Test\CommonBundle\Twig; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Contract\Service\MenuServiceInterface; use Meritoo\CommonBundle\Twig\MenuRuntime; use PHPUnit\Framework\MockObject\MockObject; @@ -41,9 +41,9 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( MenuRuntime::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, + 1, 1, - 1 ); } diff --git a/tests/Type/Date/DateLengthTest.php b/tests/Type/Date/DateLengthTest.php deleted file mode 100644 index c1d4de4..0000000 --- a/tests/Type/Date/DateLengthTest.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Meritoo - * - * @internal - * @covers \Meritoo\CommonBundle\Type\Date\DateLength - */ -class DateLengthTest extends BaseTypeTestCase -{ - /** - * {@inheritdoc} - */ - public function provideTypeToVerify(): Generator - { - yield [ - (new DateLength())->isCorrectType(''), - false, - ]; - - yield [ - (new DateLength())->isCorrectType(null), - false, - ]; - - yield [ - (new DateLength())->isCorrectType('0'), - false, - ]; - - yield [ - (new DateLength())->isCorrectType('1'), - false, - ]; - - yield [ - (new DateLength())->isCorrectType('date'), - true, - ]; - - yield [ - (new DateLength())->isCorrectType('datetime'), - true, - ]; - - yield [ - (new DateLength())->isCorrectType('time'), - true, - ]; - } - - /** - * {@inheritdoc} - */ - protected function getAllExpectedTypes(): array - { - return [ - 'DATE' => DateLength::DATE, - 'DATETIME' => DateLength::DATETIME, - 'TIME' => DateLength::TIME, - ]; - } - - /** - * {@inheritdoc} - */ - protected function getTestedTypeInstance(): BaseType - { - return new DateLength(); - } -} diff --git a/tests/Type/DependencyInjection/ConfigurationFileTypeTest.php b/tests/Type/DependencyInjection/ConfigurationFileTypeTest.php deleted file mode 100644 index c800408..0000000 --- a/tests/Type/DependencyInjection/ConfigurationFileTypeTest.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright Meritoo - * - * @internal - * @covers \Meritoo\CommonBundle\Type\DependencyInjection\ConfigurationFileType - */ -class ConfigurationFileTypeTest extends BaseTypeTestCase -{ - /** - * Provides name and type of configuration file - * - * @return Generator - */ - public function provideFileNameAndType(): Generator - { - yield [ - 'example.yaml', - 'yaml', - ]; - - yield [ - 'example.xml', - 'xml', - ]; - - yield [ - 'example.php', - 'php', - ]; - } - - /** - * Provides name of configuration file with unknown extension - * - * @return Generator - */ - public function provideFileNameWithUnknownExtension(): Generator - { - yield [ - '', - '', - ]; - - yield [ - '0', - '', - ]; - - yield [ - 'example.jpg', - '', - ]; - - yield [ - 'example.yml', - '', - ]; - } - - /** - * {@inheritdoc} - */ - public function provideTypeToVerify(): Generator - { - yield [ - (new ConfigurationFileType())->isCorrectType(''), - false, - ]; - - yield [ - (new ConfigurationFileType())->isCorrectType(null), - false, - ]; - - yield [ - (new ConfigurationFileType())->isCorrectType('0'), - false, - ]; - - yield [ - (new ConfigurationFileType())->isCorrectType('1'), - false, - ]; - - yield [ - (new ConfigurationFileType())->isCorrectType('jpg'), - false, - ]; - - yield [ - (new ConfigurationFileType())->isCorrectType('php'), - true, - ]; - - yield [ - (new ConfigurationFileType())->isCorrectType('xml'), - true, - ]; - - yield [ - (new ConfigurationFileType())->isCorrectType('yaml'), - true, - ]; - } - - /** - * @param string $fileName Name of configuration file - * @param string $expected Expected type of configuration file - * - * @dataProvider provideFileNameAndType - */ - public function testGetTypeFromFileName(string $fileName, string $expected): void - { - static::assertSame($expected, (new ConfigurationFileType())->getTypeFromFileName($fileName)); - } - - /** - * @param string $fileName Name of configuration file - * - * @dataProvider provideFileNameWithUnknownExtension - */ - public function testGetTypeFromFileNameWithUnknownExtension(string $fileName): void - { - $this->expectException(UnknownConfigurationFileTypeException::class); - (new ConfigurationFileType())->getTypeFromFileName($fileName); - } - - /** - * {@inheritdoc} - */ - protected function getAllExpectedTypes(): array - { - return [ - 'PHP' => ConfigurationFileType::PHP, - 'XML' => ConfigurationFileType::XML, - 'YAML' => ConfigurationFileType::YAML, - ]; - } - - /** - * {@inheritdoc} - */ - protected function getTestedTypeInstance(): BaseType - { - return new ConfigurationFileType(); - } -} diff --git a/tests/ValueObject/PaginationTest.php b/tests/ValueObject/PaginationTest.php index 227cd5f..86fa58a 100644 --- a/tests/ValueObject/PaginationTest.php +++ b/tests/ValueObject/PaginationTest.php @@ -11,8 +11,8 @@ namespace Meritoo\Test\CommonBundle\ValueObject; use Generator; +use Meritoo\Common\Enums\OopVisibility; use Meritoo\Common\Test\Base\BaseTestCase; -use Meritoo\Common\Type\OopVisibilityType; use Meritoo\CommonBundle\Exception\ValueObject\Pagination\IncorrectCurrentPageException; use Meritoo\CommonBundle\Exception\ValueObject\Pagination\IncorrectPerPageException; use Meritoo\CommonBundle\Exception\ValueObject\Pagination\IncorrectTotalAmountException; @@ -181,10 +181,10 @@ public function providePaginationToValidatePageNumber(): ?Generator /** * @param string $description - * @param int $expected - * @param int $totalAmount - * @param int $perPage - * @param int $currentPage + * @param int $expected + * @param int $totalAmount + * @param int $perPage + * @param int $currentPage * * @dataProvider providePaginationToCalculateOffset */ @@ -193,7 +193,7 @@ public function testCalculateOffset( int $expected, int $totalAmount, int $perPage, - int $currentPage = 1 + int $currentPage = 1, ): void { $pagination = new Pagination($totalAmount, $perPage, $currentPage); static::assertSame($pagination->calculateOffset(), $expected, $description); @@ -201,10 +201,10 @@ public function testCalculateOffset( /** * @param string $description - * @param int $expected - * @param int $totalAmount - * @param int $perPage - * @param int $currentPage + * @param int $expected + * @param int $totalAmount + * @param int $perPage + * @param int $currentPage * * @dataProvider providePaginationToCalculatePagesCount */ @@ -213,7 +213,7 @@ public function testCalculatePagesCount( int $expected, int $totalAmount, int $perPage, - int $currentPage = 1 + int $currentPage = 1, ): void { $pagination = new Pagination($totalAmount, $perPage, $currentPage); static::assertSame($pagination->calculatePagesCount(), $expected, $description); @@ -223,16 +223,16 @@ public function testConstructor(): void { static::assertConstructorVisibilityAndArguments( Pagination::class, - OopVisibilityType::IS_PUBLIC, + OopVisibility::Public, 3, - 2 + 2, ); } /** - * @param int $totalAmount - * @param int $perPage - * @param int $currentPage + * @param int $totalAmount + * @param int $perPage + * @param int $currentPage * @param string $expectedExceptionClass * * @dataProvider provideIncorrectParametersToCreate @@ -241,7 +241,7 @@ public function testCreateUsingIncorrectParameters( int $totalAmount, int $perPage, int $currentPage, - string $expectedExceptionClass + string $expectedExceptionClass, ): void { $this->expectException($expectedExceptionClass); new Pagination($totalAmount, $perPage, $currentPage); @@ -249,10 +249,10 @@ public function testCreateUsingIncorrectParameters( /** * @param string $description - * @param int $expected - * @param int $totalAmount - * @param int $perPage - * @param int $currentPage + * @param int $expected + * @param int $totalAmount + * @param int $perPage + * @param int $currentPage * * @dataProvider providePaginationToCurrentPage */ @@ -261,7 +261,7 @@ public function testGetCurrentPage( int $expected, int $totalAmount, int $perPage, - int $currentPage = 1 + int $currentPage = 1, ): void { $pagination = new Pagination($totalAmount, $perPage, $currentPage); static::assertSame($pagination->getCurrentPage(), $expected, $description); @@ -277,11 +277,11 @@ public function testGetPerPage(): void /** * @param string $description - * @param bool $expected - * @param int $page - * @param int $totalAmount - * @param int $perPage - * @param int $currentPage + * @param bool $expected + * @param int $page + * @param int $totalAmount + * @param int $perPage + * @param int $currentPage * * @dataProvider providePaginationToValidatePageNumber */ @@ -291,7 +291,7 @@ public function testIsValidPage( int $page, int $totalAmount, int $perPage, - int $currentPage = 1 + int $currentPage = 1, ): void { $pagination = new Pagination($totalAmount, $perPage, $currentPage); static::assertSame($pagination->isValidPage($page), $expected, $description);