From d5b2ee10befcfe8cd4232376ef7a8b724eda622f Mon Sep 17 00:00:00 2001 From: Mykhailo Shtanko Date: Mon, 6 Mar 2023 18:28:36 +0200 Subject: [PATCH] [RequestMapper] Added SonarCloud checks, refactor GitHub actions --- .github/workflows/build.yml | 112 ++++++++++++++++++ .github/workflows/ci.yml | 84 ------------- README.md | 14 ++- .../EventListener/JsonRequestListenerTest.php | 2 +- .../RequestMapperListenerTest.php | 2 +- .../ExceptionFormatterTest.php | 2 +- .../Locator/ExceptionFormatterLocatorTest.php | 4 +- .../Func/RequestMapper/RequestMapperTest.php | 2 +- .../Attribute/RequestBodyAttributeTest.php | 2 +- Tests/Unit/Data/TypeErrorTest.php | 2 +- .../EventListener/ExceptionListenerTest.php | 2 +- .../RequestMapperListenerTest.php | 2 +- .../Mapper/TypeErrorExceptionMapperTest.php | 2 +- .../DiscriminatorMapExtractorTest.php | 2 +- .../Extractor/ParametersExtractorTest.php | 2 +- Tests/Unit/Helper/ClassHelperTest.php | 12 +- Tests/Unit/Helper/ConstraintHelperTest.php | 2 +- Tests/Unit/Helper/SerializerHelperTest.php | 2 +- Tests/Unit/Helper/StringHelperTest.php | 16 +-- .../Unit/RequestMapper/RequestMapperTest.php | 2 +- phpunit.xml.dist | 9 -- sonar-project.properties | 10 ++ 22 files changed, 164 insertions(+), 125 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a5b02d0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,112 @@ +name: Build + +on: + push: + branches: + - main + - develop + - 'releases/**' + paths-ignore: + - '**/*.md' + - '**/*.gitignore' + - '**/*.gitattributes' + + pull_request: + types: + - published + - created + - edited + - opened + - synchronize + - reopened + paths-ignore: + - '**/*.md' + - '**/*.gitignore' + - '**/*.gitattributes' + +jobs: + build: + name: PHP + runs-on: ubuntu-latest + + strategy: + matrix: + php: + - "8.1" + - "8.2" + include: + - php-versions: ["8.1", "8.2"] + - composer-options: "--ignore-platform-reqs" + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + extensions: mbstring, intl + coverage: xdebug + tools: pecl, phpunit, composer + ini-values: post_max_size=256M + + - name: Setup composer + uses: ramsey/composer-install@v1 + with: + composer-options: "${{ matrix.composer-options }}" + + - name: Validate composer files + run: composer validate + + - name: Cache composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer update --prefer-dist --no-progress + + - name: Setup tests directories + run: mkdir -p build/logs + + - name: Execute unit tests + run: ./vendor/bin/phpunit --colors=always --configuration phpunit.xml.dist --coverage-cobertura tests-cobertura.xml --coverage-clover tests-coverage.xml --log-junit tests-execution.xml + + - name: Prepare coverages and logs + run: cp tests-coverage.xml build/logs/clover.xml && cp tests-cobertura.xml build/logs/cobertura.xml && cp tests-execution.xml build/logs/junit.xml + + - name: Push to Coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_PARALLEL: true + COVERALLS_FLAG_NAME: php-${{ matrix.php-versions }} + run: | + composer global require php-coveralls/php-coveralls + php-coveralls -v + + - name: SonarCloud scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + projectBaseDir: ${{ github.workspace }} + + finish: + needs: [ build ] + runs-on: ubuntu-latest + + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index b3e1214..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: CI - -on: - push: - branches: [ main ] - - pull_request: - branches: [ main ] - - page_build: - release: - types: [ published, created, edited ] - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - php: - - "8.1" - include: - - php-version: "8.1" - composer-options: "--ignore-platform-reqs" - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - extensions: mbstring, intl - coverage: xdebug - tools: pecl, phpunit, composer - ini-values: post_max_size=256M - - - name: Setup Composer - uses: ramsey/composer-install@v1 - with: - composer-options: "${{ matrix.composer-options }}" - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v2 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer update --prefer-dist --no-progress - - - name: Setup tests directories - run: mkdir -p build/logs - - - name: Unit Tests - run: ./vendor/bin/phpunit --colors=always --configuration phpunit.xml.dist - - - name: Push to Coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_PARALLEL: true - COVERALLS_FLAG_NAME: php-${{ matrix.php-versions }} - run: | - composer global require php-coveralls/php-coveralls - php-coveralls -v - - finish: - needs: [ build ] - runs-on: ubuntu-18.04 - - steps: - - name: Coveralls Finished - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true diff --git a/README.md b/README.md index e98fd51..0b5b795 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,25 @@ RequestMapper Component ============================= -![Workflow Build Status](https://github.com/fractalzombie/frzb-request-mapper/actions/workflows/ci.yml/badge.svg?event=push) +![Workflow Build Status](https://github.com/fractalzombie/frzb-request-mapper/actions/workflows/build.yml/badge.svg?event=push) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/fractalzombie/frzb-request-mapper/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/fractalzombie/frzb-request-mapper/?branch=main) [![Code Intelligence Status](https://scrutinizer-ci.com/g/fractalzombie/frzb-request-mapper/badges/code-intelligence.svg?b=main)](https://scrutinizer-ci.com/code-intelligence) [![Build Status](https://scrutinizer-ci.com/g/fractalzombie/frzb-request-mapper/badges/build.png?b=main)](https://scrutinizer-ci.com/g/fractalzombie/frzb-request-mapper/build-status/main) [![Coverage Status](https://coveralls.io/repos/github/fractalzombie/frzb-request-mapper/badge.svg?branch=main)](https://coveralls.io/github/fractalzombie/frzb-request-mapper?branch=main) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=bugs)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=coverage)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) +[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=fractalzombie_frzb-request-mapper&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=fractalzombie_frzb-request-mapper) The RequestMapper component allows you to serialize JSON request to Request class and validate it. Resources --------- - * [Documentation](https://github.com/fractalzombie/frzb-request-mapper/blob/main/Documentation/USAGE.MD) * [License](https://github.com/fractalzombie/frzb-request-mapper/blob/main/LICENSE) diff --git a/Tests/Func/EventListener/JsonRequestListenerTest.php b/Tests/Func/EventListener/JsonRequestListenerTest.php index 88860c0..f160cf6 100644 --- a/Tests/Func/EventListener/JsonRequestListenerTest.php +++ b/Tests/Func/EventListener/JsonRequestListenerTest.php @@ -51,7 +51,7 @@ public function testOnKernelRequestMethod( } /** @throws \JsonException */ - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield 'with valid GET JSON request' => [ 'method' => Request::METHOD_GET, diff --git a/Tests/Func/EventListener/RequestMapperListenerTest.php b/Tests/Func/EventListener/RequestMapperListenerTest.php index 439b6ef..226ff53 100644 --- a/Tests/Func/EventListener/RequestMapperListenerTest.php +++ b/Tests/Func/EventListener/RequestMapperListenerTest.php @@ -62,7 +62,7 @@ public function testOnKernelController( } } - public function dataProvider(): iterable + public static function dataProvider(): iterable { $params = ['name' => 'some name', 'model' => 'Product']; diff --git a/Tests/Func/ExceptionFormatter/ExceptionFormatterTest.php b/Tests/Func/ExceptionFormatter/ExceptionFormatterTest.php index ea2e950..4076b9e 100644 --- a/Tests/Func/ExceptionFormatter/ExceptionFormatterTest.php +++ b/Tests/Func/ExceptionFormatter/ExceptionFormatterTest.php @@ -46,7 +46,7 @@ public function test(\Throwable $e, ErrorContract $errorContract): void self::assertJsonStringEqualsJsonString(json_encode($errorContract), json_encode($formattedErrorContract)); } - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield sprintf('Format "%s"', HttpException::class) => [ 'exception' => new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, 'Internal Server Error'), diff --git a/Tests/Func/Locator/ExceptionFormatterLocatorTest.php b/Tests/Func/Locator/ExceptionFormatterLocatorTest.php index e697c36..9cc5fd0 100644 --- a/Tests/Func/Locator/ExceptionFormatterLocatorTest.php +++ b/Tests/Func/Locator/ExceptionFormatterLocatorTest.php @@ -38,11 +38,11 @@ public function testGetAndHasMethods(\Throwable $e, string $formatterClass, bool { $formatter = $this->locator->get($e); - self::assertSame($formatterClass, $formatter::class); + self::assertInstanceOf($formatterClass, $formatter); self::assertSame($existsInLocator, $this->locator->has($e)); } - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield sprintf('"%s" uses "%s" converter', HttpException::class, HttpExceptionFormatter::class) => [ 'exception' => new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, 'Internal Server Error'), diff --git a/Tests/Func/RequestMapper/RequestMapperTest.php b/Tests/Func/RequestMapper/RequestMapperTest.php index b419209..3a9c560 100644 --- a/Tests/Func/RequestMapper/RequestMapperTest.php +++ b/Tests/Func/RequestMapper/RequestMapperTest.php @@ -64,7 +64,7 @@ public function testConvertMethod(Request $nativeRequest, RequestBody $requestBo } /** @throws \Exception */ - public function caseProvider(): iterable + public static function caseProvider(): iterable { $params = ['name' => TestConstant::USER_NAME, 'userId' => TestConstant::USER_ID, 'amount' => TestConstant::USER_AMOUNT, 'testEnum' => TestEnum::One->value]; $attribute = new RequestBody(requestClass: CreateUserRequestWithEnum::class, argumentName: 'typed_request'); diff --git a/Tests/Unit/Attribute/RequestBodyAttributeTest.php b/Tests/Unit/Attribute/RequestBodyAttributeTest.php index b9a3a09..5da6ccf 100644 --- a/Tests/Unit/Attribute/RequestBodyAttributeTest.php +++ b/Tests/Unit/Attribute/RequestBodyAttributeTest.php @@ -31,7 +31,7 @@ public function testEqualsMethod(RequestBody $first, object $second, bool $expec self::assertSame($expected, $first->equals($second)); } - public function equalsCaseProvider(): iterable + public static function equalsCaseProvider(): iterable { yield 'with equals parameter class' => [ 'first' => new RequestBody(CreateUserRequest::class), diff --git a/Tests/Unit/Data/TypeErrorTest.php b/Tests/Unit/Data/TypeErrorTest.php index 5e10e97..c0de7c0 100644 --- a/Tests/Unit/Data/TypeErrorTest.php +++ b/Tests/Unit/Data/TypeErrorTest.php @@ -32,7 +32,7 @@ public function testCreation(array $params, bool $throws = false): void self::assertSame($params['proposed'], $error->proposed); } - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield 'all parameters are exists' => [ 'params' => [ diff --git a/Tests/Unit/EventListener/ExceptionListenerTest.php b/Tests/Unit/EventListener/ExceptionListenerTest.php index d223ed1..c7595e1 100644 --- a/Tests/Unit/EventListener/ExceptionListenerTest.php +++ b/Tests/Unit/EventListener/ExceptionListenerTest.php @@ -53,7 +53,7 @@ public function testOnKernelRequestMethod(array $headers, InvocationOrder $expec self::assertSame($headers, HeaderHelper::getHeaders($request)); } - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield 'with header content-type equals application/json' => [ 'headers' => ['content-type' => 'application/json'], diff --git a/Tests/Unit/EventListener/RequestMapperListenerTest.php b/Tests/Unit/EventListener/RequestMapperListenerTest.php index 8bc5fb9..8506547 100644 --- a/Tests/Unit/EventListener/RequestMapperListenerTest.php +++ b/Tests/Unit/EventListener/RequestMapperListenerTest.php @@ -47,7 +47,7 @@ public function testOnKernelController(array $params, string $httpMethod, string } } - public function dataProvider(): iterable + public static function dataProvider(): iterable { $params = ['name' => 'some name', 'model' => 'Product']; diff --git a/Tests/Unit/ExceptionMapper/Mapper/TypeErrorExceptionMapperTest.php b/Tests/Unit/ExceptionMapper/Mapper/TypeErrorExceptionMapperTest.php index ae74b87..83b9552 100644 --- a/Tests/Unit/ExceptionMapper/Mapper/TypeErrorExceptionMapperTest.php +++ b/Tests/Unit/ExceptionMapper/Mapper/TypeErrorExceptionMapperTest.php @@ -47,7 +47,7 @@ public function testMapping( self::assertSame($message, $error->getMessage()); } - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield 'test it with type of template' => [ 'parameter' => 'name', diff --git a/Tests/Unit/Extractor/DiscriminatorMapExtractorTest.php b/Tests/Unit/Extractor/DiscriminatorMapExtractorTest.php index 264210b..3e0a00e 100644 --- a/Tests/Unit/Extractor/DiscriminatorMapExtractorTest.php +++ b/Tests/Unit/Extractor/DiscriminatorMapExtractorTest.php @@ -37,7 +37,7 @@ public function testExtractMethod(string $givenClass, string $expectedClass, arr self::assertSame($expectedClass, $extractedClass); } - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield sprintf('Class "%s" without discriminator', CreateUserRequest::class) => [ 'given_class' => CreateUserRequest::class, diff --git a/Tests/Unit/Extractor/ParametersExtractorTest.php b/Tests/Unit/Extractor/ParametersExtractorTest.php index 2e441f5..ec693e5 100644 --- a/Tests/Unit/Extractor/ParametersExtractorTest.php +++ b/Tests/Unit/Extractor/ParametersExtractorTest.php @@ -49,7 +49,7 @@ public function testExtractMethod(string $class, array $parameters): void self::assertSame($parameters, $this->parameterExtractor->extract($class, $parameters)); } - public function caseProvider(): iterable + public static function caseProvider(): iterable { $parameters = [ 'name' => TestConstant::USER_NAME, diff --git a/Tests/Unit/Helper/ClassHelperTest.php b/Tests/Unit/Helper/ClassHelperTest.php index 187ac70..fe5c9e9 100644 --- a/Tests/Unit/Helper/ClassHelperTest.php +++ b/Tests/Unit/Helper/ClassHelperTest.php @@ -21,7 +21,7 @@ public function testIsNotBuiltinAndExistsMethod(string $class, bool $isNotBuilti self::assertSame($isNotBuiltinAndExists, ClassHelper::isNotBuiltinAndExists($class)); } - public function isNotBuiltinCaseProvider(): iterable + public static function isNotBuiltinCaseProvider(): iterable { yield sprintf('with "%s"', CreateUserRequest::class) => [ 'class' => CreateUserRequest::class, @@ -45,7 +45,7 @@ public function testGetShortNameMethod(string $className, string $expectedName): self::assertSame($expectedName, ClassHelper::getShortName($className)); } - public function getShortNameCaseProvider(): iterable + public static function getShortNameCaseProvider(): iterable { yield sprintf('class "%s"', CreateUserRequest::class) => [ 'class_name' => CreateUserRequest::class, @@ -69,7 +69,7 @@ public function testIsNameContainsMethod(string $className, array $haystack, boo self::assertSame($contains, ClassHelper::isNameContains($className, ...$haystack)); } - public function nameContainsCaseProvider(): iterable + public static function nameContainsCaseProvider(): iterable { yield sprintf('class "%s" and haystack "%s"', CreateUserRequest::class, implode(', ', ['Request'])) => [ 'class_name' => CreateUserRequest::class, @@ -107,7 +107,7 @@ public function testGetMethodParametersMethod(string $className, string $method, self::assertSame($expectedMapping, $mapping); } - public function getMethodParametersCaseProvider(): iterable + public static function getMethodParametersCaseProvider(): iterable { yield sprintf('class "%s", mapping "%s"', CreateUserRequest::class, implode(', ', ['name', 'userId', 'amount'])) => [ 'class_name' => CreateUserRequest::class, @@ -128,7 +128,7 @@ public function testIsEnumMethod(string $className, bool $expectedResult): void self::assertSame(ClassHelper::isEnum($className), $expectedResult); } - public function isEnumCaseProvider(): iterable + public static function isEnumCaseProvider(): iterable { yield sprintf('enum "%s" is valid', TestEnum::class) => [ 'value' => TestEnum::class, @@ -147,7 +147,7 @@ public function testIsArrayHasAllPropertiesFromClass(array $properties, string $ self::assertSame($expected, ClassHelper::isArrayHasAllPropertiesFromClass($properties, $class)); } - public function isArrayHasAllPropertiesFromClassCaseProvider(): iterable + public static function isArrayHasAllPropertiesFromClassCaseProvider(): iterable { $properties = ['name' => TestConstant::USER_NAME, 'userId' => TestConstant::UUID, 'amount' => TestConstant::USER_AMOUNT]; diff --git a/Tests/Unit/Helper/ConstraintHelperTest.php b/Tests/Unit/Helper/ConstraintHelperTest.php index 933030f..59f0429 100644 --- a/Tests/Unit/Helper/ConstraintHelperTest.php +++ b/Tests/Unit/Helper/ConstraintHelperTest.php @@ -29,7 +29,7 @@ public function testFromPropertyMethod(array $properties, array $expectedConstra } } - public function fromPropertyCaseProvider(): iterable + public static function fromPropertyCaseProvider(): iterable { yield sprintf('with "%s"', CreateUserRequest::class) => [ 'properties' => (new \ReflectionClass(CreateUserRequest::class))->getProperties(), diff --git a/Tests/Unit/Helper/SerializerHelperTest.php b/Tests/Unit/Helper/SerializerHelperTest.php index 5ddcff1..836b090 100644 --- a/Tests/Unit/Helper/SerializerHelperTest.php +++ b/Tests/Unit/Helper/SerializerHelperTest.php @@ -24,7 +24,7 @@ public function testGetSerializedNameAttributeMethod(array $properties, array $e } } - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield sprintf('with "%s"', CreateUserWithSerializedNameRequest::class) => [ 'properties' => (new \ReflectionClass(CreateUserWithSerializedNameRequest::class))->getProperties(), diff --git a/Tests/Unit/Helper/StringHelperTest.php b/Tests/Unit/Helper/StringHelperTest.php index 3b89bfc..1a7c1e9 100644 --- a/Tests/Unit/Helper/StringHelperTest.php +++ b/Tests/Unit/Helper/StringHelperTest.php @@ -18,7 +18,7 @@ public function testNormalizePrefix(string $prefix, string $expectedValue): void self::assertSame($expectedValue, StringHelper::normalize($prefix)); } - public function normalizeProvider(): iterable + public static function normalizeProvider(): iterable { return [ ['some-domain.local', 'some-domain-local'], @@ -34,7 +34,7 @@ public function testMakePrefixMethod(string $prefix, string $expectedValue, ?str self::assertSame($expectedValue, StringHelper::makePrefix($prefix, $value, $delimiter)); } - public function prefixProvider(): iterable + public static function prefixProvider(): iterable { return [ ['some-domain.local', 'some-domain-local', null, '-'], @@ -52,7 +52,7 @@ public function testToSnakeCaseMethod(string $sourceValue, string $expectedValue self::assertSame($expectedValue, StringHelper::toSnakeCase($sourceValue)); } - public function snakeCaseProvider(): iterable + public static function snakeCaseProvider(): iterable { return [ ['SomeTrueValue', 'some_true_value'], @@ -67,7 +67,7 @@ public function testToCamelCaseMethod(string $sourceValue, string $expectedValue self::assertSame($expectedValue, StringHelper::toCamelCase($sourceValue)); } - public function snakeCaseToCamelCaseProvider(): iterable + public static function snakeCaseToCamelCaseProvider(): iterable { return [ ['camel_case_name', 'CamelCaseName'], @@ -84,7 +84,7 @@ public function testToLowerCamelCaseMethod(string $sourceValue, string $expected self::assertSame($expectedValue, StringHelper::toLowerCamelCase($sourceValue)); } - public function snakeCaseToLowerCamelCaseProvider(): iterable + public static function snakeCaseToLowerCamelCaseProvider(): iterable { return [ ['camel_case_name', 'camelCaseName'], @@ -101,7 +101,7 @@ public function testToKebabCaseMethod(string $sourceValue, string $expectedValue self::assertSame($expectedValue, StringHelper::toKebabCase($sourceValue)); } - public function kebabCaseProvider(): iterable + public static function kebabCaseProvider(): iterable { return [ ['SomeTrueValue', 'some-true-value'], @@ -116,7 +116,7 @@ public function testContainsMethod(string $sourceValue, string $subValue, bool $ self::assertSame($expected, StringHelper::contains($sourceValue, $subValue)); } - public function successSubValuesProvider(): iterable + public static function successSubValuesProvider(): iterable { return [ ['SomeTrueValue', 'True', true], @@ -134,7 +134,7 @@ public function testRemoveBracketsMethod(string $inputValue, string $expectedVal self::assertEquals($expectedValue, StringHelper::removeBrackets($inputValue, $brackets)); } - public function bracketsProvider(): iterable + public static function bracketsProvider(): iterable { yield 'standard brackets' => [ '[hello_world]', diff --git a/Tests/Unit/RequestMapper/RequestMapperTest.php b/Tests/Unit/RequestMapper/RequestMapperTest.php index ac65e40..50d1e3d 100644 --- a/Tests/Unit/RequestMapper/RequestMapperTest.php +++ b/Tests/Unit/RequestMapper/RequestMapperTest.php @@ -77,7 +77,7 @@ public function testConvertMethod(string $service, InvokedCountMatcher $expects, $this->converter->map($request, $attribute); } - public function caseProvider(): iterable + public static function caseProvider(): iterable { yield sprintf('%s::%s expects %s, exception %s, expected exception %s', DiscriminatorMapExtractor::class, 'extract', 'once', ClassExtractorException::class, ValidationException::class) => [ 'service' => 'classExtractor', diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2645b8c..204fc1c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -39,14 +39,5 @@ ./RequestMapperBundle.php ./RequestMapperExtension.php - - - - - - - - - diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..869293f --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,10 @@ +sonar.projectKey=fractalzombie_frzb-request-mapper +sonar.organization=fractalzombie +sonar.projectName=frzb-request-mapper +sonar.sources=Attribute,ClassMapper,Data,Event,EventListener,Exception,ExceptionMapper,Extractor,Helper,PropertyMapper,RequestMapper,TypeExtractor +sonar.sourceEncoding=UTF-8 +sonar.tests=Tests +sonar.exclusions=Resources/**,.docker/**,.github/**,vendor/**,Documentation/** +sonar.php.coverage.reportPaths=tests-coverage.xml +sonar.php.tests.reportPath=tests-execution.xml +verbose=true