diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml new file mode 100644 index 00000000..b7bfc793 --- /dev/null +++ b/.github/workflows/code_checks.yaml @@ -0,0 +1,86 @@ +name: Code_Checks + +on: ["push", "pull_request"] + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.2'] + stability: [ prefer-stable ] + symfony-version: ['7.0.*'] + include: + - php: '8.0' + symfony-version: 5.4.* + stability: prefer-lowest + - php: '8.0' + symfony-version: 5.4.* + stability: prefer-stable + - php: '8.1' + symfony-version: 6.0.* + stability: prefer-stable + - php: '8.2' + symfony-version: 7.0.* + stability: prefer-stable + - php: '8.3' + symfony-version: 7.0.* + stability: prefer-stable + + name: PHP ${{ matrix.php }} - ${{ matrix.symfony-version }} - ${{ matrix.stability }} + steps: + # basically git clone + - uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.composer/cache/files + key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + # use PHP of specific version + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: pcov, curl + coverage: pcov + + - name: Install dependencies + env: + SYMFONY_REQUIRE: ${{ matrix.symfony-version }} + run: | + composer global config --no-plugins allow-plugins.symfony/flex true + composer global require --no-progress --no-scripts --no-plugins symfony/flex + composer update --no-interaction --prefer-dist + vendor/bin/simple-phpunit install + + - name: Execute tests + env: + SYMFONY_DEPRECATIONS_HELPER: 'weak' + run: vendor/bin/phpunit --coverage-text + + + cs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + coverage: none + - run: | + composer install --no-progress + composer require friendsofphp/php-cs-fixer "^3.48" + vendor/bin/php-cs-fixer + + psalm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + coverage: none + - run: composer install --no-progress + - run: vendor/bin/psalm diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b2a835cb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: php - -matrix: - include: - - php: 8.0 - env: 'HIGHEST_LOWEST="update"' - - php: 8.0 - env: 'HIGHEST_LOWEST="update --prefer-lowest"' - - php: 8.1 - env: 'HIGHEST_LOWEST="update"' - - php: 8.1 - env: 'HIGHEST_LOWEST="update --prefer-lowest"' - fast_finish: true - -before_script: - - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --working-dir=tools - -install: - - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer -n ${HIGHEST_LOWEST-install} --prefer-dist --no-interaction - -script: - - tools/vendor/bin/php-cs-fixer --dry-run --diff - - vendor/bin/psalm - - vendor/bin/phpunit --coverage-text diff --git a/README.md b/README.md index 373bc5a2..4330d6c4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ TbbcMoneyBundle =============== -[![Build Status](https://img.shields.io/travis/TheBigBrainsCompany/TbbcMoneyBundle/master.svg?style=flat-square)](https://travis-ci.org/TheBigBrainsCompany/TbbcMoneyBundle) +[![Build Status](https://github.com/TheBigBrainsCompany/TbbcMoneyBundle/actions/workflows/code_checks.yaml/badge.svg)](https://github.com/TheBigBrainsCompany/TbbcMoneyBundle/actions/workflows/code_checks.yaml) [![PHP](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net) [![Symfony](https://img.shields.io/badge/symfony-%5E4%7C%5E5-green.svg?style=flat-square)](https://symfony.com) [![Downloads](https://img.shields.io/packagist/dt/tbbc/money-bundle.svg?style=flat-square)](https://packagist.org/packages/tbbc/money-bundle/stats) @@ -15,7 +15,7 @@ a Symfony project. This library is based on Fowler's [Money pattern](https://verraes.net/2011/04/fowler-money-pattern-in-php/) -* This bundle is tested and is stable with Symfony 3.4, 4.3, 4.4, 5.0, 6.0 +* This bundle is tested and is stable with Symfony 3.4, 4.3, 4.4, 5.0, 6.0, 7.0 Quick Start ----------- diff --git a/Tests/Form/Type/SimpleMoneyTypeTest.php b/Tests/Form/Type/SimpleMoneyTypeTest.php index 65689bad..bfd0097a 100644 --- a/Tests/Form/Type/SimpleMoneyTypeTest.php +++ b/Tests/Form/Type/SimpleMoneyTypeTest.php @@ -107,7 +107,13 @@ protected function getExtensions(): array $currencies = ['EUR', 'USD']; $referenceCurrency = 'EUR'; - if ('testBindValidDecimals' === $this->getName()) { + # PHPUnit 10 + if (method_exists($this, 'name') && 'testBindValidDecimals' === $this->name()) { + $decimals = 3; + } + + # PHPUnit 9 + if (method_exists($this, 'getName') && 'testBindValidDecimals' === $this->getName()) { $decimals = 3; } diff --git a/Tests/Pair/RatioProvider/AbstractRatioProviderTest.php b/Tests/Pair/RatioProvider/AbstractRatioProvider.php similarity index 97% rename from Tests/Pair/RatioProvider/AbstractRatioProviderTest.php rename to Tests/Pair/RatioProvider/AbstractRatioProvider.php index da967a84..673730df 100644 --- a/Tests/Pair/RatioProvider/AbstractRatioProviderTest.php +++ b/Tests/Pair/RatioProvider/AbstractRatioProvider.php @@ -13,7 +13,7 @@ * * @author Hugues Maignol */ -abstract class AbstractRatioProviderTest extends TestCase +abstract class AbstractRatioProvider extends TestCase { /** * The currently tested RatioProvider. diff --git a/Tests/Pair/RatioProvider/ECBRatioProviderTest.php b/Tests/Pair/RatioProvider/ECBRatioProviderTest.php index a3aef032..4341886a 100644 --- a/Tests/Pair/RatioProvider/ECBRatioProviderTest.php +++ b/Tests/Pair/RatioProvider/ECBRatioProviderTest.php @@ -55,7 +55,7 @@ public function testNotCorrectReferenceCode(): void public function testUnknownCurrency(): void { $this->expectException(MoneyException::class); - $this->expectExceptionMessage('The currency code "" does not exists'); + $this->expectExceptionMessage('The currency code "" does not exist'); $this->ratio->fetchRatio('EUR', ''); } diff --git a/Tests/Pair/RatioProvider/ExchangerAdapterRatioProviderTest.php b/Tests/Pair/RatioProvider/ExchangerAdapterRatioProviderTest.php index 0d83749d..9b0ebba2 100644 --- a/Tests/Pair/RatioProvider/ExchangerAdapterRatioProviderTest.php +++ b/Tests/Pair/RatioProvider/ExchangerAdapterRatioProviderTest.php @@ -11,7 +11,7 @@ use Tbbc\MoneyBundle\Pair\RatioProvider\ExchangerAdapterRatioProvider; use Tbbc\MoneyBundle\Pair\RatioProviderInterface; -class ExchangerAdapterRatioProviderTest extends AbstractRatioProviderTest +class ExchangerAdapterRatioProviderTest extends AbstractRatioProvider { protected function getRatioProvider(): RatioProviderInterface { diff --git a/Tests/Pair/RatioProvider/StaticRatioProviderTest.php b/Tests/Pair/RatioProvider/StaticRatioProviderTest.php index cf5acdf7..ead65bb6 100644 --- a/Tests/Pair/RatioProvider/StaticRatioProviderTest.php +++ b/Tests/Pair/RatioProvider/StaticRatioProviderTest.php @@ -7,7 +7,7 @@ use Tbbc\MoneyBundle\Pair\RatioProvider\StaticRatioProvider; use Tbbc\MoneyBundle\Pair\RatioProviderInterface; -class StaticRatioProviderTest extends AbstractRatioProviderTest +class StaticRatioProviderTest extends AbstractRatioProvider { protected function getRatioProvider(): RatioProviderInterface { diff --git a/Tests/Twig/Extension/CurrencyExtensionTest.php b/Tests/Twig/Extension/CurrencyExtensionTest.php index 33f8da1c..3e0b00f6 100644 --- a/Tests/Twig/Extension/CurrencyExtensionTest.php +++ b/Tests/Twig/Extension/CurrencyExtensionTest.php @@ -38,7 +38,7 @@ public function testCurrency($template, $expected): void $this->assertSame($expected, $this->getTemplate($template)->render($this->variables)); } - public function getCurrencyTests(): array + public static function getCurrencyTests(): array { return [ ['{{ currency|currency_name }}', 'EUR'], diff --git a/Tests/Twig/Extension/MoneyExtensionTest.php b/Tests/Twig/Extension/MoneyExtensionTest.php index 0a9d2094..30fc68af 100644 --- a/Tests/Twig/Extension/MoneyExtensionTest.php +++ b/Tests/Twig/Extension/MoneyExtensionTest.php @@ -60,7 +60,7 @@ public function testMoney($template, $expected): void $this->assertSame($expected, $this->getTemplate($template)->render($this->variables)); } - public function getMoneyTests(): array + public static function getMoneyTests(): array { return [ ['{{ price|money_localized_format }}', "1\u{202f}234\u{202f}567,89\u{a0}€"], diff --git a/composer.json b/composer.json index 1b7544c2..ad1ea7ed 100644 --- a/composer.json +++ b/composer.json @@ -44,20 +44,19 @@ "florianv/exchanger": "^2.0", "php-http/message": "^1.0", "php-http/guzzle6-adapter": "^2.0", - "vimeo/psalm": "^4.13", + "vimeo/psalm": "^4.13 | ^5.20", "symfony/phpunit-bridge": "^5.4|^6.0|^7.0", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^9.6|^10.5", "symfony/yaml": "^5.4|^6.0|^7.0", "http-interop/http-factory-guzzle": "^1.2" }, "autoload-dev": { "psr-4": { - "Tbbc\\MoneyBundle\\Tests\\": "tests" + "Tbbc\\MoneyBundle\\Tests\\": "Tests" } }, "scripts": { "fix": [ - "tools/vendor/bin/php-cs-fixer fix", "vendor/bin/psalm", "vendor/bin/phpunit --coverage-text --coverage-html=.build" ] diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7bda8476..aebb4556 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,8 @@ - + @@ -10,7 +12,7 @@ - tests + Tests diff --git a/tools/.gitignore b/tools/.gitignore deleted file mode 100644 index 88e99d50..00000000 --- a/tools/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor -composer.lock \ No newline at end of file diff --git a/tools/composer.json b/tools/composer.json deleted file mode 100644 index f0b7eda0..00000000 --- a/tools/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "friendsofphp/php-cs-fixer": "^3.4" - } -}