From 5ba5755b6072e93f08b0fa532ad1448a114cc28c Mon Sep 17 00:00:00 2001 From: Gilles Gauthier Date: Mon, 12 Apr 2021 09:57:08 +0200 Subject: [PATCH] php8 (#341) --- .github/workflows/ci.yml | 59 +++++++++++++++++++ .travis.yml | 41 ------------- Event/Listener/PrepareListener.php | 5 -- .../Event/Listenener/PrepareListenerTest.php | 5 +- .../Doctrine/DoctrineQueryBuilderUpdater.php | 2 +- .../MongodbQueryBuilderUpdaterTest.php | 2 +- Tests/TestCase.php | 2 +- composer.json | 10 ++-- phpunit.xml.dist | 4 -- 9 files changed, 69 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..01a85ac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: "CI Tests" + +on: + pull_request: + push: + +env: + fail-fast: true + PHPUNIT_FLAGS: "-v" + SYMFONY_DEPRECATIONS_HELPER: 40 + +jobs: + build: + runs-on: ${{ matrix.os }} + name: PHP v${{ matrix.php }} with Mongo v${{ matrix.mongodb }} + strategy: + matrix: + include: + - { os: ubuntu-latest, php: 7.3, mongodb: 3.6, symfony: "4.4.*"} + - { os: ubuntu-latest, php: 7.3, mongodb: 3.6, symfony: "5.1.*"} + - { os: ubuntu-latest, php: 7.4, mongodb: 3.6, symfony: "5.2.*"} + - { os: ubuntu-latest, php: 8.0, mongodb: 3.6, symfony: "5.x-dev"} + services: + mongo: + image: mongo:${{ matrix.mongodb }} + ports: + - 27017:27017 + + steps: + - uses: actions/checkout@v2 + - name: "Installing php" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: curl,mbstring,xdebug,mongodb + ini-values: date.timezone="Europe/Paris" + coverage: xdebug + tools: composer + - name: Show PHP version + run: php -v && composer -V + - name: Download Composer cache dependencies from cache + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Install Symfony ${{ matrix.symfony }} + run: composer require symfony/symfony:${{ matrix.symfony }} --no-update + - name: Cache Composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ matrix.os }}-composer- + - name: Install dependencies + run: | + perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json + composer config platform.ext-mongo 1.6.16 + composer require alcaeus/mongo-php-adapter --no-update + composer install --no-interaction + - name: "Run PHPUnit Tests" + run: "composer test" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 98d1080..0000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: php - -dist: trusty - -cache: - directories: - - $HOME/.composer/cache/files - -env: - global: - - MONGO_EXTENSION="mongodb.so" - - COMPOSER_FLAGS="" - -matrix: - fast_finish: true - include: - - php: 7.3 - env: SYMFONY_VERSION=4.3.* - - php: 7.3 - env: SYMFONY_VERSION=4.4.* - - php: 7.3 - env: SYMFONY_VERSION=5.0.* - - php: 7.4 - env: SYMFONY_VERSION=5.1.* - - php: 7.4 - env: SYMFONY_VERSION=5.2.* -services: - - mongodb - -before_install: - - echo "extension = $MONGO_EXTENSION" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - composer config platform.ext-mongo 1.6.16 - - if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi; - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi; - - if ! [[ $TRAVIS_PHP_VERSION =~ ^5 ]]; then composer require alcaeus/mongo-php-adapter --no-update; fi; - -install: composer update --no-interaction - -script: composer test diff --git a/Event/Listener/PrepareListener.php b/Event/Listener/PrepareListener.php index c77deed..f82a070 100644 --- a/Event/Listener/PrepareListener.php +++ b/Event/Listener/PrepareListener.php @@ -20,11 +20,6 @@ class PrepareListener */ protected $encoding; - /** - * @param boolean $value - * @return PrepareListener $this - * @throws \InvalidArgumentException - */ public function setForceCaseInsensitivity($value) { if (!is_bool($value)) { diff --git a/Tests/Event/Listenener/PrepareListenerTest.php b/Tests/Event/Listenener/PrepareListenerTest.php index e88f15e..1ac2615 100644 --- a/Tests/Event/Listenener/PrepareListenerTest.php +++ b/Tests/Event/Listenener/PrepareListenerTest.php @@ -7,9 +7,6 @@ class PrepareListenerTest extends TestCase { - /** - * @expectedException \InvalidArgumentException - */ public function testGetForceCaseInsensitivity() { $listener = new PrepareListener(); @@ -72,6 +69,8 @@ public function testGetForceCaseInsensitivity() $this->assertSame($listener, $listener->setForceCaseInsensitivity(false)); $this->assertFalse($listener->getForceCaseInsensitivity('should not matter here')); + self::expectException(\InvalidArgumentException::class); + $listener->setForceCaseInsensitivity('some string'); } } diff --git a/Tests/Filter/Doctrine/DoctrineQueryBuilderUpdater.php b/Tests/Filter/Doctrine/DoctrineQueryBuilderUpdater.php index d636980..ce6beff 100644 --- a/Tests/Filter/Doctrine/DoctrineQueryBuilderUpdater.php +++ b/Tests/Filter/Doctrine/DoctrineQueryBuilderUpdater.php @@ -26,7 +26,7 @@ abstract class DoctrineQueryBuilderUpdater extends TestCase */ protected $conn; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/Tests/Filter/Doctrine/MongodbQueryBuilderUpdaterTest.php b/Tests/Filter/Doctrine/MongodbQueryBuilderUpdaterTest.php index bf7a30e..791b643 100644 --- a/Tests/Filter/Doctrine/MongodbQueryBuilderUpdaterTest.php +++ b/Tests/Filter/Doctrine/MongodbQueryBuilderUpdaterTest.php @@ -23,7 +23,7 @@ class MongodbQueryBuilderUpdaterTest extends TestCase */ protected $dm; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/Tests/TestCase.php b/Tests/TestCase.php index 41ce8af..b05c224 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -35,7 +35,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase */ protected $formFactory; - public function setUp() + public function setUp(): void { $this->formFactory = $this->getFormFactory(); } diff --git a/composer.json b/composer.json index 04153e7..c456f77 100644 --- a/composer.json +++ b/composer.json @@ -17,16 +17,16 @@ } ], "require": { - "php": ">=7.0", + "php": ">=7.1", "doctrine/orm": "^2.7", - "symfony/form": "^4.0|^5.0", - "symfony/framework-bundle": "^4.0|^5.0" + "symfony/form": "^4.4|^5.1", + "symfony/framework-bundle": "^4.4|^5.1" }, "require-dev": { "doctrine/doctrine-bundle": "^1.8 || ^2.0", "doctrine/mongodb-odm-bundle": "^4.1", - "symfony/phpunit-bridge": "^4.0|^5.0", - "symfony/var-dumper": "^4.0|^5.0" + "symfony/phpunit-bridge": "^4.4|^5.1", + "symfony/var-dumper": "^4.4|^5.1" }, "autoload": { "psr-4": { "Lexik\\Bundle\\FormFilterBundle\\": "" } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 652a020..da6d9ac 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -27,10 +27,6 @@ - - - -