Skip to content

Commit

Permalink
Merge pull request #151 from Chris53897/feature/migratetravis-to-gh-a…
Browse files Browse the repository at this point in the history
…ctions-phpunit10

feat: migrate travis to gh actions, allow phpunit10
  • Loading branch information
johanwilfer authored Jan 29, 2024
2 parents dd1a444 + d192d6e commit f23eece
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 47 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/code_checks.yaml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
-----------
Expand Down
8 changes: 7 additions & 1 deletion Tests/Form/Type/SimpleMoneyTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author Hugues Maignol <[email protected]>
*/
abstract class AbstractRatioProviderTest extends TestCase
abstract class AbstractRatioProvider extends TestCase
{
/**
* The currently tested RatioProvider.
Expand Down
2 changes: 1 addition & 1 deletion Tests/Pair/RatioProvider/ECBRatioProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Pair/RatioProvider/StaticRatioProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Twig/Extension/CurrencyExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Twig/Extension/MoneyExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}"],
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="Tests/bootstrap.php"
colors="true"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd">

<php>
<server name="KERNEL_DIR" value="tests"/>
Expand All @@ -10,7 +12,7 @@

<testsuites>
<testsuite name="TbbcMoneyBundle test suite">
<directory>tests</directory>
<directory>Tests</directory>
</testsuite>
</testsuites>

Expand Down
2 changes: 0 additions & 2 deletions tools/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions tools/composer.json

This file was deleted.

0 comments on commit f23eece

Please sign in to comment.