diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..caff1b0c7
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,169 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ static_analysis:
+ name: Static analysis
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: technote-space/get-diff-action@v6
+ with:
+ PATTERNS: |
+ pkg/**/*.php
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.2'
+ coverage: none
+ extensions: mongodb, redis, :xdebug
+ ini-values: memory_limit=2048M
+
+ - run: php ./bin/fix-symfony-version.php "5.4.*"
+
+ - uses: "ramsey/composer-install@v3"
+
+ - run: sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php
+
+ - run: cd docker && docker build --rm --force-rm --no-cache --pull --tag "enqueue/dev:latest" -f Dockerfile .
+ - run: docker run --workdir="/mqdev" -v "`pwd`:/mqdev" --rm enqueue/dev:latest php -d memory_limit=1024M bin/phpstan analyse -l 1 -c phpstan.neon --error-format=github -- ${{ env.GIT_DIFF_FILTERED }}
+ if: env.GIT_DIFF_FILTERED
+
+ code_style_check:
+ name: Code style check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: technote-space/get-diff-action@v6
+ with:
+ PATTERNS: |
+ pkg/**/*.php
+
+ - name: Get Composer Cache Directory
+ id: composer-cache
+ run: |
+ echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+ - uses: actions/cache@v4
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: composer-cs-check-${{ hashFiles('**/composer.json') }}
+ restore-keys: |
+ composer-cs-check-
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.2'
+ coverage: none
+ extensions: mongodb, redis, :xdebug
+ ini-values: memory_limit=2048M
+
+ - run: php ./bin/fix-symfony-version.php "5.4.*"
+
+ - run: composer update --no-progress
+
+ - run: sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php
+
+ - run: ./bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --no-interaction --dry-run --diff -v --path-mode=intersection -- ${{ env.GIT_DIFF_FILTERED }}
+ if: env.GIT_DIFF_FILTERED
+
+ unit_tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['8.1', '8.2']
+ symfony_version: ['6.2.*', '6.3.*', '6.4.*', '7.0.*']
+ dependencies: ['--prefer-lowest', '--prefer-dist']
+ exclude:
+ - php: '8.1'
+ symfony_version: '7.0.*'
+
+ name: PHP ${{ matrix.php }} unit tests on Sf ${{ matrix.symfony_version }}, deps=${{ matrix.dependencies }}
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Get Composer Cache Directory
+ id: composer-cache
+ run: |
+ echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+ - uses: actions/cache@v4
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: composer-${{ matrix.php }}-${{ matrix.symfony_version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
+ restore-keys: |
+ composer-${{ matrix.php }}-${{ matrix.symfony_version }}-${{ matrix.dependencies }}-
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+ extensions: mongodb, redis, :xdebug
+ ini-values: memory_limit=2048M
+
+ - run: php ./bin/fix-symfony-version.php "${{ matrix.symfony_version }}"
+
+ - run: composer update --no-progress ${{ matrix.dependencies }}
+
+ - run: sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php
+
+ - run: bin/phpunit --exclude-group=functional
+
+ functional_tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: [ '8.1', '8.2' ]
+ symfony_version: [ '6.4.*', '7.0.*', '7.1.*', '7.2.*' ]
+ dependencies: [ '--prefer-lowest', '--prefer-dist' ]
+ exclude:
+ - php: '8.1'
+ symfony_version: '7.0.*'
+ - php: '8.1'
+ symfony_version: '7.1.*'
+ - php: '8.1'
+ symfony_version: '7.2.*'
+
+ name: PHP ${{ matrix.php }} functional tests on Sf ${{ matrix.symfony_version }}, deps=${{ matrix.dependencies }}
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Get Composer Cache Directory
+ id: composer-cache
+ run: |
+ echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+ - uses: actions/cache@v4
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: composer-${{ matrix.php }}-${{ matrix.symfony_version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
+ restore-keys: |
+ composer-${{ matrix.php }}-${{ matrix.symfony_version }}-${{ matrix.dependencies }}-
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+ extensions: mongodb, redis, :xdebug
+ ini-values: memory_limit=2048M
+
+ - run: php ./bin/fix-symfony-version.php "${{ matrix.symfony_version }}"
+
+ - run: composer update --no-progress ${{ matrix.dependencies }}
+
+ - run: sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php
+
+ - run: bin/dev -b
+ env:
+ PHP_VERSION: ${{ matrix.php }}
+
+ - run: bin/test.sh --group=functional
diff --git a/.gitignore b/.gitignore
index 2bd575f69..7a2e2ec9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,19 +1,21 @@
*~
/.idea/
bin/doctrine*
-bin/php-cs-fixer
-bin/phpunit
-bin/sql-formatter
-bin/phpstan
-bin/jp.php
-bin/php-parse
-bin/google-cloud-batch
+bin/php-cs-fixer*
+bin/phpunit*
+bin/sql-formatter*
+bin/phpstan*
+bin/jp.php*
+bin/php-parse*
+bin/google-cloud-batch*
+bin/patch-type-declarations*
bin/thruway
-bin/phpstan.phar
-bin/var-dump-server
-bin/yaml-lint
+bin/var-dump-server*
+bin/yaml-lint*
vendor
var
.php_cs
.php_cs.cache
composer.lock
+.phpunit.result.cache
+.php-cs-fixer.cache
diff --git a/.php_cs.php b/.php-cs-fixer.dist.php
similarity index 64%
rename from .php_cs.php
rename to .php-cs-fixer.dist.php
index e28581304..b9316b59b 100644
--- a/.php_cs.php
+++ b/.php-cs-fixer.dist.php
@@ -1,6 +1,7 @@
setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
@@ -8,9 +9,13 @@
'array_syntax' => array('syntax' => 'short'),
'combine_consecutive_unsets' => true,
// one should use PHPUnit methods to set up expected exception instead of annotations
- 'general_phpdoc_annotation_remove' => array('expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'),
+ 'general_phpdoc_annotation_remove' => ['annotations' =>
+ ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']
+ ],
'heredoc_to_nowdoc' => true,
- 'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'),
+ 'no_extra_blank_lines' => ['tokens' => [
+ 'break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']
+ ],
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
@@ -18,7 +23,7 @@
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
- 'psr4' => true,
+ 'psr_autoloading' => true,
'strict_param' => true,
'native_function_invocation' => false,
))
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 7c3c68762..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,91 +0,0 @@
-git:
- depth: 10
-
-language: php
-dist: bionic
-
-matrix:
- include:
- - php: 7.1
- sudo: false
- env: SYMFONY_VERSION=4.3.* PHPSTAN=true
- - php: 7.1
- sudo: false
- env: SYMFONY_VERSION=4.3.* PHP_CS_FIXER=true
- - php: 7.1
- sudo: false
- env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true
- - php: 7.2
- sudo: false
- env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true
- - php: 7.2
- sudo: false
- env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true
- - php: 7.3
- sudo: false
- env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true
- - php: 7.3
- sudo: false
- env: SYMFONY_VERSION=4.4.* UNIT_TESTS=true
- - php: 7.3
- sudo: false
- env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true
- - php: 7.4
- sudo: false
- env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true
- - php: 7.4
- sudo: false
- env: SYMFONY_VERSION=4.4.* UNIT_TESTS=true
- - php: 7.4
- sudo: false
- env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true
- - php: 7.1
- sudo: required
- services: docker
- env: SYMFONY_VERSION=4.3.* FUNCTIONAL_TESTS=true PREPARE_CONTAINER=true
- - php: 7.3
- sudo: required
- services: docker
- env: SYMFONY_VERSION=5.0.* FUNCTIONAL_TESTS=true PREPARE_CONTAINER=true
- - php: 7.1
- sudo: required
- services: docker
- env: SYMFONY_VERSION=4.3.* RDKAFKA_TESTS=true PREPARE_CONTAINER=true
- allow_failures:
- - env: SYMFONY_VERSION=4.3.* RDKAFKA_TESTS=true PREPARE_CONTAINER=true
-
-cache:
- directories:
- - $HOME/.composer/cache
- - $HOME/php-cs-fixer
-
-before_install:
- - echo "extension = mongodb.so" >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- - echo "extension = redis.so" >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-
-install:
- - rm $HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini;
- - echo "memory_limit=2048M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- - php ./bin/fix-symfony-version.php "$SYMFONY_VERSION"
- - composer install
- - sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php
- - if [ "$PREPARE_CONTAINER" = true ]; then docker --version; fi
- - if [ "$PREPARE_CONTAINER" = true ]; then docker-compose --version; fi
- - if [ "$PREPARE_CONTAINER" = true ]; then bin/dev -b; fi
-
-script:
- - PKG_PHP_CHANGED_FILES=`./bin/git-find-changed-php-files.sh "${TRAVIS_COMMIT_RANGE}"`
- - if [ "$PHP_CS_FIXER" = true ] && [ ! -z "${PKG_PHP_CHANGED_FILES}" ]; then ./bin/php-cs-fixer fix --config=.php_cs.php --no-interaction --dry-run --diff -v --path-mode=intersection -- ${PKG_PHP_CHANGED_FILES[@]} ; fi
- - if [ "$PHPSTAN" = true ] && [ ! -z "${PKG_PHP_CHANGED_FILES}" ]; then docker run --workdir="/mqdev" -v "`pwd`:/mqdev" --rm enqueue/dev:latest php -d memory_limit=1024M bin/phpstan analyse -l 1 -c phpstan.neon -- ${PKG_PHP_CHANGED_FILES[@]} ; fi
- - if [ "$UNIT_TESTS" = true ]; then bin/phpunit --exclude-group=functional; fi
- - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/test.sh --exclude-group=rdkafka; fi
- - if [ "$RDKAFKA_TESTS" = true ]; then bin/test.sh --group=rdkafka; fi
-
-notifications:
- webhooks:
- urls:
- - https://webhooks.gitter.im/e/3f8b3668e7792de23a49
- on_success: change
- on_failure: always
- on_start: never
-
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19683ca8c..fe4ddabbd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,208 @@
# Change Log
+## [0.10.26](https://github.com/php-enqueue/enqueue-dev/tree/0.10.26) (2025-05-10)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.25...0.10.26)
+
+**Merged pull requests:**
+
+- Fix: Updating composer [\#1383](https://github.com/php-enqueue/enqueue-dev/pull/1383) ([JimTools](https://github.com/JimTools))
+- Fix: Fixing CI [\#1382](https://github.com/php-enqueue/enqueue-dev/pull/1382) ([JimTools](https://github.com/JimTools))
+
+## [0.10.25](https://github.com/php-enqueue/enqueue-dev/tree/0.10.25) (2025-04-18)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.24...0.10.25)
+
+**Merged pull requests:**
+
+- Bugfix/static drift [\#1373](https://github.com/php-enqueue/enqueue-dev/pull/1373) ([JimTools](https://github.com/JimTools))
+- CS Fixes [\#1372](https://github.com/php-enqueue/enqueue-dev/pull/1372) ([JimTools](https://github.com/JimTools))
+- Fixing risky tests [\#1371](https://github.com/php-enqueue/enqueue-dev/pull/1371) ([JimTools](https://github.com/JimTools))
+
+## [0.10.24](https://github.com/php-enqueue/enqueue-dev/tree/0.10.24) (2024-11-30)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.23...0.10.24)
+
+**Merged pull requests:**
+
+- SF7 deprecations fix [\#1364](https://github.com/php-enqueue/enqueue-dev/pull/1364) ([zavitkov](https://github.com/zavitkov))
+- add symfony 7 support for enqueue-bundle [\#1362](https://github.com/php-enqueue/enqueue-dev/pull/1362) ([zavitkov](https://github.com/zavitkov))
+
+## [0.10.23](https://github.com/php-enqueue/enqueue-dev/tree/0.10.23) (2024-10-01)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.22...0.10.23)
+
+**Merged pull requests:**
+
+- Drop useless call to end method [\#1359](https://github.com/php-enqueue/enqueue-dev/pull/1359) ([ddziaduch](https://github.com/ddziaduch))
+
+## [0.10.22](https://github.com/php-enqueue/enqueue-dev/tree/0.10.22) (2024-08-13)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.21...0.10.22)
+
+**Merged pull requests:**
+
+- GPS: revert the attributes and use the headers instead. [\#1355](https://github.com/php-enqueue/enqueue-dev/pull/1355) ([p-pichet](https://github.com/p-pichet))
+
+## [0.10.21](https://github.com/php-enqueue/enqueue-dev/tree/0.10.21) (2024-08-12)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.20...0.10.21)
+
+**Merged pull requests:**
+
+- feat\(GPS\): allow send attributes in Google PubSub message. [\#1349](https://github.com/php-enqueue/enqueue-dev/pull/1349) ([p-pichet](https://github.com/p-pichet))
+
+## [0.10.19](https://github.com/php-enqueue/enqueue-dev/tree/0.10.19) (2023-07-15)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.18...0.10.19)
+
+**Merged pull requests:**
+
+- fix: do not reset attemps header when message is requeue [\#1301](https://github.com/php-enqueue/enqueue-dev/pull/1301) ([eortiz-tracktik](https://github.com/eortiz-tracktik))
+- Allow doctrine/persistence 3.1 version [\#1300](https://github.com/php-enqueue/enqueue-dev/pull/1300) ([xNarkon](https://github.com/xNarkon))
+- Add support for rediss and phpredis [\#1297](https://github.com/php-enqueue/enqueue-dev/pull/1297) ([splagemann](https://github.com/splagemann))
+- Replaced `json\_array` with `json` due to Doctrine Dbal 3.0 [\#1294](https://github.com/php-enqueue/enqueue-dev/pull/1294) ([NovakHonza](https://github.com/NovakHonza))
+- pkg PHP 8.1 and 8.2 support [\#1292](https://github.com/php-enqueue/enqueue-dev/pull/1292) ([snapshotpl](https://github.com/snapshotpl))
+- Update doctrine/persistence [\#1290](https://github.com/php-enqueue/enqueue-dev/pull/1290) ([jlabedo](https://github.com/jlabedo))
+- Add PHP 8.1 and 8.2, Symfony 6.2 to CI [\#1285](https://github.com/php-enqueue/enqueue-dev/pull/1285) ([andrewmy](https://github.com/andrewmy))
+- \[SNSQS\] added possibility to send FIFO-related parameters using snsqs transport [\#1278](https://github.com/php-enqueue/enqueue-dev/pull/1278) ([onatskyy](https://github.com/onatskyy))
+
+## [0.10.18](https://github.com/php-enqueue/enqueue-dev/tree/0.10.18) (2023-03-18)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.17...0.10.18)
+
+**Merged pull requests:**
+
+- Fix Shield URLs in READMEs [\#1289](https://github.com/php-enqueue/enqueue-dev/pull/1289) ([amayer5125](https://github.com/amayer5125))
+- Fix AWS SDK token parameter [\#1284](https://github.com/php-enqueue/enqueue-dev/pull/1284) ([andrewmy](https://github.com/andrewmy))
+- MongoDB - Add combined index [\#1283](https://github.com/php-enqueue/enqueue-dev/pull/1283) ([ddziaduch](https://github.com/ddziaduch))
+- Add setting subscription attributes to Sns and SnsQs [\#1281](https://github.com/php-enqueue/enqueue-dev/pull/1281) ([andrewmy](https://github.com/andrewmy))
+- code style fix \(native\_constant\_invocation\) [\#1276](https://github.com/php-enqueue/enqueue-dev/pull/1276) ([EmilMassey](https://github.com/EmilMassey))
+- \[amqp-lib\] Replace amqp-lib deprecated public property with getters [\#1273](https://github.com/php-enqueue/enqueue-dev/pull/1273) ([ramunasd](https://github.com/ramunasd))
+- fix: parenthesis missing allowed invalid delays [\#1266](https://github.com/php-enqueue/enqueue-dev/pull/1266) ([aldenw](https://github.com/aldenw))
+- Allow rdkafka falsy keys [\#1264](https://github.com/php-enqueue/enqueue-dev/pull/1264) ([qkdreyer](https://github.com/qkdreyer))
+- Symfony config allow null [\#1263](https://github.com/php-enqueue/enqueue-dev/pull/1263) ([h0raz](https://github.com/h0raz))
+- Ensure pass consumer tag as string to bunny amqp [\#1255](https://github.com/php-enqueue/enqueue-dev/pull/1255) ([snapshotpl](https://github.com/snapshotpl))
+- chore: Update dependency dbal [\#1253](https://github.com/php-enqueue/enqueue-dev/pull/1253) ([meidlinga](https://github.com/meidlinga))
+
+## [0.10.17](https://github.com/php-enqueue/enqueue-dev/tree/0.10.17) (2022-05-17)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.16...0.10.17)
+
+**Merged pull requests:**
+
+- Disable sleep while queue items available [\#1250](https://github.com/php-enqueue/enqueue-dev/pull/1250) ([mordilion](https://github.com/mordilion))
+
+## [0.10.16](https://github.com/php-enqueue/enqueue-dev/tree/0.10.16) (2022-04-28)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.15...0.10.16)
+
+**Merged pull requests:**
+
+- Upgrade ext-rdkafka to 6.0 [\#1241](https://github.com/php-enqueue/enqueue-dev/pull/1241) ([lucasrivoiro](https://github.com/lucasrivoiro))
+- Replace rabbitmq-management-api with a packagist source and fixed small github actions typo [\#1240](https://github.com/php-enqueue/enqueue-dev/pull/1240) ([oreillysean](https://github.com/oreillysean))
+- Add support for Symfony 6; drop \< 5.1 [\#1239](https://github.com/php-enqueue/enqueue-dev/pull/1239) ([andrewmy](https://github.com/andrewmy))
+- Replace rabbitmq-management-api with a packagist source [\#1238](https://github.com/php-enqueue/enqueue-dev/pull/1238) ([andrewmy](https://github.com/andrewmy))
+- Fix CI [\#1237](https://github.com/php-enqueue/enqueue-dev/pull/1237) ([jdecool](https://github.com/jdecool))
+- Allow ext-rdkafka 6 usage [\#1233](https://github.com/php-enqueue/enqueue-dev/pull/1233) ([jdecool](https://github.com/jdecool))
+- Fix types for Symfony 5.4 [\#1225](https://github.com/php-enqueue/enqueue-dev/pull/1225) ([shyim](https://github.com/shyim))
+
+## [0.10.15](https://github.com/php-enqueue/enqueue-dev/tree/0.10.15) (2021-12-11)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.14...0.10.15)
+
+**Merged pull requests:**
+
+- feat\(snsqs\): allow client http configuration for sns and sqs [\#1216](https://github.com/php-enqueue/enqueue-dev/pull/1216) ([eortiz-tracktik](https://github.com/eortiz-tracktik))
+- Add FIFO logic to SNS [\#1214](https://github.com/php-enqueue/enqueue-dev/pull/1214) ([kate-simozhenko](https://github.com/kate-simozhenko))
+- Fix falling tests [\#1211](https://github.com/php-enqueue/enqueue-dev/pull/1211) ([snapshotpl](https://github.com/snapshotpl))
+- RdKafka; Replace composer-modifying for testing with --ignore-platform-req argument [\#1210](https://github.com/php-enqueue/enqueue-dev/pull/1210) ([maartenderie](https://github.com/maartenderie))
+- Allow psr/container v2 [\#1206](https://github.com/php-enqueue/enqueue-dev/pull/1206) ([ADmad](https://github.com/ADmad))
+
+## [0.10.14](https://github.com/php-enqueue/enqueue-dev/tree/0.10.14) (2021-10-29)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.13...0.10.14)
+
+**Merged pull requests:**
+
+- Fix passed parameters for compatibility with newest version of dbal [\#1203](https://github.com/php-enqueue/enqueue-dev/pull/1203) ([dgafka](https://github.com/dgafka))
+- Allow psr/log v2 and v3 [\#1198](https://github.com/php-enqueue/enqueue-dev/pull/1198) ([snapshotpl](https://github.com/snapshotpl))
+- Fix partition's choice for the cases when partition number is zero [\#1196](https://github.com/php-enqueue/enqueue-dev/pull/1196) ([rodrigosarmentopicpay](https://github.com/rodrigosarmentopicpay))
+- Added getter for offset field in RdKafkaConsumer class [\#1184](https://github.com/php-enqueue/enqueue-dev/pull/1184) ([DigitVE](https://github.com/DigitVE))
+
+## [0.10.13](https://github.com/php-enqueue/enqueue-dev/tree/0.10.13) (2021-08-25)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.12...0.10.13)
+
+**Merged pull requests:**
+
+- \[SNSQS\] added possibility to send message attributes using snsqs transport [\#1195](https://github.com/php-enqueue/enqueue-dev/pull/1195) ([onatskyy](https://github.com/onatskyy))
+- Add in missing arg [\#1194](https://github.com/php-enqueue/enqueue-dev/pull/1194) ([gdsmith](https://github.com/gdsmith))
+- \#1190 add index on delivery\_id to prevent slow queries [\#1191](https://github.com/php-enqueue/enqueue-dev/pull/1191) ([commercewerft](https://github.com/commercewerft))
+- Add setTopicArn methods to SnsContext and SnsQsContext [\#1189](https://github.com/php-enqueue/enqueue-dev/pull/1189) ([gdsmith](https://github.com/gdsmith))
+
+## [0.10.11](https://github.com/php-enqueue/enqueue-dev/tree/0.10.11) (2021-04-28)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.10...0.10.11)
+
+**Merged pull requests:**
+
+- Perform at least once delivery when rejecting with requeue [\#1165](https://github.com/php-enqueue/enqueue-dev/pull/1165) ([dgafka](https://github.com/dgafka))
+- Fix dbal delivery delay to always keep integer value [\#1161](https://github.com/php-enqueue/enqueue-dev/pull/1161) ([dgafka](https://github.com/dgafka))
+- Add SqsConsumer methods to SnsQsConsumer [\#1160](https://github.com/php-enqueue/enqueue-dev/pull/1160) ([gdsmith](https://github.com/gdsmith))
+- add subscription\_interval as config for dbal subscription consumer [\#1159](https://github.com/php-enqueue/enqueue-dev/pull/1159) ([mordilion](https://github.com/mordilion))
+- register worker callback only once, move to constructor [\#1157](https://github.com/php-enqueue/enqueue-dev/pull/1157) ([cturbelin](https://github.com/cturbelin))
+- Try to change doctrine/orm version for supporting 2.8 \(PHP 8 support\). [\#1155](https://github.com/php-enqueue/enqueue-dev/pull/1155) ([GothShoot](https://github.com/GothShoot))
+- sns context - fallback for not breaking BC with 10.10 previous versions [\#1149](https://github.com/php-enqueue/enqueue-dev/pull/1149) ([bafor](https://github.com/bafor))
+
+## [0.10.10](https://github.com/php-enqueue/enqueue-dev/tree/0.10.10) (2021-03-24)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.9...0.10.10)
+
+**Merged pull requests:**
+
+- \[sns\] added possibility to define already existing topics \(prevent create topic call\) \#1022 [\#1147](https://github.com/php-enqueue/enqueue-dev/pull/1147) ([paramonov](https://github.com/paramonov))
+- \[gps\] Add support for consuming message from external publisher in non-standard format [\#1118](https://github.com/php-enqueue/enqueue-dev/pull/1118) ([maciejzgadzaj](https://github.com/maciejzgadzaj))
+
+## [0.10.9](https://github.com/php-enqueue/enqueue-dev/tree/0.10.9) (2021-03-17)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.8...0.10.9)
+
+**Merged pull requests:**
+
+- Upgrade php-amqplib to v3.0 [\#1146](https://github.com/php-enqueue/enqueue-dev/pull/1146) ([masterjus](https://github.com/masterjus))
+- Split tests into different matrices; fix highest/lowest dependencies [\#1139](https://github.com/php-enqueue/enqueue-dev/pull/1139) ([andrewmy](https://github.com/andrewmy))
+
+## [0.10.8](https://github.com/php-enqueue/enqueue-dev/tree/0.10.8) (2021-02-17)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.7...0.10.8)
+
+**Merged pull requests:**
+
+- Fix package CI [\#1138](https://github.com/php-enqueue/enqueue-dev/pull/1138) ([andrewmy](https://github.com/andrewmy))
+- add sns driver + use profile to establish connection [\#1134](https://github.com/php-enqueue/enqueue-dev/pull/1134) ([fbaudry](https://github.com/fbaudry))
+- Add PHP 8 [\#1132](https://github.com/php-enqueue/enqueue-dev/pull/1132) ([andrewmy](https://github.com/andrewmy))
+
+## [0.10.7](https://github.com/php-enqueue/enqueue-dev/tree/0.10.7) (2021-02-03)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.6...0.10.7)
+
+**Merged pull requests:**
+
+- PHPUnit 9.5 [\#1131](https://github.com/php-enqueue/enqueue-dev/pull/1131) ([andrewmy](https://github.com/andrewmy))
+- Fix the build matrix [\#1130](https://github.com/php-enqueue/enqueue-dev/pull/1130) ([andrewmy](https://github.com/andrewmy))
+- Disable Travis CI [\#1129](https://github.com/php-enqueue/enqueue-dev/pull/1129) ([makasim](https://github.com/makasim))
+- Add GitHub Action CI [\#1127](https://github.com/php-enqueue/enqueue-dev/pull/1127) ([andrewmy](https://github.com/andrewmy))
+- Allow ext-rdkafka 5 [\#1126](https://github.com/php-enqueue/enqueue-dev/pull/1126) ([andrewmy](https://github.com/andrewmy))
+- Fix - Bad parameter for exception [\#1124](https://github.com/php-enqueue/enqueue-dev/pull/1124) ([atrauzzi](https://github.com/atrauzzi))
+- \[fix\] queue consumption: catch throwable for processing errors [\#1114](https://github.com/php-enqueue/enqueue-dev/pull/1114) ([macghriogair](https://github.com/macghriogair))
+- Ramsey dependency removed in favor to \Enqueue\Util\UUID::generate [\#1110](https://github.com/php-enqueue/enqueue-dev/pull/1110) ([inri13666](https://github.com/inri13666))
+- Added: ability to choose different entity manager [\#1081](https://github.com/php-enqueue/enqueue-dev/pull/1081) ([balabis](https://github.com/balabis))
+
+## [0.10.6](https://github.com/php-enqueue/enqueue-dev/tree/0.10.6) (2020-10-16)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.5...0.10.6)
+
+**Merged pull requests:**
+
+- fixing issue \#1085 [\#1105](https://github.com/php-enqueue/enqueue-dev/pull/1105) ([nivpenso](https://github.com/nivpenso))
+- Fix DoctrineConnectionFactoryFactory due to doctrine/common changes [\#1089](https://github.com/php-enqueue/enqueue-dev/pull/1089) ([kdefives](https://github.com/kdefives))
+
+## [0.10.5](https://github.com/php-enqueue/enqueue-dev/tree/0.10.5) (2020-10-09)
+[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.4...0.10.5)
+
+**Merged pull requests:**
+
+- update image [\#1104](https://github.com/php-enqueue/enqueue-dev/pull/1104) ([nick-zh](https://github.com/nick-zh))
+- \[rdkafka\]use supported librdkafka version of ext [\#1103](https://github.com/php-enqueue/enqueue-dev/pull/1103) ([nick-zh](https://github.com/nick-zh))
+- \[rdkafka\] add non-blocking poll call to serve cb's [\#1102](https://github.com/php-enqueue/enqueue-dev/pull/1102) ([nick-zh](https://github.com/nick-zh))
+- \[rdkafka\] remove topic conf, deprecated [\#1101](https://github.com/php-enqueue/enqueue-dev/pull/1101) ([nick-zh](https://github.com/nick-zh))
+- \[stomp\] Fix - Add automatic reconnect support for STOMP producers [\#1099](https://github.com/php-enqueue/enqueue-dev/pull/1099) ([atrauzzi](https://github.com/atrauzzi))
+- fix localstack version \(one that worked\) [\#1094](https://github.com/php-enqueue/enqueue-dev/pull/1094) ([makasim](https://github.com/makasim))
+- Allow false-y values for unsupported options [\#1093](https://github.com/php-enqueue/enqueue-dev/pull/1093) ([atrauzzi](https://github.com/atrauzzi))
+- Lock doctrine perisistence version. Fix tests. [\#1092](https://github.com/php-enqueue/enqueue-dev/pull/1092) ([makasim](https://github.com/makasim))
+
## [0.10.4](https://github.com/php-enqueue/enqueue-dev/tree/0.10.4) (2020-09-24)
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.3...0.10.4)
diff --git a/README.md b/README.md
index 1d1cccb5f..5e0dacec3 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
+[](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
+

-
+
@@ -30,71 +32,71 @@ Features:
* Battle-tested. Used in production.
* Supported transports
* [AMQP(s)](https://php-enqueue.github.io/transport/amqp/) based on [PHP AMQP extension](https://github.com/pdezwart/php-amqp)
-[](https://travis-ci.org/php-enqueue/amqp-ext)
+[](https://github.com/php-enqueue/amqp-ext/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/amqp-ext/stats)
[](https://packagist.org/packages/enqueue/amqp-ext)
* [AMQP](https://php-enqueue.github.io/transport/amqp_bunny/) based on [bunny](https://github.com/jakubkulhan/bunny)
-[](https://travis-ci.org/php-enqueue/amqp-bunny)
+[](https://github.com/php-enqueue/amqp-bunny/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/amqp-bunny/stats)
[](https://packagist.org/packages/enqueue/amqp-bunny)
* [AMQP(s)](https://php-enqueue.github.io/transport/amqp_lib/) based on [php-amqplib](https://github.com/php-amqplib/php-amqplib)
-[](https://travis-ci.org/php-enqueue/amqp-lib)
+[](https://github.com/php-enqueue/amqp-lib/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/amqp-lib/stats)
[](https://packagist.org/packages/enqueue/amqp-lib)
* [Beanstalk](https://php-enqueue.github.io/transport/pheanstalk/)
-[](https://travis-ci.org/php-enqueue/pheanstalk)
+[](https://github.com/php-enqueue/pheanstalk/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/pheanstalk/stats)
[](https://packagist.org/packages/enqueue/pheanstalk)
* [STOMP](https://php-enqueue.github.io/transport/stomp/)
-[](https://travis-ci.org/php-enqueue/stomp)
+[](https://github.com/php-enqueue/stomp/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/stomp/stats)
[](https://packagist.org/packages/enqueue/stomp)
* [Amazon SQS](https://php-enqueue.github.io/transport/sqs/)
-[](https://travis-ci.org/php-enqueue/sqs)
+[](https://github.com/php-enqueue/sqs/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/sqs/stats)
[](https://packagist.org/packages/enqueue/sqs)
* [Amazon SNS](https://php-enqueue.github.io/transport/sns/)
-[](https://travis-ci.org/php-enqueue/sns)
+[](https://github.com/php-enqueue/sns/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/sns/stats)
[](https://packagist.org/packages/enqueue/sns)
* [Amazon SNS\SQS](https://php-enqueue.github.io/transport/snsqs/)
-[](https://travis-ci.org/php-enqueue/snsqs)
+[](https://github.com/php-enqueue/snsqs/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/snsqs/stats)
[](https://packagist.org/packages/enqueue/snsqs)
* [Google PubSub](https://php-enqueue.github.io/transport/gps/)
-[](https://travis-ci.org/php-enqueue/gps)
+[](https://github.com/php-enqueue/gps/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/gps/stats)
[](https://packagist.org/packages/enqueue/gps)
* [Kafka](https://php-enqueue.github.io/transport/kafka/)
-[](https://travis-ci.org/php-enqueue/rdkafka)
+[](https://github.com/php-enqueue/rdkafka/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/rdkafka/stats)
[](https://packagist.org/packages/enqueue/rdkafka)
* [Redis](https://php-enqueue.github.io/transport/redis/)
-[](https://travis-ci.org/php-enqueue/redis)
+[](https://github.com/php-enqueue/redis/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/redis/stats)
[](https://packagist.org/packages/enqueue/redis)
* [Gearman](https://php-enqueue.github.io/transport/gearman/)
-[](https://travis-ci.org/php-enqueue/gearman)
+[](https://github.com/php-enqueue/gearman/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/gearman/stats)
[](https://packagist.org/packages/enqueue/gearman)
* [Doctrine DBAL](https://php-enqueue.github.io/transport/dbal/)
-[](https://travis-ci.org/php-enqueue/dbal)
+[](https://github.com/php-enqueue/dbal/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/dbal/stats)
[](https://packagist.org/packages/enqueue/dbal)
* [Filesystem](https://php-enqueue.github.io/transport/filesystem/)
-[](https://travis-ci.org/php-enqueue/fs)
+[](https://github.com/php-enqueue/fs/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/fs/stats)
[](https://packagist.org/packages/enqueue/fs)
* [Mongodb](https://php-enqueue.github.io/transport/mongodb/)
-[](https://travis-ci.org/php-enqueue/mongodb)
+[](https://github.com/php-enqueue/mongodb/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/mongodb/stats)
[](https://packagist.org/packages/enqueue/mongodb)
* [WAMP](https://php-enqueue.github.io/transport/wamp/)
-[](https://travis-ci.org/php-enqueue/wamp)
+[](https://github.com/php-enqueue/wamp/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/wamp/stats)
[](https://packagist.org/packages/enqueue/wamp)
* [Null](https://php-enqueue.github.io/transport/null/)
-[](https://travis-ci.org/php-enqueue/null)
+[](https://github.com/php-enqueue/null/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/null/stats)
[](https://packagist.org/packages/enqueue/null)
* [the others are coming](https://github.com/php-enqueue/enqueue-dev/issues/284)
diff --git a/bin/changelog b/bin/changelog
index 8a9296175..ba2db0813 100755
--- a/bin/changelog
+++ b/bin/changelog
@@ -8,6 +8,6 @@ then
exit 1
fi
-docker-compose run -e CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN:-""} --workdir="/mqdev" --rm generate-changelog github_changelog_generator --future-release "$1" --no-issues --unreleased-only --output "CHANGELOG_FUTURE.md"
+docker compose run -e CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN:-""} --workdir="/mqdev" --rm generate-changelog github_changelog_generator --future-release "$1" --no-issues --unreleased-only --output "CHANGELOG_FUTURE.md"
-#git add CHANGELOG.md && git commit -m "Release $1" -S && git push origin "$CURRENT_BRANCH"
\ No newline at end of file
+ git add CHANGELOG.md && git commit -m "Release $1" -S && git push origin "$CURRENT_BRANCH"
diff --git a/bin/dev b/bin/dev
index e5f40ffbd..45a3e7124 100755
--- a/bin/dev
+++ b/bin/dev
@@ -6,13 +6,13 @@ set -e
while getopts "bustefdp" OPTION; do
case $OPTION in
b)
- docker-compose pull && docker-compose build
+ docker compose pull -q && docker compose build
;;
u)
- docker-compose up
+ docker compose up
;;
s)
- docker-compose stop
+ docker compose stop
;;
e)
docker exec -it mqdev_dev_1 /bin/bash
@@ -21,7 +21,7 @@ while getopts "bustefdp" OPTION; do
./bin/php-cs-fixer fix
;;
- d) docker-compose run --workdir="/mqdev" --rm dev php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue -vvv
+ d) docker compose run --workdir="/mqdev" --rm dev php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue -vvv
;;
\?)
echo "Invalid option: -$OPTARG" >&2
diff --git a/bin/fix-symfony-version.php b/bin/fix-symfony-version.php
index efd0eb50e..6eaafebab 100644
--- a/bin/fix-symfony-version.php
+++ b/bin/fix-symfony-version.php
@@ -1,14 +1,14 @@
/etc/php/7.3/cli/conf.d/10-rdkafka.ini && \
- echo "extension=rdkafka.so" > /etc/php/7.3/fpm/conf.d/10-rdkafka.ini
-
-COPY ./php/cli.ini /etc/php/7.3/cli/conf.d/1-dev_cli.ini
+ARG PHP_VERSION=8.2
+FROM php:${PHP_VERSION}-alpine
+
+ARG PHP_VERSION
+
+RUN --mount=type=cache,target=/var/cache/apk apk add --no-cache $PHPIZE_DEPS \
+ libpq-dev \
+ librdkafka-dev \
+ rabbitmq-c-dev \
+ linux-headers && \
+ apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing \
+ gearman-dev
+
+# Install First Party Modules
+RUN docker-php-ext-install -j$(nproc) \
+ pcntl \
+ pdo_mysql \
+ pdo_pgsql
+
+# Install Third Party Modules
+RUN --mount=type=cache,target=/tmp/pear pecl install redis \
+ mongodb-1.21.0 \
+ gearman \
+ rdkafka \
+ xdebug && \
+ pecl install --configureoptions 'with-librabbitmq-dir="autodetect"' amqp
+RUN docker-php-ext-enable redis mongodb gearman rdkafka xdebug amqp
+
+COPY ./php/cli.ini /usr/local/etc/php/conf.d/.user.ini
COPY ./bin/dev_entrypoiny.sh /usr/local/bin/entrypoint.sh
+RUN mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
RUN chmod u+x /usr/local/bin/entrypoint.sh
RUN mkdir -p /mqdev
WORKDIR /mqdev
-CMD /usr/local/bin/entrypoint.sh
+COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
+
+CMD ["/usr/local/bin/entrypoint.sh"]
diff --git a/docker/bin/dev_entrypoiny.sh b/docker/bin/dev_entrypoiny.sh
index a18b06b1e..c56e146fa 100644
--- a/docker/bin/dev_entrypoiny.sh
+++ b/docker/bin/dev_entrypoiny.sh
@@ -1,3 +1,3 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
while true; do sleep 1; done
diff --git a/docker/bin/refresh-mysql-database.php b/docker/bin/refresh-mysql-database.php
index adcb7adb7..05e78f43d 100644
--- a/docker/bin/refresh-mysql-database.php
+++ b/docker/bin/refresh-mysql-database.php
@@ -5,7 +5,7 @@
require_once getcwd().'/vendor/autoload.php';
$dsn = getenv('DOCTRINE_DSN');
-$database = trim(parse_url($dsn, PHP_URL_PATH), '/');
+$database = trim(parse_url($dsn, \PHP_URL_PATH), '/');
$dbalContext = (new DbalConnectionFactory($dsn))->createContext();
@@ -13,4 +13,4 @@
$dbalContext->getDbalConnection()->exec('USE '.$database);
$dbalContext->createDataBaseTable();
-echo 'MySQL Database is updated'.PHP_EOL;
+echo 'MySQL Database is updated'.\PHP_EOL;
diff --git a/docker/bin/refresh-postgres-database.php b/docker/bin/refresh-postgres-database.php
index 7efaf4806..1d96c3c07 100644
--- a/docker/bin/refresh-postgres-database.php
+++ b/docker/bin/refresh-postgres-database.php
@@ -11,4 +11,4 @@
$dbalContext->getDbalConnection()->getSchemaManager()->dropAndCreateDatabase('postgres');
$dbalContext->createDataBaseTable();
-echo 'Postgresql Database is updated'.PHP_EOL;
+echo 'Postgresql Database is updated'.\PHP_EOL;
diff --git a/docker/bin/test.sh b/docker/bin/test.sh
index 2070584bb..1a6d35453 100755
--- a/docker/bin/test.sh
+++ b/docker/bin/test.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
# wait for service
# $1 host
@@ -12,7 +12,7 @@ function waitForService()
ATTEMPTS=0
until nc -z $1 $2; do
printf "wait for service %s:%s\n" $1 $2
- ((ATTEMPTS++))
+ ATTEMPTS=$((ATTEMPTS++))
if [ $ATTEMPTS -ge $3 ]; then
printf "service is not running %s:%s\n" $1 $2
exit 1
@@ -39,12 +39,12 @@ waitForService gearmand 4730 50
waitForService kafka 9092 50
waitForService mongo 27017 50
waitForService thruway 9090 50
-waitForService localstack 4576 50
+waitForService localstack 4566 50
php docker/bin/refresh-mysql-database.php || exit 1
php docker/bin/refresh-postgres-database.php || exit 1
php pkg/job-queue/Tests/Functional/app/console doctrine:database:create --if-not-exists || exit 1
-php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force || exit 1
+php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force --complete || exit 1
#php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue
-bin/phpunit "$@"
+php -d memory_limit=-1 bin/phpunit "$@"
diff --git a/docker/php/cli.ini b/docker/php/cli.ini
index e308fbb9d..40361c920 100644
--- a/docker/php/cli.ini
+++ b/docker/php/cli.ini
@@ -1,4 +1,4 @@
-error_reporting=E_ALL
+error_reporting=E_ALL&~E_DEPRECATED&~E_USER_DEPRECATED
display_errors=on
memory_limit = 2G
max_execution_time=0
diff --git a/docker/thruway/Dockerfile b/docker/thruway/Dockerfile
index c9e795478..042a49d64 100644
--- a/docker/thruway/Dockerfile
+++ b/docker/thruway/Dockerfile
@@ -1,4 +1,4 @@
-FROM formapro/nginx-php-fpm:latest-all-exts
+FROM makasim/nginx-php-fpm:7.4-all-exts
RUN mkdir -p /thruway
WORKDIR /thruway
diff --git a/docs/bundle/async_events.md b/docs/bundle/async_events.md
index 7264f5f20..d2d256146 100644
--- a/docs/bundle/async_events.md
+++ b/docs/bundle/async_events.md
@@ -39,7 +39,7 @@ enqueue:
## Usage
-To make your listener async you have add `async: true` attribute to the tag `kernel.event_listener`, like this:
+To make your listener async you have add `async: true` and `dispatcher: 'enqueue.events.event_dispatcher'` attributes to the tag `kernel.event_listener`, like this:
```yaml
# app/config/config.yml
@@ -48,7 +48,7 @@ services:
acme.foo_listener:
class: 'AcmeBundle\Listener\FooListener'
tags:
- - { name: 'kernel.event_listener', async: true, event: 'foo', method: 'onEvent' }
+ - { name: 'kernel.event_listener', async: true, event: 'foo', method: 'onEvent', dispatcher: 'enqueue.events.event_dispatcher' }
```
or to `kernel.event_subscriber`:
@@ -60,7 +60,7 @@ services:
test_async_subscriber:
class: 'AcmeBundle\Listener\TestAsyncSubscriber'
tags:
- - { name: 'kernel.event_subscriber', async: true }
+ - { name: 'kernel.event_subscriber', async: true, dispatcher: 'enqueue.events.event_dispatcher' }
```
That's basically it. The rest of the doc describes advanced features.
@@ -78,7 +78,7 @@ services:
public: false
arguments: ['@enqueue.transport.default.context', '@enqueue.events.registry', 'a_queue_name']
tags:
- - { name: 'kernel.event_listener', event: 'foo', method: 'onEvent' }
+ - { name: 'kernel.event_listener', event: 'foo', method: 'onEvent', dispatcher: 'enqueue.events.event_dispatcher' }
```
diff --git a/docs/bundle/config_reference.md b/docs/bundle/config_reference.md
index d27877765..042b93cfa 100644
--- a/docs/bundle/config_reference.md
+++ b/docs/bundle/config_reference.md
@@ -67,6 +67,7 @@ enqueue:
queue_name: ~
job:
enabled: false
+ default_mapping: true
async_events:
enabled: false
extensions:
diff --git a/docs/bundle/functional_testing.md b/docs/bundle/functional_testing.md
index 7e81f8eaa..ca475a2e4 100644
--- a/docs/bundle/functional_testing.md
+++ b/docs/bundle/functional_testing.md
@@ -57,7 +57,7 @@ class FooTest extends WebTestCase
/** @var \Symfony\Bundle\FrameworkBundle\Client */
private $client;
- public function setUp()
+ public function setUp(): void
{
$this->client = static::createClient();
}
diff --git a/docs/bundle/job_queue.md b/docs/bundle/job_queue.md
index eb1e25281..cd13ca3cd 100644
--- a/docs/bundle/job_queue.md
+++ b/docs/bundle/job_queue.md
@@ -60,6 +60,10 @@ enqueue:
# plus basic bundle configuration
job: true
+
+ # adds bundle's default Job entity mapping to application's entity manager.
+ # set it to false when using your own mapped entities for jobs.
+ default_mapping: true
doctrine:
# plus basic bundle configuration
diff --git a/docs/contribution.md b/docs/contribution.md
index 455f6950e..68d051fc5 100644
--- a/docs/contribution.md
+++ b/docs/contribution.md
@@ -49,6 +49,6 @@ Once everything is done open a pull request on official repository.
## WTF?!
-* If you get `rabbitmqssl: forward host lookup failed: Unknown host, wait for service rabbitmqssl:5671` do `docker-compose down`.
+* If you get `rabbitmqssl: forward host lookup failed: Unknown host, wait for service rabbitmqssl:5671` do `docker compose down`.
[back to index](index.md)
diff --git a/phpstan.neon b/phpstan.neon
index 3bd6187d9..b689b6b8a 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,5 +1,5 @@
parameters:
- excludes_analyse:
+ excludePaths:
- docs
- bin
- docker
@@ -14,10 +14,3 @@ parameters:
- pkg/enqueue-bundle/DependencyInjection/Configuration.php
- pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php
- pkg/simple-client/SimpleClient.php
- ignoreErrors:
- -
- message: '#Class Symfony\\Component\\EventDispatcher\\LegacyEventDispatcherProxy not found#'
- path: %currentWorkingDirectory%/*
- -
- message: '#.*Symfony\\Contracts\\EventDispatcher\\Event.*#'
- path: %currentWorkingDirectory%/*
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 43abe1afc..f5ba01d8f 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -2,7 +2,7 @@
pkg/sns/Tests
-
- pkg/snsqs/Tests
-
-
pkg/pheanstalk/Tests
@@ -123,18 +119,22 @@
pkg/monitoring/Tests
+
+
+ pkg/snsqs/Tests
+
-
-
+
+
.
-
- ./vendor
-
-
-
+
+
+ ./vendor
+
+
diff --git a/pkg/amqp-bunny/.github/workflows/ci.yml b/pkg/amqp-bunny/.github/workflows/ci.yml
new file mode 100644
index 000000000..5448d7b1a
--- /dev/null
+++ b/pkg/amqp-bunny/.github/workflows/ci.yml
@@ -0,0 +1,27 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/amqp-bunny/.travis.yml b/pkg/amqp-bunny/.travis.yml
deleted file mode 100644
index 02ba7238b..000000000
--- a/pkg/amqp-bunny/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/amqp-bunny/AmqpConnectionFactory.php b/pkg/amqp-bunny/AmqpConnectionFactory.php
index 241929abe..749e63be0 100644
--- a/pkg/amqp-bunny/AmqpConnectionFactory.php
+++ b/pkg/amqp-bunny/AmqpConnectionFactory.php
@@ -26,7 +26,7 @@ class AmqpConnectionFactory implements InteropAmqpConnectionFactory, DelayStrate
private $client;
/**
- * @see \Enqueue\AmqpTools\ConnectionConfig for possible config formats and values
+ * @see ConnectionConfig for possible config formats and values
*
* @param array|string|null $config
*/
@@ -89,10 +89,10 @@ private function establishConnection(): BunnyClient
$bunnyConfig['timeout'] = $this->config->getConnectionTimeout();
// @see https://github.com/php-enqueue/enqueue-dev/issues/229
-// $bunnyConfig['persistent'] = $this->config->isPersisted();
-// if ($this->config->isPersisted()) {
-// $bunnyConfig['path'] = 'enqueue';//$this->config->getOption('path', $this->config->getOption('vhost'));
-// }
+ // $bunnyConfig['persistent'] = $this->config->isPersisted();
+ // if ($this->config->isPersisted()) {
+ // $bunnyConfig['path'] = 'enqueue';//$this->config->getOption('path', $this->config->getOption('vhost'));
+ // }
if ($this->config->getHeartbeat()) {
$bunnyConfig['heartbeat'] = $this->config->getHeartbeat();
diff --git a/pkg/amqp-bunny/AmqpConsumer.php b/pkg/amqp-bunny/AmqpConsumer.php
index f1b52a99d..89301c80c 100644
--- a/pkg/amqp-bunny/AmqpConsumer.php
+++ b/pkg/amqp-bunny/AmqpConsumer.php
@@ -48,7 +48,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue)
$this->flags = self::FLAG_NOPARAM;
}
- public function setConsumerTag(string $consumerTag = null): void
+ public function setConsumerTag(?string $consumerTag = null): void
{
$this->consumerTag = $consumerTag;
}
@@ -98,7 +98,7 @@ public function receive(int $timeout = 0): ?Message
return $message;
}
- usleep(100000); //100ms
+ usleep(100000); // 100ms
}
return null;
diff --git a/pkg/amqp-bunny/AmqpContext.php b/pkg/amqp-bunny/AmqpContext.php
index f57554335..151cbd842 100644
--- a/pkg/amqp-bunny/AmqpContext.php
+++ b/pkg/amqp-bunny/AmqpContext.php
@@ -51,7 +51,6 @@ class AmqpContext implements InteropAmqpContext, DelayStrategyAware
* Callable must return instance of \Bunny\Channel once called.
*
* @param Channel|callable $bunnyChannel
- * @param array $config
*/
public function __construct($bunnyChannel, array $config)
{
@@ -294,10 +293,7 @@ public function getBunnyChannel(): Channel
if (false == $this->bunnyChannel) {
$bunnyChannel = call_user_func($this->bunnyChannelFactory);
if (false == $bunnyChannel instanceof Channel) {
- throw new \LogicException(sprintf(
- 'The factory must return instance of \Bunny\Channel. It returned %s',
- is_object($bunnyChannel) ? get_class($bunnyChannel) : gettype($bunnyChannel)
- ));
+ throw new \LogicException(sprintf('The factory must return instance of \Bunny\Channel. It returned %s', is_object($bunnyChannel) ? $bunnyChannel::class : gettype($bunnyChannel)));
}
$this->bunnyChannel = $bunnyChannel;
diff --git a/pkg/amqp-bunny/AmqpProducer.php b/pkg/amqp-bunny/AmqpProducer.php
index 76892ebeb..178ff81a8 100644
--- a/pkg/amqp-bunny/AmqpProducer.php
+++ b/pkg/amqp-bunny/AmqpProducer.php
@@ -79,7 +79,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return self
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $this->delayStrategy) {
throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
@@ -98,7 +98,7 @@ public function getDeliveryDelay(): ?int
/**
* @return self
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;
@@ -113,7 +113,7 @@ public function getPriority(): ?int
/**
* @return self
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
diff --git a/pkg/amqp-bunny/AmqpSubscriptionConsumer.php b/pkg/amqp-bunny/AmqpSubscriptionConsumer.php
index 4fff4f8ab..2904c1c19 100644
--- a/pkg/amqp-bunny/AmqpSubscriptionConsumer.php
+++ b/pkg/amqp-bunny/AmqpSubscriptionConsumer.php
@@ -47,7 +47,7 @@ public function consume(int $timeout = 0): void
try {
$this->context->getBunnyChannel()->getClient()->run(0 !== $timeout ? $timeout / 1000 : null);
} catch (ClientException $e) {
- if (0 === strpos($e->getMessage(), 'stream_select() failed') && $signalHandler->wasThereSignal()) {
+ if (str_starts_with($e->getMessage(), 'stream_select() failed') && $signalHandler->wasThereSignal()) {
return;
}
@@ -63,7 +63,7 @@ public function consume(int $timeout = 0): void
public function subscribe(Consumer $consumer, callable $callback): void
{
if (false == $consumer instanceof AmqpConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class));
}
if ($consumer->getConsumerTag() && array_key_exists($consumer->getConsumerTag(), $this->subscribers)) {
@@ -88,7 +88,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
$frame = $this->context->getBunnyChannel()->consume(
$bunnyCallback,
$consumer->getQueue()->getQueueName(),
- $consumer->getConsumerTag(),
+ $consumer->getConsumerTag() ?? '',
(bool) ($consumer->getFlags() & InteropAmqpConsumer::FLAG_NOLOCAL),
(bool) ($consumer->getFlags() & InteropAmqpConsumer::FLAG_NOACK),
(bool) ($consumer->getFlags() & InteropAmqpConsumer::FLAG_EXCLUSIVE),
@@ -110,7 +110,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
public function unsubscribe(Consumer $consumer): void
{
if (false == $consumer instanceof AmqpConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class));
}
if (false == $consumer->getConsumerTag()) {
diff --git a/pkg/amqp-bunny/README.md b/pkg/amqp-bunny/README.md
index 9efcfa531..09f4005fe 100644
--- a/pkg/amqp-bunny/README.md
+++ b/pkg/amqp-bunny/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# AMQP Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/amqp-bunny)
+[](https://github.com/php-enqueue/amqp-bunny/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/amqp-bunny)
[](https://packagist.org/packages/enqueue/amqp-bunny)
diff --git a/pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php b/pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php
index 56d819206..da54dfc0d 100644
--- a/pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php
+++ b/pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php
@@ -5,12 +5,14 @@
use Enqueue\AmqpBunny\AmqpConnectionFactory;
use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
class AmqpConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
diff --git a/pkg/amqp-bunny/Tests/AmqpConsumerTest.php b/pkg/amqp-bunny/Tests/AmqpConsumerTest.php
index a588c2e56..c2c694566 100644
--- a/pkg/amqp-bunny/Tests/AmqpConsumerTest.php
+++ b/pkg/amqp-bunny/Tests/AmqpConsumerTest.php
@@ -27,11 +27,6 @@ public function testShouldImplementConsumerInterface()
$this->assertClassImplements(Consumer::class, AmqpConsumer::class);
}
- public function testCouldBeConstructedWithContextAndQueueAsArguments()
- {
- new AmqpConsumer($this->createContextMock(), new AmqpQueue('aName'));
- }
-
public function testShouldReturnQueue()
{
$queue = new AmqpQueue('aName');
diff --git a/pkg/amqp-bunny/Tests/AmqpProducerTest.php b/pkg/amqp-bunny/Tests/AmqpProducerTest.php
index e9244297c..17b390341 100644
--- a/pkg/amqp-bunny/Tests/AmqpProducerTest.php
+++ b/pkg/amqp-bunny/Tests/AmqpProducerTest.php
@@ -24,11 +24,6 @@ class AmqpProducerTest extends TestCase
{
use ClassExtensionTrait;
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new AmqpProducer($this->createBunnyChannelMock(), $this->createContextMock());
- }
-
public function testShouldImplementQueueInteropProducerInterface()
{
$this->assertClassImplements(Producer::class, AmqpProducer::class);
diff --git a/pkg/amqp-bunny/Tests/AmqpSubscriptionConsumerTest.php b/pkg/amqp-bunny/Tests/AmqpSubscriptionConsumerTest.php
index c1d056268..4bf08ded5 100644
--- a/pkg/amqp-bunny/Tests/AmqpSubscriptionConsumerTest.php
+++ b/pkg/amqp-bunny/Tests/AmqpSubscriptionConsumerTest.php
@@ -17,11 +17,6 @@ public function testShouldImplementQueueInteropSubscriptionConsumerInterface()
$this->assertTrue($rc->implementsInterface(SubscriptionConsumer::class));
}
- public function testCouldBeConstructedWithAmqpContextAsFirstArgument()
- {
- new AmqpSubscriptionConsumer($this->createAmqpContextMock());
- }
-
/**
* @return AmqpContext|MockObject
*/
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
index ae4b74c6a..e5c2d1302 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
@@ -18,9 +18,6 @@ public function test()
$this->markTestIncomplete();
}
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -31,8 +28,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
index 00710aad7..b7c311cfb 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -26,8 +23,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
index bf2041c4b..89530e2e6 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePriorityMessagesFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
index a50bdf98e..793e3fa78 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php
index f253d73c9..37ef1d0bd 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php
@@ -10,9 +10,6 @@
*/
class AmqpSendAndReceiveTimestampAsIntegerTest extends SendAndReceiveTimestampAsIntegerSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
index e715f5c80..e3286ae9c 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
index ac7efaf1d..ce9fc2794 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -24,8 +21,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
index 9d37cade4..f1210d03a 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
index 8947fe9f1..cc47cf44a 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -24,8 +21,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
index 28deeac86..f13ead179 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
@@ -14,9 +14,6 @@
*/
class AmqpSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -25,8 +22,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
@@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName)
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
index 5facc03b2..683e0b1ca 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
@@ -14,9 +14,6 @@
*/
class AmqpSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -25,8 +22,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
@@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName)
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
index f22c6d6a7..4a549fcf8 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
@@ -19,9 +19,6 @@ public function test()
parent::test();
}
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$baseDir = realpath(__DIR__.'/../../../../');
@@ -44,8 +41,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
index c2403792b..5d4d8d40e 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
@@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri
{
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
index a1f4ac57f..6cae48148 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
@@ -24,8 +24,6 @@ protected function tearDown(): void
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -39,8 +37,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
index 624d0a8f4..d9d8527d3 100644
--- a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
+++ b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
@@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn
{
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-bunny/composer.json b/pkg/amqp-bunny/composer.json
index 8c8d053be..84d0f4309 100644
--- a/pkg/amqp-bunny/composer.json
+++ b/pkg/amqp-bunny/composer.json
@@ -6,17 +6,17 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
- "queue-interop/amqp-interop": "^0.8",
+ "php": "^8.1",
+ "queue-interop/amqp-interop": "^0.8.2",
"queue-interop/queue-interop": "^0.8",
- "bunny/bunny": "^0.4",
+ "bunny/bunny": "^0.4|^0.5",
"enqueue/amqp-tools": "^0.10"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/amqp-ext/.github/workflows/ci.yml b/pkg/amqp-ext/.github/workflows/ci.yml
new file mode 100644
index 000000000..d48deb0af
--- /dev/null
+++ b/pkg/amqp-ext/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - run: php Tests/fix_composer_json.php
+
+ - uses: "ramsey/composer-install@v1"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/amqp-ext/.travis.yml b/pkg/amqp-ext/.travis.yml
deleted file mode 100644
index 8210653a3..000000000
--- a/pkg/amqp-ext/.travis.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - php Tests/fix_composer_json.php
- - composer self-update
- - composer install
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/amqp-ext/AmqpConnectionFactory.php b/pkg/amqp-ext/AmqpConnectionFactory.php
index 177a786d8..c3241d72a 100644
--- a/pkg/amqp-ext/AmqpConnectionFactory.php
+++ b/pkg/amqp-ext/AmqpConnectionFactory.php
@@ -24,7 +24,7 @@ class AmqpConnectionFactory implements InteropAmqpConnectionFactory, DelayStrate
private $connection;
/**
- * @see \Enqueue\AmqpTools\ConnectionConfig for possible config formats and values
+ * @see ConnectionConfig for possible config formats and values
*
* @param array|string|null $config
*/
diff --git a/pkg/amqp-ext/AmqpConsumer.php b/pkg/amqp-ext/AmqpConsumer.php
index 03c949714..700e8d77f 100644
--- a/pkg/amqp-ext/AmqpConsumer.php
+++ b/pkg/amqp-ext/AmqpConsumer.php
@@ -43,7 +43,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue)
$this->flags = self::FLAG_NOPARAM;
}
- public function setConsumerTag(string $consumerTag = null): void
+ public function setConsumerTag(?string $consumerTag = null): void
{
$this->consumerTag = $consumerTag;
}
@@ -93,7 +93,7 @@ public function receive(int $timeout = 0): ?Message
return $message;
}
- usleep(100000); //100ms
+ usleep(100000); // 100ms
}
return null;
@@ -130,7 +130,7 @@ public function reject(Message $message, bool $requeue = false): void
$this->getExtQueue()->reject(
$message->getDeliveryTag(),
- $requeue ? AMQP_REQUEUE : AMQP_NOPARAM
+ $requeue ? \AMQP_REQUEUE : \AMQP_NOPARAM
);
}
diff --git a/pkg/amqp-ext/AmqpContext.php b/pkg/amqp-ext/AmqpContext.php
index 5ea099da2..c339dc0a1 100644
--- a/pkg/amqp-ext/AmqpContext.php
+++ b/pkg/amqp-ext/AmqpContext.php
@@ -177,7 +177,7 @@ public function unbind(InteropAmqpBind $bind): void
public function createTemporaryQueue(): Queue
{
$extQueue = new \AMQPQueue($this->getExtChannel());
- $extQueue->setFlags(AMQP_EXCLUSIVE);
+ $extQueue->setFlags(\AMQP_EXCLUSIVE);
$extQueue->declareQueue();
@@ -243,10 +243,7 @@ public function getExtChannel(): \AMQPChannel
if (false == $this->extChannel) {
$extChannel = call_user_func($this->extChannelFactory);
if (false == $extChannel instanceof \AMQPChannel) {
- throw new \LogicException(sprintf(
- 'The factory must return instance of AMQPChannel. It returns %s',
- is_object($extChannel) ? get_class($extChannel) : gettype($extChannel)
- ));
+ throw new \LogicException(sprintf('The factory must return instance of AMQPChannel. It returns %s', is_object($extChannel) ? $extChannel::class : gettype($extChannel)));
}
$this->extChannel = $extChannel;
diff --git a/pkg/amqp-ext/AmqpProducer.php b/pkg/amqp-ext/AmqpProducer.php
index 0fe6b7a39..fc55ca29e 100644
--- a/pkg/amqp-ext/AmqpProducer.php
+++ b/pkg/amqp-ext/AmqpProducer.php
@@ -72,7 +72,7 @@ public function send(Destination $destination, Message $message): void
}
}
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $this->delayStrategy) {
throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
@@ -88,7 +88,7 @@ public function getDeliveryDelay(): ?int
return $this->deliveryDelay;
}
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;
@@ -100,7 +100,7 @@ public function getPriority(): ?int
return $this->priority;
}
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
@@ -146,7 +146,7 @@ private function doSend(AmqpDestination $destination, AmqpMessage $message): voi
} else {
/** @var AmqpQueue $destination */
$amqpExchange = new \AMQPExchange($this->amqpChannel);
- $amqpExchange->setType(AMQP_EX_TYPE_DIRECT);
+ $amqpExchange->setType(\AMQP_EX_TYPE_DIRECT);
$amqpExchange->setName('');
$amqpExchange->publish(
diff --git a/pkg/amqp-ext/AmqpSubscriptionConsumer.php b/pkg/amqp-ext/AmqpSubscriptionConsumer.php
index 4b03f6bbb..3d0faccb7 100644
--- a/pkg/amqp-ext/AmqpSubscriptionConsumer.php
+++ b/pkg/amqp-ext/AmqpSubscriptionConsumer.php
@@ -68,7 +68,7 @@ public function consume(int $timeout = 0): void
} finally {
$extConnection->setReadTimeout($consumeTimeout);
}
- }, AMQP_JUST_CONSUME);
+ }, \AMQP_JUST_CONSUME);
} catch (\AMQPQueueException $e) {
if ('Consumer timeout exceed' == $e->getMessage()) {
return;
@@ -86,7 +86,7 @@ public function consume(int $timeout = 0): void
public function subscribe(Consumer $consumer, callable $callback): void
{
if (false == $consumer instanceof AmqpConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class));
}
if ($consumer->getConsumerTag() && array_key_exists($consumer->getConsumerTag(), $this->subscribers)) {
@@ -109,7 +109,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
public function unsubscribe(Consumer $consumer): void
{
if (false == $consumer instanceof AmqpConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class));
}
if (false == $consumer->getConsumerTag()) {
diff --git a/pkg/amqp-ext/Flags.php b/pkg/amqp-ext/Flags.php
index ca31a4b74..2054f5526 100644
--- a/pkg/amqp-ext/Flags.php
+++ b/pkg/amqp-ext/Flags.php
@@ -12,14 +12,14 @@ class Flags
{
public static function convertMessageFlags(int $interop): int
{
- $flags = AMQP_NOPARAM;
+ $flags = \AMQP_NOPARAM;
if ($interop & InteropAmqpMessage::FLAG_MANDATORY) {
- $flags |= AMQP_MANDATORY;
+ $flags |= \AMQP_MANDATORY;
}
if ($interop & InteropAmqpMessage::FLAG_IMMEDIATE) {
- $flags |= AMQP_IMMEDIATE;
+ $flags |= \AMQP_IMMEDIATE;
}
return $flags;
@@ -27,12 +27,12 @@ public static function convertMessageFlags(int $interop): int
public static function convertTopicFlags(int $interop): int
{
- $flags = AMQP_NOPARAM;
+ $flags = \AMQP_NOPARAM;
$flags |= static::convertDestinationFlags($interop);
if ($interop & InteropAmqpTopic::FLAG_INTERNAL) {
- $flags |= AMQP_INTERNAL;
+ $flags |= \AMQP_INTERNAL;
}
return $flags;
@@ -40,12 +40,12 @@ public static function convertTopicFlags(int $interop): int
public static function convertQueueFlags(int $interop): int
{
- $flags = AMQP_NOPARAM;
+ $flags = \AMQP_NOPARAM;
$flags |= static::convertDestinationFlags($interop);
if ($interop & InteropAmqpQueue::FLAG_EXCLUSIVE) {
- $flags |= AMQP_EXCLUSIVE;
+ $flags |= \AMQP_EXCLUSIVE;
}
return $flags;
@@ -53,22 +53,22 @@ public static function convertQueueFlags(int $interop): int
public static function convertDestinationFlags(int $interop): int
{
- $flags = AMQP_NOPARAM;
+ $flags = \AMQP_NOPARAM;
if ($interop & InteropAmqpDestination::FLAG_PASSIVE) {
- $flags |= AMQP_PASSIVE;
+ $flags |= \AMQP_PASSIVE;
}
if ($interop & InteropAmqpDestination::FLAG_DURABLE) {
- $flags |= AMQP_DURABLE;
+ $flags |= \AMQP_DURABLE;
}
if ($interop & InteropAmqpDestination::FLAG_AUTODELETE) {
- $flags |= AMQP_AUTODELETE;
+ $flags |= \AMQP_AUTODELETE;
}
if ($interop & InteropAmqpDestination::FLAG_NOWAIT) {
- $flags |= AMQP_NOWAIT;
+ $flags |= \AMQP_NOWAIT;
}
return $flags;
@@ -76,22 +76,22 @@ public static function convertDestinationFlags(int $interop): int
public static function convertConsumerFlags(int $interop): int
{
- $flags = AMQP_NOPARAM;
+ $flags = \AMQP_NOPARAM;
if ($interop & InteropAmqpConsumer::FLAG_NOLOCAL) {
- $flags |= AMQP_NOLOCAL;
+ $flags |= \AMQP_NOLOCAL;
}
if ($interop & InteropAmqpConsumer::FLAG_NOACK) {
- $flags |= AMQP_AUTOACK;
+ $flags |= \AMQP_AUTOACK;
}
if ($interop & InteropAmqpConsumer::FLAG_EXCLUSIVE) {
- $flags |= AMQP_EXCLUSIVE;
+ $flags |= \AMQP_EXCLUSIVE;
}
if ($interop & InteropAmqpConsumer::FLAG_NOWAIT) {
- $flags |= AMQP_NOWAIT;
+ $flags |= \AMQP_NOWAIT;
}
return $flags;
diff --git a/pkg/amqp-ext/README.md b/pkg/amqp-ext/README.md
index e750d3c36..1b254a860 100644
--- a/pkg/amqp-ext/README.md
+++ b/pkg/amqp-ext/README.md
@@ -8,7 +8,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# AMQP Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/amqp-ext)
+[](https://github.com/php-enqueue/amqp-ext/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/amqp-ext)
[](https://packagist.org/packages/enqueue/amqp-ext)
diff --git a/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php b/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php
index 0bceae358..7ea58f947 100644
--- a/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php
+++ b/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php
@@ -6,12 +6,14 @@
use Enqueue\AmqpExt\AmqpContext;
use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
class AmqpConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
@@ -34,6 +36,6 @@ public function testShouldCreateLazyContext()
$this->assertInstanceOf(AmqpContext::class, $context);
$this->assertAttributeEquals(null, 'extChannel', $context);
- $this->assertInternalType('callable', $this->readAttribute($context, 'extChannelFactory'));
+ self::assertIsCallable($this->readAttribute($context, 'extChannelFactory'));
}
}
diff --git a/pkg/amqp-ext/Tests/AmqpConsumerTest.php b/pkg/amqp-ext/Tests/AmqpConsumerTest.php
index 75c49cf01..1dcc0f349 100644
--- a/pkg/amqp-ext/Tests/AmqpConsumerTest.php
+++ b/pkg/amqp-ext/Tests/AmqpConsumerTest.php
@@ -5,7 +5,6 @@
use Enqueue\AmqpExt\AmqpConsumer;
use Enqueue\AmqpExt\AmqpContext;
use Enqueue\Test\ClassExtensionTrait;
-use Interop\Amqp\Impl\AmqpQueue;
use Interop\Queue\Consumer;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -19,11 +18,6 @@ public function testShouldImplementConsumerInterface()
$this->assertClassImplements(Consumer::class, AmqpConsumer::class);
}
- public function testCouldBeConstructedWithContextAndQueueAsArguments()
- {
- new AmqpConsumer($this->createContext(), new AmqpQueue('aName'));
- }
-
/**
* @return MockObject|AmqpContext
*/
diff --git a/pkg/amqp-ext/Tests/AmqpContextTest.php b/pkg/amqp-ext/Tests/AmqpContextTest.php
index bcf3b2200..2b03bb3d2 100644
--- a/pkg/amqp-ext/Tests/AmqpContextTest.php
+++ b/pkg/amqp-ext/Tests/AmqpContextTest.php
@@ -9,6 +9,7 @@
use Enqueue\Null\NullQueue;
use Enqueue\Null\NullTopic;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Amqp\Impl\AmqpMessage;
use Interop\Amqp\Impl\AmqpQueue;
use Interop\Amqp\Impl\AmqpTopic;
@@ -20,24 +21,13 @@
class AmqpContextTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementQueueInteropContextInterface()
{
$this->assertClassImplements(Context::class, AmqpContext::class);
}
- public function testCouldBeConstructedWithExtChannelAsFirstArgument()
- {
- new AmqpContext($this->createExtChannelMock());
- }
-
- public function testCouldBeConstructedWithExtChannelCallbackFactoryAsFirstArgument()
- {
- new AmqpContext(function () {
- return $this->createExtChannelMock();
- });
- }
-
public function testThrowIfNeitherCallbackNorExtChannelAsFirstArgument()
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/pkg/amqp-ext/Tests/AmqpSubscriptionConsumerTest.php b/pkg/amqp-ext/Tests/AmqpSubscriptionConsumerTest.php
index 153fe275e..d71ddd776 100644
--- a/pkg/amqp-ext/Tests/AmqpSubscriptionConsumerTest.php
+++ b/pkg/amqp-ext/Tests/AmqpSubscriptionConsumerTest.php
@@ -17,11 +17,6 @@ public function testShouldImplementQueueInteropSubscriptionConsumerInterface()
$this->assertTrue($rc->implementsInterface(SubscriptionConsumer::class));
}
- public function testCouldBeConstructedWithAmqpContextAsFirstArgument()
- {
- new AmqpSubscriptionConsumer($this->createAmqpContextMock());
- }
-
/**
* @return AmqpContext|MockObject
*/
diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php
index ee73345e9..ee53ad90b 100644
--- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php
+++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php
@@ -14,15 +14,15 @@
*/
class AmqpCommonUseCasesTest extends TestCase
{
- use RabbitmqAmqpExtension;
use RabbitManagementExtensionTrait;
+ use RabbitmqAmqpExtension;
/**
* @var AmqpContext
*/
private $amqpContext;
- public function setUp()
+ protected function setUp(): void
{
$this->amqpContext = $this->buildAmqpContext();
@@ -30,7 +30,7 @@ public function setUp()
$this->removeExchange('amqp_ext.test_exchange');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->amqpContext->close();
}
@@ -112,6 +112,7 @@ public function testProduceAndReceiveOneMessageSentDirectlyToTemporaryQueue()
$queue = $this->amqpContext->createTemporaryQueue();
$message = $this->amqpContext->createMessage(__METHOD__);
+ $message->setDeliveryTag(145);
$producer = $this->amqpContext->createProducer();
$producer->send($queue, $message);
@@ -128,7 +129,7 @@ public function testProduceAndReceiveOneMessageSentDirectlyToTemporaryQueue()
public function testProduceAndReceiveOneMessageSentDirectlyToTopic()
{
$topic = $this->amqpContext->createTopic('amqp_ext.test_exchange');
- $topic->setType(AMQP_EX_TYPE_FANOUT);
+ $topic->setType(\AMQP_EX_TYPE_FANOUT);
$this->amqpContext->declareTopic($topic);
$queue = $this->amqpContext->createQueue('amqp_ext.test');
@@ -137,6 +138,7 @@ public function testProduceAndReceiveOneMessageSentDirectlyToTopic()
$this->amqpContext->bind(new AmqpBind($topic, $queue));
$message = $this->amqpContext->createMessage(__METHOD__);
+ $message->setDeliveryTag(145);
$producer = $this->amqpContext->createProducer();
$producer->send($topic, $message);
@@ -153,15 +155,16 @@ public function testProduceAndReceiveOneMessageSentDirectlyToTopic()
public function testConsumerReceiveMessageFromTopicDirectly()
{
$topic = $this->amqpContext->createTopic('amqp_ext.test_exchange');
- $topic->setType(AMQP_EX_TYPE_FANOUT);
+ $topic->setType(\AMQP_EX_TYPE_FANOUT);
$this->amqpContext->declareTopic($topic);
$consumer = $this->amqpContext->createConsumer($topic);
- //guard
+ // guard
$this->assertNull($consumer->receive(1000));
$message = $this->amqpContext->createMessage(__METHOD__);
+ $message->setDeliveryTag(145);
$producer = $this->amqpContext->createProducer();
$producer->send($topic, $message);
@@ -176,15 +179,16 @@ public function testConsumerReceiveMessageFromTopicDirectly()
public function testConsumerReceiveMessageWithZeroTimeout()
{
$topic = $this->amqpContext->createTopic('amqp_ext.test_exchange');
- $topic->setType(AMQP_EX_TYPE_FANOUT);
+ $topic->setType(\AMQP_EX_TYPE_FANOUT);
$this->amqpContext->declareTopic($topic);
$consumer = $this->amqpContext->createConsumer($topic);
- //guard
+ // guard
$this->assertNull($consumer->receive(1000));
$message = $this->amqpContext->createMessage(__METHOD__);
+ $message->setDeliveryTag(145);
$producer = $this->amqpContext->createProducer();
$producer->send($topic, $message);
@@ -205,6 +209,7 @@ public function testPurgeMessagesFromQueue()
$consumer = $this->amqpContext->createConsumer($queue);
$message = $this->amqpContext->createMessage(__METHOD__);
+ $message->setDeliveryTag(145);
$producer = $this->amqpContext->createProducer();
$producer->send($queue, $message);
diff --git a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php
index 220554859..51d5a7c54 100644
--- a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php
+++ b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php
@@ -21,22 +21,22 @@
*/
class AmqpConsumptionUseCasesTest extends TestCase
{
- use RabbitmqAmqpExtension;
use RabbitManagementExtensionTrait;
+ use RabbitmqAmqpExtension;
/**
* @var AmqpContext
*/
private $amqpContext;
- public function setUp()
+ protected function setUp(): void
{
$this->amqpContext = $this->buildAmqpContext();
$this->removeQueue('amqp_ext.test');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->amqpContext->close();
}
diff --git a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php
index 9e5dc4df3..66ae69241 100644
--- a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php
+++ b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php
@@ -15,15 +15,15 @@
*/
class AmqpRpcUseCasesTest extends TestCase
{
- use RabbitmqAmqpExtension;
use RabbitManagementExtensionTrait;
+ use RabbitmqAmqpExtension;
/**
* @var AmqpContext
*/
private $amqpContext;
- public function setUp()
+ protected function setUp(): void
{
$this->amqpContext = $this->buildAmqpContext();
@@ -31,7 +31,7 @@ public function setUp()
$this->removeQueue('rpc.reply_test');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->amqpContext->close();
}
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpMessageTest.php b/pkg/amqp-ext/Tests/Spec/AmqpMessageTest.php
index e11afd964..73fc4ad14 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpMessageTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpMessageTest.php
@@ -7,9 +7,6 @@
class AmqpMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new AmqpMessage();
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpProducerTest.php b/pkg/amqp-ext/Tests/Spec/AmqpProducerTest.php
index 3dead4d9f..1183e3a8e 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpProducerTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpProducerTest.php
@@ -10,9 +10,6 @@
*/
class AmqpProducerTest extends ProducerSpec
{
- /**
- * {@inheritdoc}
- */
protected function createProducer()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
index ac30c510f..f79f7e635 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -26,8 +23,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
index 311f82ab6..71da671f4 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -26,8 +23,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
index 0bfab937b..40edcd865 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePriorityMessagesFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
index 6f0d7b6cf..6654107c9 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php
index 00d7e3840..5ecc00046 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php
@@ -10,9 +10,6 @@
*/
class AmqpSendAndReceiveTimestampAsIntengerTest extends SendAndReceiveTimestampAsIntegerSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
index 9d4713dee..cb45dc5a5 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
index 629703303..fb8e62750 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -24,8 +21,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
index c4e602f8d..a0d93c38b 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
index 6a599c9f7..f9867d1b1 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -24,8 +21,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
index 2f2e30d6b..058606b51 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
@@ -14,9 +14,6 @@
*/
class AmqpSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -25,8 +22,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
@@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName)
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
index b9d4510d5..b8ac82403 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
@@ -14,9 +14,6 @@
*/
class AmqpSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -25,8 +22,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
@@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName)
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
index 31e4e175f..0aa03cbd0 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSslSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$baseDir = realpath(__DIR__.'/../../../../');
@@ -37,8 +34,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
index 1adda733d..c069acefd 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
@@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri
{
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
index ccb13bb89..c3341c937 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
@@ -24,8 +24,6 @@ protected function tearDown(): void
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -39,8 +37,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
index 424013f4a..e017bb603 100644
--- a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
+++ b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
@@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn
{
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-ext/Tests/fix_composer_json.php b/pkg/amqp-ext/Tests/fix_composer_json.php
index f025f6081..01f73c95e 100644
--- a/pkg/amqp-ext/Tests/fix_composer_json.php
+++ b/pkg/amqp-ext/Tests/fix_composer_json.php
@@ -6,4 +6,4 @@
$composerJson['config']['platform']['ext-amqp'] = '1.9.3';
-file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, JSON_PRETTY_PRINT));
+file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, \JSON_PRETTY_PRINT));
diff --git a/pkg/amqp-ext/composer.json b/pkg/amqp-ext/composer.json
index 5bc1b3f07..99f88c507 100644
--- a/pkg/amqp-ext/composer.json
+++ b/pkg/amqp-ext/composer.json
@@ -6,17 +6,17 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
- "ext-amqp": "^1.9.3",
- "queue-interop/amqp-interop": "^0.8",
+ "php": "^8.1",
+ "ext-amqp": "^1.9.3|^2.0.0",
+ "queue-interop/amqp-interop": "^0.8.2",
"queue-interop/queue-interop": "^0.8",
"enqueue/amqp-tools": "^0.10"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6",
+ "queue-interop/queue-spec": "^0.6.2",
"empi89/php-amqp-stubs": "*@dev"
},
"support": {
diff --git a/pkg/amqp-ext/examples/consume.php b/pkg/amqp-ext/examples/consume.php
index 74ed8fab5..d510bf077 100644
--- a/pkg/amqp-ext/examples/consume.php
+++ b/pkg/amqp-ext/examples/consume.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\AmqpExt\AmqpConnectionFactory;
@@ -32,7 +32,7 @@
while (true) {
if ($m = $consumer->receive(1)) {
- echo $m->getBody(), PHP_EOL;
+ echo $m->getBody(), \PHP_EOL;
$consumer->acknowledge($m);
}
diff --git a/pkg/amqp-ext/examples/produce.php b/pkg/amqp-ext/examples/produce.php
index 72acb7e94..dfc4374da 100644
--- a/pkg/amqp-ext/examples/produce.php
+++ b/pkg/amqp-ext/examples/produce.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\AmqpExt\AmqpConnectionFactory;
diff --git a/pkg/amqp-lib/.github/workflows/ci.yml b/pkg/amqp-lib/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/amqp-lib/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/amqp-lib/.travis.yml b/pkg/amqp-lib/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/amqp-lib/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/amqp-lib/AmqpConnectionFactory.php b/pkg/amqp-lib/AmqpConnectionFactory.php
index 3cb1c29b7..198e6874d 100644
--- a/pkg/amqp-lib/AmqpConnectionFactory.php
+++ b/pkg/amqp-lib/AmqpConnectionFactory.php
@@ -32,7 +32,7 @@ class AmqpConnectionFactory implements InteropAmqpConnectionFactory, DelayStrate
private $connection;
/**
- * @see \Enqueue\AmqpTools\ConnectionConfig for possible config formats and values.
+ * @see ConnectionConfig for possible config formats and values.
*
* @param array|string|null $config
*/
diff --git a/pkg/amqp-lib/AmqpConsumer.php b/pkg/amqp-lib/AmqpConsumer.php
index 0218db6b2..0534a9371 100644
--- a/pkg/amqp-lib/AmqpConsumer.php
+++ b/pkg/amqp-lib/AmqpConsumer.php
@@ -47,7 +47,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue)
$this->flags = self::FLAG_NOPARAM;
}
- public function setConsumerTag(string $consumerTag = null): void
+ public function setConsumerTag(?string $consumerTag = null): void
{
$this->consumerTag = $consumerTag;
}
@@ -97,7 +97,7 @@ public function receive(int $timeout = 0): ?Message
return $message;
}
- usleep(100000); //100ms
+ usleep(100000); // 100ms
}
return null;
@@ -127,7 +127,6 @@ public function acknowledge(Message $message): void
/**
* @param InteropAmqpMessage $message
- * @param bool $requeue
*/
public function reject(Message $message, bool $requeue = false): void
{
diff --git a/pkg/amqp-lib/AmqpContext.php b/pkg/amqp-lib/AmqpContext.php
index 32f60c21b..34569659d 100644
--- a/pkg/amqp-lib/AmqpContext.php
+++ b/pkg/amqp-lib/AmqpContext.php
@@ -309,9 +309,9 @@ public function convertMessage(LibAMQPMessage $amqpMessage): InteropAmqpMessage
unset($headers['application_headers']);
$message = new AmqpMessage($amqpMessage->getBody(), $properties, $headers);
- $message->setDeliveryTag((int) $amqpMessage->delivery_info['delivery_tag']);
- $message->setRedelivered($amqpMessage->delivery_info['redelivered']);
- $message->setRoutingKey($amqpMessage->delivery_info['routing_key']);
+ $message->setDeliveryTag((int) $amqpMessage->getDeliveryTag());
+ $message->setRedelivered($amqpMessage->isRedelivered());
+ $message->setRoutingKey($amqpMessage->getRoutingKey());
return $message;
}
diff --git a/pkg/amqp-lib/AmqpProducer.php b/pkg/amqp-lib/AmqpProducer.php
index 70e876793..928597298 100644
--- a/pkg/amqp-lib/AmqpProducer.php
+++ b/pkg/amqp-lib/AmqpProducer.php
@@ -81,7 +81,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return self
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $this->delayStrategy) {
throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
@@ -100,7 +100,7 @@ public function getDeliveryDelay(): ?int
/**
* @return self
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;
@@ -115,7 +115,7 @@ public function getPriority(): ?int
/**
* @return self
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
diff --git a/pkg/amqp-lib/AmqpSubscriptionConsumer.php b/pkg/amqp-lib/AmqpSubscriptionConsumer.php
index e70b61a24..f96c4e49a 100644
--- a/pkg/amqp-lib/AmqpSubscriptionConsumer.php
+++ b/pkg/amqp-lib/AmqpSubscriptionConsumer.php
@@ -93,7 +93,7 @@ public function consume(int $timeout = 0): void
public function subscribe(Consumer $consumer, callable $callback): void
{
if (false == $consumer instanceof AmqpConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class));
}
if ($consumer->getConsumerTag() && array_key_exists($consumer->getConsumerTag(), $this->subscribers)) {
@@ -102,13 +102,13 @@ public function subscribe(Consumer $consumer, callable $callback): void
$libCallback = function (LibAMQPMessage $message) {
$receivedMessage = $this->context->convertMessage($message);
- $receivedMessage->setConsumerTag($message->delivery_info['consumer_tag']);
+ $receivedMessage->setConsumerTag($message->getConsumerTag());
/**
* @var AmqpConsumer
* @var callable $callback
*/
- list($consumer, $callback) = $this->subscribers[$message->delivery_info['consumer_tag']];
+ list($consumer, $callback) = $this->subscribers[$message->getConsumerTag()];
if (false === call_user_func($callback, $receivedMessage, $consumer)) {
throw new StopBasicConsumptionException();
@@ -140,7 +140,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
public function unsubscribe(Consumer $consumer): void
{
if (false == $consumer instanceof AmqpConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class));
}
if (false == $consumer->getConsumerTag()) {
diff --git a/pkg/amqp-lib/README.md b/pkg/amqp-lib/README.md
index 1a7be690a..f85ce7c5f 100644
--- a/pkg/amqp-lib/README.md
+++ b/pkg/amqp-lib/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# AMQP Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/amqp-lib)
+[](https://github.com/php-enqueue/amqp-lib/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/amqp-lib)
[](https://packagist.org/packages/enqueue/amqp-lib)
diff --git a/pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php b/pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php
index 9db9f6288..1a2cf4e4d 100644
--- a/pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php
+++ b/pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php
@@ -5,12 +5,14 @@
use Enqueue\AmqpLib\AmqpConnectionFactory;
use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
class AmqpConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
diff --git a/pkg/amqp-lib/Tests/AmqpConsumerTest.php b/pkg/amqp-lib/Tests/AmqpConsumerTest.php
index 16b59227c..3961e1ab9 100644
--- a/pkg/amqp-lib/Tests/AmqpConsumerTest.php
+++ b/pkg/amqp-lib/Tests/AmqpConsumerTest.php
@@ -27,9 +27,11 @@ public function testShouldImplementConsumerInterface()
public function testCouldBeConstructedWithContextAndQueueAsArguments()
{
- new AmqpConsumer(
- $this->createContextMock(),
- new AmqpQueue('aName')
+ self::assertInstanceOf(AmqpConsumer::class,
+ new AmqpConsumer(
+ $this->createContextMock(),
+ new AmqpQueue('aName')
+ )
);
}
@@ -113,10 +115,7 @@ public function testOnRejectShouldRejectMessage()
public function testShouldReturnMessageOnReceiveNoWait()
{
$libMessage = new \PhpAmqpLib\Message\AMQPMessage('body');
- $libMessage->delivery_info['delivery_tag'] = 'delivery-tag';
- $libMessage->delivery_info['routing_key'] = 'routing-key';
- $libMessage->delivery_info['redelivered'] = true;
- $libMessage->delivery_info['routing_key'] = 'routing-key';
+ $libMessage->setDeliveryInfo('delivery-tag', true, '', 'routing-key');
$message = new AmqpMessage();
@@ -150,9 +149,7 @@ public function testShouldReturnMessageOnReceiveNoWait()
public function testShouldReturnMessageOnReceiveWithReceiveMethodBasicGet()
{
$libMessage = new \PhpAmqpLib\Message\AMQPMessage('body');
- $libMessage->delivery_info['delivery_tag'] = 'delivery-tag';
- $libMessage->delivery_info['routing_key'] = 'routing-key';
- $libMessage->delivery_info['redelivered'] = true;
+ $libMessage->setDeliveryInfo('delivery-tag', true, '', 'routing-key');
$message = new AmqpMessage();
diff --git a/pkg/amqp-lib/Tests/AmqpProducerTest.php b/pkg/amqp-lib/Tests/AmqpProducerTest.php
index 0bce53361..5746d911a 100644
--- a/pkg/amqp-lib/Tests/AmqpProducerTest.php
+++ b/pkg/amqp-lib/Tests/AmqpProducerTest.php
@@ -25,7 +25,10 @@ class AmqpProducerTest extends TestCase
public function testCouldBeConstructedWithRequiredArguments()
{
- new AmqpProducer($this->createAmqpChannelMock(), $this->createContextMock());
+ self::assertInstanceOf(
+ AmqpProducer::class,
+ new AmqpProducer($this->createAmqpChannelMock(), $this->createContextMock())
+ );
}
public function testShouldImplementProducerInterface()
diff --git a/pkg/amqp-lib/Tests/AmqpSubscriptionConsumerTest.php b/pkg/amqp-lib/Tests/AmqpSubscriptionConsumerTest.php
index a87349771..a375657b2 100644
--- a/pkg/amqp-lib/Tests/AmqpSubscriptionConsumerTest.php
+++ b/pkg/amqp-lib/Tests/AmqpSubscriptionConsumerTest.php
@@ -19,7 +19,10 @@ public function testShouldImplementSubscriptionConsumerInterface()
public function testCouldBeConstructedWithAmqpContextAndHeartbeatOnTickAsArguments()
{
- new AmqpSubscriptionConsumer($this->createAmqpContextMock(), $heartbeatOnTick = true);
+ self::assertInstanceOf(
+ AmqpSubscriptionConsumer::class,
+ new AmqpSubscriptionConsumer($this->createAmqpContextMock(), $heartbeatOnTick = true)
+ );
}
/**
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpProducerTest.php b/pkg/amqp-lib/Tests/Spec/AmqpProducerTest.php
index 510b72ab9..f72296a66 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpProducerTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpProducerTest.php
@@ -10,9 +10,6 @@
*/
class AmqpProducerTest extends ProducerSpec
{
- /**
- * {@inheritdoc}
- */
protected function createProducer()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
index 8b618e912..1a5fb70b3 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -26,8 +23,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
index f3eb0f7c7..0e00b10e9 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -26,8 +23,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
index bd88088a9..83c4c948f 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePriorityMessagesFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
index 39fcb6fc1..d5f35ed65 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php
index 2574f5ab2..ade42b346 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php
@@ -10,9 +10,6 @@
*/
class AmqpSendAndReceiveTimestampAsIntengerTest extends SendAndReceiveTimestampAsIntegerSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
index a80e91b8a..6d66532c6 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
index 72a4eb5c4..621608020 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -24,8 +21,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
index 47da126e6..db536948a 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -23,8 +20,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
index 49a168ba7..c2b184209 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php
@@ -13,9 +13,6 @@
*/
class AmqpSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -24,8 +21,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
index d2b2aee06..ec404b59e 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php
@@ -14,9 +14,6 @@
*/
class AmqpSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -25,8 +22,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
@@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName)
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
index c42c4213b..665382fe4 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php
@@ -14,9 +14,6 @@
*/
class AmqpSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new AmqpConnectionFactory(getenv('AMQP_DSN'));
@@ -25,8 +22,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
@@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName)
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createTopic(Context $context, $topicName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
index 19d6a7030..7bf142e5d 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class AmqpSslSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$baseDir = realpath(__DIR__.'/../../../../');
@@ -37,8 +34,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param AmqpContext $context
*/
protected function createQueue(Context $context, $queueName)
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
index 284a03c11..b81b139e8 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
@@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri
{
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
index a8bd48e01..288ab25f4 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php
@@ -24,8 +24,6 @@ protected function tearDown(): void
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -39,8 +37,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
index b1987bbe7..345007135 100644
--- a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
+++ b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php
@@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn
{
/**
* @return AmqpContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param AmqpContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/amqp-lib/composer.json b/pkg/amqp-lib/composer.json
index a04900d1c..62f906c66 100644
--- a/pkg/amqp-lib/composer.json
+++ b/pkg/amqp-lib/composer.json
@@ -6,17 +6,17 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
- "php-amqplib/php-amqplib": "^2.10",
- "queue-interop/amqp-interop": "^0.8",
+ "php": "^8.1",
+ "php-amqplib/php-amqplib": "^3.2",
+ "queue-interop/amqp-interop": "^0.8.2",
"queue-interop/queue-interop": "^0.8",
"enqueue/amqp-tools": "^0.10"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/amqp-lib/examples/consume.php b/pkg/amqp-lib/examples/consume.php
index 633efca66..03f609c71 100644
--- a/pkg/amqp-lib/examples/consume.php
+++ b/pkg/amqp-lib/examples/consume.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\AmqpLib\AmqpConnectionFactory;
@@ -32,7 +32,7 @@
while (true) {
if ($m = $consumer->receive(100)) {
- echo $m->getBody(), PHP_EOL;
+ echo $m->getBody(), \PHP_EOL;
$consumer->acknowledge($m);
}
diff --git a/pkg/amqp-lib/examples/produce.php b/pkg/amqp-lib/examples/produce.php
index 2753f4ac7..7527b2620 100644
--- a/pkg/amqp-lib/examples/produce.php
+++ b/pkg/amqp-lib/examples/produce.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\AmqpLib\AmqpConnectionFactory;
@@ -26,7 +26,7 @@
$topic = $context->createTopic('test.amqp.ext');
$topic->addFlag(AmqpTopic::FLAG_DURABLE);
$topic->setType(AmqpTopic::TYPE_FANOUT);
-//$topic->setArguments(['alternate-exchange' => 'foo']);
+// $topic->setArguments(['alternate-exchange' => 'foo']);
$context->deleteTopic($topic);
$context->declareTopic($topic);
diff --git a/pkg/amqp-lib/tutorial/rpc_client.php b/pkg/amqp-lib/tutorial/rpc_client.php
index 74368c20f..6ad091bc0 100644
--- a/pkg/amqp-lib/tutorial/rpc_client.php
+++ b/pkg/amqp-lib/tutorial/rpc_client.php
@@ -11,12 +11,12 @@
'pass' => 'guest',
];
-class FibonacciRpcClient
+class rpc_client
{
- /** @var \Interop\Amqp\AmqpContext */
+ /** @var Interop\Amqp\AmqpContext */
private $context;
- /** @var \Interop\Amqp\AmqpQueue */
+ /** @var Interop\Amqp\AmqpQueue */
private $callback_queue;
public function __construct(array $config)
@@ -43,7 +43,7 @@ public function call($n)
while (true) {
if ($message = $consumer->receive()) {
if ($message->getCorrelationId() == $corr_id) {
- return (int) ($message->getBody());
+ return (int) $message->getBody();
}
}
}
diff --git a/pkg/amqp-lib/tutorial/rpc_server.php b/pkg/amqp-lib/tutorial/rpc_server.php
index 954d21f25..241471684 100644
--- a/pkg/amqp-lib/tutorial/rpc_server.php
+++ b/pkg/amqp-lib/tutorial/rpc_server.php
@@ -37,7 +37,7 @@ function fib($n)
while (true) {
if ($req = $consumer->receive()) {
- $n = (int) ($req->getBody());
+ $n = (int) $req->getBody();
echo ' [.] fib(', $n, ")\n";
$msg = $context->createMessage((string) fib($n));
diff --git a/pkg/amqp-tools/.github/workflows/ci.yml b/pkg/amqp-tools/.github/workflows/ci.yml
new file mode 100644
index 000000000..5448d7b1a
--- /dev/null
+++ b/pkg/amqp-tools/.github/workflows/ci.yml
@@ -0,0 +1,27 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/amqp-tools/ConnectionConfig.php b/pkg/amqp-tools/ConnectionConfig.php
index 224d54b9d..e1356c7cb 100644
--- a/pkg/amqp-tools/ConnectionConfig.php
+++ b/pkg/amqp-tools/ConnectionConfig.php
@@ -104,9 +104,6 @@ public function __construct($config = null)
$this->addSupportedScheme('amqps');
}
- /**
- * @param string[] $extensions
- */
public function addSupportedScheme(string $schema): self
{
$this->supportedSchemes[] = $schema;
@@ -117,7 +114,6 @@ public function addSupportedScheme(string $schema): self
/**
* @param string $name
- * @param mixed $value
*
* @return self
*/
@@ -153,18 +149,18 @@ public function parse()
$config = array_replace($this->defaultConfig, $config);
$config['host'] = (string) $config['host'];
- $config['port'] = (int) ($config['port']);
+ $config['port'] = (int) $config['port'];
$config['user'] = (string) $config['user'];
$config['pass'] = (string) $config['pass'];
- $config['read_timeout'] = max((float) ($config['read_timeout']), 0);
- $config['write_timeout'] = max((float) ($config['write_timeout']), 0);
- $config['connection_timeout'] = max((float) ($config['connection_timeout']), 0);
- $config['heartbeat'] = max((float) ($config['heartbeat']), 0);
+ $config['read_timeout'] = max((float) $config['read_timeout'], 0);
+ $config['write_timeout'] = max((float) $config['write_timeout'], 0);
+ $config['connection_timeout'] = max((float) $config['connection_timeout'], 0);
+ $config['heartbeat'] = max((float) $config['heartbeat'], 0);
$config['persisted'] = !empty($config['persisted']);
$config['lazy'] = !empty($config['lazy']);
$config['qos_global'] = !empty($config['qos_global']);
- $config['qos_prefetch_count'] = max((int) ($config['qos_prefetch_count']), 0);
- $config['qos_prefetch_size'] = max((int) ($config['qos_prefetch_size']), 0);
+ $config['qos_prefetch_count'] = max((int) $config['qos_prefetch_count'], 0);
+ $config['qos_prefetch_size'] = max((int) $config['qos_prefetch_size'], 0);
$config['ssl_on'] = !empty($config['ssl_on']);
$config['ssl_verify'] = !empty($config['ssl_verify']);
$config['ssl_cacert'] = (string) $config['ssl_cacert'];
@@ -346,10 +342,8 @@ public function getSslPassPhrase()
}
/**
- * @param string $name
- * @param mixed $default
- *
- * @return mixed
+ * @param string $name
+ * @param mixed|null $default
*/
public function getOption($name, $default = null)
{
@@ -383,11 +377,7 @@ private function parseDsn($dsn)
$supportedSchemes = $this->supportedSchemes;
if (false == in_array($dsn->getSchemeProtocol(), $supportedSchemes, true)) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be one of "%s".',
- $dsn->getSchemeProtocol(),
- implode('", "', $supportedSchemes)
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be one of "%s".', $dsn->getSchemeProtocol(), implode('", "', $supportedSchemes)));
}
$sslOn = false;
@@ -406,7 +396,7 @@ private function parseDsn($dsn)
'user' => $dsn->getUser(),
'pass' => $dsn->getPassword(),
'vhost' => null !== ($path = $dsn->getPath()) ?
- (0 === strpos($path, '/') ? substr($path, 1) : $path)
+ (str_starts_with($path, '/') ? substr($path, 1) : $path)
: null,
'read_timeout' => $dsn->getFloat('read_timeout'),
'write_timeout' => $dsn->getFloat('write_timeout'),
diff --git a/pkg/amqp-tools/DelayStrategyAware.php b/pkg/amqp-tools/DelayStrategyAware.php
index f41a856a1..af488ce07 100644
--- a/pkg/amqp-tools/DelayStrategyAware.php
+++ b/pkg/amqp-tools/DelayStrategyAware.php
@@ -6,5 +6,5 @@
interface DelayStrategyAware
{
- public function setDelayStrategy(DelayStrategy $delayStrategy = null): self;
+ public function setDelayStrategy(?DelayStrategy $delayStrategy = null): self;
}
diff --git a/pkg/amqp-tools/DelayStrategyAwareTrait.php b/pkg/amqp-tools/DelayStrategyAwareTrait.php
index 785f12895..b29f05797 100644
--- a/pkg/amqp-tools/DelayStrategyAwareTrait.php
+++ b/pkg/amqp-tools/DelayStrategyAwareTrait.php
@@ -11,7 +11,7 @@ trait DelayStrategyAwareTrait
*/
protected $delayStrategy;
- public function setDelayStrategy(DelayStrategy $delayStrategy = null): DelayStrategyAware
+ public function setDelayStrategy(?DelayStrategy $delayStrategy = null): DelayStrategyAware
{
$this->delayStrategy = $delayStrategy;
diff --git a/pkg/amqp-tools/README.md b/pkg/amqp-tools/README.md
index 14f007cbb..16cb1667f 100644
--- a/pkg/amqp-tools/README.md
+++ b/pkg/amqp-tools/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# AMQP tools
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/amqp-tools)
+[](https://github.com/php-enqueue/amqp-tools/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/amqp-tools)
[](https://packagist.org/packages/enqueue/amqp-tools)
diff --git a/pkg/amqp-tools/RabbitMqDelayPluginDelayStrategy.php b/pkg/amqp-tools/RabbitMqDelayPluginDelayStrategy.php
index 192135965..180d43bd9 100644
--- a/pkg/amqp-tools/RabbitMqDelayPluginDelayStrategy.php
+++ b/pkg/amqp-tools/RabbitMqDelayPluginDelayStrategy.php
@@ -39,10 +39,7 @@ public function delayMessage(AmqpContext $context, AmqpDestination $dest, AmqpMe
$context->declareTopic($delayTopic);
$context->bind(new AmqpBind($dest, $delayTopic, $delayMessage->getRoutingKey()));
} else {
- throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.',
- AmqpTopic::class.'|'.AmqpQueue::class,
- get_class($dest)
- ));
+ throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.', AmqpTopic::class.'|'.AmqpQueue::class, $dest::class));
}
$producer = $context->createProducer();
diff --git a/pkg/amqp-tools/RabbitMqDlxDelayStrategy.php b/pkg/amqp-tools/RabbitMqDlxDelayStrategy.php
index f0fdd8956..35d9b59fe 100644
--- a/pkg/amqp-tools/RabbitMqDlxDelayStrategy.php
+++ b/pkg/amqp-tools/RabbitMqDlxDelayStrategy.php
@@ -13,9 +13,6 @@
class RabbitMqDlxDelayStrategy implements DelayStrategy
{
- /**
- * {@inheritdoc}
- */
public function delayMessage(AmqpContext $context, AmqpDestination $dest, AmqpMessage $message, int $delay): void
{
$properties = $message->getProperties();
@@ -44,10 +41,7 @@ public function delayMessage(AmqpContext $context, AmqpDestination $dest, AmqpMe
$delayQueue->setArgument('x-dead-letter-exchange', '');
$delayQueue->setArgument('x-dead-letter-routing-key', $dest->getQueueName());
} else {
- throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.',
- AmqpTopic::class.'|'.AmqpQueue::class,
- get_class($dest)
- ));
+ throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.', AmqpTopic::class.'|'.AmqpQueue::class, $dest::class));
}
$context->declareQueue($delayQueue);
diff --git a/pkg/amqp-tools/SignalSocketHelper.php b/pkg/amqp-tools/SignalSocketHelper.php
index 0bee8f22e..623a5e3e2 100644
--- a/pkg/amqp-tools/SignalSocketHelper.php
+++ b/pkg/amqp-tools/SignalSocketHelper.php
@@ -28,7 +28,7 @@ public function beforeSocket(): void
return;
}
- $signals = [SIGTERM, SIGQUIT, SIGINT];
+ $signals = [\SIGTERM, \SIGQUIT, \SIGINT];
if ($this->handlers) {
throw new \LogicException('The handlers property should be empty but it is not. The afterSocket method might not have been called.');
@@ -60,12 +60,12 @@ public function afterSocket(): void
return;
}
- $signals = [SIGTERM, SIGQUIT, SIGINT];
+ $signals = [\SIGTERM, \SIGQUIT, \SIGINT];
$this->wasThereSignal = null;
foreach ($signals as $signal) {
- $handler = isset($this->handlers[$signal]) ? $this->handlers[$signal] : SIG_DFL;
+ $handler = isset($this->handlers[$signal]) ? $this->handlers[$signal] : \SIG_DFL;
pcntl_signal($signal, $handler);
}
@@ -73,9 +73,6 @@ public function afterSocket(): void
$this->handlers = [];
}
- /**
- * @return bool
- */
public function wasThereSignal(): bool
{
return (bool) $this->wasThereSignal;
diff --git a/pkg/amqp-tools/Tests/ConnectionConfigTest.php b/pkg/amqp-tools/Tests/ConnectionConfigTest.php
index 67a3f624b..1a1dc477d 100644
--- a/pkg/amqp-tools/Tests/ConnectionConfigTest.php
+++ b/pkg/amqp-tools/Tests/ConnectionConfigTest.php
@@ -122,9 +122,6 @@ public function testShouldGetSchemeExtensions()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
diff --git a/pkg/amqp-tools/Tests/RabbitMqDelayPluginDelayStrategyTest.php b/pkg/amqp-tools/Tests/RabbitMqDelayPluginDelayStrategyTest.php
index de2b77ec5..d20506919 100644
--- a/pkg/amqp-tools/Tests/RabbitMqDelayPluginDelayStrategyTest.php
+++ b/pkg/amqp-tools/Tests/RabbitMqDelayPluginDelayStrategyTest.php
@@ -192,7 +192,7 @@ public function send(Destination $destination, Message $message): void
{
}
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
throw new \BadMethodCallException('This should not be called directly');
}
@@ -202,7 +202,7 @@ public function getDeliveryDelay(): ?int
throw new \BadMethodCallException('This should not be called directly');
}
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
throw new \BadMethodCallException('This should not be called directly');
}
@@ -212,7 +212,7 @@ public function getPriority(): ?int
throw new \BadMethodCallException('This should not be called directly');
}
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
throw new \BadMethodCallException('This should not be called directly');
}
diff --git a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php
index d869878c9..a44e42a70 100644
--- a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php
+++ b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php
@@ -3,10 +3,13 @@
namespace Enqueue\AmqpTools\Tests;
use Enqueue\AmqpTools\SignalSocketHelper;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
class SignalSocketHelperTest extends TestCase
{
+ use ReadAttributeTrait;
+
/**
* @var SignalSocketHelper
*/
@@ -16,7 +19,7 @@ class SignalSocketHelperTest extends TestCase
private $backupSigIntHandler;
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -25,16 +28,16 @@ public function setUp()
$this->markTestSkipped('PHP 7.1+ needed');
}
- $this->backupSigTermHandler = pcntl_signal_get_handler(SIGTERM);
- $this->backupSigIntHandler = pcntl_signal_get_handler(SIGINT);
+ $this->backupSigTermHandler = pcntl_signal_get_handler(\SIGTERM);
+ $this->backupSigIntHandler = pcntl_signal_get_handler(\SIGINT);
- pcntl_signal(SIGTERM, SIG_DFL);
- pcntl_signal(SIGINT, SIG_DFL);
+ pcntl_signal(\SIGTERM, \SIG_DFL);
+ pcntl_signal(\SIGINT, \SIG_DFL);
$this->signalHelper = new SignalSocketHelper();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
@@ -43,11 +46,11 @@ public function tearDown(): void
}
if ($this->backupSigTermHandler) {
- pcntl_signal(SIGTERM, $this->backupSigTermHandler);
+ pcntl_signal(\SIGTERM, $this->backupSigTermHandler);
}
if ($this->backupSigIntHandler) {
- pcntl_signal(SIGINT, $this->backupSigIntHandler);
+ pcntl_signal(\SIGINT, $this->backupSigIntHandler);
}
}
@@ -68,7 +71,7 @@ public function testShouldRegisterHandlerOnBeforeSocketAndBackupCurrentOne()
{
$handler = function () {};
- pcntl_signal(SIGTERM, $handler);
+ pcntl_signal(\SIGTERM, $handler);
$this->signalHelper->beforeSocket();
@@ -76,9 +79,9 @@ public function testShouldRegisterHandlerOnBeforeSocketAndBackupCurrentOne()
$handlers = $this->readAttribute($this->signalHelper, 'handlers');
- $this->assertInternalType('array', $handlers);
- $this->assertArrayHasKey(SIGTERM, $handlers);
- $this->assertSame($handler, $handlers[SIGTERM]);
+ self::assertIsArray($handlers);
+ $this->assertArrayHasKey(\SIGTERM, $handlers);
+ $this->assertSame($handler, $handlers[\SIGTERM]);
}
public function testRestoreDefaultPropertiesOnAfterSocket()
@@ -94,12 +97,12 @@ public function testRestorePreviousHandlerOnAfterSocket()
{
$handler = function () {};
- pcntl_signal(SIGTERM, $handler);
+ pcntl_signal(\SIGTERM, $handler);
$this->signalHelper->beforeSocket();
$this->signalHelper->afterSocket();
- $this->assertSame($handler, pcntl_signal_get_handler(SIGTERM));
+ $this->assertSame($handler, pcntl_signal_get_handler(\SIGTERM));
}
public function testThrowsIfBeforeSocketCalledSecondTime()
@@ -115,7 +118,7 @@ public function testShouldReturnTrueOnWasThereSignal()
{
$this->signalHelper->beforeSocket();
- posix_kill(getmypid(), SIGINT);
+ posix_kill(getmypid(), \SIGINT);
pcntl_signal_dispatch();
$this->assertTrue($this->signalHelper->wasThereSignal());
diff --git a/pkg/amqp-tools/composer.json b/pkg/amqp-tools/composer.json
index 6cb280fd5..966e065e8 100644
--- a/pkg/amqp-tools/composer.json
+++ b/pkg/amqp-tools/composer.json
@@ -6,13 +6,13 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
- "queue-interop/amqp-interop": "^0.8",
+ "php": "^8.1",
+ "queue-interop/amqp-interop": "^0.8.2",
"queue-interop/queue-interop": "^0.8",
"enqueue/dsn": "^0.10"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev"
},
diff --git a/pkg/async-command/.github/workflows/ci.yml b/pkg/async-command/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/async-command/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/async-command/.travis.yml b/pkg/async-command/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/async-command/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/async-command/CommandResult.php b/pkg/async-command/CommandResult.php
index 1c746a9a2..10080d587 100644
--- a/pkg/async-command/CommandResult.php
+++ b/pkg/async-command/CommandResult.php
@@ -19,11 +19,6 @@ final class CommandResult implements \JsonSerializable
*/
private $errorOutput;
- /**
- * @param int $exitCode
- * @param string $output
- * @param string $errorOutput
- */
public function __construct(int $exitCode, string $output, string $errorOutput)
{
$this->exitCode = $exitCode;
@@ -58,12 +53,8 @@ public function jsonSerialize(): array
public static function jsonUnserialize(string $json): self
{
$data = json_decode($json, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return new self($data['exitCode'], $data['output'], $data['errorOutput']);
diff --git a/pkg/async-command/Commands.php b/pkg/async-command/Commands.php
index 0d751accd..abc015cf8 100644
--- a/pkg/async-command/Commands.php
+++ b/pkg/async-command/Commands.php
@@ -4,5 +4,5 @@
final class Commands
{
- const RUN_COMMAND = 'run_command';
+ public const RUN_COMMAND = 'run_command';
}
diff --git a/pkg/async-command/README.md b/pkg/async-command/README.md
index bd895676d..711e97163 100644
--- a/pkg/async-command/README.md
+++ b/pkg/async-command/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Symfony Async Command.
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/async-command)
+[](https://github.com/php-enqueue/async-command/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/async-command)
[](https://packagist.org/packages/enqueue/async-command)
diff --git a/pkg/async-command/RunCommand.php b/pkg/async-command/RunCommand.php
index 437c3a6d9..573a6200b 100644
--- a/pkg/async-command/RunCommand.php
+++ b/pkg/async-command/RunCommand.php
@@ -20,7 +20,6 @@ final class RunCommand implements \JsonSerializable
private $options;
/**
- * @param string $command
* @param string[] $arguments
* @param string[] $options
*/
@@ -64,12 +63,8 @@ public function jsonSerialize(): array
public static function jsonUnserialize(string $json): self
{
$data = json_decode($json, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return new self($data['command'], $data['arguments'], $data['options']);
diff --git a/pkg/async-command/Tests/RunCommandProcessorTest.php b/pkg/async-command/Tests/RunCommandProcessorTest.php
index 3065ec315..7a7a36428 100644
--- a/pkg/async-command/Tests/RunCommandProcessorTest.php
+++ b/pkg/async-command/Tests/RunCommandProcessorTest.php
@@ -3,11 +3,14 @@
namespace Enqueue\AsyncCommand\Tests;
use Enqueue\AsyncCommand\RunCommandProcessor;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Processor;
use PHPUnit\Framework\TestCase;
class RunCommandProcessorTest extends TestCase
{
+ use ReadAttributeTrait;
+
public function testShouldImplementProcessorInterface()
{
$rc = new \ReflectionClass(RunCommandProcessor::class);
diff --git a/pkg/async-command/composer.json b/pkg/async-command/composer.json
index a511f8b0e..95d57ce3a 100644
--- a/pkg/async-command/composer.json
+++ b/pkg/async-command/composer.json
@@ -6,19 +6,19 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": ">=7.1",
+ "php": "^8.1",
"enqueue/enqueue": "^0.10",
"queue-interop/queue-interop": "^0.8",
- "symfony/console": "^4.3|^5",
- "symfony/process": "^4.3|^5"
+ "symfony/console": "^5.4|^6.0",
+ "symfony/process": "^5.4|^6.0"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
- "symfony/dependency-injection": "^4.3|^5",
- "symfony/config": "^4.3|^5",
- "symfony/http-kernel": "^4.3|^5",
- "symfony/filesystem": "^4.3|^5",
- "symfony/yaml": "^4.3|^5",
+ "phpunit/phpunit": "^9.5",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/http-kernel": "^5.4|^6.0",
+ "symfony/filesystem": "^5.4|^6.0",
+ "symfony/yaml": "^5.4|^6.0",
"enqueue/null": "0.10.x-dev",
"enqueue/fs": "0.10.x-dev",
"enqueue/test": "0.10.x-dev"
@@ -31,7 +31,7 @@
"docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md"
},
"suggest": {
- "symfony/dependency-injection": "^4.3|^5 If you'd like to use async event dispatcher container extension."
+ "symfony/dependency-injection": "^5.4|^6.0 If you'd like to use async event dispatcher container extension."
},
"autoload": {
"psr-4": { "Enqueue\\AsyncCommand\\": "" },
diff --git a/pkg/async-event-dispatcher/.github/workflows/ci.yml b/pkg/async-event-dispatcher/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/async-event-dispatcher/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/async-event-dispatcher/.travis.yml b/pkg/async-event-dispatcher/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/async-event-dispatcher/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/async-event-dispatcher/AsyncEventDispatcher.php b/pkg/async-event-dispatcher/AsyncEventDispatcher.php
index 153fdc111..e39136eff 100644
--- a/pkg/async-event-dispatcher/AsyncEventDispatcher.php
+++ b/pkg/async-event-dispatcher/AsyncEventDispatcher.php
@@ -2,48 +2,17 @@
namespace Enqueue\AsyncEventDispatcher;
-use Symfony\Component\EventDispatcher\Event;
-
-if (class_exists(Event::class)) {
- /**
- * Symfony < 5.0.
- */
- class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
+class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
+{
+ public function dispatch(object $event, ?string $eventName = null): object
{
- /**
- * {@inheritdoc}
- */
- public function dispatch($event, $eventName = null)
- {
- $this->parentDispatch($event, $eventName);
-
- return $this->trueEventDispatcher->dispatch($event, $eventName);
- }
+ $this->parentDispatch($event, $eventName);
- protected function parentDispatch($event, $eventName)
- {
- parent::dispatch($event, $eventName);
- }
+ return $this->trueEventDispatcher->dispatch($event, $eventName);
}
-} else {
- /**
- * Symfony >= 5.0.
- */
- class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
- {
- /**
- * {@inheritdoc}
- */
- public function dispatch(object $event, string $eventName = null): object
- {
- $this->parentDispatch($event, $eventName);
- return $this->trueEventDispatcher->dispatch($event, $eventName);
- }
-
- protected function parentDispatch($event, $eventName)
- {
- return parent::dispatch($event, $eventName);
- }
+ protected function parentDispatch($event, $eventName)
+ {
+ return parent::dispatch($event, $eventName);
}
}
diff --git a/pkg/async-event-dispatcher/AsyncListener.php b/pkg/async-event-dispatcher/AsyncListener.php
index ccbe5b038..2be4976fb 100644
--- a/pkg/async-event-dispatcher/AsyncListener.php
+++ b/pkg/async-event-dispatcher/AsyncListener.php
@@ -2,66 +2,28 @@
namespace Enqueue\AsyncEventDispatcher;
-use Symfony\Component\EventDispatcher\Event;
-use Symfony\Contracts\EventDispatcher\Event as ContractEvent;
+use Symfony\Contracts\EventDispatcher\Event;
-if (class_exists(Event::class)) {
- /**
- * Symfony < 5.0.
- */
- class AsyncListener extends AbstractAsyncListener
+class AsyncListener extends AbstractAsyncListener
+{
+ public function __invoke(Event $event, $eventName)
{
- /**
- * @param Event|ContractEvent $event
- * @param string $eventName
- */
- public function __invoke($event, $eventName)
- {
- $this->onEvent($event, $eventName);
- }
-
- /**
- * @param Event|ContractEvent $event
- * @param string $eventName
- */
- public function onEvent($event, $eventName)
- {
- if (false == isset($this->syncMode[$eventName])) {
- $transformerName = $this->registry->getTransformerNameForEvent($eventName);
-
- $message = $this->registry->getTransformer($transformerName)->toMessage($eventName, $event);
- $message->setProperty('event_name', $eventName);
- $message->setProperty('transformer_name', $transformerName);
-
- $this->context->createProducer()->send($this->eventQueue, $message);
- }
- }
+ $this->onEvent($event, $eventName);
}
-} else {
+
/**
- * Symfony >= 5.0.
+ * @param string $eventName
*/
- class AsyncListener extends AbstractAsyncListener
+ public function onEvent(Event $event, $eventName)
{
- public function __invoke(ContractEvent $event, $eventName)
- {
- $this->onEvent($event, $eventName);
- }
-
- /**
- * @param string $eventName
- */
- public function onEvent(ContractEvent $event, $eventName)
- {
- if (false == isset($this->syncMode[$eventName])) {
- $transformerName = $this->registry->getTransformerNameForEvent($eventName);
+ if (false == isset($this->syncMode[$eventName])) {
+ $transformerName = $this->registry->getTransformerNameForEvent($eventName);
- $message = $this->registry->getTransformer($transformerName)->toMessage($eventName, $event);
- $message->setProperty('event_name', $eventName);
- $message->setProperty('transformer_name', $transformerName);
+ $message = $this->registry->getTransformer($transformerName)->toMessage($eventName, $event);
+ $message->setProperty('event_name', $eventName);
+ $message->setProperty('transformer_name', $transformerName);
- $this->context->createProducer()->send($this->eventQueue, $message);
- }
+ $this->context->createProducer()->send($this->eventQueue, $message);
}
}
}
diff --git a/pkg/async-event-dispatcher/AsyncProcessor.php b/pkg/async-event-dispatcher/AsyncProcessor.php
index c89f7e1de..dc61c5381 100644
--- a/pkg/async-event-dispatcher/AsyncProcessor.php
+++ b/pkg/async-event-dispatcher/AsyncProcessor.php
@@ -25,11 +25,7 @@ public function __construct(Registry $registry, EventDispatcherInterface $dispat
$this->registry = $registry;
if (false == $dispatcher instanceof AsyncEventDispatcher) {
- throw new \InvalidArgumentException(sprintf(
- 'The dispatcher argument must be instance of "%s" but got "%s"',
- AsyncEventDispatcher::class,
- get_class($dispatcher)
- ));
+ throw new \InvalidArgumentException(sprintf('The dispatcher argument must be instance of "%s" but got "%s"', AsyncEventDispatcher::class, $dispatcher::class));
}
$this->dispatcher = $dispatcher;
diff --git a/pkg/async-event-dispatcher/Commands.php b/pkg/async-event-dispatcher/Commands.php
index a00ed6fa9..c2263ee38 100644
--- a/pkg/async-event-dispatcher/Commands.php
+++ b/pkg/async-event-dispatcher/Commands.php
@@ -4,5 +4,5 @@
final class Commands
{
- const DISPATCH_ASYNC_EVENTS = 'symfony.dispatch_async_events';
+ public const DISPATCH_ASYNC_EVENTS = 'symfony.dispatch_async_events';
}
diff --git a/pkg/async-event-dispatcher/ContainerAwareRegistry.php b/pkg/async-event-dispatcher/ContainerAwareRegistry.php
index 2763ed72b..b0e23f222 100644
--- a/pkg/async-event-dispatcher/ContainerAwareRegistry.php
+++ b/pkg/async-event-dispatcher/ContainerAwareRegistry.php
@@ -2,12 +2,14 @@
namespace Enqueue\AsyncEventDispatcher;
-use Symfony\Component\DependencyInjection\ContainerAwareInterface;
-use Symfony\Component\DependencyInjection\ContainerAwareTrait;
+use Psr\Container\ContainerInterface;
-class ContainerAwareRegistry implements Registry, ContainerAwareInterface
+class ContainerAwareRegistry implements Registry
{
- use ContainerAwareTrait;
+ /**
+ * @var ContainerInterface
+ */
+ private $container;
/**
* @var string[]
@@ -23,15 +25,13 @@ class ContainerAwareRegistry implements Registry, ContainerAwareInterface
* @param string[] $eventsMap [eventName => transformerName]
* @param string[] $transformersMap [transformerName => transformerServiceId]
*/
- public function __construct(array $eventsMap, array $transformersMap)
+ public function __construct(array $eventsMap, array $transformersMap, ContainerInterface $container)
{
$this->eventsMap = $eventsMap;
$this->transformersMap = $transformersMap;
+ $this->container = $container;
}
- /**
- * {@inheritdoc}
- */
public function getTransformerNameForEvent($eventName)
{
$transformerName = null;
@@ -39,7 +39,7 @@ public function getTransformerNameForEvent($eventName)
$transformerName = $this->eventsMap[$eventName];
} else {
foreach ($this->eventsMap as $eventNamePattern => $name) {
- if ('/' != $eventNamePattern[0]) {
+ if ('/' !== $eventNamePattern[0]) {
continue;
}
@@ -58,9 +58,6 @@ public function getTransformerNameForEvent($eventName)
return $transformerName;
}
- /**
- * {@inheritdoc}
- */
public function getTransformer($name)
{
if (false == array_key_exists($name, $this->transformersMap)) {
@@ -69,12 +66,8 @@ public function getTransformer($name)
$transformer = $this->container->get($this->transformersMap[$name]);
- if (false == $transformer instanceof EventTransformer) {
- throw new \LogicException(sprintf(
- 'The container must return instance of %s but got %s',
- EventTransformer::class,
- is_object($transformer) ? get_class($transformer) : gettype($transformer)
- ));
+ if (false == $transformer instanceof EventTransformer) {
+ throw new \LogicException(sprintf('The container must return instance of %s but got %s', EventTransformer::class, is_object($transformer) ? $transformer::class : gettype($transformer)));
}
return $transformer;
diff --git a/pkg/async-event-dispatcher/DependencyInjection/AsyncEventsPass.php b/pkg/async-event-dispatcher/DependencyInjection/AsyncEventsPass.php
index 5371eb869..42774adf7 100644
--- a/pkg/async-event-dispatcher/DependencyInjection/AsyncEventsPass.php
+++ b/pkg/async-event-dispatcher/DependencyInjection/AsyncEventsPass.php
@@ -4,7 +4,6 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AsyncEventsPass implements CompilerPassInterface
@@ -30,11 +29,6 @@ public function process(ContainerBuilder $container): void
$event = $tagAttribute['event'];
- $service = $container->getDefinition($serviceId);
-
- $service->clearTag('kernel.event_listener');
- $service->addTag('enqueue.async_event_listener', $tagAttribute);
-
if (false == isset($registeredToEvent[$event])) {
$container->getDefinition('enqueue.events.async_listener')
->addTag('kernel.event_listener', [
@@ -43,6 +37,14 @@ public function process(ContainerBuilder $container): void
])
;
+ $container->getDefinition('enqueue.events.async_listener')
+ ->addTag('kernel.event_listener', [
+ 'event' => $event,
+ 'method' => 'onEvent',
+ 'dispatcher' => 'enqueue.events.event_dispatcher',
+ ])
+ ;
+
$container->getDefinition('enqueue.events.async_processor')
->addTag('enqueue.processor', [
'topic' => 'event.'.$event,
@@ -62,8 +64,6 @@ public function process(ContainerBuilder $container): void
}
$service = $container->getDefinition($serviceId);
- $service->clearTag('kernel.event_subscriber');
- $service->addTag('enqueue.async_event_subscriber', $tagAttribute);
/** @var EventSubscriberInterface $serviceClass */
$serviceClass = $service->getClass();
@@ -77,6 +77,14 @@ public function process(ContainerBuilder $container): void
])
;
+ $container->getDefinition('enqueue.events.async_listener')
+ ->addTag('kernel.event_listener', [
+ 'event' => $event,
+ 'method' => 'onEvent',
+ 'dispatcher' => 'enqueue.events.event_dispatcher',
+ ])
+ ;
+
$container->getDefinition('enqueue.events.async_processor')
->addTag('enqueue.processor', [
'topicName' => 'event.'.$event,
@@ -89,12 +97,5 @@ public function process(ContainerBuilder $container): void
}
}
}
-
- $registerListenersPass = new RegisterListenersPass(
- 'enqueue.events.event_dispatcher',
- 'enqueue.async_event_listener',
- 'enqueue.async_event_subscriber'
- );
- $registerListenersPass->process($container);
}
}
diff --git a/pkg/async-event-dispatcher/DependencyInjection/AsyncTransformersPass.php b/pkg/async-event-dispatcher/DependencyInjection/AsyncTransformersPass.php
index afe10217d..89046dd58 100644
--- a/pkg/async-event-dispatcher/DependencyInjection/AsyncTransformersPass.php
+++ b/pkg/async-event-dispatcher/DependencyInjection/AsyncTransformersPass.php
@@ -7,9 +7,6 @@
class AsyncTransformersPass implements CompilerPassInterface
{
- /**
- * {@inheritdoc}
- */
public function process(ContainerBuilder $container)
{
if (false == $container->hasDefinition('enqueue.events.registry')) {
diff --git a/pkg/async-event-dispatcher/DependencyInjection/Configuration.php b/pkg/async-event-dispatcher/DependencyInjection/Configuration.php
index 56151e956..7b85a469d 100644
--- a/pkg/async-event-dispatcher/DependencyInjection/Configuration.php
+++ b/pkg/async-event-dispatcher/DependencyInjection/Configuration.php
@@ -7,10 +7,7 @@
class Configuration implements ConfigurationInterface
{
- /**
- * {@inheritdoc}
- */
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$tb = new TreeBuilder('enqueue_async_event_dispatcher');
diff --git a/pkg/async-event-dispatcher/EventTransformer.php b/pkg/async-event-dispatcher/EventTransformer.php
index 352930cef..271dffa08 100644
--- a/pkg/async-event-dispatcher/EventTransformer.php
+++ b/pkg/async-event-dispatcher/EventTransformer.php
@@ -3,61 +3,25 @@
namespace Enqueue\AsyncEventDispatcher;
use Interop\Queue\Message;
-use Symfony\Component\EventDispatcher\Event;
-use Symfony\Contracts\EventDispatcher\Event as ContractEvent;
+use Symfony\Contracts\EventDispatcher\Event;
-if (class_exists(Event::class)) {
+interface EventTransformer
+{
/**
- * Symfony < 5.0.
+ * @param string $eventName
+ *
+ * @return Message
*/
- interface EventTransformer
- {
- /**
- * @param string $eventName
- * @param ContractEvent|Event|null $event
- *
- * @return Message
- */
- public function toMessage($eventName, $event = null);
+ public function toMessage($eventName, ?Event $event = null);
- /**
- * If you able to transform message back to event return it.
- * If you failed to transform for some reason you can return a string status.
- *
- * @param mixed $eventName
- *
- * @return ContractEvent|Event|string|object
- *
- * @see Process constants) or an object that implements __toString method.
- * The object must have a __toString method is supposed to be used as Processor::process return value.
- */
- public function toEvent($eventName, Message $message);
- }
-} else {
/**
- * Symfony >= 5.0.
+ * If you able to transform message back to event return it.
+ * If you failed to transform for some reason you can return a string status.
+ *
+ * @return Event|string|object
+ *
+ * @see Process constants) or an object that implements __toString method.
+ * The object must have a __toString method is supposed to be used as Processor::process return value.
*/
- interface EventTransformer
- {
- /**
- * @param string $eventName
- *
- * @return Message
- */
- public function toMessage($eventName, ContractEvent $event = null);
-
- /**
- * If you able to transform message back to event return it.
- * If you failed to transform for some reason you can return a string status.
- *
- * @param mixed $eventNAme
- * @param mixed $eventName
- *
- * @return ContractEvent|string|object
- *
- * @see Process constants) or an object that implements __toString method.
- * The object must have a __toString method is supposed to be used as Processor::process return value.
- */
- public function toEvent($eventName, Message $message);
- }
+ public function toEvent($eventName, Message $message);
}
diff --git a/pkg/async-event-dispatcher/PhpSerializerEventTransformer.php b/pkg/async-event-dispatcher/PhpSerializerEventTransformer.php
index c6a3e2c97..9c23883aa 100644
--- a/pkg/async-event-dispatcher/PhpSerializerEventTransformer.php
+++ b/pkg/async-event-dispatcher/PhpSerializerEventTransformer.php
@@ -2,29 +2,12 @@
namespace Enqueue\AsyncEventDispatcher;
-use Symfony\Component\EventDispatcher\Event;
-use Symfony\Contracts\EventDispatcher\Event as ContractEvent;
+use Symfony\Contracts\EventDispatcher\Event;
-if (class_exists(Event::class)) {
- /**
- * Symfony < 5.0.
- */
- class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
+class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
+{
+ public function toMessage($eventName, ?Event $event = null)
{
- public function toMessage($eventName, $event = null)
- {
- return $this->context->createMessage(serialize($event));
- }
- }
-} else {
- /**
- * Symfony >= 5.0.
- */
- class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
- {
- public function toMessage($eventName, ContractEvent $event = null)
- {
- return $this->context->createMessage(serialize($event));
- }
+ return $this->context->createMessage(serialize($event));
}
}
diff --git a/pkg/async-event-dispatcher/README.md b/pkg/async-event-dispatcher/README.md
index 93cee308e..c4804d981 100644
--- a/pkg/async-event-dispatcher/README.md
+++ b/pkg/async-event-dispatcher/README.md
@@ -10,12 +10,12 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Symfony Async Event Dispatcher.
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/async-event-dispathcer)
-[](https://packagist.org/packages/enqueue/async-event-dispathcer)
-[](https://packagist.org/packages/enqueue/async-event-dispathcer)
+[](https://github.com/php-enqueue/async-event-dispathcer/actions?query=workflow%3ACI)
+[](https://packagist.org/packages/enqueue/async-event-dispatcher)
+[](https://packagist.org/packages/enqueue/async-event-dispatcher)
It contains an extension to Symfony's [EventDispatcher](https://symfony.com/doc/current/components/event_dispatcher.html) component.
-It allows to processes events in background by sending them to MQ.
+It allows to process events in background by sending them to MQ.
## Resources
diff --git a/pkg/async-event-dispatcher/Resources/config/services.yml b/pkg/async-event-dispatcher/Resources/config/services.yml
index 2b3fbc0b0..67365dcb5 100644
--- a/pkg/async-event-dispatcher/Resources/config/services.yml
+++ b/pkg/async-event-dispatcher/Resources/config/services.yml
@@ -8,9 +8,7 @@ services:
enqueue.events.registry:
class: 'Enqueue\AsyncEventDispatcher\ContainerAwareRegistry'
public: false
- arguments: [[], []]
- calls:
- - ['setContainer', ['@service_container']]
+ arguments: [[], [], '@service_container']
enqueue.events.async_listener:
class: 'Enqueue\AsyncEventDispatcher\AsyncListener'
diff --git a/pkg/async-event-dispatcher/SimpleRegistry.php b/pkg/async-event-dispatcher/SimpleRegistry.php
index 2f39d0cac..e5ba16ef8 100644
--- a/pkg/async-event-dispatcher/SimpleRegistry.php
+++ b/pkg/async-event-dispatcher/SimpleRegistry.php
@@ -24,9 +24,6 @@ public function __construct(array $eventsMap, array $transformersMap)
$this->transformersMap = $transformersMap;
}
- /**
- * {@inheritdoc}
- */
public function getTransformerNameForEvent($eventName)
{
$transformerName = null;
@@ -53,9 +50,6 @@ public function getTransformerNameForEvent($eventName)
return $transformerName;
}
- /**
- * {@inheritdoc}
- */
public function getTransformer($name)
{
if (false == array_key_exists($name, $this->transformersMap)) {
@@ -64,12 +58,8 @@ public function getTransformer($name)
$transformer = $this->transformersMap[$name];
- if (false == $transformer instanceof EventTransformer) {
- throw new \LogicException(sprintf(
- 'The container must return instance of %s but got %s',
- EventTransformer::class,
- is_object($transformer) ? get_class($transformer) : gettype($transformer)
- ));
+ if (false == $transformer instanceof EventTransformer) {
+ throw new \LogicException(sprintf('The container must return instance of %s but got %s', EventTransformer::class, is_object($transformer) ? $transformer::class : gettype($transformer)));
}
return $transformer;
diff --git a/pkg/async-event-dispatcher/Tests/AsyncListenerTest.php b/pkg/async-event-dispatcher/Tests/AsyncListenerTest.php
index c5a1c3567..d888c0228 100644
--- a/pkg/async-event-dispatcher/Tests/AsyncListenerTest.php
+++ b/pkg/async-event-dispatcher/Tests/AsyncListenerTest.php
@@ -8,18 +8,18 @@
use Enqueue\Null\NullMessage;
use Enqueue\Null\NullQueue;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Context;
use Interop\Queue\Producer;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\GenericEvent;
-use Symfony\Component\HttpKernel\Kernel;
-use Symfony\Contracts\EventDispatcher\Event as ContractEvent;
+use Symfony\Contracts\EventDispatcher\Event;
class AsyncListenerTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testCouldBeConstructedWithContextAndRegistryAndEventQueueAsString()
{
@@ -71,9 +71,7 @@ public function testShouldDoNothingIfSyncModeOn()
$listener->syncMode('fooEvent');
- $eventClass = Kernel::VERSION_ID >= 50000 ? ContractEvent::class : Event::class;
-
- $listener->onEvent(new $eventClass(), 'fooEvent');
+ $listener->onEvent(new Event(), 'fooEvent');
$listener->onEvent(new GenericEvent(), 'fooEvent');
}
diff --git a/pkg/async-event-dispatcher/Tests/AsyncProcessorTest.php b/pkg/async-event-dispatcher/Tests/AsyncProcessorTest.php
index 7237c9ae2..019f9bcbe 100644
--- a/pkg/async-event-dispatcher/Tests/AsyncProcessorTest.php
+++ b/pkg/async-event-dispatcher/Tests/AsyncProcessorTest.php
@@ -24,11 +24,6 @@ public function testShouldImplementProcessorInterface()
$this->assertClassImplements(Processor::class, AsyncProcessor::class);
}
- public function testCouldBeConstructedWithRegistryAndProxyEventDispatcher()
- {
- new AsyncProcessor($this->createRegistryMock(), $this->createProxyEventDispatcherMock());
- }
-
public function testRejectIfMessageMissingEventNameProperty()
{
$processor = new AsyncProcessor($this->createRegistryMock(), $this->createProxyEventDispatcherMock());
diff --git a/pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php b/pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php
index 125550268..79762ac17 100644
--- a/pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php
+++ b/pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php
@@ -6,49 +6,39 @@
use Enqueue\AsyncEventDispatcher\EventTransformer;
use Enqueue\AsyncEventDispatcher\Registry;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Container;
class ContainerAwareRegistryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementRegistryInterface()
{
$this->assertClassImplements(Registry::class, ContainerAwareRegistry::class);
}
- public function testCouldBeConstructedWithEventsMapAndTransformersMapAsArguments()
- {
- new ContainerAwareRegistry([], []);
- }
-
- public function testShouldSetContainerToContainerProperty()
+ public function testShouldAllowGetTransportNameByEventName()
{
$container = new Container();
- $registry = new ContainerAwareRegistry([], []);
-
- $registry->setContainer($container);
-
- $this->assertAttributeSame($container, 'container', $registry);
- }
-
- public function testShouldAllowGetTransportNameByEventName()
- {
$registry = new ContainerAwareRegistry([
- 'fooEvent' => 'fooTrans',
- ], []);
+ 'fooEvent' => 'fooTrans',
+ ], [], $container);
$this->assertEquals('fooTrans', $registry->getTransformerNameForEvent('fooEvent'));
}
public function testShouldAllowDefineTransportNameAsRegExpPattern()
{
+ $container = new Container();
+
$registry = new ContainerAwareRegistry([
'/.*/' => 'fooRegExpTrans',
'fooEvent' => 'fooTrans',
- ], []);
+ ], [], $container);
// guard
$this->assertEquals('fooTrans', $registry->getTransformerNameForEvent('fooEvent'));
@@ -58,9 +48,11 @@ public function testShouldAllowDefineTransportNameAsRegExpPattern()
public function testThrowIfNotSupportedEventGiven()
{
+ $container = new Container();
+
$registry = new ContainerAwareRegistry([
'fooEvent' => 'fooTrans',
- ], []);
+ ], [], $container);
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('There is no transformer registered for the given event fooNotSupportedEvent');
@@ -69,9 +61,11 @@ public function testThrowIfNotSupportedEventGiven()
public function testThrowIfThereIsNoRegisteredTransformerWithSuchName()
{
+ $container = new Container();
+
$registry = new ContainerAwareRegistry([], [
'fooTrans' => 'foo_trans_id',
- ]);
+ ], $container);
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('There is no transformer named fooNotRegisteredName');
@@ -85,8 +79,7 @@ public function testThrowIfContainerReturnsServiceNotInstanceOfEventTransformer(
$registry = new ContainerAwareRegistry([], [
'fooTrans' => 'foo_trans_id',
- ]);
- $registry->setContainer($container);
+ ], $container);
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The container must return instance of Enqueue\AsyncEventDispatcher\EventTransformer but got stdClass');
@@ -102,8 +95,7 @@ public function testShouldReturnEventTransformer()
$registry = new ContainerAwareRegistry([], [
'fooTrans' => 'foo_trans_id',
- ]);
- $registry->setContainer($container);
+ ], $container);
$this->assertSame($eventTransformerMock, $registry->getTransformer('fooTrans'));
}
diff --git a/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php b/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php
index d05a9add5..169d8ea5b 100644
--- a/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php
+++ b/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php
@@ -53,7 +53,7 @@ class UseCasesTest extends TestCase
*/
protected $asyncProcessor;
- public function setUp()
+ protected function setUp(): void
{
(new Filesystem())->remove(__DIR__.'/queues/');
diff --git a/pkg/async-event-dispatcher/Tests/PhpSerializerEventTransformerTest.php b/pkg/async-event-dispatcher/Tests/PhpSerializerEventTransformerTest.php
index 49f3a9371..498ca3ae9 100644
--- a/pkg/async-event-dispatcher/Tests/PhpSerializerEventTransformerTest.php
+++ b/pkg/async-event-dispatcher/Tests/PhpSerializerEventTransformerTest.php
@@ -21,11 +21,6 @@ public function testShouldImplementEventTransformerInterface()
$this->assertClassImplements(EventTransformer::class, PhpSerializerEventTransformer::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new PhpSerializerEventTransformer($this->createContextStub());
- }
-
public function testShouldReturnMessageWithPhpSerializedEventAsBodyOnToMessage()
{
$transformer = new PhpSerializerEventTransformer($this->createContextStub());
diff --git a/pkg/async-event-dispatcher/Tests/SimpleRegistryTest.php b/pkg/async-event-dispatcher/Tests/SimpleRegistryTest.php
index 328ed1780..c144e7466 100644
--- a/pkg/async-event-dispatcher/Tests/SimpleRegistryTest.php
+++ b/pkg/async-event-dispatcher/Tests/SimpleRegistryTest.php
@@ -18,15 +18,10 @@ public function testShouldImplementRegistryInterface()
$this->assertClassImplements(Registry::class, SimpleRegistry::class);
}
- public function testCouldBeConstructedWithEventsMapAndTransformersMapAsArguments()
- {
- new SimpleRegistry([], []);
- }
-
public function testShouldAllowGetTransportNameByEventName()
{
$registry = new SimpleRegistry([
- 'fooEvent' => 'fooTrans',
+ 'fooEvent' => 'fooTrans',
], []);
$this->assertEquals('fooTrans', $registry->getTransformerNameForEvent('fooEvent'));
diff --git a/pkg/async-event-dispatcher/composer.json b/pkg/async-event-dispatcher/composer.json
index dae5bb529..f78597af4 100644
--- a/pkg/async-event-dispatcher/composer.json
+++ b/pkg/async-event-dispatcher/composer.json
@@ -6,18 +6,18 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"enqueue/enqueue": "^0.10",
"queue-interop/queue-interop": "^0.8",
- "symfony/event-dispatcher": "^4.3|^5"
+ "symfony/event-dispatcher": "^5.4|^6.0"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
- "symfony/dependency-injection": "^4.3|^5",
- "symfony/config": "^4.3|^5",
- "symfony/http-kernel": "^4.3|^5",
- "symfony/filesystem": "^4.3|^5",
- "symfony/yaml": "^4.3|^5",
+ "phpunit/phpunit": "^9.5",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/http-kernel": "^5.4|^6.0",
+ "symfony/filesystem": "^5.4|^6.0",
+ "symfony/yaml": "^5.4|^6.0",
"enqueue/null": "0.10.x-dev",
"enqueue/fs": "0.10.x-dev",
"enqueue/test": "0.10.x-dev"
@@ -30,7 +30,7 @@
"docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md"
},
"suggest": {
- "symfony/dependency-injection": "^2.8|^3|^4|^5 If you'd like to use async event dispatcher container extension."
+ "symfony/dependency-injection": "^5.4|^6.0 If you'd like to use async event dispatcher container extension."
},
"autoload": {
"psr-4": { "Enqueue\\AsyncEventDispatcher\\": "" },
diff --git a/pkg/dbal/.github/workflows/ci.yml b/pkg/dbal/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/dbal/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/dbal/.travis.yml b/pkg/dbal/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/dbal/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/dbal/DbalConnectionFactory.php b/pkg/dbal/DbalConnectionFactory.php
index 2e0fe702e..305375a89 100644
--- a/pkg/dbal/DbalConnectionFactory.php
+++ b/pkg/dbal/DbalConnectionFactory.php
@@ -92,7 +92,7 @@ private function establishConnection(): Connection
return $this->connection;
}
- private function parseDsn(string $dsn, array $config = null): array
+ private function parseDsn(string $dsn, ?array $config = null): array
{
$parsedDsn = Dsn::parseFirst($dsn);
diff --git a/pkg/dbal/DbalConsumer.php b/pkg/dbal/DbalConsumer.php
index 98d348996..f1f397441 100644
--- a/pkg/dbal/DbalConsumer.php
+++ b/pkg/dbal/DbalConsumer.php
@@ -100,14 +100,14 @@ public function reject(Message $message, bool $requeue = false): void
{
InvalidMessageException::assertMessageInstanceOf($message, DbalMessage::class);
- $this->acknowledge($message);
-
if ($requeue) {
$message = clone $message;
$message->setRedelivered(false);
$this->getContext()->createProducer()->send($this->queue, $message);
}
+
+ $this->acknowledge($message);
}
protected function getContext(): DbalContext
diff --git a/pkg/dbal/DbalConsumerHelperTrait.php b/pkg/dbal/DbalConsumerHelperTrait.php
index 55ec77c00..617f37ba0 100644
--- a/pkg/dbal/DbalConsumerHelperTrait.php
+++ b/pkg/dbal/DbalConsumerHelperTrait.php
@@ -6,7 +6,6 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception\RetryableException;
-use Doctrine\DBAL\Types\Type;
use Ramsey\Uuid\Uuid;
trait DbalConsumerHelperTrait
@@ -39,7 +38,7 @@ protected function fetchMessage(array $queues, int $redeliveryDelay): ?DbalMessa
->addOrderBy('priority', 'asc')
->addOrderBy('published_at', 'asc')
->setParameter('queues', $queues, Connection::PARAM_STR_ARRAY)
- ->setParameter('delayedUntil', $now, Type::INTEGER)
+ ->setParameter('delayedUntil', $now, DbalType::INTEGER)
->setMaxResults(1);
$update = $this->getConnection()->createQueryBuilder()
@@ -48,29 +47,29 @@ protected function fetchMessage(array $queues, int $redeliveryDelay): ?DbalMessa
->set('redeliver_after', ':redeliverAfter')
->andWhere('id = :messageId')
->andWhere('delivery_id IS NULL')
- ->setParameter('deliveryId', $deliveryId, Type::GUID)
- ->setParameter('redeliverAfter', $now + $redeliveryDelay, Type::BIGINT)
+ ->setParameter('deliveryId', $deliveryId, DbalType::GUID)
+ ->setParameter('redeliverAfter', $now + $redeliveryDelay, DbalType::BIGINT)
;
while (microtime(true) < $endAt) {
try {
- $result = $select->execute()->fetch();
+ $result = $select->execute()->fetchAssociative();
if (empty($result)) {
return null;
}
$update
- ->setParameter('messageId', $result['id'], Type::GUID);
+ ->setParameter('messageId', $result['id'], DbalType::GUID);
if ($update->execute()) {
$deliveredMessage = $this->getConnection()->createQueryBuilder()
->select('*')
->from($this->getContext()->getTableName())
->andWhere('delivery_id = :deliveryId')
- ->setParameter('deliveryId', $deliveryId, Type::GUID)
+ ->setParameter('deliveryId', $deliveryId, DbalType::GUID)
->setMaxResults(1)
->execute()
- ->fetch();
+ ->fetchAssociative();
// the message has been removed by a 3rd party, such as truncate operation.
if (false === $deliveredMessage) {
@@ -103,9 +102,9 @@ protected function redeliverMessages(): void
->set('redelivered', ':redelivered')
->andWhere('redeliver_after < :now')
->andWhere('delivery_id IS NOT NULL')
- ->setParameter(':now', time(), Type::BIGINT)
- ->setParameter('deliveryId', null, Type::GUID)
- ->setParameter('redelivered', true, Type::BOOLEAN)
+ ->setParameter('now', time(), DbalType::BIGINT)
+ ->setParameter('deliveryId', null, DbalType::GUID)
+ ->setParameter('redelivered', true, DbalType::BOOLEAN)
;
try {
@@ -131,8 +130,8 @@ protected function removeExpiredMessages(): void
->andWhere('delivery_id IS NULL')
->andWhere('redelivered = :redelivered')
- ->setParameter(':now', time(), Type::BIGINT)
- ->setParameter('redelivered', false, Type::BOOLEAN)
+ ->setParameter('now', time(), DbalType::BIGINT)
+ ->setParameter('redelivered', false, DbalType::BOOLEAN)
;
try {
@@ -153,7 +152,7 @@ private function deleteMessage(string $deliveryId): void
$this->getConnection()->delete(
$this->getContext()->getTableName(),
['delivery_id' => $deliveryId],
- ['delivery_id' => Type::GUID]
+ ['delivery_id' => DbalType::GUID]
);
}
}
diff --git a/pkg/dbal/DbalContext.php b/pkg/dbal/DbalContext.php
index c775efc02..869dd67b8 100644
--- a/pkg/dbal/DbalContext.php
+++ b/pkg/dbal/DbalContext.php
@@ -6,7 +6,6 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Table;
-use Doctrine\DBAL\Types\Type;
use Interop\Queue\Consumer;
use Interop\Queue\Context;
use Interop\Queue\Destination;
@@ -39,13 +38,13 @@ class DbalContext implements Context
* Callable must return instance of Doctrine\DBAL\Connection once called.
*
* @param Connection|callable $connection
- * @param array $config
*/
public function __construct($connection, array $config = [])
{
$this->config = array_replace([
'table_name' => 'enqueue',
'polling_interval' => null,
+ 'subscription_polling_interval' => null,
], $config);
if ($connection instanceof Connection) {
@@ -53,17 +52,10 @@ public function __construct($connection, array $config = [])
} elseif (is_callable($connection)) {
$this->connectionFactory = $connection;
} else {
- throw new \InvalidArgumentException(sprintf(
- 'The connection argument must be either %s or callable that returns %s.',
- Connection::class,
- Connection::class
- ));
+ throw new \InvalidArgumentException(sprintf('The connection argument must be either %s or callable that returns %s.', Connection::class, Connection::class));
}
}
- /**
- * {@inheritdoc}
- */
public function createMessage(string $body = '', array $properties = [], array $headers = []): Message
{
$message = new DbalMessage();
@@ -135,6 +127,10 @@ public function createSubscriptionConsumer(): SubscriptionConsumer
$consumer->setRedeliveryDelay($this->config['redelivery_delay']);
}
+ if (isset($this->config['subscription_polling_interval'])) {
+ $consumer->setPollingInterval($this->config['subscription_polling_interval']);
+ }
+
return $consumer;
}
@@ -183,7 +179,7 @@ public function purgeQueue(Queue $queue): void
$this->getDbalConnection()->delete(
$this->getTableName(),
['queue' => $queue->getQueueName()],
- ['queue' => Type::STRING]
+ ['queue' => DbalType::STRING]
);
}
@@ -202,10 +198,7 @@ public function getDbalConnection(): Connection
if (false == $this->connection) {
$connection = call_user_func($this->connectionFactory);
if (false == $connection instanceof Connection) {
- throw new \LogicException(sprintf(
- 'The factory must return instance of Doctrine\DBAL\Connection. It returns %s',
- is_object($connection) ? get_class($connection) : gettype($connection)
- ));
+ throw new \LogicException(sprintf('The factory must return instance of Doctrine\DBAL\Connection. It returns %s', is_object($connection) ? $connection::class : gettype($connection)));
}
$this->connection = $connection;
@@ -224,24 +217,25 @@ public function createDataBaseTable(): void
$table = new Table($this->getTableName());
- $table->addColumn('id', Type::GUID, ['length' => 16, 'fixed' => true]);
- $table->addColumn('published_at', Type::BIGINT);
- $table->addColumn('body', Type::TEXT, ['notnull' => false]);
- $table->addColumn('headers', Type::TEXT, ['notnull' => false]);
- $table->addColumn('properties', Type::TEXT, ['notnull' => false]);
- $table->addColumn('redelivered', Type::BOOLEAN, ['notnull' => false]);
- $table->addColumn('queue', Type::STRING);
- $table->addColumn('priority', Type::SMALLINT, ['notnull' => false]);
- $table->addColumn('delayed_until', Type::BIGINT, ['notnull' => false]);
- $table->addColumn('time_to_live', Type::BIGINT, ['notnull' => false]);
- $table->addColumn('delivery_id', Type::GUID, ['length' => 16, 'fixed' => true, 'notnull' => false]);
- $table->addColumn('redeliver_after', Type::BIGINT, ['notnull' => false]);
+ $table->addColumn('id', DbalType::GUID, ['length' => 16, 'fixed' => true]);
+ $table->addColumn('published_at', DbalType::BIGINT);
+ $table->addColumn('body', DbalType::TEXT, ['notnull' => false]);
+ $table->addColumn('headers', DbalType::TEXT, ['notnull' => false]);
+ $table->addColumn('properties', DbalType::TEXT, ['notnull' => false]);
+ $table->addColumn('redelivered', DbalType::BOOLEAN, ['notnull' => false]);
+ $table->addColumn('queue', DbalType::STRING);
+ $table->addColumn('priority', DbalType::SMALLINT, ['notnull' => false]);
+ $table->addColumn('delayed_until', DbalType::BIGINT, ['notnull' => false]);
+ $table->addColumn('time_to_live', DbalType::BIGINT, ['notnull' => false]);
+ $table->addColumn('delivery_id', DbalType::GUID, ['length' => 16, 'fixed' => true, 'notnull' => false]);
+ $table->addColumn('redeliver_after', DbalType::BIGINT, ['notnull' => false]);
$table->setPrimaryKey(['id']);
$table->addIndex(['priority', 'published_at', 'queue', 'delivery_id', 'delayed_until', 'id']);
$table->addIndex(['redeliver_after', 'delivery_id']);
$table->addIndex(['time_to_live', 'delivery_id']);
+ $table->addIndex(['delivery_id']);
$sm->createTable($table);
}
diff --git a/pkg/dbal/DbalMessage.php b/pkg/dbal/DbalMessage.php
index dc5435b17..2485f0691 100644
--- a/pkg/dbal/DbalMessage.php
+++ b/pkg/dbal/DbalMessage.php
@@ -67,11 +67,6 @@ class DbalMessage implements Message
*/
private $publishedAt;
- /**
- * @param string $body
- * @param array $properties
- * @param array $headers
- */
public function __construct(string $body = '', array $properties = [], array $headers = [])
{
$this->body = $body;
@@ -144,7 +139,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -159,7 +154,7 @@ public function getPriority(): ?int
return $this->priority;
}
- public function setPriority(int $priority = null): void
+ public function setPriority(?int $priority = null): void
{
$this->priority = $priority;
}
@@ -172,14 +167,11 @@ public function getDeliveryDelay(): ?int
/**
* Set delay in milliseconds.
*/
- public function setDeliveryDelay(int $deliveryDelay = null): void
+ public function setDeliveryDelay(?int $deliveryDelay = null): void
{
$this->deliveryDelay = $deliveryDelay;
}
- /**
- * @return int
- */
public function getTimeToLive(): ?int
{
return $this->timeToLive;
@@ -188,12 +180,12 @@ public function getTimeToLive(): ?int
/**
* Set time to live in milliseconds.
*/
- public function setTimeToLive(int $timeToLive = null): void
+ public function setTimeToLive(?int $timeToLive = null): void
{
$this->timeToLive = $timeToLive;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', $correlationId);
}
@@ -203,7 +195,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id', null);
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', $messageId);
}
@@ -220,7 +212,7 @@ public function getTimestamp(): ?int
return null === $value ? null : $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
@@ -240,7 +232,7 @@ public function getRedeliverAfter(): int
return $this->redeliverAfter;
}
- public function setRedeliverAfter(int $redeliverAfter = null): void
+ public function setRedeliverAfter(?int $redeliverAfter = null): void
{
$this->redeliverAfter = $redeliverAfter;
}
@@ -250,7 +242,7 @@ public function getPublishedAt(): ?int
return $this->publishedAt;
}
- public function setPublishedAt(int $publishedAt = null): void
+ public function setPublishedAt(?int $publishedAt = null): void
{
$this->publishedAt = $publishedAt;
}
diff --git a/pkg/dbal/DbalProducer.php b/pkg/dbal/DbalProducer.php
index 5435629eb..9e3c203dd 100644
--- a/pkg/dbal/DbalProducer.php
+++ b/pkg/dbal/DbalProducer.php
@@ -4,7 +4,6 @@
namespace Enqueue\Dbal;
-use Doctrine\DBAL\Types\Type;
use Interop\Queue\Destination;
use Interop\Queue\Exception\Exception;
use Interop\Queue\Exception\InvalidDestinationException;
@@ -35,9 +34,6 @@ class DbalProducer implements Producer
*/
private $context;
- /**
- * @param DbalContext $context
- */
public function __construct(DbalContext $context)
{
$this->context = $context;
@@ -85,49 +81,43 @@ public function send(Destination $destination, Message $message): void
$delay = $message->getDeliveryDelay();
if ($delay) {
if (!is_int($delay)) {
- throw new \LogicException(sprintf(
- 'Delay must be integer but got: "%s"',
- is_object($delay) ? get_class($delay) : gettype($delay)
- ));
+ throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? $delay::class : gettype($delay)));
}
if ($delay <= 0) {
throw new \LogicException(sprintf('Delay must be positive integer but got: "%s"', $delay));
}
- $dbalMessage['delayed_until'] = time() + (int) $delay / 1000;
+ $dbalMessage['delayed_until'] = time() + (int) ($delay / 1000);
}
$timeToLive = $message->getTimeToLive();
if ($timeToLive) {
if (!is_int($timeToLive)) {
- throw new \LogicException(sprintf(
- 'TimeToLive must be integer but got: "%s"',
- is_object($timeToLive) ? get_class($timeToLive) : gettype($timeToLive)
- ));
+ throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? $timeToLive::class : gettype($timeToLive)));
}
if ($timeToLive <= 0) {
throw new \LogicException(sprintf('TimeToLive must be positive integer but got: "%s"', $timeToLive));
}
- $dbalMessage['time_to_live'] = time() + (int) $timeToLive / 1000;
+ $dbalMessage['time_to_live'] = time() + (int) ($timeToLive / 1000);
}
try {
$rowsAffected = $this->context->getDbalConnection()->insert($this->context->getTableName(), $dbalMessage, [
- 'id' => Type::GUID,
- 'published_at' => Type::INTEGER,
- 'body' => Type::TEXT,
- 'headers' => Type::TEXT,
- 'properties' => Type::TEXT,
- 'priority' => Type::SMALLINT,
- 'queue' => Type::STRING,
- 'time_to_live' => Type::INTEGER,
- 'delayed_until' => Type::INTEGER,
- 'redelivered' => Type::SMALLINT,
- 'delivery_id' => Type::STRING,
- 'redeliver_after' => Type::BIGINT,
+ 'id' => DbalType::GUID,
+ 'published_at' => DbalType::INTEGER,
+ 'body' => DbalType::TEXT,
+ 'headers' => DbalType::TEXT,
+ 'properties' => DbalType::TEXT,
+ 'priority' => DbalType::SMALLINT,
+ 'queue' => DbalType::STRING,
+ 'time_to_live' => DbalType::INTEGER,
+ 'delayed_until' => DbalType::INTEGER,
+ 'redelivered' => DbalType::SMALLINT,
+ 'delivery_id' => DbalType::STRING,
+ 'redeliver_after' => DbalType::BIGINT,
]);
if (1 !== $rowsAffected) {
@@ -138,7 +128,7 @@ public function send(Destination $destination, Message $message): void
}
}
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
$this->deliveryDelay = $deliveryDelay;
@@ -150,7 +140,7 @@ public function getDeliveryDelay(): ?int
return $this->deliveryDelay;
}
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;
@@ -162,7 +152,7 @@ public function getPriority(): ?int
return $this->priority;
}
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
diff --git a/pkg/dbal/DbalSubscriptionConsumer.php b/pkg/dbal/DbalSubscriptionConsumer.php
index 60d30cc7e..472fdfcb4 100644
--- a/pkg/dbal/DbalSubscriptionConsumer.php
+++ b/pkg/dbal/DbalSubscriptionConsumer.php
@@ -25,7 +25,7 @@ class DbalSubscriptionConsumer implements SubscriptionConsumer
private $subscribers;
/**
- * @var \Doctrine\DBAL\Connection
+ * @var Connection
*/
private $dbal;
@@ -37,8 +37,12 @@ class DbalSubscriptionConsumer implements SubscriptionConsumer
private $redeliveryDelay;
/**
- * @param DbalContext $context
+ * Time to wait between subscription requests in milliseconds.
+ *
+ * @var int
*/
+ private $pollingInterval = 200;
+
public function __construct(DbalContext $context)
{
$this->context = $context;
@@ -63,6 +67,18 @@ public function setRedeliveryDelay(int $redeliveryDelay): self
return $this;
}
+ public function getPollingInterval(): int
+ {
+ return $this->pollingInterval;
+ }
+
+ public function setPollingInterval(int $msec): self
+ {
+ $this->pollingInterval = $msec;
+
+ return $this;
+ }
+
public function consume(int $timeout = 0): void
{
if (empty($this->subscribers)) {
@@ -79,20 +95,24 @@ public function consume(int $timeout = 0): void
$redeliveryDelay = $this->getRedeliveryDelay() / 1000; // milliseconds to seconds
$currentQueueNames = [];
+ $queueConsumed = false;
while (true) {
if (empty($currentQueueNames)) {
$currentQueueNames = $queueNames;
+ $queueConsumed = false;
}
$this->removeExpiredMessages();
$this->redeliverMessages();
if ($message = $this->fetchMessage($currentQueueNames, $redeliveryDelay)) {
+ $queueConsumed = true;
+
/**
- * @var DbalConsumer
+ * @var DbalConsumer $consumer
* @var callable $callback
*/
- list($consumer, $callback) = $this->subscribers[$message->getQueue()];
+ [$consumer, $callback] = $this->subscribers[$message->getQueue()];
if (false === call_user_func($callback, $message, $consumer)) {
return;
@@ -102,7 +122,9 @@ public function consume(int $timeout = 0): void
} else {
$currentQueueNames = [];
- usleep(200000); // 200ms
+ if (!$queueConsumed) {
+ usleep($this->getPollingInterval() * 1000);
+ }
}
if ($timeout && microtime(true) >= $now + $timeout) {
@@ -117,7 +139,7 @@ public function consume(int $timeout = 0): void
public function subscribe(Consumer $consumer, callable $callback): void
{
if (false == $consumer instanceof DbalConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', DbalConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', DbalConsumer::class, $consumer::class));
}
$queueName = $consumer->getQueue()->getQueueName();
@@ -138,7 +160,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
public function unsubscribe(Consumer $consumer): void
{
if (false == $consumer instanceof DbalConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', DbalConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', DbalConsumer::class, $consumer::class));
}
$queueName = $consumer->getQueue()->getQueueName();
diff --git a/pkg/dbal/DbalType.php b/pkg/dbal/DbalType.php
new file mode 100644
index 000000000..38a14381f
--- /dev/null
+++ b/pkg/dbal/DbalType.php
@@ -0,0 +1,34 @@
+assertInstanceOf(DbalContext::class, $context);
$this->assertAttributeEquals(null, 'connection', $context);
- $this->assertAttributeInternalType('callable', 'connectionFactory', $context);
+ $this->assertIsCallable($this->readAttribute($context, 'connectionFactory'));
}
public function testShouldParseGenericDSN()
diff --git a/pkg/dbal/Tests/DbalConsumerTest.php b/pkg/dbal/Tests/DbalConsumerTest.php
index add41a1df..0b78eab00 100644
--- a/pkg/dbal/Tests/DbalConsumerTest.php
+++ b/pkg/dbal/Tests/DbalConsumerTest.php
@@ -5,12 +5,12 @@
namespace Enqueue\Dbal\Tests;
use Doctrine\DBAL\Connection;
-use Doctrine\DBAL\Types\Type;
use Enqueue\Dbal\DbalConsumer;
use Enqueue\Dbal\DbalContext;
use Enqueue\Dbal\DbalDestination;
use Enqueue\Dbal\DbalMessage;
use Enqueue\Dbal\DbalProducer;
+use Enqueue\Dbal\DbalType;
use Enqueue\Test\ClassExtensionTrait;
use Interop\Queue\Consumer;
use Interop\Queue\Exception\InvalidMessageException;
@@ -28,11 +28,6 @@ public function testShouldImplementConsumerInterface()
$this->assertClassImplements(Consumer::class, DbalConsumer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new DbalConsumer($this->createContextMock(), new DbalDestination('queue'));
- }
-
public function testShouldReturnInstanceOfDestination()
{
$destination = new DbalDestination('queue');
@@ -72,7 +67,7 @@ public function testShouldDeleteMessageOnAcknowledge()
->with(
'some-table-name',
['delivery_id' => $deliveryId->toString()],
- ['delivery_id' => Type::GUID]
+ ['delivery_id' => DbalType::GUID]
)
;
@@ -143,7 +138,7 @@ public function testShouldDeleteMessageFromQueueOnReject()
->with(
'some-table-name',
['delivery_id' => $deliveryId->toString()],
- ['delivery_id' => Type::GUID]
+ ['delivery_id' => DbalType::GUID]
)
;
@@ -270,7 +265,7 @@ public function isRedelivered(): bool
throw new \BadMethodCallException('This should not be called directly');
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
}
@@ -279,7 +274,7 @@ public function getCorrelationId(): ?string
throw new \BadMethodCallException('This should not be called directly');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
}
@@ -293,11 +288,11 @@ public function getTimestamp(): ?int
throw new \BadMethodCallException('This should not be called directly');
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
}
diff --git a/pkg/dbal/Tests/DbalContextTest.php b/pkg/dbal/Tests/DbalContextTest.php
index b89abae2e..a1900b788 100644
--- a/pkg/dbal/Tests/DbalContextTest.php
+++ b/pkg/dbal/Tests/DbalContextTest.php
@@ -9,6 +9,7 @@
use Enqueue\Dbal\DbalMessage;
use Enqueue\Dbal\DbalProducer;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Context;
use Interop\Queue\Destination;
use Interop\Queue\Exception\InvalidDestinationException;
@@ -19,17 +20,13 @@
class DbalContextTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementContextInterface()
{
$this->assertClassImplements(Context::class, DbalContext::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new DbalContext($this->createConnectionMock());
- }
-
public function testCouldBeConstructedWithEmptyConfiguration()
{
$factory = new DbalContext($this->createConnectionMock(), []);
@@ -37,6 +34,7 @@ public function testCouldBeConstructedWithEmptyConfiguration()
$this->assertAttributeEquals([
'table_name' => 'enqueue',
'polling_interval' => null,
+ 'subscription_polling_interval' => null,
], 'config', $factory);
}
@@ -45,11 +43,13 @@ public function testCouldBeConstructedWithCustomConfiguration()
$factory = new DbalContext($this->createConnectionMock(), [
'table_name' => 'theTableName',
'polling_interval' => 12345,
+ 'subscription_polling_interval' => 12345,
]);
$this->assertAttributeEquals([
'table_name' => 'theTableName',
'polling_interval' => 12345,
+ 'subscription_polling_interval' => 12345,
], 'config', $factory);
}
diff --git a/pkg/dbal/Tests/DbalProducerTest.php b/pkg/dbal/Tests/DbalProducerTest.php
index 4dcb015e3..ec4d2043c 100644
--- a/pkg/dbal/Tests/DbalProducerTest.php
+++ b/pkg/dbal/Tests/DbalProducerTest.php
@@ -21,11 +21,6 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(Producer::class, DbalProducer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new DbalProducer($this->createContextMock());
- }
-
public function testShouldThrowIfDestinationOfInvalidType()
{
$this->expectException(InvalidDestinationException::class);
diff --git a/pkg/dbal/Tests/DbalSubscriptionConsumerTest.php b/pkg/dbal/Tests/DbalSubscriptionConsumerTest.php
index 82787f19f..bacbec127 100644
--- a/pkg/dbal/Tests/DbalSubscriptionConsumerTest.php
+++ b/pkg/dbal/Tests/DbalSubscriptionConsumerTest.php
@@ -7,6 +7,7 @@
use Enqueue\Dbal\DbalConsumer;
use Enqueue\Dbal\DbalContext;
use Enqueue\Dbal\DbalSubscriptionConsumer;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Consumer;
use Interop\Queue\Queue;
use Interop\Queue\SubscriptionConsumer;
@@ -15,6 +16,8 @@
class DbalSubscriptionConsumerTest extends TestCase
{
+ use ReadAttributeTrait;
+
public function testShouldImplementSubscriptionConsumerInterface()
{
$rc = new \ReflectionClass(DbalSubscriptionConsumer::class);
@@ -22,11 +25,6 @@ public function testShouldImplementSubscriptionConsumerInterface()
$this->assertTrue($rc->implementsInterface(SubscriptionConsumer::class));
}
- public function testCouldBeConstructedWithDbalContextAsFirstArgument()
- {
- new DbalSubscriptionConsumer($this->createDbalContextMock());
- }
-
public function testShouldAddConsumerAndCallbackToSubscribersPropertyOnSubscribe()
{
$subscriptionConsumer = new DbalSubscriptionConsumer($this->createDbalContextMock());
@@ -63,6 +61,9 @@ public function testThrowsIfTrySubscribeAnotherConsumerToAlreadySubscribedQueue(
$subscriptionConsumer->subscribe($barConsumer, $barCallback);
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldAllowSubscribeSameConsumerAndCallbackSecondTime()
{
$subscriptionConsumer = new DbalSubscriptionConsumer($this->createDbalContextMock());
diff --git a/pkg/dbal/Tests/Functional/DbalConsumerTest.php b/pkg/dbal/Tests/Functional/DbalConsumerTest.php
index 69b644ed4..8042598b9 100644
--- a/pkg/dbal/Tests/Functional/DbalConsumerTest.php
+++ b/pkg/dbal/Tests/Functional/DbalConsumerTest.php
@@ -21,7 +21,7 @@ class DbalConsumerTest extends TestCase
*/
private $context;
- public function setUp()
+ protected function setUp(): void
{
$this->context = $this->createDbalContext();
}
@@ -117,15 +117,15 @@ public function testShouldDeleteExpiredMessage()
$this->context->getDbalConnection()->insert(
$this->context->getTableName(), [
- 'id' => 'id',
- 'published_at' => '123',
- 'body' => 'expiredMessage',
- 'headers' => json_encode([]),
- 'properties' => json_encode([]),
- 'queue' => __METHOD__,
- 'redelivered' => 0,
- 'time_to_live' => time() - 10000,
- ]);
+ 'id' => 'id',
+ 'published_at' => '123',
+ 'body' => 'expiredMessage',
+ 'headers' => json_encode([]),
+ 'properties' => json_encode([]),
+ 'queue' => __METHOD__,
+ 'redelivered' => 0,
+ 'time_to_live' => time() - 10000,
+ ]);
$message = $context->createMessage('notExpiredMessage');
$message->setRedelivered(false);
@@ -173,7 +173,7 @@ private function getQuerySize(): int
{
return (int) $this->context->getDbalConnection()
->executeQuery('SELECT count(*) FROM '.$this->context->getTableName())
- ->fetchColumn(0)
+ ->fetchOne()
;
}
}
diff --git a/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php b/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php
index 3adefff01..83135c2ed 100644
--- a/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php
+++ b/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php
@@ -7,6 +7,7 @@
use Enqueue\Dbal\DbalContext;
use Enqueue\Dbal\ManagerRegistryConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -14,6 +15,7 @@
class ManagerRegistryConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
@@ -71,7 +73,7 @@ public function testShouldCreateLazyContext()
$this->assertInstanceOf(DbalContext::class, $context);
$this->assertAttributeEquals(null, 'connection', $context);
- $this->assertAttributeInternalType('callable', 'connectionFactory', $context);
+ $this->assertIsCallable($this->readAttribute($context, 'connectionFactory'));
}
/**
diff --git a/pkg/dbal/Tests/Spec/DbalConnectionFactoryTest.php b/pkg/dbal/Tests/Spec/DbalConnectionFactoryTest.php
index d7fbfcde5..dc39cffe3 100644
--- a/pkg/dbal/Tests/Spec/DbalConnectionFactoryTest.php
+++ b/pkg/dbal/Tests/Spec/DbalConnectionFactoryTest.php
@@ -7,9 +7,6 @@
class DbalConnectionFactoryTest extends ConnectionFactorySpec
{
- /**
- * {@inheritdoc}
- */
protected function createConnectionFactory()
{
return new DbalConnectionFactory();
diff --git a/pkg/dbal/Tests/Spec/DbalMessageTest.php b/pkg/dbal/Tests/Spec/DbalMessageTest.php
index c9ce855df..ee5bdcf6c 100644
--- a/pkg/dbal/Tests/Spec/DbalMessageTest.php
+++ b/pkg/dbal/Tests/Spec/DbalMessageTest.php
@@ -7,9 +7,6 @@
class DbalMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new DbalMessage();
diff --git a/pkg/dbal/Tests/Spec/DbalQueueTest.php b/pkg/dbal/Tests/Spec/DbalQueueTest.php
index a9eebbb88..690f7e1d6 100644
--- a/pkg/dbal/Tests/Spec/DbalQueueTest.php
+++ b/pkg/dbal/Tests/Spec/DbalQueueTest.php
@@ -7,9 +7,6 @@
class DbalQueueTest extends QueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createQueue()
{
return new DbalDestination(self::EXPECTED_QUEUE_NAME);
diff --git a/pkg/dbal/Tests/Spec/DbalTopicTest.php b/pkg/dbal/Tests/Spec/DbalTopicTest.php
index bb9885ea8..4bd554681 100644
--- a/pkg/dbal/Tests/Spec/DbalTopicTest.php
+++ b/pkg/dbal/Tests/Spec/DbalTopicTest.php
@@ -7,9 +7,6 @@
class DbalTopicTest extends TopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createTopic()
{
return new DbalDestination(self::EXPECTED_TOPIC_NAME);
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalContextTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalContextTest.php
index f147f63b4..f235dd50a 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalContextTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalContextTest.php
@@ -11,9 +11,6 @@ class DbalContextTest extends ContextSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalProducerTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalProducerTest.php
index 86abe4f63..99cfa2aa6 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalProducerTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalProducerTest.php
@@ -11,9 +11,6 @@ class DbalProducerTest extends ProducerSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createProducer()
{
return $this->createDbalContext()->createProducer();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalRequeueMessageTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalRequeueMessageTest.php
index 7dcec7a75..a642d7288 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalRequeueMessageTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalRequeueMessageTest.php
@@ -11,9 +11,6 @@ class DbalRequeueMessageTest extends RequeueMessageSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveDelayedMessageFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveDelayedMessageFromQueueTest.php
index 227ac9705..2455217d6 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveDelayedMessageFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveDelayedMessageFromQueueTest.php
@@ -11,9 +11,6 @@ class DbalSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDelaye
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php
index 5a051a729..6926a3d57 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php
@@ -16,7 +16,7 @@ class DbalSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePrio
private $publishedAt;
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -32,8 +32,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param DbalContext $context
*
* @return DbalMessage
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php
index fe863e4cc..7ec1dd64f 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php
@@ -11,9 +11,6 @@ class DbalSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTi
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromQueueTest.php
index 2d8c7979f..798e4b844 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromQueueTest.php
@@ -11,9 +11,6 @@ class DbalSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromTopicTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromTopicTest.php
index 5a715a414..1d6f99456 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromTopicTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromTopicTest.php
@@ -11,9 +11,6 @@ class DbalSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromQueueTest.php
index 7f64871c4..d96cb85a4 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromQueueTest.php
@@ -11,9 +11,6 @@ class DbalSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFrom
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromTopicTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromTopicTest.php
index 8ca133dd8..b211fc0ab 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromTopicTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromTopicTest.php
@@ -11,9 +11,6 @@ class DbalSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFrom
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
index a1ebe3a9b..015f1b716 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
@@ -18,8 +18,6 @@ class DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri
/**
* @return DbalContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param DbalContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php
index df4b75ee7..37c406804 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php
@@ -18,8 +18,6 @@ class DbalSubscriptionConsumerConsumeUntilUnsubscribedTest extends SubscriptionC
/**
* @return DbalContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param DbalContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerStopOnFalseTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerStopOnFalseTest.php
index 427195486..ad59c9e6f 100644
--- a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerStopOnFalseTest.php
+++ b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerStopOnFalseTest.php
@@ -18,8 +18,6 @@ class DbalSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn
/**
* @return DbalContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param DbalContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalContextTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalContextTest.php
index 89aa1d45d..b07978cbd 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalContextTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalContextTest.php
@@ -11,9 +11,6 @@ class DbalContextTest extends ContextSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalProducerTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalProducerTest.php
index 533d032e9..aa8894de3 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalProducerTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalProducerTest.php
@@ -11,9 +11,6 @@ class DbalProducerTest extends ProducerSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createProducer()
{
return $this->createDbalContext()->createProducer();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalRequeueMessageTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalRequeueMessageTest.php
index e61f5a352..300a572eb 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalRequeueMessageTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalRequeueMessageTest.php
@@ -11,9 +11,6 @@ class DbalRequeueMessageTest extends RequeueMessageSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveDelayedMessageFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveDelayedMessageFromQueueTest.php
index f33c5688b..4d915c3b5 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveDelayedMessageFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveDelayedMessageFromQueueTest.php
@@ -11,9 +11,6 @@ class DbalSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDelaye
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php
index a645cbad6..556f53b00 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php
@@ -16,7 +16,7 @@ class DbalSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePrio
private $publishedAt;
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -32,8 +32,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param DbalContext $context
*
* @return DbalMessage
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php
index 99b007770..db92febe3 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php
@@ -11,9 +11,6 @@ class DbalSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTi
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromQueueTest.php
index c486f0f37..63e4456f0 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromQueueTest.php
@@ -11,9 +11,6 @@ class DbalSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromTopicTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromTopicTest.php
index 0802c0935..a2989fd54 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromTopicTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromTopicTest.php
@@ -11,9 +11,6 @@ class DbalSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromQueueTest.php
index 74e13d89f..9a08f3676 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromQueueTest.php
@@ -11,9 +11,6 @@ class DbalSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFrom
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromTopicTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromTopicTest.php
index 0b6b30c17..4383acd36 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromTopicTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromTopicTest.php
@@ -11,9 +11,6 @@ class DbalSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFrom
{
use CreateDbalContextTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->createDbalContext();
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
index d50da8acf..d2c8ee22e 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
@@ -18,8 +18,6 @@ class DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri
/**
* @return DbalContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param DbalContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php
index 64473a30f..892adf372 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php
@@ -18,8 +18,6 @@ class DbalSubscriptionConsumerConsumeUntilUnsubscribedTest extends SubscriptionC
/**
* @return DbalContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param DbalContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerStopOnFalseTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerStopOnFalseTest.php
index 2b493ba84..9eeb918b8 100644
--- a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerStopOnFalseTest.php
+++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerStopOnFalseTest.php
@@ -18,8 +18,6 @@ class DbalSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn
/**
* @return DbalContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param DbalContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/dbal/composer.json b/pkg/dbal/composer.json
index e097f228c..9499d394d 100644
--- a/pkg/dbal/composer.json
+++ b/pkg/dbal/composer.json
@@ -6,19 +6,17 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8",
- "doctrine/dbal": "^2.6",
- "ramsey/uuid": "^3|^4"
+ "doctrine/dbal": "^2.12|^3.1",
+ "doctrine/persistence": "^2.0|^3.0",
+ "ramsey/uuid": "^3.5|^4"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
- },
- "conflict": {
- "doctrine/persistence": "<1.3.0"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/dbal/examples/consume.php b/pkg/dbal/examples/consume.php
index 6b404c93a..f63cf8a77 100644
--- a/pkg/dbal/examples/consume.php
+++ b/pkg/dbal/examples/consume.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\Dbal\DbalConnectionFactory;
@@ -35,7 +35,7 @@
while (true) {
if ($m = $consumer->receive(1000)) {
$consumer->acknowledge($m);
- echo 'Received message: '.$m->getBody().PHP_EOL;
+ echo 'Received message: '.$m->getBody().\PHP_EOL;
}
}
diff --git a/pkg/dbal/examples/produce.php b/pkg/dbal/examples/produce.php
index c13b4f3b0..9f282bd0b 100644
--- a/pkg/dbal/examples/produce.php
+++ b/pkg/dbal/examples/produce.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\Dbal\DbalConnectionFactory;
@@ -34,7 +34,7 @@
while (true) {
$context->createProducer()->send($destination, $message);
- echo 'Sent message: '.$message->getBody().PHP_EOL;
+ echo 'Sent message: '.$message->getBody().\PHP_EOL;
sleep(1);
}
diff --git a/pkg/dsn/.github/workflows/ci.yml b/pkg/dsn/.github/workflows/ci.yml
new file mode 100644
index 000000000..71bcbbd61
--- /dev/null
+++ b/pkg/dsn/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit
diff --git a/pkg/dsn/.travis.yml b/pkg/dsn/.travis.yml
deleted file mode 100644
index 27c064a7c..000000000
--- a/pkg/dsn/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit
diff --git a/pkg/dsn/Dsn.php b/pkg/dsn/Dsn.php
index a5cc139b2..f46d7c056 100644
--- a/pkg/dsn/Dsn.php
+++ b/pkg/dsn/Dsn.php
@@ -66,7 +66,7 @@ public function __construct(
?int $port,
?string $path,
?string $queryString,
- array $query
+ array $query,
) {
$this->scheme = $scheme;
$this->schemeProtocol = $schemeProtocol;
@@ -140,27 +140,27 @@ public function getQuery(): array
return $this->queryBag->toArray();
}
- public function getString(string $name, string $default = null): ?string
+ public function getString(string $name, ?string $default = null): ?string
{
return $this->queryBag->getString($name, $default);
}
- public function getDecimal(string $name, int $default = null): ?int
+ public function getDecimal(string $name, ?int $default = null): ?int
{
return $this->queryBag->getDecimal($name, $default);
}
- public function getOctal(string $name, int $default = null): ?int
+ public function getOctal(string $name, ?int $default = null): ?int
{
return $this->queryBag->getOctal($name, $default);
}
- public function getFloat(string $name, float $default = null): ?float
+ public function getFloat(string $name, ?float $default = null): ?float
{
return $this->queryBag->getFloat($name, $default);
}
- public function getBool(string $name, bool $default = null): ?bool
+ public function getBool(string $name, ?bool $default = null): ?bool
{
return $this->queryBag->getBool($name, $default);
}
@@ -192,14 +192,12 @@ public static function parseFirst(string $dsn): ?self
}
/**
- * @param string $dsn
- *
* @return Dsn[]
*/
public static function parse(string $dsn): array
{
- if (false === strpos($dsn, ':')) {
- throw new \LogicException(sprintf('The DSN is invalid. It does not have scheme separator ":".'));
+ if (!str_contains($dsn, ':')) {
+ throw new \LogicException('The DSN is invalid. It does not have scheme separator ":".');
}
list($scheme, $dsnWithoutScheme) = explode(':', $dsn, 2);
@@ -215,28 +213,28 @@ public static function parse(string $dsn): array
unset($schemeParts[0]);
$schemeExtensions = array_values($schemeParts);
- $user = parse_url($dsn, PHP_URL_USER) ?: null;
+ $user = parse_url($dsn, \PHP_URL_USER) ?: null;
if (is_string($user)) {
$user = rawurldecode($user);
}
- $password = parse_url($dsn, PHP_URL_PASS) ?: null;
+ $password = parse_url($dsn, \PHP_URL_PASS) ?: null;
if (is_string($password)) {
$password = rawurldecode($password);
}
- $path = parse_url($dsn, PHP_URL_PATH) ?: null;
+ $path = parse_url($dsn, \PHP_URL_PATH) ?: null;
if ($path) {
$path = rawurldecode($path);
}
$query = [];
- $queryString = parse_url($dsn, PHP_URL_QUERY) ?: null;
+ $queryString = parse_url($dsn, \PHP_URL_QUERY) ?: null;
if (is_string($queryString)) {
- $query = self::httpParseQuery($queryString, '&', PHP_QUERY_RFC3986);
+ $query = self::httpParseQuery($queryString, '&', \PHP_QUERY_RFC3986);
}
$hostsPorts = '';
- if (0 === strpos($dsnWithoutScheme, '//')) {
+ if (str_starts_with($dsnWithoutScheme, '//')) {
$dsnWithoutScheme = substr($dsnWithoutScheme, 2);
$dsnWithoutUserPassword = explode('@', $dsnWithoutScheme, 2);
$dsnWithoutUserPassword = 2 === count($dsnWithoutUserPassword) ?
@@ -299,7 +297,7 @@ public static function parse(string $dsn): array
/**
* based on http://php.net/manual/en/function.parse-str.php#119484 with some slight modifications.
*/
- private static function httpParseQuery(string $queryString, string $argSeparator = '&', int $decType = PHP_QUERY_RFC1738): array
+ private static function httpParseQuery(string $queryString, string $argSeparator = '&', int $decType = \PHP_QUERY_RFC1738): array
{
$result = [];
$parts = explode($argSeparator, $queryString);
@@ -308,11 +306,11 @@ private static function httpParseQuery(string $queryString, string $argSeparator
list($paramName, $paramValue) = explode('=', $part, 2);
switch ($decType) {
- case PHP_QUERY_RFC3986:
+ case \PHP_QUERY_RFC3986:
$paramName = rawurldecode($paramName);
$paramValue = rawurldecode($paramValue);
break;
- case PHP_QUERY_RFC1738:
+ case \PHP_QUERY_RFC1738:
default:
$paramName = urldecode($paramName);
$paramValue = urldecode($paramValue);
diff --git a/pkg/dsn/QueryBag.php b/pkg/dsn/QueryBag.php
index 53d82b8ed..ea15aa854 100644
--- a/pkg/dsn/QueryBag.php
+++ b/pkg/dsn/QueryBag.php
@@ -21,12 +21,12 @@ public function toArray(): array
return $this->query;
}
- public function getString(string $name, string $default = null): ?string
+ public function getString(string $name, ?string $default = null): ?string
{
return array_key_exists($name, $this->query) ? $this->query[$name] : $default;
}
- public function getDecimal(string $name, int $default = null): ?int
+ public function getDecimal(string $name, ?int $default = null): ?int
{
$value = $this->getString($name);
if (null === $value) {
@@ -40,7 +40,7 @@ public function getDecimal(string $name, int $default = null): ?int
return (int) $value;
}
- public function getOctal(string $name, int $default = null): ?int
+ public function getOctal(string $name, ?int $default = null): ?int
{
$value = $this->getString($name);
if (null === $value) {
@@ -54,7 +54,7 @@ public function getOctal(string $name, int $default = null): ?int
return intval($value, 8);
}
- public function getFloat(string $name, float $default = null): ?float
+ public function getFloat(string $name, ?float $default = null): ?float
{
$value = $this->getString($name);
if (null === $value) {
@@ -68,7 +68,7 @@ public function getFloat(string $name, float $default = null): ?float
return (float) $value;
}
- public function getBool(string $name, bool $default = null): ?bool
+ public function getBool(string $name, ?bool $default = null): ?bool
{
$value = $this->getString($name);
if (null === $value) {
diff --git a/pkg/dsn/Tests/DsnTest.php b/pkg/dsn/Tests/DsnTest.php
index 0bcd7d43a..8bf4137ed 100644
--- a/pkg/dsn/Tests/DsnTest.php
+++ b/pkg/dsn/Tests/DsnTest.php
@@ -8,11 +8,6 @@
class DsnTest extends TestCase
{
- public function testCouldBeConstructedWithDsnAsFirstArgument()
- {
- Dsn::parseFirst('foo://localhost:1234');
- }
-
public function testThrowsIfSchemePartIsMissing()
{
$this->expectException(\LogicException::class);
diff --git a/pkg/dsn/composer.json b/pkg/dsn/composer.json
index 06ef139e9..dbd39aed7 100644
--- a/pkg/dsn/composer.json
+++ b/pkg/dsn/composer.json
@@ -6,10 +6,10 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3"
+ "php": "^8.0"
},
"require-dev": {
- "phpunit/phpunit": "~7.5"
+ "phpunit/phpunit": "^9.5"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/enqueue-bundle/.github/workflows/ci.yml b/pkg/enqueue-bundle/.github/workflows/ci.yml
new file mode 100644
index 000000000..4c397bef1
--- /dev/null
+++ b/pkg/enqueue-bundle/.github/workflows/ci.yml
@@ -0,0 +1,32 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+ extensions: mongodb
+
+ - run: php Tests/fix_composer_json.php
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/enqueue-bundle/.travis.yml b/pkg/enqueue-bundle/.travis.yml
deleted file mode 100644
index 880a93f5e..000000000
--- a/pkg/enqueue-bundle/.travis.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-
-php:
- - '7.1'
-
-services:
- - mongodb
-
-before_install:
- - echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - php Tests/fix_composer_json.php
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php b/pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php
index 77212508f..7fd9527db 100644
--- a/pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php
+++ b/pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php
@@ -27,7 +27,7 @@ public function onMessageReceived(MessageReceived $context): void
continue;
}
- if ($connection->ping()) {
+ if ($this->ping($connection)) {
continue;
}
@@ -43,4 +43,23 @@ public function onMessageReceived(MessageReceived $context): void
);
}
}
+
+ private function ping(Connection $connection): bool
+ {
+ set_error_handler(static function (int $severity, string $message, string $file, int $line): bool {
+ throw new \ErrorException($message, $severity, $severity, $file, $line);
+ });
+
+ try {
+ $dummySelectSQL = $connection->getDatabasePlatform()->getDummySelectSQL();
+
+ $connection->executeQuery($dummySelectSQL);
+
+ return true;
+ } catch (\Throwable $exception) {
+ return false;
+ } finally {
+ restore_error_handler();
+ }
+ }
}
diff --git a/pkg/enqueue-bundle/Consumption/Extension/ResetServicesExtension.php b/pkg/enqueue-bundle/Consumption/Extension/ResetServicesExtension.php
index 36eb21782..0bf642197 100644
--- a/pkg/enqueue-bundle/Consumption/Extension/ResetServicesExtension.php
+++ b/pkg/enqueue-bundle/Consumption/Extension/ResetServicesExtension.php
@@ -2,11 +2,11 @@
namespace Enqueue\Bundle\Consumption\Extension;
-use Enqueue\Consumption\Context\MessageReceived;
-use Enqueue\Consumption\MessageReceivedExtensionInterface;
+use Enqueue\Consumption\Context\PostMessageReceived;
+use Enqueue\Consumption\PostMessageReceivedExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
-class ResetServicesExtension implements MessageReceivedExtensionInterface
+class ResetServicesExtension implements PostMessageReceivedExtensionInterface
{
/**
* @var ServicesResetter
@@ -18,7 +18,7 @@ public function __construct(ServicesResetter $resetter)
$this->resetter = $resetter;
}
- public function onMessageReceived(MessageReceived $context): void
+ public function onPostMessageReceived(PostMessageReceived $context): void
{
$context->getLogger()->debug('[ResetServicesExtension] Resetting services.');
diff --git a/pkg/enqueue-bundle/DependencyInjection/Configuration.php b/pkg/enqueue-bundle/DependencyInjection/Configuration.php
index 3b6367fda..733849d35 100644
--- a/pkg/enqueue-bundle/DependencyInjection/Configuration.php
+++ b/pkg/enqueue-bundle/DependencyInjection/Configuration.php
@@ -94,6 +94,12 @@ private function getJobConfiguration(): ArrayNodeDefinition
}
return (new ArrayNodeDefinition('job'))
+ ->children()
+ ->booleanNode('default_mapping')
+ ->defaultTrue()
+ ->info('Adds bundle\'s default Job entity mapping to application\'s entity manager')
+ ->end()
+ ->end()
->addDefaultsIfNotSet()
->canBeEnabled()
;
diff --git a/pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php b/pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php
index 10521b3a0..96fca6fde 100644
--- a/pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php
+++ b/pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php
@@ -22,10 +22,10 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
-use Symfony\Component\HttpKernel\DependencyInjection\Extension;
final class EnqueueExtension extends Extension implements PrependExtensionInterface
{
@@ -171,6 +171,18 @@ private function registerJobQueueDoctrineEntityMapping(ContainerBuilder $contain
return;
}
+ $config = $container->getExtensionConfig('enqueue');
+
+ if (!empty($config)) {
+ $processedConfig = $this->processConfiguration(new Configuration(false), $config);
+
+ foreach ($processedConfig as $name => $modules) {
+ if (isset($modules['job']) && false === $modules['job']['default_mapping']) {
+ return;
+ }
+ }
+ }
+
foreach ($container->getExtensionConfig('doctrine') as $config) {
// do not register mappings if dbal not configured.
if (!empty($config['dbal'])) {
diff --git a/pkg/enqueue-bundle/EnqueueBundle.php b/pkg/enqueue-bundle/EnqueueBundle.php
index 195013578..5010ba0ed 100644
--- a/pkg/enqueue-bundle/EnqueueBundle.php
+++ b/pkg/enqueue-bundle/EnqueueBundle.php
@@ -23,11 +23,11 @@ class EnqueueBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
- //transport passes
+ // transport passes
$container->addCompilerPass(new BuildConsumptionExtensionsPass());
$container->addCompilerPass(new BuildProcessorRegistryPass());
- //client passes
+ // client passes
$container->addCompilerPass(new BuildClientConsumptionExtensionsPass());
$container->addCompilerPass(new BuildClientExtensionsPass());
$container->addCompilerPass(new BuildClientTopicSubscriberRoutesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 100);
diff --git a/pkg/enqueue-bundle/Profiler/AbstractMessageQueueCollector.php b/pkg/enqueue-bundle/Profiler/AbstractMessageQueueCollector.php
index a63e75431..e2e5eee5a 100644
--- a/pkg/enqueue-bundle/Profiler/AbstractMessageQueueCollector.php
+++ b/pkg/enqueue-bundle/Profiler/AbstractMessageQueueCollector.php
@@ -59,8 +59,6 @@ public function prettyPrintPriority($priority)
}
/**
- * @param mixed $body
- *
* @return string
*/
public function ensureString($body)
@@ -68,18 +66,12 @@ public function ensureString($body)
return is_string($body) ? $body : JSON::encode($body);
}
- /**
- * {@inheritdoc}
- */
- public function getName()
+ public function getName(): string
{
return 'enqueue.message_queue';
}
- /**
- * {@inheritdoc}
- */
- public function reset()
+ public function reset(): void
{
$this->data = [];
}
diff --git a/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php b/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php
index e44429413..3c484a7d1 100644
--- a/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php
+++ b/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php
@@ -4,28 +4,11 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpKernel\Kernel;
-if (Kernel::MAJOR_VERSION < 5) {
- class MessageQueueCollector extends AbstractMessageQueueCollector
+class MessageQueueCollector extends AbstractMessageQueueCollector
+{
+ public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
{
- /**
- * {@inheritdoc}
- */
- public function collect(Request $request, Response $response, \Exception $exception = null)
- {
- $this->collectInternal($request, $response);
- }
- }
-} else {
- class MessageQueueCollector extends AbstractMessageQueueCollector
- {
- /**
- * {@inheritdoc}
- */
- public function collect(Request $request, Response $response, \Throwable $exception = null)
- {
- $this->collectInternal($request, $response);
- }
+ $this->collectInternal($request, $response);
}
}
diff --git a/pkg/enqueue-bundle/README.md b/pkg/enqueue-bundle/README.md
index 54c242600..2b8bbfe68 100644
--- a/pkg/enqueue-bundle/README.md
+++ b/pkg/enqueue-bundle/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Message Queue Bundle
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/enqueue-bundle)
+[](https://github.com/php-enqueue/enqueue-bundle/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/enqueue-bundle)
[](https://packagist.org/packages/enqueue/enqueue-bundle)
diff --git a/pkg/enqueue-bundle/Tests/Functional/App/AppKernel.php b/pkg/enqueue-bundle/Tests/Functional/App/AppKernel.php
index e484f0bfd..3cafeedda 100644
--- a/pkg/enqueue-bundle/Tests/Functional/App/AppKernel.php
+++ b/pkg/enqueue-bundle/Tests/Functional/App/AppKernel.php
@@ -7,10 +7,7 @@
class AppKernel extends Kernel
{
- /**
- * @return array
- */
- public function registerBundles()
+ public function registerBundles(): iterable
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
@@ -21,31 +18,28 @@ public function registerBundles()
return $bundles;
}
- /**
- * @return string
- */
- public function getCacheDir()
+ public function getCacheDir(): string
{
return sys_get_temp_dir().'/EnqueueBundle/cache';
}
- /**
- * @return string
- */
- public function getLogDir()
+ public function getLogDir(): string
{
return sys_get_temp_dir().'/EnqueueBundle/cache/logs';
}
- /**
- * @param \Symfony\Component\Config\Loader\LoaderInterface $loader
- */
public function registerContainerConfiguration(LoaderInterface $loader)
{
+ if (self::VERSION_ID < 60000) {
+ $loader->load(__DIR__.'/config/config-sf5.yml');
+
+ return;
+ }
+
$loader->load(__DIR__.'/config/config.yml');
}
- protected function getContainerClass()
+ protected function getContainerClass(): string
{
return parent::getContainerClass().'BundleDefault';
}
diff --git a/pkg/enqueue-bundle/Tests/Functional/App/AsyncListener.php b/pkg/enqueue-bundle/Tests/Functional/App/AsyncListener.php
index 2248dc5d1..23ab4af79 100644
--- a/pkg/enqueue-bundle/Tests/Functional/App/AsyncListener.php
+++ b/pkg/enqueue-bundle/Tests/Functional/App/AsyncListener.php
@@ -2,36 +2,15 @@
namespace Enqueue\Bundle\Tests\Functional\App;
-use Symfony\Component\EventDispatcher\Event;
-use Symfony\Contracts\EventDispatcher\Event as ContractEvent;
+use Symfony\Contracts\EventDispatcher\Event;
-if (class_exists(Event::class)) {
+class AsyncListener extends AbstractAsyncListener
+{
/**
- * Symfony < 5.0.
+ * @param string $eventName
*/
- class AsyncListener extends AbstractAsyncListener
+ public function onEvent(Event $event, $eventName)
{
- /**
- * @param Event|ContractEvent $event
- * @param string $eventName
- */
- public function onEvent($event, $eventName)
- {
- $this->onEventInternal($event, $eventName);
- }
- }
-} else {
- /**
- * Symfony >= 5.0.
- */
- class AsyncListener extends AbstractAsyncListener
- {
- /**
- * @param string $eventName
- */
- public function onEvent(ContractEvent $event, $eventName)
- {
- $this->onEventInternal($event, $eventName);
- }
+ $this->onEventInternal($event, $eventName);
}
}
diff --git a/pkg/enqueue-bundle/Tests/Functional/App/CustomAppKernel.php b/pkg/enqueue-bundle/Tests/Functional/App/CustomAppKernel.php
index 2f272bf1b..81d73796e 100644
--- a/pkg/enqueue-bundle/Tests/Functional/App/CustomAppKernel.php
+++ b/pkg/enqueue-bundle/Tests/Functional/App/CustomAppKernel.php
@@ -7,7 +7,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;
-use Symfony\Component\Routing\RouteCollectionBuilder;
+use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
class CustomAppKernel extends Kernel
{
@@ -27,7 +27,7 @@ class CustomAppKernel extends Kernel
],
];
- public function setEnqueueConfig(array $config)
+ public function setEnqueueConfig(array $config): void
{
$this->enqueueConfig = array_replace_recursive($this->enqueueConfig, $config);
$this->enqueueConfig['default']['client']['app_name'] = str_replace('.', '', uniqid('app_name', true));
@@ -38,10 +38,7 @@ public function setEnqueueConfig(array $config)
$fs->mkdir(sys_get_temp_dir().'/EnqueueBundleCustom/cache/'.$this->enqueueConfigId);
}
- /**
- * @return array
- */
- public function registerBundles()
+ public function registerBundles(): iterable
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
@@ -52,41 +49,33 @@ public function registerBundles()
return $bundles;
}
- /**
- * @return string
- */
- public function getCacheDir()
+ public function getCacheDir(): string
{
return sys_get_temp_dir().'/EnqueueBundleCustom/cache/'.$this->enqueueConfigId;
}
- /**
- * @return string
- */
- public function getLogDir()
+ public function getLogDir(): string
{
return sys_get_temp_dir().'/EnqueueBundleCustom/cache/logs/'.$this->enqueueConfigId;
}
- protected function getContainerClass()
+ protected function getContainerClass(): string
{
return parent::getContainerClass().'Custom'.$this->enqueueConfigId;
}
- /**
- * {@inheritdoc}
- */
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
{
- $loader->load(__DIR__.'/config/custom-config.yml');
+ if (self::VERSION_ID < 60000) {
+ $loader->load(__DIR__.'/config/custom-config-sf5.yml');
+ } else {
+ $loader->load(__DIR__.'/config/custom-config.yml');
+ }
$c->loadFromExtension('enqueue', $this->enqueueConfig);
}
- /**
- * {@inheritdoc}
- */
- protected function configureRoutes(RouteCollectionBuilder $routes)
+ protected function configureRoutes(RoutingConfigurator $routes)
{
}
}
diff --git a/pkg/enqueue-bundle/Tests/Functional/App/TestAsyncEventTransformer.php b/pkg/enqueue-bundle/Tests/Functional/App/TestAsyncEventTransformer.php
index 7c85e076c..0a83a04b6 100644
--- a/pkg/enqueue-bundle/Tests/Functional/App/TestAsyncEventTransformer.php
+++ b/pkg/enqueue-bundle/Tests/Functional/App/TestAsyncEventTransformer.php
@@ -6,96 +6,46 @@
use Enqueue\Util\JSON;
use Interop\Queue\Context;
use Interop\Queue\Message;
-use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\GenericEvent;
-use Symfony\Contracts\EventDispatcher\Event as ContractEvent;
+use Symfony\Contracts\EventDispatcher\Event;
-if (class_exists(Event::class)) {
+class TestAsyncEventTransformer implements EventTransformer
+{
/**
- * Symfony < 5.0.
+ * @var Context
*/
- class TestAsyncEventTransformer implements EventTransformer
+ private $context;
+
+ public function __construct(Context $context)
{
- /**
- * @var Context
- */
- private $context;
+ $this->context = $context;
+ }
- public function __construct(Context $context)
- {
- $this->context = $context;
+ public function toMessage($eventName, ?Event $event = null)
+ {
+ if (Event::class === $event::class) {
+ return $this->context->createMessage(json_encode(''));
}
- public function toMessage($eventName, $event = null)
- {
- if (Event::class === get_class($event) || ContractEvent::class === get_class($event)) {
- return $this->context->createMessage(json_encode(''));
- }
-
- /** @var GenericEvent $event */
- if (false == $event instanceof GenericEvent) {
- throw new \LogicException('Must be GenericEvent');
- }
-
- return $this->context->createMessage(json_encode([
- 'subject' => $event->getSubject(),
- 'arguments' => $event->getArguments(),
- ]));
+ /** @var GenericEvent $event */
+ if (false == $event instanceof GenericEvent) {
+ throw new \LogicException('Must be GenericEvent');
}
- public function toEvent($eventName, Message $message)
- {
- $data = JSON::decode($message->getBody());
-
- if ('' === $data) {
- return new Event();
- }
-
- return new GenericEvent($data['subject'], $data['arguments']);
- }
+ return $this->context->createMessage(json_encode([
+ 'subject' => $event->getSubject(),
+ 'arguments' => $event->getArguments(),
+ ]));
}
-} else {
- /**
- * Symfony >= 5.0.
- */
- class TestAsyncEventTransformer implements EventTransformer
- {
- /**
- * @var Context
- */
- private $context;
-
- public function __construct(Context $context)
- {
- $this->context = $context;
- }
-
- public function toMessage($eventName, ContractEvent $event = null)
- {
- if (ContractEvent::class === get_class($event)) {
- return $this->context->createMessage(json_encode(''));
- }
- /** @var GenericEvent $event */
- if (false == $event instanceof GenericEvent) {
- throw new \LogicException('Must be GenericEvent');
- }
+ public function toEvent($eventName, Message $message)
+ {
+ $data = JSON::decode($message->getBody());
- return $this->context->createMessage(json_encode([
- 'subject' => $event->getSubject(),
- 'arguments' => $event->getArguments(),
- ]));
+ if ('' === $data) {
+ return new Event();
}
- public function toEvent($eventName, Message $message)
- {
- $data = JSON::decode($message->getBody());
-
- if ('' === $data) {
- return new ContractEvent();
- }
-
- return new GenericEvent($data['subject'], $data['arguments']);
- }
+ return new GenericEvent($data['subject'], $data['arguments']);
}
}
diff --git a/pkg/enqueue-bundle/Tests/Functional/App/config/config-sf5.yml b/pkg/enqueue-bundle/Tests/Functional/App/config/config-sf5.yml
new file mode 100644
index 000000000..e202bb86f
--- /dev/null
+++ b/pkg/enqueue-bundle/Tests/Functional/App/config/config-sf5.yml
@@ -0,0 +1,129 @@
+parameters:
+ locale: 'en'
+ secret: 'ThisTokenIsNotSoSecretChangeIt'
+
+
+framework:
+ #esi: ~
+ #translator: { fallback: "%locale%" }
+ test: ~
+ assets: false
+ session:
+ # option incompatible with Symfony 6
+ storage_id: session.storage.mock_file
+ secret: '%secret%'
+ router: { resource: '%kernel.project_dir%/config/routing.yml' }
+ default_locale: '%locale%'
+
+doctrine:
+ dbal:
+ url: "%env(DOCTRINE_DSN)%"
+ driver: pdo_mysql
+ charset: UTF8
+
+enqueue:
+ default:
+ transport: 'null:'
+ client:
+ traceable_producer: true
+ job: true
+ async_events: true
+ async_commands:
+ enabled: true
+ timeout: 60
+ command_name: ~
+ queue_name: ~
+
+services:
+ test_enqueue.client.default.traceable_producer:
+ alias: 'enqueue.client.default.traceable_producer'
+ public: true
+
+ test_enqueue.transport.default.queue_consumer:
+ alias: 'enqueue.transport.default.queue_consumer'
+ public: true
+
+ test_enqueue.client.default.queue_consumer:
+ alias: 'enqueue.client.default.queue_consumer'
+ public: true
+
+ test_enqueue.transport.default.rpc_client:
+ alias: 'enqueue.transport.default.rpc_client'
+ public: true
+
+ test_enqueue.client.default.producer:
+ alias: 'enqueue.client.default.producer'
+ public: true
+
+ test_enqueue.client.default.spool_producer:
+ alias: 'enqueue.client.default.spool_producer'
+ public: true
+
+ test_Enqueue\Client\ProducerInterface:
+ alias: 'Enqueue\Client\ProducerInterface'
+ public: true
+
+ test_enqueue.client.default.driver:
+ alias: 'enqueue.client.default.driver'
+ public: true
+
+ test_enqueue.transport.default.context:
+ alias: 'enqueue.transport.default.context'
+ public: true
+
+ test_enqueue.client.consume_command:
+ alias: 'enqueue.client.consume_command'
+ public: true
+
+ test.enqueue.client.routes_command:
+ alias: 'enqueue.client.routes_command'
+ public: true
+
+ test.enqueue.events.async_processor:
+ alias: 'enqueue.events.async_processor'
+ public: true
+
+ test_async_listener:
+ class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncListener'
+ public: true
+ tags:
+ - { name: 'kernel.event_listener', async: true, event: 'test_async', method: 'onEvent', dispatcher: 'enqueue.events.event_dispatcher' }
+
+ test_command_subscriber_processor:
+ class: 'Enqueue\Bundle\Tests\Functional\App\TestCommandSubscriberProcessor'
+ public: true
+ tags:
+ - { name: 'enqueue.command_subscriber', client: 'default' }
+
+ test_topic_subscriber_processor:
+ class: 'Enqueue\Bundle\Tests\Functional\App\TestTopicSubscriberProcessor'
+ public: true
+ tags:
+ - { name: 'enqueue.topic_subscriber', client: 'default' }
+
+ test_exclusive_command_subscriber_processor:
+ class: 'Enqueue\Bundle\Tests\Functional\App\TestExclusiveCommandSubscriberProcessor'
+ public: true
+ tags:
+ - { name: 'enqueue.command_subscriber', client: 'default' }
+
+ test_async_subscriber:
+ class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncSubscriber'
+ public: true
+ tags:
+ - { name: 'kernel.event_subscriber', async: true, dispatcher: 'enqueue.events.event_dispatcher' }
+
+ test_async_event_transformer:
+ class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncEventTransformer'
+ public: true
+ arguments:
+ - '@enqueue.transport.default.context'
+ tags:
+ - {name: 'enqueue.event_transformer', eventName: 'test_async', transformerName: 'test_async' }
+ - {name: 'enqueue.event_transformer', eventName: 'test_async_subscriber', transformerName: 'test_async' }
+
+ # overwrite async listener with one based on client producer. so we can use traceable producer.
+ enqueue.events.async_listener:
+ class: 'Enqueue\Bundle\Tests\Functional\App\AsyncListener'
+ public: true
+ arguments: ['@enqueue.client.default.producer', '@enqueue.events.registry']
diff --git a/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml b/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml
index 7b04a3f30..d3ca2a37f 100644
--- a/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml
+++ b/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml
@@ -9,7 +9,7 @@ framework:
test: ~
assets: false
session:
- storage_id: session.storage.mock_file
+ storage_factory_id: session.storage.factory.mock_file
secret: '%secret%'
router: { resource: '%kernel.project_dir%/config/routing.yml' }
default_locale: '%locale%'
@@ -86,7 +86,7 @@ services:
class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncListener'
public: true
tags:
- - { name: 'kernel.event_listener', async: true, event: 'test_async', method: 'onEvent' }
+ - { name: 'kernel.event_listener', async: true, event: 'test_async', method: 'onEvent', dispatcher: 'enqueue.events.event_dispatcher' }
test_command_subscriber_processor:
class: 'Enqueue\Bundle\Tests\Functional\App\TestCommandSubscriberProcessor'
@@ -110,7 +110,7 @@ services:
class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncSubscriber'
public: true
tags:
- - { name: 'kernel.event_subscriber', async: true }
+ - { name: 'kernel.event_subscriber', async: true, dispatcher: 'enqueue.events.event_dispatcher' }
test_async_event_transformer:
class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncEventTransformer'
diff --git a/pkg/enqueue-bundle/Tests/Functional/App/config/custom-config-sf5.yml b/pkg/enqueue-bundle/Tests/Functional/App/config/custom-config-sf5.yml
new file mode 100644
index 000000000..35192652e
--- /dev/null
+++ b/pkg/enqueue-bundle/Tests/Functional/App/config/custom-config-sf5.yml
@@ -0,0 +1,85 @@
+parameters:
+ locale: 'en'
+ secret: 'ThisTokenIsNotSoSecretChangeIt'
+
+framework:
+ #esi: ~
+ #translator: { fallback: "%locale%" }
+ test: ~
+ assets: false
+ session:
+ # the only option incompatible with Symfony 6
+ storage_id: session.storage.mock_file
+ secret: '%secret%'
+ router: { resource: '%kernel.project_dir%/config/routing.yml' }
+ default_locale: '%locale%'
+
+doctrine:
+ dbal:
+ connections:
+ custom:
+ url: "%env(DOCTRINE_DSN)%"
+ driver: pdo_mysql
+ charset: UTF8
+
+services:
+ test_enqueue.client.default.driver:
+ alias: 'enqueue.client.default.driver'
+ public: true
+
+ test_enqueue.client.default.producer:
+ alias: 'enqueue.client.default.producer'
+ public: true
+
+ test_enqueue.client.default.lazy_producer:
+ alias: 'enqueue.client.default.lazy_producer'
+ public: true
+
+ test_enqueue.transport.default.context:
+ alias: 'enqueue.transport.default.context'
+ public: true
+
+ test_enqueue.transport.consume_command:
+ alias: 'enqueue.transport.consume_command'
+ public: true
+
+ test_enqueue.client.consume_command:
+ alias: 'enqueue.client.consume_command'
+ public: true
+
+ test_enqueue.client.produce_command:
+ alias: 'enqueue.client.produce_command'
+ public: true
+
+ test_enqueue.client.setup_broker_command:
+ alias: 'enqueue.client.setup_broker_command'
+ public: true
+
+ test.message.processor:
+ class: 'Enqueue\Bundle\Tests\Functional\TestProcessor'
+ public: true
+ tags:
+ - { name: 'enqueue.topic_subscriber', client: 'default' }
+ - { name: 'enqueue.transport.processor', transport: 'default' }
+
+ test.message.command_processor:
+ class: 'Enqueue\Bundle\Tests\Functional\TestCommandProcessor'
+ public: true
+ tags:
+ - { name: 'enqueue.command_subscriber', client: 'default' }
+
+ test.sqs_client:
+ public: true
+ class: 'Aws\Sqs\SqsClient'
+ arguments:
+ -
+ endpoint: '%env(AWS_SQS_ENDPOINT)%'
+ region: '%env(AWS_SQS_REGION)%'
+ version: '%env(AWS_SQS_VERSION)%'
+ credentials:
+ key: '%env(AWS_SQS_KEY)%'
+ secret: '%env(AWS_SQS_SECRET)%'
+
+ test.sqs_custom_connection_factory_factory:
+ class: 'Enqueue\Bundle\Tests\Functional\App\SqsCustomConnectionFactoryFactory'
+ arguments: ['@service_container']
diff --git a/pkg/enqueue-bundle/Tests/Functional/App/config/custom-config.yml b/pkg/enqueue-bundle/Tests/Functional/App/config/custom-config.yml
index 37c4660a0..d02f3002d 100644
--- a/pkg/enqueue-bundle/Tests/Functional/App/config/custom-config.yml
+++ b/pkg/enqueue-bundle/Tests/Functional/App/config/custom-config.yml
@@ -8,7 +8,7 @@ framework:
test: ~
assets: false
session:
- storage_id: session.storage.mock_file
+ storage_factory_id: session.storage.factory.mock_file
secret: '%secret%'
router: { resource: '%kernel.project_dir%/config/routing.yml' }
default_locale: '%locale%'
diff --git a/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php b/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php
index 51db9dc25..29a96aa7d 100644
--- a/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php
+++ b/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php
@@ -4,7 +4,6 @@
use Enqueue\Bundle\Tests\Functional\WebTestCase;
use Enqueue\Client\Message;
-use Enqueue\Client\Producer;
use Enqueue\Client\ProducerInterface;
use Enqueue\Client\TraceableProducer;
use Enqueue\Rpc\Promise;
diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php
index 457a0ffcd..7fb6fdd86 100644
--- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php
+++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php
@@ -16,7 +16,7 @@
*/
class AsyncListenerTest extends WebTestCase
{
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php
index e595414ae..d85567509 100644
--- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php
+++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php
@@ -18,7 +18,7 @@
*/
class AsyncProcessorTest extends WebTestCase
{
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php
index 7404e6af8..4b145524a 100644
--- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php
+++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php
@@ -16,7 +16,7 @@
*/
class AsyncSubscriberTest extends WebTestCase
{
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php b/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php
index fefbe882b..18375aef3 100644
--- a/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php
+++ b/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php
@@ -4,30 +4,18 @@
use Enqueue\Bundle\Tests\Functional\App\CustomAppKernel;
use Enqueue\Symfony\Client\LazyProducer;
-use Symfony\Component\Filesystem\Filesystem;
/**
* @group functional
*/
class LazyProducerTest extends WebTestCase
{
- public function setUp()
+ protected function setUp(): void
{
// do not call parent::setUp.
// parent::setUp();
}
- public function tearDown(): void
- {
- if (static::$kernel) {
- $fs = new Filesystem();
- $fs->remove(static::$kernel->getLogDir());
- $fs->remove(static::$kernel->getCacheDir());
- }
-
- parent::tearDown();
- }
-
public function testShouldAllowGetLazyProducerWithoutError()
{
$this->customSetUp([
@@ -47,10 +35,7 @@ public function testShouldAllowGetLazyProducerWithoutError()
$producer->sendEvent('foo', 'foo');
}
- /**
- * @return string
- */
- public static function getKernelClass()
+ public static function getKernelClass(): string
{
include_once __DIR__.'/App/CustomAppKernel.php';
diff --git a/pkg/enqueue-bundle/Tests/Functional/RoutesCommandTest.php b/pkg/enqueue-bundle/Tests/Functional/RoutesCommandTest.php
index 4970e9b43..66833b1ce 100644
--- a/pkg/enqueue-bundle/Tests/Functional/RoutesCommandTest.php
+++ b/pkg/enqueue-bundle/Tests/Functional/RoutesCommandTest.php
@@ -26,11 +26,11 @@ public function testShouldDisplayRegisteredTopics()
$tester->execute([]);
$this->assertSame(0, $tester->getStatusCode());
- $this->assertContains('| topic', $tester->getDisplay());
- $this->assertContains('| theTopic', $tester->getDisplay());
- $this->assertContains('| default (prefixed)', $tester->getDisplay());
- $this->assertContains('| test_topic_subscriber_processor', $tester->getDisplay());
- $this->assertContains('| (hidden)', $tester->getDisplay());
+ $this->assertStringContainsString('| topic', $tester->getDisplay());
+ $this->assertStringContainsString('| theTopic', $tester->getDisplay());
+ $this->assertStringContainsString('| default (prefixed)', $tester->getDisplay());
+ $this->assertStringContainsString('| test_topic_subscriber_processor', $tester->getDisplay());
+ $this->assertStringContainsString('| (hidden)', $tester->getDisplay());
}
public function testShouldDisplayCommands()
@@ -42,10 +42,10 @@ public function testShouldDisplayCommands()
$tester->execute([]);
$this->assertSame(0, $tester->getStatusCode());
- $this->assertContains('| command', $tester->getDisplay());
- $this->assertContains('| theCommand', $tester->getDisplay());
- $this->assertContains('| test_command_subscriber_processor', $tester->getDisplay());
- $this->assertContains('| default (prefixed)', $tester->getDisplay());
- $this->assertContains('| (hidden)', $tester->getDisplay());
+ $this->assertStringContainsString('| command', $tester->getDisplay());
+ $this->assertStringContainsString('| theCommand', $tester->getDisplay());
+ $this->assertStringContainsString('| test_command_subscriber_processor', $tester->getDisplay());
+ $this->assertStringContainsString('| default (prefixed)', $tester->getDisplay());
+ $this->assertStringContainsString('| (hidden)', $tester->getDisplay());
}
}
diff --git a/pkg/enqueue-bundle/Tests/Functional/TestCommandProcessor.php b/pkg/enqueue-bundle/Tests/Functional/TestCommandProcessor.php
index 5875a865b..dfc2bb864 100644
--- a/pkg/enqueue-bundle/Tests/Functional/TestCommandProcessor.php
+++ b/pkg/enqueue-bundle/Tests/Functional/TestCommandProcessor.php
@@ -9,7 +9,7 @@
class TestCommandProcessor implements Processor, CommandSubscriberInterface
{
- const COMMAND = 'test-command';
+ public const COMMAND = 'test-command';
/**
* @var Message
diff --git a/pkg/enqueue-bundle/Tests/Functional/TestProcessor.php b/pkg/enqueue-bundle/Tests/Functional/TestProcessor.php
index 8d21cb7ac..9b54bdf2d 100644
--- a/pkg/enqueue-bundle/Tests/Functional/TestProcessor.php
+++ b/pkg/enqueue-bundle/Tests/Functional/TestProcessor.php
@@ -9,7 +9,7 @@
class TestProcessor implements Processor, TopicSubscriberInterface
{
- const TOPIC = 'test-topic';
+ public const TOPIC = 'test-topic';
/**
* @var Message
diff --git a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php
index 7c2936c0e..7417412bd 100644
--- a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php
+++ b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php
@@ -11,33 +11,26 @@
use Interop\Queue\Message;
use Interop\Queue\Queue;
use Symfony\Component\Console\Tester\CommandTester;
-use Symfony\Component\Filesystem\Filesystem;
/**
* @group functional
*/
class UseCasesTest extends WebTestCase
{
- const RECEIVE_TIMEOUT = 500;
+ private const RECEIVE_TIMEOUT = 500;
- public function setUp()
+ protected function setUp(): void
{
// do not call parent::setUp.
// parent::setUp();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
if ($this->getContext()) {
$this->getContext()->close();
}
- if (static::$kernel) {
- $fs = new Filesystem();
- $fs->remove(static::$kernel->getLogDir());
- $fs->remove(static::$kernel->getCacheDir());
- }
-
parent::tearDown();
}
@@ -153,12 +146,12 @@ public function provideEnqueueConfigs()
],
]];
-//
-// yield 'gps' => [[
-// 'transport' => [
-// 'dsn' => getenv('GPS_DSN'),
-// ],
-// ]];
+ //
+ // yield 'gps' => [[
+ // 'transport' => [
+ // 'dsn' => getenv('GPS_DSN'),
+ // ],
+ // ]];
}
/**
@@ -360,10 +353,7 @@ public function testTransportConsumeCommandShouldConsumeOneMessage()
$this->assertEquals($expectedBody, $processor->message->getBody());
}
- /**
- * @return string
- */
- public static function getKernelClass()
+ public static function getKernelClass(): string
{
include_once __DIR__.'/App/CustomAppKernel.php';
diff --git a/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php b/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php
index 8e3569a98..6a348a9f3 100644
--- a/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php
+++ b/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php
@@ -20,7 +20,7 @@ abstract class WebTestCase extends BaseWebTestCase
*/
protected static $container;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -39,10 +39,7 @@ protected function tearDown(): void
static::$client = null;
}
- /**
- * @return string
- */
- public static function getKernelClass()
+ public static function getKernelClass(): string
{
include_once __DIR__.'/App/AppKernel.php';
diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php
index 604012e78..7c5c2dd5d 100644
--- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php
+++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php
@@ -16,11 +16,6 @@
class DoctrineClearIdentityMapExtensionTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new DoctrineClearIdentityMapExtension($this->createRegistryMock());
- }
-
public function testShouldClearIdentityMap()
{
$manager = $this->createManagerMock();
diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php
index fd2ae06aa..36df82e52 100644
--- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php
+++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php
@@ -3,24 +3,20 @@
namespace Enqueue\Bundle\Tests\Unit\Consumption\Extension;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Persistence\ManagerRegistry;
use Enqueue\Bundle\Consumption\Extension\DoctrinePingConnectionExtension;
use Enqueue\Consumption\Context\MessageReceived;
+use Enqueue\Test\TestLogger;
use Interop\Queue\Consumer;
use Interop\Queue\Context as InteropContext;
use Interop\Queue\Message;
use Interop\Queue\Processor;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
class DoctrinePingConnectionExtensionTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredAttributes()
- {
- new DoctrinePingConnectionExtension($this->createRegistryMock());
- }
-
public function testShouldNotReconnectIfConnectionIsOK()
{
$connection = $this->createConnectionMock();
@@ -29,10 +25,17 @@ public function testShouldNotReconnectIfConnectionIsOK()
->method('isConnected')
->willReturn(true)
;
+
+ $abstractPlatform = $this->createMock(AbstractPlatform::class);
+ $abstractPlatform->expects($this->once())
+ ->method('getDummySelectSQL')
+ ->willReturn('dummy')
+ ;
+
$connection
->expects($this->once())
- ->method('ping')
- ->willReturn(true)
+ ->method('getDatabasePlatform')
+ ->willReturn($abstractPlatform)
;
$connection
->expects($this->never())
@@ -44,20 +47,20 @@ public function testShouldNotReconnectIfConnectionIsOK()
;
$context = $this->createContext();
- $context->getLogger()
- ->expects($this->never())
- ->method('debug')
- ;
$registry = $this->createRegistryMock();
$registry
- ->expects($this->once())
+ ->expects(self::once())
->method('getConnections')
->willReturn([$connection])
;
$extension = new DoctrinePingConnectionExtension($registry);
$extension->onMessageReceived($context);
+
+ /** @var TestLogger $logger */
+ $logger = $context->getLogger();
+ self::assertFalse($logger->hasDebugRecords());
}
public function testShouldDoesReconnectIfConnectionFailed()
@@ -68,10 +71,11 @@ public function testShouldDoesReconnectIfConnectionFailed()
->method('isConnected')
->willReturn(true)
;
+
$connection
->expects($this->once())
- ->method('ping')
- ->willReturn(false)
+ ->method('getDatabasePlatform')
+ ->willThrowException(new \Exception())
;
$connection
->expects($this->once())
@@ -83,16 +87,6 @@ public function testShouldDoesReconnectIfConnectionFailed()
;
$context = $this->createContext();
- $context->getLogger()
- ->expects($this->at(0))
- ->method('debug')
- ->with('[DoctrinePingConnectionExtension] Connection is not active trying to reconnect.')
- ;
- $context->getLogger()
- ->expects($this->at(1))
- ->method('debug')
- ->with('[DoctrinePingConnectionExtension] Connection is active now.')
- ;
$registry = $this->createRegistryMock();
$registry
@@ -103,6 +97,19 @@ public function testShouldDoesReconnectIfConnectionFailed()
$extension = new DoctrinePingConnectionExtension($registry);
$extension->onMessageReceived($context);
+
+ /** @var TestLogger $logger */
+ $logger = $context->getLogger();
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[DoctrinePingConnectionExtension] Connection is not active trying to reconnect.'
+ )
+ );
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[DoctrinePingConnectionExtension] Connection is active now.'
+ )
+ );
}
public function testShouldSkipIfConnectionWasNotOpened()
@@ -115,7 +122,7 @@ public function testShouldSkipIfConnectionWasNotOpened()
;
$connection1
->expects($this->never())
- ->method('ping')
+ ->method('getDatabasePlatform')
;
// 2nd connection was opened in the past
@@ -125,17 +132,19 @@ public function testShouldSkipIfConnectionWasNotOpened()
->method('isConnected')
->willReturn(true)
;
+ $abstractPlatform = $this->createMock(AbstractPlatform::class);
+ $abstractPlatform->expects($this->once())
+ ->method('getDummySelectSQL')
+ ->willReturn('dummy')
+ ;
+
$connection2
->expects($this->once())
- ->method('ping')
- ->willReturn(true)
+ ->method('getDatabasePlatform')
+ ->willReturn($abstractPlatform)
;
$context = $this->createContext();
- $context->getLogger()
- ->expects($this->never())
- ->method('debug')
- ;
$registry = $this->createRegistryMock();
$registry
@@ -146,6 +155,10 @@ public function testShouldSkipIfConnectionWasNotOpened()
$extension = new DoctrinePingConnectionExtension($registry);
$extension->onMessageReceived($context);
+
+ /** @var TestLogger $logger */
+ $logger = $context->getLogger();
+ $this->assertFalse($logger->hasDebugRecords());
}
protected function createContext(): MessageReceived
@@ -156,7 +169,7 @@ protected function createContext(): MessageReceived
$this->createMock(Message::class),
$this->createMock(Processor::class),
1,
- $this->createMock(LoggerInterface::class)
+ new TestLogger()
);
}
diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/ResetServicesExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/ResetServicesExtensionTest.php
index bfd772a5c..63282a255 100644
--- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/ResetServicesExtensionTest.php
+++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/ResetServicesExtensionTest.php
@@ -4,7 +4,7 @@
use Doctrine\Persistence\ManagerRegistry;
use Enqueue\Bundle\Consumption\Extension\ResetServicesExtension;
-use Enqueue\Consumption\Context\MessageReceived;
+use Enqueue\Consumption\Context\PostMessageReceived;
use Interop\Queue\Consumer;
use Interop\Queue\Context as InteropContext;
use Interop\Queue\Message;
@@ -16,11 +16,6 @@
class ResetServicesExtensionTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new ResetServicesExtension($this->createResetterMock());
- }
-
public function testItShouldResetServices()
{
$resetter = $this->createResetterMock();
@@ -37,12 +32,12 @@ public function testItShouldResetServices()
;
$extension = new ResetServicesExtension($resetter);
- $extension->onMessageReceived($context);
+ $extension->onPostMessageReceived($context);
}
- protected function createContext(): MessageReceived
+ protected function createContext(): PostMessageReceived
{
- return new MessageReceived(
+ return new PostMessageReceived(
$this->createMock(InteropContext::class),
$this->createMock(Consumer::class),
$this->createMock(Message::class),
diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php
index 3f3aae8ee..5330cde82 100644
--- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php
+++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php
@@ -2,6 +2,7 @@
namespace Enqueue\Bundle\Tests\Unit\DependencyInjection;
+use DMS\PHPUnitExtensions\ArraySubset\Assert;
use Enqueue\Bundle\DependencyInjection\Configuration;
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;
@@ -24,11 +25,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(Configuration::class);
}
- public function testCouldBeConstructedWithDebugAsArgument()
- {
- new Configuration(true);
- }
-
public function testShouldProcessSeveralTransports()
{
$configuration = new Configuration(true);
@@ -112,7 +108,11 @@ public function testThrowIfClientDriverOptionsIsNotArray()
$processor = new Processor();
$this->expectException(InvalidTypeException::class);
- $this->expectExceptionMessage('Invalid type for path "enqueue.default.client.driver_options". Expected array, but got string');
+ // Exception messages vary slightly between versions
+ $this->expectExceptionMessageMatches(
+ '/Invalid type for path "enqueue\.default\.client\.driver_options"\. Expected "?array"?, but got "?string"?/'
+ );
+
$processor->processConfiguration($configuration, [[
'default' => [
'transport' => 'null:',
@@ -222,7 +222,7 @@ public function testJobShouldBeDisabledByDefault()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'job' => [
'enabled' => false,
@@ -243,7 +243,7 @@ public function testCouldEnableJob()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'job' => true,
],
@@ -261,7 +261,7 @@ public function testDoctrinePingConnectionExtensionShouldBeDisabledByDefault()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'doctrine_ping_connection_extension' => false,
@@ -284,7 +284,7 @@ public function testDoctrinePingConnectionExtensionCouldBeEnabled()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'doctrine_ping_connection_extension' => true,
@@ -304,7 +304,7 @@ public function testDoctrineClearIdentityMapExtensionShouldBeDisabledByDefault()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'doctrine_clear_identity_map_extension' => false,
@@ -327,7 +327,7 @@ public function testDoctrineClearIdentityMapExtensionCouldBeEnabled()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'doctrine_clear_identity_map_extension' => true,
@@ -347,7 +347,7 @@ public function testDoctrineOdmClearIdentityMapExtensionShouldBeDisabledByDefaul
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'doctrine_odm_clear_identity_map_extension' => false,
@@ -370,7 +370,7 @@ public function testDoctrineOdmClearIdentityMapExtensionCouldBeEnabled()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'doctrine_odm_clear_identity_map_extension' => true,
@@ -390,7 +390,7 @@ public function testDoctrineClosedEntityManagerExtensionShouldBeDisabledByDefaul
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'doctrine_closed_entity_manager_extension' => false,
@@ -413,7 +413,7 @@ public function testDoctrineClosedEntityManagerExtensionCouldBeEnabled()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'doctrine_closed_entity_manager_extension' => true,
@@ -433,7 +433,7 @@ public function testResetServicesExtensionShouldBeDisabledByDefault()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'reset_services_extension' => false,
@@ -456,7 +456,7 @@ public function testResetServicesExtensionCouldBeEnabled()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'reset_services_extension' => true,
@@ -478,7 +478,7 @@ public function testSignalExtensionShouldBeEnabledIfPcntlExtensionIsLoaded()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'signal_extension' => $isLoaded,
@@ -501,7 +501,7 @@ public function testSignalExtensionCouldBeDisabled()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'signal_extension' => false,
@@ -521,7 +521,7 @@ public function testReplyExtensionShouldBeEnabledByDefault()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'reply_extension' => true,
@@ -544,7 +544,7 @@ public function testReplyExtensionCouldBeDisabled()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'extensions' => [
'reply_extension' => false,
@@ -564,7 +564,7 @@ public function testShouldDisableAsyncEventsByDefault()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'async_events' => [
'enabled' => false,
@@ -586,7 +586,7 @@ public function testShouldAllowEnableAsyncEvents()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'async_events' => [
'enabled' => true,
@@ -603,7 +603,7 @@ public function testShouldAllowEnableAsyncEvents()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'async_events' => [
'enabled' => true,
@@ -623,7 +623,7 @@ public function testShouldSetDefaultConfigurationForConsumption()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'consumption' => [
'receive_timeout' => 10000,
@@ -646,7 +646,7 @@ public function testShouldAllowConfigureConsumption()
],
]]);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'default' => [
'consumption' => [
'receive_timeout' => 456,
@@ -657,6 +657,6 @@ public function testShouldAllowConfigureConsumption()
private function assertConfigEquals(array $expected, array $actual): void
{
- $this->assertArraySubset($expected, $actual, false, var_export($actual, true));
+ Assert::assertArraySubset($expected, $actual, false, var_export($actual, true));
}
}
diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php
index 51bbaa26d..6358bd24d 100644
--- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php
+++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php
@@ -13,8 +13,8 @@
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Reference;
-use Symfony\Component\HttpKernel\DependencyInjection\Extension;
class EnqueueExtensionTest extends TestCase
{
@@ -22,17 +22,12 @@ class EnqueueExtensionTest extends TestCase
public function testShouldImplementConfigurationInterface()
{
- self::assertClassExtends(Extension::class, EnqueueExtension::class);
+ $this->assertClassExtends(Extension::class, EnqueueExtension::class);
}
public function testShouldBeFinal()
{
- self::assertClassFinal(EnqueueExtension::class);
- }
-
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new EnqueueExtension();
+ $this->assertClassFinal(EnqueueExtension::class);
}
public function testShouldRegisterConnectionFactory()
diff --git a/pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php b/pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php
index d93a1f1f9..7d5b0232b 100644
--- a/pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php
+++ b/pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php
@@ -15,9 +15,4 @@ public function testShouldExtendBundleClass()
{
$this->assertClassExtends(Bundle::class, EnqueueBundle::class);
}
-
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new EnqueueBundle();
- }
}
diff --git a/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php b/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php
index 96d4bc940..d6d638d75 100644
--- a/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php
+++ b/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php
@@ -2,6 +2,7 @@
namespace Enqueue\Bundle\Tests\Unit\Profiler;
+use DMS\PHPUnitExtensions\ArraySubset\Assert;
use Enqueue\Bundle\Profiler\MessageQueueCollector;
use Enqueue\Client\MessagePriority;
use Enqueue\Client\ProducerInterface;
@@ -22,11 +23,6 @@ public function testShouldExtendDataCollectorClass()
$this->assertClassExtends(DataCollector::class, MessageQueueCollector::class);
}
- public function testCouldBeConstructedWithEmptyConstructor()
- {
- new MessageQueueCollector();
- }
-
public function testShouldReturnExpectedName()
{
$collector = new MessageQueueCollector();
@@ -59,7 +55,7 @@ public function testShouldReturnSentMessageArrayTakenFromTraceableProducers()
$collector->collect(new Request(), new Response());
- $this->assertArraySubset(
+ Assert::assertArraySubset(
[
'foo' => [
[
diff --git a/pkg/enqueue-bundle/Tests/fix_composer_json.php b/pkg/enqueue-bundle/Tests/fix_composer_json.php
index 6cc24aa03..5c80237ea 100644
--- a/pkg/enqueue-bundle/Tests/fix_composer_json.php
+++ b/pkg/enqueue-bundle/Tests/fix_composer_json.php
@@ -7,4 +7,4 @@
$composerJson['config']['platform']['ext-amqp'] = '1.9.3';
$composerJson['config']['platform']['ext-mongo'] = '1.6.14';
-file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, JSON_PRETTY_PRINT));
+file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, \JSON_PRETTY_PRINT));
diff --git a/pkg/enqueue-bundle/composer.json b/pkg/enqueue-bundle/composer.json
index ee7c5459e..99d237bf6 100644
--- a/pkg/enqueue-bundle/composer.json
+++ b/pkg/enqueue-bundle/composer.json
@@ -6,9 +6,9 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
- "symfony/framework-bundle": "^4.3|^5",
- "queue-interop/amqp-interop": "^0.8",
+ "php": "^8.1",
+ "symfony/framework-bundle": "^6.2|^7.0",
+ "queue-interop/amqp-interop": "^0.8.2",
"queue-interop/queue-interop": "^0.8",
"enqueue/enqueue": "^0.10",
"enqueue/null": "^0.10"
@@ -21,7 +21,7 @@
"docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/stomp": "0.10.x-dev",
"enqueue/amqp-ext": "0.10.x-dev",
"enqueue/amqp-lib": "0.10.x-dev",
@@ -35,13 +35,14 @@
"enqueue/test": "0.10.x-dev",
"enqueue/async-event-dispatcher": "0.10.x-dev",
"enqueue/async-command": "0.10.x-dev",
- "php-amqplib/php-amqplib": "^2.7",
- "doctrine/doctrine-bundle": "~1.2|^2",
- "doctrine/mongodb-odm-bundle": "^3.5|^4",
+ "php-amqplib/php-amqplib": "^3.0",
+ "doctrine/doctrine-bundle": "^2.3.2",
+ "doctrine/mongodb-odm-bundle": "^3.5|^4.3|^5.0",
"alcaeus/mongo-php-adapter": "^1.0",
- "symfony/browser-kit": "^4.3|^5",
- "symfony/expression-language": "^4.3|^5",
- "symfony/yaml": "^4.3|^5"
+ "symfony/browser-kit": "^6.2|^7.0",
+ "symfony/expression-language": "^6.2|^7.0",
+ "symfony/validator": "^6.2|^7.0",
+ "symfony/yaml": "^6.2|^7.0"
},
"suggest": {
"enqueue/async-command": "If want to run Symfony command via message queue",
@@ -57,5 +58,10 @@
"branch-alias": {
"dev-master": "0.10.x-dev"
}
+ },
+ "config": {
+ "allow-plugins": {
+ "php-http/discovery": true
+ }
}
}
diff --git a/pkg/enqueue/.github/workflows/ci.yml b/pkg/enqueue/.github/workflows/ci.yml
new file mode 100644
index 000000000..28a46e908
--- /dev/null
+++ b/pkg/enqueue/.github/workflows/ci.yml
@@ -0,0 +1,30 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+ extensions: mongodb
+
+ - run: php Tests/fix_composer_json.php
+
+ - uses: "ramsey/composer-install@v1"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/enqueue/.travis.yml b/pkg/enqueue/.travis.yml
deleted file mode 100644
index 2c830d0a6..000000000
--- a/pkg/enqueue/.travis.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
-
-services:
- - mongodb
-
-before_install:
- - echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - php Tests/fix_composer_json.php
- - composer self-update
- - composer install
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/enqueue/Client/ChainExtension.php b/pkg/enqueue/Client/ChainExtension.php
index d01da379f..655b75f6a 100644
--- a/pkg/enqueue/Client/ChainExtension.php
+++ b/pkg/enqueue/Client/ChainExtension.php
@@ -67,7 +67,7 @@ public function __construct(array $extensions)
}
if (false == $extensionValid) {
- throw new \LogicException(sprintf('Invalid extension given %s', get_class($extension)));
+ throw new \LogicException(sprintf('Invalid extension given %s', $extension::class));
}
});
}
diff --git a/pkg/enqueue/Client/CommandSubscriberInterface.php b/pkg/enqueue/Client/CommandSubscriberInterface.php
index 9ee09d0ab..d7b06daaf 100644
--- a/pkg/enqueue/Client/CommandSubscriberInterface.php
+++ b/pkg/enqueue/Client/CommandSubscriberInterface.php
@@ -2,6 +2,15 @@
namespace Enqueue\Client;
+/**
+ * @phpstan-type CommandConfig = array{
+ * command: string,
+ * processor?: string,
+ * queue?: string,
+ * prefix_queue?: bool,
+ * exclusive?: bool,
+ * }
+ */
interface CommandSubscriberInterface
{
/**
@@ -44,6 +53,8 @@ interface CommandSubscriberInterface
* Note: If you set "prefix_queue" to true then the "queue" is used as is and therefor the driver is not used to create a transport queue name.
*
* @return string|array
+ *
+ * @phpstan-return string|CommandConfig|array
*/
public static function getSubscribedCommand();
}
diff --git a/pkg/enqueue/Client/Config.php b/pkg/enqueue/Client/Config.php
index 888384207..8210dff68 100644
--- a/pkg/enqueue/Client/Config.php
+++ b/pkg/enqueue/Client/Config.php
@@ -4,13 +4,13 @@
class Config
{
- const TOPIC = 'enqueue.topic';
- const COMMAND = 'enqueue.command';
- const PROCESSOR = 'enqueue.processor';
- const EXPIRE = 'enqueue.expire';
- const PRIORITY = 'enqueue.priority';
- const DELAY = 'enqueue.delay';
- const CONTENT_TYPE = 'enqueue.content_type';
+ public const TOPIC = 'enqueue.topic';
+ public const COMMAND = 'enqueue.command';
+ public const PROCESSOR = 'enqueue.processor';
+ public const EXPIRE = 'enqueue.expire';
+ public const PRIORITY = 'enqueue.priority';
+ public const DELAY = 'enqueue.delay';
+ public const CONTENT_TYPE = 'enqueue.content_type';
/**
* @var string
@@ -66,7 +66,7 @@ public function __construct(
string $defaultQueue,
string $routerProcessor,
array $transportConfig,
- array $driverConfig
+ array $driverConfig,
) {
$this->prefix = trim($prefix);
$this->app = trim($app);
@@ -153,17 +153,17 @@ public function getDriverOptions(): array
}
public static function create(
- string $prefix = null,
- string $separator = null,
- string $app = null,
- string $routerTopic = null,
- string $routerQueue = null,
- string $defaultQueue = null,
- string $routerProcessor = null,
+ ?string $prefix = null,
+ ?string $separator = null,
+ ?string $app = null,
+ ?string $routerTopic = null,
+ ?string $routerQueue = null,
+ ?string $defaultQueue = null,
+ ?string $routerProcessor = null,
array $transportConfig = [],
- array $driverConfig = []
+ array $driverConfig = [],
): self {
- return new static(
+ return new self(
$prefix ?: '',
$separator ?: '.',
$app ?: '',
diff --git a/pkg/enqueue/Client/ConsumptionExtension/DelayRedeliveredMessageExtension.php b/pkg/enqueue/Client/ConsumptionExtension/DelayRedeliveredMessageExtension.php
index 77e3bc451..475e2cf5b 100644
--- a/pkg/enqueue/Client/ConsumptionExtension/DelayRedeliveredMessageExtension.php
+++ b/pkg/enqueue/Client/ConsumptionExtension/DelayRedeliveredMessageExtension.php
@@ -9,7 +9,7 @@
class DelayRedeliveredMessageExtension implements MessageReceivedExtensionInterface
{
- const PROPERTY_REDELIVER_COUNT = 'enqueue.redelivery_count';
+ public const PROPERTY_REDELIVER_COUNT = 'enqueue.redelivery_count';
/**
* @var DriverInterface
@@ -24,8 +24,7 @@ class DelayRedeliveredMessageExtension implements MessageReceivedExtensionInterf
private $delay;
/**
- * @param DriverInterface $driver
- * @param int $delay The number of seconds the message should be delayed
+ * @param int $delay The number of seconds the message should be delayed
*/
public function __construct(DriverInterface $driver, $delay)
{
diff --git a/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php b/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php
index c7682f60e..0d2278349 100644
--- a/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php
+++ b/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php
@@ -14,9 +14,6 @@ class SetRouterPropertiesExtension implements MessageReceivedExtensionInterface
*/
private $driver;
- /**
- * @param DriverInterface $driver
- */
public function __construct(DriverInterface $driver)
{
$this->driver = $driver;
diff --git a/pkg/enqueue/Client/ConsumptionExtension/SetupBrokerExtension.php b/pkg/enqueue/Client/ConsumptionExtension/SetupBrokerExtension.php
index e35580794..44d610fb9 100644
--- a/pkg/enqueue/Client/ConsumptionExtension/SetupBrokerExtension.php
+++ b/pkg/enqueue/Client/ConsumptionExtension/SetupBrokerExtension.php
@@ -18,9 +18,6 @@ class SetupBrokerExtension implements StartExtensionInterface
*/
private $isDone;
- /**
- * @param DriverInterface $driver
- */
public function __construct(DriverInterface $driver)
{
$this->driver = $driver;
diff --git a/pkg/enqueue/Client/DelegateProcessor.php b/pkg/enqueue/Client/DelegateProcessor.php
index 18985b454..7582c52dc 100644
--- a/pkg/enqueue/Client/DelegateProcessor.php
+++ b/pkg/enqueue/Client/DelegateProcessor.php
@@ -14,25 +14,19 @@ class DelegateProcessor implements Processor
*/
private $registry;
- /**
- * @param ProcessorRegistryInterface $registry
- */
public function __construct(ProcessorRegistryInterface $registry)
{
$this->registry = $registry;
}
/**
- * {@inheritdoc}
+ * @return string|object
*/
public function process(InteropMessage $message, Context $context)
{
$processorName = $message->getProperty(Config::PROCESSOR);
if (false == $processorName) {
- throw new \LogicException(sprintf(
- 'Got message without required parameter: "%s"',
- Config::PROCESSOR
- ));
+ throw new \LogicException(sprintf('Got message without required parameter: "%s"', Config::PROCESSOR));
}
return $this->registry->get($processorName)->process($message, $context);
diff --git a/pkg/enqueue/Client/Driver/AmqpDriver.php b/pkg/enqueue/Client/Driver/AmqpDriver.php
index be62753bf..1def3fb23 100644
--- a/pkg/enqueue/Client/Driver/AmqpDriver.php
+++ b/pkg/enqueue/Client/Driver/AmqpDriver.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-namespace Enqueue\Client\Driver;
+namespace Enqueue\Client\Driver;
use Enqueue\AmqpExt\AmqpProducer;
use Enqueue\Client\Message;
@@ -45,11 +45,7 @@ public function createTransportMessage(Message $clientMessage): InteropMessage
$priorityMap = $this->getPriorityMap();
if ($priority = $clientMessage->getPriority()) {
if (false == array_key_exists($priority, $priorityMap)) {
- throw new \InvalidArgumentException(sprintf(
- 'Cant convert client priority "%s" to transport one. Could be one of "%s"',
- $priority,
- implode('", "', array_keys($priorityMap))
- ));
+ throw new \InvalidArgumentException(sprintf('Cant convert client priority "%s" to transport one. Could be one of "%s"', $priority, implode('", "', array_keys($priorityMap))));
}
$transportMessage->setPriority($priorityMap[$priority]);
@@ -58,7 +54,7 @@ public function createTransportMessage(Message $clientMessage): InteropMessage
return $transportMessage;
}
- public function setupBroker(LoggerInterface $logger = null): void
+ public function setupBroker(?LoggerInterface $logger = null): void
{
$logger = $logger ?: new NullLogger();
$log = function ($text, ...$args) use ($logger) {
diff --git a/pkg/enqueue/Client/Driver/DbalDriver.php b/pkg/enqueue/Client/Driver/DbalDriver.php
index 8b1f32655..34875eff7 100644
--- a/pkg/enqueue/Client/Driver/DbalDriver.php
+++ b/pkg/enqueue/Client/Driver/DbalDriver.php
@@ -16,7 +16,7 @@ public function __construct(DbalContext $context, ...$args)
parent::__construct($context, ...$args);
}
- public function setupBroker(LoggerInterface $logger = null): void
+ public function setupBroker(?LoggerInterface $logger = null): void
{
$logger = $logger ?: new NullLogger();
$log = function ($text, ...$args) use ($logger) {
diff --git a/pkg/enqueue/Client/Driver/FsDriver.php b/pkg/enqueue/Client/Driver/FsDriver.php
index 9de59c23b..f578b172d 100644
--- a/pkg/enqueue/Client/Driver/FsDriver.php
+++ b/pkg/enqueue/Client/Driver/FsDriver.php
@@ -1,6 +1,6 @@
context = $context;
$this->config = $config;
@@ -120,7 +120,7 @@ public function sendToProcessor(Message $message): DriverSendResult
return new DriverSendResult($queue, $transportMessage);
}
- public function setupBroker(LoggerInterface $logger = null): void
+ public function setupBroker(?LoggerInterface $logger = null): void
{
}
diff --git a/pkg/enqueue/Client/Driver/GpsDriver.php b/pkg/enqueue/Client/Driver/GpsDriver.php
index 37a7110c1..32d14f721 100644
--- a/pkg/enqueue/Client/Driver/GpsDriver.php
+++ b/pkg/enqueue/Client/Driver/GpsDriver.php
@@ -20,7 +20,7 @@ public function __construct(GpsContext $context, ...$args)
parent::__construct($context, ...$args);
}
- public function setupBroker(LoggerInterface $logger = null): void
+ public function setupBroker(?LoggerInterface $logger = null): void
{
$logger = $logger ?: new NullLogger();
$log = function ($text, ...$args) use ($logger) {
diff --git a/pkg/enqueue/Client/Driver/MongodbDriver.php b/pkg/enqueue/Client/Driver/MongodbDriver.php
index 19f2c57d3..1c9cff4bc 100644
--- a/pkg/enqueue/Client/Driver/MongodbDriver.php
+++ b/pkg/enqueue/Client/Driver/MongodbDriver.php
@@ -16,7 +16,7 @@ public function __construct(MongodbContext $context, ...$args)
parent::__construct($context, ...$args);
}
- public function setupBroker(LoggerInterface $logger = null): void
+ public function setupBroker(?LoggerInterface $logger = null): void
{
$logger = $logger ?: new NullLogger();
$log = function ($text, ...$args) use ($logger) {
diff --git a/pkg/enqueue/Client/Driver/RabbitMqDriver.php b/pkg/enqueue/Client/Driver/RabbitMqDriver.php
index 096de6d26..f215d555e 100644
--- a/pkg/enqueue/Client/Driver/RabbitMqDriver.php
+++ b/pkg/enqueue/Client/Driver/RabbitMqDriver.php
@@ -1,6 +1,6 @@
debug('[RdKafkaDriver] setup broker');
diff --git a/pkg/enqueue/Client/Driver/SnsQsDriver.php b/pkg/enqueue/Client/Driver/SnsQsDriver.php
index 2b1d4f233..f4bde10c2 100644
--- a/pkg/enqueue/Client/Driver/SnsQsDriver.php
+++ b/pkg/enqueue/Client/Driver/SnsQsDriver.php
@@ -19,7 +19,7 @@ public function __construct(SnsQsContext $context, ...$args)
parent::__construct($context, ...$args);
}
- public function setupBroker(LoggerInterface $logger = null): void
+ public function setupBroker(?LoggerInterface $logger = null): void
{
$logger = $logger ?: new NullLogger();
$log = function ($text, ...$args) use ($logger) {
diff --git a/pkg/enqueue/Client/Driver/SqsDriver.php b/pkg/enqueue/Client/Driver/SqsDriver.php
index bf66c050c..49b696aae 100644
--- a/pkg/enqueue/Client/Driver/SqsDriver.php
+++ b/pkg/enqueue/Client/Driver/SqsDriver.php
@@ -18,7 +18,7 @@ public function __construct(SqsContext $context, ...$args)
parent::__construct($context, ...$args);
}
- public function setupBroker(LoggerInterface $logger = null): void
+ public function setupBroker(?LoggerInterface $logger = null): void
{
$logger = $logger ?: new NullLogger();
$log = function ($text, ...$args) use ($logger) {
diff --git a/pkg/enqueue/Client/Driver/StompDriver.php b/pkg/enqueue/Client/Driver/StompDriver.php
index 7040c71dd..811ad76e7 100644
--- a/pkg/enqueue/Client/Driver/StompDriver.php
+++ b/pkg/enqueue/Client/Driver/StompDriver.php
@@ -22,7 +22,7 @@ public function __construct(StompContext $context, ...$args)
parent::__construct($context, ...$args);
}
- public function setupBroker(LoggerInterface $logger = null): void
+ public function setupBroker(?LoggerInterface $logger = null): void
{
$logger = $logger ?: new NullLogger();
$logger->debug('[StompDriver] Stomp protocol does not support broker configuration');
diff --git a/pkg/enqueue/Client/Driver/StompManagementClient.php b/pkg/enqueue/Client/Driver/StompManagementClient.php
index c068a57df..0d64450dd 100644
--- a/pkg/enqueue/Client/Driver/StompManagementClient.php
+++ b/pkg/enqueue/Client/Driver/StompManagementClient.php
@@ -24,7 +24,7 @@ public function __construct(Client $client, string $vhost = '/')
public static function create(string $vhost = '/', string $host = 'localhost', int $port = 15672, string $login = 'guest', string $password = 'guest'): self
{
- return new static(new Client(null, 'http://'.$host.':'.$port, $login, $password), $vhost);
+ return new self(new Client(null, 'http://'.$host.':'.$port, $login, $password), $vhost);
}
public function declareQueue(string $name, array $options)
@@ -37,7 +37,7 @@ public function declareExchange(string $name, array $options)
return $this->client->exchanges()->create($this->vhost, $name, $options);
}
- public function bind(string $exchange, string $queue, string $routingKey = null, $arguments = null)
+ public function bind(string $exchange, string $queue, ?string $routingKey = null, $arguments = null)
{
return $this->client->bindings()->create($this->vhost, $exchange, $queue, $routingKey, $arguments);
}
diff --git a/pkg/enqueue/Client/DriverFactory.php b/pkg/enqueue/Client/DriverFactory.php
index 0dd9412d8..5c827e7e7 100644
--- a/pkg/enqueue/Client/DriverFactory.php
+++ b/pkg/enqueue/Client/DriverFactory.php
@@ -31,18 +31,10 @@ public function create(ConnectionFactory $factory, Config $config, RouteCollecti
$knownDrivers = Resources::getKnownDrivers();
if ($driverInfo = $this->findDriverInfo($dsn, $knownDrivers)) {
- throw new \LogicException(sprintf(
- 'To use given scheme "%s" a package has to be installed. Run "composer req %s" to add it.',
- $dsn->getScheme(),
- implode(' ', $driverInfo['packages'])
- ));
+ throw new \LogicException(sprintf('To use given scheme "%s" a package has to be installed. Run "composer req %s" to add it.', $dsn->getScheme(), implode(' ', $driverInfo['packages'])));
}
- throw new \LogicException(sprintf(
- 'A given scheme "%s" is not supported. Maybe it is a custom driver, make sure you registered it with "%s::addDriver".',
- $dsn->getScheme(),
- Resources::class
- ));
+ throw new \LogicException(sprintf('A given scheme "%s" is not supported. Maybe it is a custom driver, make sure you registered it with "%s::addDriver".', $dsn->getScheme(), Resources::class));
}
private function findDriverInfo(Dsn $dsn, array $factories): ?array
@@ -84,7 +76,7 @@ private function findDriverInfo(Dsn $dsn, array $factories): ?array
private function createRabbitMqStompDriver(ConnectionFactory $factory, Dsn $dsn, Config $config, RouteCollection $collection): RabbitMqStompDriver
{
$defaultManagementHost = $dsn->getHost() ?: $config->getTransportOption('host', 'localhost');
- $managementVast = ltrim($dsn->getPath(), '/') ?: $config->getTransportOption('vhost', '/');
+ $managementVast = ltrim($dsn->getPath() ?? '', '/') ?: $config->getTransportOption('vhost', '/');
$managementClient = StompManagementClient::create(
urldecode($managementVast),
diff --git a/pkg/enqueue/Client/DriverInterface.php b/pkg/enqueue/Client/DriverInterface.php
index 1832e0f9a..9d1dde679 100644
--- a/pkg/enqueue/Client/DriverInterface.php
+++ b/pkg/enqueue/Client/DriverInterface.php
@@ -27,7 +27,7 @@ public function createRouteQueue(Route $route): InteropQueue;
* Prepare broker for work.
* Creates all required queues, exchanges, topics, bindings etc.
*/
- public function setupBroker(LoggerInterface $logger = null): void;
+ public function setupBroker(?LoggerInterface $logger = null): void;
public function getConfig(): Config;
diff --git a/pkg/enqueue/Client/Extension/PrepareBodyExtension.php b/pkg/enqueue/Client/Extension/PrepareBodyExtension.php
index eeb0ded03..e7924548c 100644
--- a/pkg/enqueue/Client/Extension/PrepareBodyExtension.php
+++ b/pkg/enqueue/Client/Extension/PrepareBodyExtension.php
@@ -32,10 +32,7 @@ private function prepareBody(Message $message): void
// only array of scalars is allowed.
array_walk_recursive($body, function ($value) {
if (!is_scalar($value) && null !== $value) {
- throw new \LogicException(sprintf(
- 'The message\'s body must be an array of scalars. Found not scalar in the array: %s',
- is_object($value) ? get_class($value) : gettype($value)
- ));
+ throw new \LogicException(sprintf('The message\'s body must be an array of scalars. Found not scalar in the array: %s', is_object($value) ? $value::class : gettype($value)));
}
});
@@ -45,10 +42,7 @@ private function prepareBody(Message $message): void
$contentType = $contentType ?: 'application/json';
$body = JSON::encode($body);
} else {
- throw new \InvalidArgumentException(sprintf(
- 'The message\'s body must be either null, scalar, array or object (implements \JsonSerializable). Got: %s',
- is_object($body) ? get_class($body) : gettype($body)
- ));
+ throw new \InvalidArgumentException(sprintf('The message\'s body must be either null, scalar, array or object (implements \JsonSerializable). Got: %s', is_object($body) ? $body::class : gettype($body)));
}
$message->setContentType($contentType);
diff --git a/pkg/enqueue/Client/Message.php b/pkg/enqueue/Client/Message.php
index b1cc9c27a..7e51ea10d 100644
--- a/pkg/enqueue/Client/Message.php
+++ b/pkg/enqueue/Client/Message.php
@@ -7,12 +7,12 @@ class Message
/**
* @const string
*/
- const SCOPE_MESSAGE_BUS = 'enqueue.scope.message_bus';
+ public const SCOPE_MESSAGE_BUS = 'enqueue.scope.message_bus';
/**
* @const string
*/
- const SCOPE_APP = 'enqueue.scope.app';
+ public const SCOPE_APP = 'enqueue.scope.app';
/**
* @var string|null
@@ -256,10 +256,8 @@ public function getHeaders()
}
/**
- * @param string $name
- * @param mixed $default
- *
- * @return mixed
+ * @param string $name
+ * @param mixed|null $default
*/
public function getHeader($name, $default = null)
{
@@ -268,16 +266,12 @@ public function getHeader($name, $default = null)
/**
* @param string $name
- * @param mixed $value
*/
public function setHeader($name, $value)
{
$this->headers[$name] = $value;
}
- /**
- * @param array $headers
- */
public function setHeaders(array $headers)
{
$this->headers = $headers;
@@ -291,19 +285,14 @@ public function getProperties()
return $this->properties;
}
- /**
- * @param array $properties
- */
public function setProperties(array $properties)
{
$this->properties = $properties;
}
/**
- * @param string $name
- * @param mixed $default
- *
- * @return mixed
+ * @param string $name
+ * @param mixed|null $default
*/
public function getProperty($name, $default = null)
{
@@ -312,7 +301,6 @@ public function getProperty($name, $default = null)
/**
* @param string $name
- * @param mixed $value
*/
public function setProperty($name, $value)
{
diff --git a/pkg/enqueue/Client/MessagePriority.php b/pkg/enqueue/Client/MessagePriority.php
index efa658c14..e14be9a7d 100644
--- a/pkg/enqueue/Client/MessagePriority.php
+++ b/pkg/enqueue/Client/MessagePriority.php
@@ -4,9 +4,9 @@
class MessagePriority
{
- const VERY_LOW = 'enqueue.message_queue.client.very_low_message_priority';
- const LOW = 'enqueue.message_queue.client.low_message_priority';
- const NORMAL = 'enqueue.message_queue.client.normal_message_priority';
- const HIGH = 'enqueue.message_queue.client.high_message_priority';
- const VERY_HIGH = 'enqueue.message_queue.client.very_high_message_priority';
+ public const VERY_LOW = 'enqueue.message_queue.client.very_low_message_priority';
+ public const LOW = 'enqueue.message_queue.client.low_message_priority';
+ public const NORMAL = 'enqueue.message_queue.client.normal_message_priority';
+ public const HIGH = 'enqueue.message_queue.client.high_message_priority';
+ public const VERY_HIGH = 'enqueue.message_queue.client.very_high_message_priority';
}
diff --git a/pkg/enqueue/Client/PostSend.php b/pkg/enqueue/Client/PostSend.php
index 7bce74155..5d9526ea4 100644
--- a/pkg/enqueue/Client/PostSend.php
+++ b/pkg/enqueue/Client/PostSend.php
@@ -22,7 +22,7 @@ public function __construct(
ProducerInterface $producer,
DriverInterface $driver,
Destination $transportDestination,
- TransportMessage $transportMessage
+ TransportMessage $transportMessage,
) {
$this->message = $message;
$this->producer = $producer;
diff --git a/pkg/enqueue/Client/PreSend.php b/pkg/enqueue/Client/PreSend.php
index afd64012f..b60f90b08 100644
--- a/pkg/enqueue/Client/PreSend.php
+++ b/pkg/enqueue/Client/PreSend.php
@@ -18,7 +18,7 @@ public function __construct(
string $commandOrTopic,
Message $message,
ProducerInterface $producer,
- DriverInterface $driver
+ DriverInterface $driver,
) {
$this->message = $message;
$this->commandOrTopic = $commandOrTopic;
@@ -48,7 +48,7 @@ public function changeTopic(string $newTopic): void
$this->commandOrTopic = $newTopic;
}
- public function changeBody($body, string $contentType = null): void
+ public function changeBody($body, ?string $contentType = null): void
{
$this->message->setBody($body);
diff --git a/pkg/enqueue/Client/PreSendCommandExtensionInterface.php b/pkg/enqueue/Client/PreSendCommandExtensionInterface.php
index b2f6c7a5f..cefec097f 100644
--- a/pkg/enqueue/Client/PreSendCommandExtensionInterface.php
+++ b/pkg/enqueue/Client/PreSendCommandExtensionInterface.php
@@ -4,5 +4,8 @@
interface PreSendCommandExtensionInterface
{
+ /**
+ * @throws \Exception
+ */
public function onPreSendCommand(PreSend $context): void;
}
diff --git a/pkg/enqueue/Client/PreSendEventExtensionInterface.php b/pkg/enqueue/Client/PreSendEventExtensionInterface.php
index 1eaaae562..ecb0519c2 100644
--- a/pkg/enqueue/Client/PreSendEventExtensionInterface.php
+++ b/pkg/enqueue/Client/PreSendEventExtensionInterface.php
@@ -4,5 +4,8 @@
interface PreSendEventExtensionInterface
{
+ /**
+ * @throws \Exception
+ */
public function onPreSendEvent(PreSend $context): void;
}
diff --git a/pkg/enqueue/Client/Producer.php b/pkg/enqueue/Client/Producer.php
index 6ea612b8c..db50744a2 100644
--- a/pkg/enqueue/Client/Producer.php
+++ b/pkg/enqueue/Client/Producer.php
@@ -27,7 +27,7 @@ final class Producer implements ProducerInterface
public function __construct(
DriverInterface $driver,
RpcFactory $rpcFactory,
- ExtensionInterface $extension = null
+ ?ExtensionInterface $extension = null,
) {
$this->driver = $driver;
$this->rpcFactory = $rpcFactory;
@@ -97,10 +97,7 @@ public function sendCommand(string $command, $message, bool $needReply = false):
private function doSend(Message $message): void
{
if (false === is_string($message->getBody())) {
- throw new \LogicException(sprintf(
- 'The message body must be string at this stage, got "%s". Make sure you passed string as message or there is an extension that converts custom input to string.',
- is_object($message->getBody()) ? get_class($message->getBody()) : gettype($message->getBody())
- ));
+ throw new \LogicException(sprintf('The message body must be string at this stage, got "%s". Make sure you passed string as message or there is an extension that converts custom input to string.', is_object($message->getBody()) ? get_class($message->getBody()) : gettype($message->getBody())));
}
if ($message->getProperty(Config::PROCESSOR)) {
diff --git a/pkg/enqueue/Client/ProducerInterface.php b/pkg/enqueue/Client/ProducerInterface.php
index 1c7b056cf..3c884808a 100644
--- a/pkg/enqueue/Client/ProducerInterface.php
+++ b/pkg/enqueue/Client/ProducerInterface.php
@@ -10,6 +10,8 @@ interface ProducerInterface
* The message could be pretty much everything as long as you have a client extension that transforms a body to string on onPreSendEvent.
*
* @param string|array|Message $message
+ *
+ * @throws \Exception
*/
public function sendEvent(string $topic, $message): void;
@@ -18,6 +20,8 @@ public function sendEvent(string $topic, $message): void;
* The promise is returned if needReply argument is true.
*
* @param string|array|Message $message
+ *
+ * @throws \Exception
*/
public function sendCommand(string $command, $message, bool $needReply = false): ?Promise;
}
diff --git a/pkg/enqueue/Client/Resources.php b/pkg/enqueue/Client/Resources.php
index 6ea5988a1..a5cc6847c 100644
--- a/pkg/enqueue/Client/Resources.php
+++ b/pkg/enqueue/Client/Resources.php
@@ -26,7 +26,7 @@ final class Resources
*
* @var array
*/
- private static $knownDrivers = null;
+ private static $knownDrivers;
private function __construct()
{
diff --git a/pkg/enqueue/Client/Route.php b/pkg/enqueue/Client/Route.php
index 5c98fa6b8..8b9e31e36 100644
--- a/pkg/enqueue/Client/Route.php
+++ b/pkg/enqueue/Client/Route.php
@@ -4,9 +4,9 @@
final class Route
{
- const TOPIC = 'enqueue.client.topic_route';
+ public const TOPIC = 'enqueue.client.topic_route';
- const COMMAND = 'enqueue.client.command_route';
+ public const COMMAND = 'enqueue.client.command_route';
/**
* @var string
@@ -32,7 +32,7 @@ public function __construct(
string $source,
string $sourceType,
string $processor,
- array $options = []
+ array $options = [],
) {
$this->source = $source;
$this->sourceType = $sourceType;
diff --git a/pkg/enqueue/Client/TraceableProducer.php b/pkg/enqueue/Client/TraceableProducer.php
index 59b0c7b01..b0bd613c3 100644
--- a/pkg/enqueue/Client/TraceableProducer.php
+++ b/pkg/enqueue/Client/TraceableProducer.php
@@ -71,7 +71,7 @@ public function clearTraces(): void
$this->traces = [];
}
- private function collectTrace(string $topic = null, string $command = null, $message): void
+ private function collectTrace(?string $topic, ?string $command, $message): void
{
$trace = [
'topic' => $topic,
diff --git a/pkg/enqueue/ConnectionFactoryFactory.php b/pkg/enqueue/ConnectionFactoryFactory.php
index d89c671e7..d23518c1b 100644
--- a/pkg/enqueue/ConnectionFactoryFactory.php
+++ b/pkg/enqueue/ConnectionFactoryFactory.php
@@ -29,18 +29,10 @@ public function create($config): ConnectionFactory
$knownConnections = Resources::getKnownConnections();
if ($factoryClass = $this->findFactoryClass($dsn, $knownConnections)) {
- throw new \LogicException(sprintf(
- 'To use given scheme "%s" a package has to be installed. Run "composer req %s" to add it.',
- $dsn->getScheme(),
- $knownConnections[$factoryClass]['package']
- ));
+ throw new \LogicException(sprintf('To use given scheme "%s" a package has to be installed. Run "composer req %s" to add it.', $dsn->getScheme(), $knownConnections[$factoryClass]['package']));
}
- throw new \LogicException(sprintf(
- 'A given scheme "%s" is not supported. Maybe it is a custom connection, make sure you registered it with "%s::addConnection".',
- $dsn->getScheme(),
- Resources::class
- ));
+ throw new \LogicException(sprintf('A given scheme "%s" is not supported. Maybe it is a custom connection, make sure you registered it with "%s::addConnection".', $dsn->getScheme(), Resources::class));
}
private function findFactoryClass(Dsn $dsn, array $factories): ?string
diff --git a/pkg/enqueue/ConnectionFactoryFactoryInterface.php b/pkg/enqueue/ConnectionFactoryFactoryInterface.php
index d55808cdb..f4ca4a6d3 100644
--- a/pkg/enqueue/ConnectionFactoryFactoryInterface.php
+++ b/pkg/enqueue/ConnectionFactoryFactoryInterface.php
@@ -13,7 +13,6 @@ interface ConnectionFactoryFactoryInterface
* The other array options are treated as default values.
* Options from DSN overwrite them.
*
- *
* @param string|array $config
*
* @throws \InvalidArgumentException if invalid config provided
diff --git a/pkg/enqueue/Consumption/CallbackProcessor.php b/pkg/enqueue/Consumption/CallbackProcessor.php
index 988b76529..d15978fcb 100644
--- a/pkg/enqueue/Consumption/CallbackProcessor.php
+++ b/pkg/enqueue/Consumption/CallbackProcessor.php
@@ -13,17 +13,11 @@ class CallbackProcessor implements Processor
*/
private $callback;
- /**
- * @param callable $callback
- */
public function __construct(callable $callback)
{
$this->callback = $callback;
}
- /**
- * {@inheritdoc}
- */
public function process(InteropMessage $message, Context $context)
{
return call_user_func($this->callback, $message, $context);
diff --git a/pkg/enqueue/Consumption/ChainExtension.php b/pkg/enqueue/Consumption/ChainExtension.php
index e2c11a1f6..83b4eba3a 100644
--- a/pkg/enqueue/Consumption/ChainExtension.php
+++ b/pkg/enqueue/Consumption/ChainExtension.php
@@ -117,7 +117,7 @@ public function __construct(array $extensions)
}
if (false == $extensionValid) {
- throw new \LogicException(sprintf('Invalid extension given %s', get_class($extension)));
+ throw new \LogicException(sprintf('Invalid extension given %s', $extension::class));
}
});
}
diff --git a/pkg/enqueue/Consumption/Context/End.php b/pkg/enqueue/Consumption/Context/End.php
index ec8c1f7df..07853b3d3 100644
--- a/pkg/enqueue/Consumption/Context/End.php
+++ b/pkg/enqueue/Consumption/Context/End.php
@@ -37,7 +37,7 @@ public function __construct(
int $startTime,
int $endTime,
LoggerInterface $logger,
- ?int $exitStatus = null
+ ?int $exitStatus = null,
) {
$this->context = $context;
$this->logger = $logger;
diff --git a/pkg/enqueue/Consumption/Context/MessageReceived.php b/pkg/enqueue/Consumption/Context/MessageReceived.php
index ad6b6b969..35abf1ca8 100644
--- a/pkg/enqueue/Consumption/Context/MessageReceived.php
+++ b/pkg/enqueue/Consumption/Context/MessageReceived.php
@@ -52,7 +52,7 @@ public function __construct(
Message $message,
Processor $processor,
int $receivedAt,
- LoggerInterface $logger
+ LoggerInterface $logger,
) {
$this->context = $context;
$this->consumer = $consumer;
diff --git a/pkg/enqueue/Consumption/Context/PostMessageReceived.php b/pkg/enqueue/Consumption/Context/PostMessageReceived.php
index 91b532656..23df2c849 100644
--- a/pkg/enqueue/Consumption/Context/PostMessageReceived.php
+++ b/pkg/enqueue/Consumption/Context/PostMessageReceived.php
@@ -56,7 +56,7 @@ public function __construct(
Message $message,
$result,
int $receivedAt,
- LoggerInterface $logger
+ LoggerInterface $logger,
) {
$this->context = $context;
$this->consumer = $consumer;
diff --git a/pkg/enqueue/Consumption/Context/ProcessorException.php b/pkg/enqueue/Consumption/Context/ProcessorException.php
index f41f23271..329b13d93 100644
--- a/pkg/enqueue/Consumption/Context/ProcessorException.php
+++ b/pkg/enqueue/Consumption/Context/ProcessorException.php
@@ -26,7 +26,7 @@ final class ProcessorException
private $message;
/**
- * @var \Exception
+ * @var \Throwable
*/
private $exception;
@@ -44,7 +44,7 @@ final class ProcessorException
*/
private $logger;
- public function __construct(Context $context, Consumer $consumer, Message $message, \Exception $exception, int $receivedAt, LoggerInterface $logger)
+ public function __construct(Context $context, Consumer $consumer, Message $message, \Throwable $exception, int $receivedAt, LoggerInterface $logger)
{
$this->context = $context;
$this->consumer = $consumer;
@@ -69,7 +69,7 @@ public function getMessage(): Message
return $this->message;
}
- public function getException(): \Exception
+ public function getException(): \Throwable
{
return $this->exception;
}
diff --git a/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php b/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php
index da6015d27..89a2f4ca7 100644
--- a/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php
+++ b/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php
@@ -5,7 +5,6 @@
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
/**
- * @param mixed $argument
* @param string $class
*
* @throws static
@@ -13,11 +12,7 @@ class InvalidArgumentException extends \InvalidArgumentException implements Exce
public static function assertInstanceOf($argument, $class)
{
if (false == $argument instanceof $class) {
- throw new static(sprintf(
- 'The argument must be an instance of %s but got %s.',
- $class,
- is_object($argument) ? get_class($argument) : gettype($argument)
- ));
+ throw new self(sprintf('The argument must be an instance of %s but got %s.', $class, is_object($argument) ? $argument::class : gettype($argument)));
}
}
}
diff --git a/pkg/enqueue/Consumption/Extension/LimitConsumedMessagesExtension.php b/pkg/enqueue/Consumption/Extension/LimitConsumedMessagesExtension.php
index e89957a72..0dc6feceb 100644
--- a/pkg/enqueue/Consumption/Extension/LimitConsumedMessagesExtension.php
+++ b/pkg/enqueue/Consumption/Extension/LimitConsumedMessagesExtension.php
@@ -20,9 +20,6 @@ class LimitConsumedMessagesExtension implements PreConsumeExtensionInterface, Po
*/
protected $messageConsumed;
- /**
- * @param int $messageLimit
- */
public function __construct(int $messageLimit)
{
$this->messageLimit = $messageLimit;
diff --git a/pkg/enqueue/Consumption/Extension/LimitConsumerMemoryExtension.php b/pkg/enqueue/Consumption/Extension/LimitConsumerMemoryExtension.php
index 13d4a2898..7edbf232c 100644
--- a/pkg/enqueue/Consumption/Extension/LimitConsumerMemoryExtension.php
+++ b/pkg/enqueue/Consumption/Extension/LimitConsumerMemoryExtension.php
@@ -23,10 +23,7 @@ class LimitConsumerMemoryExtension implements PreConsumeExtensionInterface, Post
public function __construct($memoryLimit)
{
if (false == is_int($memoryLimit)) {
- throw new \InvalidArgumentException(sprintf(
- 'Expected memory limit is int but got: "%s"',
- is_object($memoryLimit) ? get_class($memoryLimit) : gettype($memoryLimit)
- ));
+ throw new \InvalidArgumentException(sprintf('Expected memory limit is int but got: "%s"', is_object($memoryLimit) ? $memoryLimit::class : gettype($memoryLimit)));
}
$this->memoryLimit = $memoryLimit * 1024 * 1024;
diff --git a/pkg/enqueue/Consumption/Extension/LimitConsumptionTimeExtension.php b/pkg/enqueue/Consumption/Extension/LimitConsumptionTimeExtension.php
index f0a577930..1953aa2e6 100644
--- a/pkg/enqueue/Consumption/Extension/LimitConsumptionTimeExtension.php
+++ b/pkg/enqueue/Consumption/Extension/LimitConsumptionTimeExtension.php
@@ -17,9 +17,6 @@ class LimitConsumptionTimeExtension implements PreConsumeExtensionInterface, Pos
*/
protected $timeLimit;
- /**
- * @param \DateTime $timeLimit
- */
public function __construct(\DateTime $timeLimit)
{
$this->timeLimit = $timeLimit;
@@ -53,8 +50,8 @@ protected function shouldBeStopped(LoggerInterface $logger): bool
$logger->debug(sprintf(
'[LimitConsumptionTimeExtension] Execution interrupted as limit time has passed.'.
' now: "%s", time-limit: "%s"',
- $now->format(DATE_ISO8601),
- $this->timeLimit->format(DATE_ISO8601)
+ $now->format(\DATE_ISO8601),
+ $this->timeLimit->format(\DATE_ISO8601)
));
return true;
diff --git a/pkg/enqueue/Consumption/Extension/LoggerExtension.php b/pkg/enqueue/Consumption/Extension/LoggerExtension.php
index 0de2739c1..90e92be8a 100644
--- a/pkg/enqueue/Consumption/Extension/LoggerExtension.php
+++ b/pkg/enqueue/Consumption/Extension/LoggerExtension.php
@@ -13,9 +13,6 @@ class LoggerExtension implements InitLoggerExtensionInterface
*/
private $logger;
- /**
- * @param LoggerInterface $logger
- */
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
@@ -28,7 +25,7 @@ public function onInitLogger(InitLogger $context): void
if ($previousLogger !== $this->logger) {
$context->changeLogger($this->logger);
- $this->logger->debug(sprintf('Change logger from "%s" to "%s"', get_class($previousLogger), get_class($this->logger)));
+ $this->logger->debug(sprintf('Change logger from "%s" to "%s"', $previousLogger::class, get_class($this->logger)));
}
}
}
diff --git a/pkg/enqueue/Consumption/Extension/NicenessExtension.php b/pkg/enqueue/Consumption/Extension/NicenessExtension.php
index 983e04b0e..436a8ec0f 100644
--- a/pkg/enqueue/Consumption/Extension/NicenessExtension.php
+++ b/pkg/enqueue/Consumption/Extension/NicenessExtension.php
@@ -20,10 +20,7 @@ class NicenessExtension implements StartExtensionInterface
public function __construct($niceness)
{
if (false === is_int($niceness)) {
- throw new \InvalidArgumentException(sprintf(
- 'Expected niceness value is int but got: "%s"',
- is_object($niceness) ? get_class($niceness) : gettype($niceness)
- ));
+ throw new \InvalidArgumentException(sprintf('Expected niceness value is int but got: "%s"', is_object($niceness) ? $niceness::class : gettype($niceness)));
}
$this->niceness = $niceness;
@@ -34,10 +31,7 @@ public function onStart(Start $context): void
if (0 !== $this->niceness) {
$changed = @proc_nice($this->niceness);
if (!$changed) {
- throw new \InvalidArgumentException(sprintf(
- 'Cannot change process niceness, got warning: "%s"',
- error_get_last()['message']
- ));
+ throw new \InvalidArgumentException(sprintf('Cannot change process niceness, got warning: "%s"', error_get_last()['message']));
}
}
}
diff --git a/pkg/enqueue/Consumption/Extension/SignalExtension.php b/pkg/enqueue/Consumption/Extension/SignalExtension.php
index 67354b99d..8ea5307d5 100644
--- a/pkg/enqueue/Consumption/Extension/SignalExtension.php
+++ b/pkg/enqueue/Consumption/Extension/SignalExtension.php
@@ -33,9 +33,9 @@ public function onStart(Start $context): void
pcntl_async_signals(true);
- pcntl_signal(SIGTERM, [$this, 'handleSignal']);
- pcntl_signal(SIGQUIT, [$this, 'handleSignal']);
- pcntl_signal(SIGINT, [$this, 'handleSignal']);
+ pcntl_signal(\SIGTERM, [$this, 'handleSignal']);
+ pcntl_signal(\SIGQUIT, [$this, 'handleSignal']);
+ pcntl_signal(\SIGINT, [$this, 'handleSignal']);
$this->logger = $context->getLogger();
$this->interruptConsumption = false;
@@ -71,9 +71,9 @@ public function handleSignal(int $signal): void
}
switch ($signal) {
- case SIGTERM: // 15 : supervisor default stop
- case SIGQUIT: // 3 : kill -s QUIT
- case SIGINT: // 2 : ctrl+c
+ case \SIGTERM: // 15 : supervisor default stop
+ case \SIGQUIT: // 3 : kill -s QUIT
+ case \SIGINT: // 2 : ctrl+c
if ($this->logger) {
$this->logger->debug('[SignalExtension] Interrupt consumption');
}
diff --git a/pkg/enqueue/Consumption/QueueConsumer.php b/pkg/enqueue/Consumption/QueueConsumer.php
index 6cb90290e..f43f5c41b 100644
--- a/pkg/enqueue/Consumption/QueueConsumer.php
+++ b/pkg/enqueue/Consumption/QueueConsumer.php
@@ -63,10 +63,10 @@ final class QueueConsumer implements QueueConsumerInterface
*/
public function __construct(
InteropContext $interopContext,
- ExtensionInterface $extension = null,
+ ?ExtensionInterface $extension = null,
array $boundProcessors = [],
- LoggerInterface $logger = null,
- int $receiveTimeout = 10000
+ ?LoggerInterface $logger = null,
+ int $receiveTimeout = 10000,
) {
$this->interopContext = $interopContext;
$this->receiveTimeout = $receiveTimeout;
@@ -122,7 +122,7 @@ public function bindCallback($queue, callable $processor): QueueConsumerInterfac
return $this->bind($queue, new CallbackProcessor($processor));
}
- public function consume(ExtensionInterface $runtimeExtension = null): void
+ public function consume(?ExtensionInterface $runtimeExtension = null): void
{
$extension = $runtimeExtension ?
new ChainExtension([$this->staticExtension, $runtimeExtension]) :
@@ -195,7 +195,7 @@ public function consume(ExtensionInterface $runtimeExtension = null): void
if (null === $result) {
try {
$result = $processor->process($message, $this->interopContext);
- } catch (\Exception $e) {
+ } catch (\Exception|\Throwable $e) {
$result = $this->onProcessorException($extension, $consumer, $message, $e, $receivedAt);
}
}
@@ -278,15 +278,13 @@ public function consume(ExtensionInterface $runtimeExtension = null): void
/**
* @internal
- *
- * @param SubscriptionConsumer $fallbackSubscriptionConsumer
*/
public function setFallbackSubscriptionConsumer(SubscriptionConsumer $fallbackSubscriptionConsumer): void
{
$this->fallbackSubscriptionConsumer = $fallbackSubscriptionConsumer;
}
- private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exitStatus = null, SubscriptionConsumer $subscriptionConsumer = null): void
+ private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exitStatus = null, ?SubscriptionConsumer $subscriptionConsumer = null): void
{
$endTime = (int) (microtime(true) * 1000);
@@ -303,7 +301,7 @@ private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exit
*
* https://github.com/symfony/symfony/blob/cbe289517470eeea27162fd2d523eb29c95f775f/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php#L77
*/
- private function onProcessorException(ExtensionInterface $extension, Consumer $consumer, Message $message, \Exception $exception, int $receivedAt)
+ private function onProcessorException(ExtensionInterface $extension, Consumer $consumer, Message $message, \Throwable $exception, int $receivedAt)
{
$processorException = new ProcessorException($this->interopContext, $consumer, $message, $exception, $receivedAt, $this->logger);
diff --git a/pkg/enqueue/Consumption/QueueConsumerInterface.php b/pkg/enqueue/Consumption/QueueConsumerInterface.php
index 430aa8786..ee2565252 100644
--- a/pkg/enqueue/Consumption/QueueConsumerInterface.php
+++ b/pkg/enqueue/Consumption/QueueConsumerInterface.php
@@ -34,9 +34,7 @@ public function bindCallback($queueName, callable $processor): self;
* Runtime extension - is an extension or a collection of extensions which could be set on runtime.
* Here's a good example: @see LimitsExtensionsCommandTrait.
*
- * @param ExtensionInterface|null $runtimeExtension
- *
* @throws \Exception
*/
- public function consume(ExtensionInterface $runtimeExtension = null): void;
+ public function consume(?ExtensionInterface $runtimeExtension = null): void;
}
diff --git a/pkg/enqueue/Consumption/Result.php b/pkg/enqueue/Consumption/Result.php
index c5659bc92..69dd7907b 100644
--- a/pkg/enqueue/Consumption/Result.php
+++ b/pkg/enqueue/Consumption/Result.php
@@ -10,19 +10,19 @@ class Result
/**
* @see Processor::ACK for more details
*/
- const ACK = Processor::ACK;
+ public const ACK = Processor::ACK;
/**
* @see Processor::REJECT for more details
*/
- const REJECT = Processor::REJECT;
+ public const REJECT = Processor::REJECT;
/**
* @see Processor::REQUEUE for more details
*/
- const REQUEUE = Processor::REQUEUE;
+ public const REQUEUE = Processor::REQUEUE;
- const ALREADY_ACKNOWLEDGED = 'enqueue.already_acknowledged';
+ public const ALREADY_ACKNOWLEDGED = 'enqueue.already_acknowledged';
/**
* @var string
@@ -39,10 +39,6 @@ class Result
*/
private $reply;
- /**
- * @param mixed $status
- * @param mixed $reason
- */
public function __construct($status, $reason = '')
{
$this->status = (string) $status;
@@ -81,10 +77,7 @@ public function getReply()
return $this->reply;
}
- /**
- * @param InteropMessage|null $reply
- */
- public function setReply(InteropMessage $reply = null)
+ public function setReply(?InteropMessage $reply = null)
{
$this->reply = $reply;
}
@@ -96,7 +89,7 @@ public function setReply(InteropMessage $reply = null)
*/
public static function ack($reason = '')
{
- return new static(self::ACK, $reason);
+ return new self(self::ACK, $reason);
}
/**
@@ -106,7 +99,7 @@ public static function ack($reason = '')
*/
public static function reject($reason)
{
- return new static(self::REJECT, $reason);
+ return new self(self::REJECT, $reason);
}
/**
@@ -116,13 +109,12 @@ public static function reject($reason)
*/
public static function requeue($reason = '')
{
- return new static(self::REQUEUE, $reason);
+ return new self(self::REQUEUE, $reason);
}
/**
- * @param InteropMessage $replyMessage
- * @param string $status
- * @param string|null $reason
+ * @param string $status
+ * @param string|null $reason
*
* @return static
*/
@@ -130,7 +122,7 @@ public static function reply(InteropMessage $replyMessage, $status = self::ACK,
{
$status = null === $status ? self::ACK : $status;
- $result = new static($status, $reason);
+ $result = new self($status, $reason);
$result->setReply($replyMessage);
return $result;
diff --git a/pkg/enqueue/Container/Container.php b/pkg/enqueue/Container/Container.php
index 255def33b..5abec276c 100644
--- a/pkg/enqueue/Container/Container.php
+++ b/pkg/enqueue/Container/Container.php
@@ -25,7 +25,7 @@ public function get($id)
return $this->services[$id];
}
- public function has($id)
+ public function has(string $id): bool
{
return array_key_exists($id, $this->services);
}
diff --git a/pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php b/pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php
index 25016a761..0eb378470 100644
--- a/pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php
+++ b/pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php
@@ -11,7 +11,7 @@
class DoctrineSchemaCompilerPass implements CompilerPassInterface
{
- public function process(ContainerBuilder $container)
+ public function process(ContainerBuilder $container): void
{
if (false === $container->hasDefinition('doctrine')) {
return;
diff --git a/pkg/enqueue/README.md b/pkg/enqueue/README.md
index 2e5aa5a00..9e1dd50c3 100644
--- a/pkg/enqueue/README.md
+++ b/pkg/enqueue/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Message Queue.
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/enqueue)
+[](https://github.com/php-enqueue/enqueue/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/enqueue)
[](https://packagist.org/packages/enqueue/enqueue)
diff --git a/pkg/enqueue/Resources.php b/pkg/enqueue/Resources.php
index 75884bab6..4c500006f 100644
--- a/pkg/enqueue/Resources.php
+++ b/pkg/enqueue/Resources.php
@@ -14,6 +14,7 @@
use Enqueue\Pheanstalk\PheanstalkConnectionFactory;
use Enqueue\RdKafka\RdKafkaConnectionFactory;
use Enqueue\Redis\RedisConnectionFactory;
+use Enqueue\Sns\SnsConnectionFactory;
use Enqueue\SnsQs\SnsQsConnectionFactory;
use Enqueue\Sqs\SqsConnectionFactory;
use Enqueue\Stomp\StompConnectionFactory;
@@ -30,7 +31,7 @@ final class Resources
*
* @var array
*/
- private static $knownConnections = null;
+ private static $knownConnections;
private function __construct()
{
@@ -42,7 +43,7 @@ public static function getAvailableConnections(): array
$availableMap = [];
foreach ($map as $connectionClass => $item) {
- if (class_exists($connectionClass)) {
+ if (\class_exists($connectionClass)) {
$availableMap[$connectionClass] = $item;
}
}
@@ -156,6 +157,10 @@ public static function getKnownConnections(): array
'schemes' => ['sqs'],
'supportedSchemeExtensions' => [],
'package' => 'enqueue/sqs', ];
+ $map[SnsConnectionFactory::class] = [
+ 'schemes' => ['sns'],
+ 'supportedSchemeExtensions' => [],
+ 'package' => 'enqueue/sns', ];
$map[SnsQsConnectionFactory::class] = [
'schemes' => ['snsqs'],
'supportedSchemeExtensions' => [],
@@ -183,9 +188,9 @@ public static function getKnownConnections(): array
public static function addConnection(string $connectionFactoryClass, array $schemes, array $extensions, string $package): void
{
- if (class_exists($connectionFactoryClass)) {
+ if (\class_exists($connectionFactoryClass)) {
if (false == (new \ReflectionClass($connectionFactoryClass))->implementsInterface(ConnectionFactory::class)) {
- throw new \InvalidArgumentException(sprintf('The connection factory class "%s" must implement "%s" interface.', $connectionFactoryClass, ConnectionFactory::class));
+ throw new \InvalidArgumentException(\sprintf('The connection factory class "%s" must implement "%s" interface.', $connectionFactoryClass, ConnectionFactory::class));
}
}
diff --git a/pkg/enqueue/Router/Recipient.php b/pkg/enqueue/Router/Recipient.php
index c7eac6af6..d2f668f42 100644
--- a/pkg/enqueue/Router/Recipient.php
+++ b/pkg/enqueue/Router/Recipient.php
@@ -17,10 +17,6 @@ class Recipient
*/
private $message;
- /**
- * @param Destination $destination
- * @param InteropMessage $message
- */
public function __construct(Destination $destination, InteropMessage $message)
{
$this->destination = $destination;
diff --git a/pkg/enqueue/Router/RecipientListRouterInterface.php b/pkg/enqueue/Router/RecipientListRouterInterface.php
index d00dd2abb..6bb950fdc 100644
--- a/pkg/enqueue/Router/RecipientListRouterInterface.php
+++ b/pkg/enqueue/Router/RecipientListRouterInterface.php
@@ -7,8 +7,6 @@
interface RecipientListRouterInterface
{
/**
- * @param InteropMessage $message
- *
* @return \Traversable|Recipient[]
*/
public function route(InteropMessage $message);
diff --git a/pkg/enqueue/Router/RouteRecipientListProcessor.php b/pkg/enqueue/Router/RouteRecipientListProcessor.php
index 22e32e2ca..22488e33f 100644
--- a/pkg/enqueue/Router/RouteRecipientListProcessor.php
+++ b/pkg/enqueue/Router/RouteRecipientListProcessor.php
@@ -13,17 +13,11 @@ class RouteRecipientListProcessor implements Processor
*/
private $router;
- /**
- * @param RecipientListRouterInterface $router
- */
public function __construct(RecipientListRouterInterface $router)
{
$this->router = $router;
}
- /**
- * {@inheritdoc}
- */
public function process(InteropMessage $message, Context $context)
{
$producer = $context->createProducer();
diff --git a/pkg/enqueue/Rpc/Promise.php b/pkg/enqueue/Rpc/Promise.php
index 0a5d28f0c..01b47e1f6 100644
--- a/pkg/enqueue/Rpc/Promise.php
+++ b/pkg/enqueue/Rpc/Promise.php
@@ -31,11 +31,6 @@ class Promise
*/
private $message;
- /**
- * @param \Closure $receiveCallback
- * @param \Closure $receiveNoWaitCallback
- * @param \Closure $finallyCallback
- */
public function __construct(\Closure $receiveCallback, \Closure $receiveNoWaitCallback, \Closure $finallyCallback)
{
$this->receiveCallback = $receiveCallback;
@@ -106,8 +101,7 @@ public function isDeleteReplyQueue()
}
/**
- * @param \Closure $cb
- * @param array $args
+ * @param array $args
*
* @return InteropMessage
*/
@@ -116,8 +110,7 @@ private function doReceive(\Closure $cb, ...$args)
$message = call_user_func_array($cb, $args);
if (null !== $message && false == $message instanceof InteropMessage) {
- throw new \RuntimeException(sprintf(
- 'Expected "%s" but got: "%s"', InteropMessage::class, is_object($message) ? get_class($message) : gettype($message)));
+ throw new \RuntimeException(sprintf('Expected "%s" but got: "%s"', InteropMessage::class, is_object($message) ? $message::class : gettype($message)));
}
return $message;
diff --git a/pkg/enqueue/Rpc/RpcClient.php b/pkg/enqueue/Rpc/RpcClient.php
index 591a4cc19..bd3d7cedb 100644
--- a/pkg/enqueue/Rpc/RpcClient.php
+++ b/pkg/enqueue/Rpc/RpcClient.php
@@ -19,20 +19,14 @@ class RpcClient
*/
private $rpcFactory;
- /**
- * @param Context $context
- * @param RpcFactory $promiseFactory
- */
- public function __construct(Context $context, RpcFactory $promiseFactory = null)
+ public function __construct(Context $context, ?RpcFactory $promiseFactory = null)
{
$this->context = $context;
$this->rpcFactory = $promiseFactory ?: new RpcFactory($context);
}
/**
- * @param Destination $destination
- * @param InteropMessage $message
- * @param int $timeout
+ * @param int $timeout
*
* @throws TimeoutException if the wait timeout is reached
*
@@ -44,9 +38,7 @@ public function call(Destination $destination, InteropMessage $message, $timeout
}
/**
- * @param Destination $destination
- * @param InteropMessage $message
- * @param int $timeout
+ * @param int $timeout
*
* @return Promise
*/
diff --git a/pkg/enqueue/Rpc/RpcFactory.php b/pkg/enqueue/Rpc/RpcFactory.php
index bd054b186..9100babd3 100644
--- a/pkg/enqueue/Rpc/RpcFactory.php
+++ b/pkg/enqueue/Rpc/RpcFactory.php
@@ -11,9 +11,6 @@ class RpcFactory
*/
private $context;
- /**
- * @param Context $context
- */
public function __construct(Context $context)
{
$this->context = $context;
diff --git a/pkg/enqueue/Rpc/TimeoutException.php b/pkg/enqueue/Rpc/TimeoutException.php
index a0b065511..a7f68b967 100644
--- a/pkg/enqueue/Rpc/TimeoutException.php
+++ b/pkg/enqueue/Rpc/TimeoutException.php
@@ -12,6 +12,6 @@ class TimeoutException extends \LogicException
*/
public static function create($timeout, $correlationId)
{
- return new static(sprintf('Rpc call timeout is reached without receiving a reply message. Timeout: %s, CorrelationId: %s', $timeout, $correlationId));
+ return new self(sprintf('Rpc call timeout is reached without receiving a reply message. Timeout: %s, CorrelationId: %s', $timeout, $correlationId));
}
}
diff --git a/pkg/enqueue/Symfony/Client/ConsumeCommand.php b/pkg/enqueue/Symfony/Client/ConsumeCommand.php
index 4b65f6276..94b56ad10 100644
--- a/pkg/enqueue/Symfony/Client/ConsumeCommand.php
+++ b/pkg/enqueue/Symfony/Client/ConsumeCommand.php
@@ -13,20 +13,20 @@
use Interop\Queue\Processor;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+#[AsCommand('enqueue:consume')]
class ConsumeCommand extends Command
{
+ use ChooseLoggerCommandTrait;
use LimitsExtensionsCommandTrait;
- use SetupBrokerExtensionCommandTrait;
use QueueConsumerOptionsCommandTrait;
- use ChooseLoggerCommandTrait;
-
- protected static $defaultName = 'enqueue:consume';
+ use SetupBrokerExtensionCommandTrait;
/**
* @var ContainerInterface
@@ -58,7 +58,7 @@ public function __construct(
string $defaultClient,
string $queueConsumerIdPattern = 'enqueue.client.%s.queue_consumer',
string $driverIdPattern = 'enqueue.client.%s.driver',
- string $processorIdPatter = 'enqueue.client.%s.delegate_processor'
+ string $processorIdPatter = 'enqueue.client.%s.delegate_processor',
) {
$this->container = $container;
$this->defaultClient = $defaultClient;
@@ -66,7 +66,7 @@ public function __construct(
$this->driverIdPattern = $driverIdPattern;
$this->processorIdPattern = $processorIdPatter;
- parent::__construct(self::$defaultName);
+ parent::__construct();
}
protected function configure(): void
@@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$consumer = $this->getQueueConsumer($client);
} catch (NotFoundExceptionInterface $e) {
- throw new \LogicException(sprintf('Client "%s" is not supported.', $client), null, $e);
+ throw new \LogicException(sprintf('Client "%s" is not supported.', $client), previous: $e);
}
$driver = $this->getDriver($client);
diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php
index c541f4179..577f15902 100644
--- a/pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php
+++ b/pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php
@@ -38,11 +38,7 @@ private function exclusiveCommandsCouldNotBeRunOnDefaultQueue(RouteCollection $c
{
foreach ($collection->all() as $route) {
if ($route->isCommand() && $route->isProcessorExclusive() && false == $route->getQueue()) {
- throw new \LogicException(sprintf(
- 'The command "%s" processor "%s" is exclusive but queue is not specified. Exclusive processors could not be run on a default queue.',
- $route->getSource(),
- $route->getProcessor()
- ));
+ throw new \LogicException(sprintf('The command "%s" processor "%s" is exclusive but queue is not specified. Exclusive processors could not be run on a default queue.', $route->getSource(), $route->getProcessor()));
}
}
}
@@ -61,25 +57,13 @@ private function exclusiveCommandProcessorMustBeSingleOnGivenQueue(RouteCollecti
if ($route->isPrefixQueue()) {
if (array_key_exists($route->getQueue(), $prefixedQueues)) {
- throw new \LogicException(sprintf(
- 'The command "%s" processor "%s" is exclusive. The queue "%s" already has another exclusive command processor "%s" bound to it.',
- $route->getSource(),
- $route->getProcessor(),
- $route->getQueue(),
- $prefixedQueues[$route->getQueue()]
- ));
+ throw new \LogicException(sprintf('The command "%s" processor "%s" is exclusive. The queue "%s" already has another exclusive command processor "%s" bound to it.', $route->getSource(), $route->getProcessor(), $route->getQueue(), $prefixedQueues[$route->getQueue()]));
}
$prefixedQueues[$route->getQueue()] = $route->getProcessor();
} else {
if (array_key_exists($route->getQueue(), $queues)) {
- throw new \LogicException(sprintf(
- 'The command "%s" processor "%s" is exclusive. The queue "%s" already has another exclusive command processor "%s" bound to it.',
- $route->getSource(),
- $route->getProcessor(),
- $route->getQueue(),
- $queues[$route->getQueue()]
- ));
+ throw new \LogicException(sprintf('The command "%s" processor "%s" is exclusive. The queue "%s" already has another exclusive command processor "%s" bound to it.', $route->getSource(), $route->getProcessor(), $route->getQueue(), $queues[$route->getQueue()]));
}
$queues[$route->getQueue()] = $route->getProcessor();
@@ -102,7 +86,7 @@ private function customQueueNamesUnique(RouteCollection $collection): void
$notPrefixedQueues = [];
foreach ($collection->all() as $route) {
- //default queue
+ // default queue
$queueName = $route->getQueue();
if (false == $queueName) {
return;
diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php
index 5ad45fd90..92124f243 100644
--- a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php
+++ b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php
@@ -46,7 +46,7 @@ public function process(ContainerBuilder $container): void
}
}
- krsort($groupByPriority, SORT_NUMERIC);
+ krsort($groupByPriority, \SORT_NUMERIC);
$flatExtensions = [];
foreach ($groupByPriority as $extension) {
diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php
index 5eee3efdb..4adc09e9d 100644
--- a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php
+++ b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php
@@ -68,7 +68,7 @@ public function process(ContainerBuilder $container): void
// 0.8 command subscriber
if (isset($commands['processorName'])) {
- @trigger_error('The command subscriber 0.8 syntax is deprecated since Enqueue 0.9.', E_USER_DEPRECATED);
+ @trigger_error('The command subscriber 0.8 syntax is deprecated since Enqueue 0.9.', \E_USER_DEPRECATED);
$source = $commands['processorName'];
$processor = $params['processorName'] ?? $serviceId;
@@ -117,11 +117,7 @@ public function process(ContainerBuilder $container): void
$routeCollection->add(new Route($source, Route::COMMAND, $processor, $options));
} else {
- throw new \LogicException(sprintf(
- 'Command subscriber configuration is invalid for "%s::getSubscribedCommand()". "%s"',
- $processorClass,
- json_encode($processorClass::getSubscribedCommand())
- ));
+ throw new \LogicException(sprintf('Command subscriber configuration is invalid for "%s::getSubscribedCommand()". "%s"', $processorClass, json_encode($processorClass::getSubscribedCommand())));
}
}
}
diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php
index c1f1ce970..274847c90 100644
--- a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php
+++ b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php
@@ -46,7 +46,7 @@ public function process(ContainerBuilder $container): void
}
}
- krsort($groupByPriority, SORT_NUMERIC);
+ krsort($groupByPriority, \SORT_NUMERIC);
$flatExtensions = [];
foreach ($groupByPriority as $extension) {
diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPass.php
index 4999921cc..ef01e6fcf 100644
--- a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPass.php
+++ b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPass.php
@@ -72,7 +72,7 @@ public function process(ContainerBuilder $container): void
// 0.8 topic subscriber
} elseif (is_array($params) && is_string($key)) {
- @trigger_error('The topic subscriber 0.8 syntax is deprecated since Enqueue 0.9.', E_USER_DEPRECATED);
+ @trigger_error('The topic subscriber 0.8 syntax is deprecated since Enqueue 0.9.', \E_USER_DEPRECATED);
$source = $key;
$processor = $params['processorName'] ?? $serviceId;
@@ -109,11 +109,7 @@ public function process(ContainerBuilder $container): void
$routeCollection->add(new Route($source, Route::TOPIC, $processor, $options));
} else {
- throw new \LogicException(sprintf(
- 'Topic subscriber configuration is invalid for "%s::getSubscribedTopics()". Got "%s"',
- $processorClass,
- json_encode($processorClass::getSubscribedTopics())
- ));
+ throw new \LogicException(sprintf('Topic subscriber configuration is invalid for "%s::getSubscribedTopics()". Got "%s"', $processorClass, json_encode($processorClass::getSubscribedTopics())));
}
}
}
diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/ClientFactory.php b/pkg/enqueue/Symfony/Client/DependencyInjection/ClientFactory.php
index 2eede31b7..be020dcff 100644
--- a/pkg/enqueue/Symfony/Client/DependencyInjection/ClientFactory.php
+++ b/pkg/enqueue/Symfony/Client/DependencyInjection/ClientFactory.php
@@ -74,12 +74,8 @@ public static function getConfiguration(bool $debug, string $name = 'client'): N
->scalarNode('router_processor')->defaultNull()->end()
->integerNode('redelivered_delay_time')->min(0)->defaultValue(0)->end()
->scalarNode('default_queue')->defaultValue('default')->cannotBeEmpty()->end()
- ->arrayNode('driver_options')
- ->addDefaultsIfNotSet()
- ->info('The array contains driver specific options')
- ->ignoreExtraKeys(false)
+ ->arrayNode('driver_options')->addDefaultsIfNotSet()->info('The array contains driver specific options')->ignoreExtraKeys(false)->end()
->end()
- ->end()->end()
;
return $builder;
diff --git a/pkg/enqueue/Symfony/Client/FlushSpoolProducerListener.php b/pkg/enqueue/Symfony/Client/FlushSpoolProducerListener.php
index 1f5fdcba7..00543f6de 100644
--- a/pkg/enqueue/Symfony/Client/FlushSpoolProducerListener.php
+++ b/pkg/enqueue/Symfony/Client/FlushSpoolProducerListener.php
@@ -14,9 +14,6 @@ class FlushSpoolProducerListener implements EventSubscriberInterface
*/
private $producer;
- /**
- * @param SpoolProducer $producer
- */
public function __construct(SpoolProducer $producer)
{
$this->producer = $producer;
@@ -27,10 +24,7 @@ public function flushMessages()
$this->producer->flush();
}
- /**
- * {@inheritdoc}
- */
- public static function getSubscribedEvents()
+ public static function getSubscribedEvents(): array
{
$events = [];
diff --git a/pkg/enqueue/Symfony/Client/ProduceCommand.php b/pkg/enqueue/Symfony/Client/ProduceCommand.php
index 667871c71..953a76687 100644
--- a/pkg/enqueue/Symfony/Client/ProduceCommand.php
+++ b/pkg/enqueue/Symfony/Client/ProduceCommand.php
@@ -6,16 +6,16 @@
use Enqueue\Client\ProducerInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+#[AsCommand('enqueue:produce')]
class ProduceCommand extends Command
{
- protected static $defaultName = 'enqueue:produce';
-
/**
* @var ContainerInterface
*/
@@ -37,7 +37,7 @@ public function __construct(ContainerInterface $container, string $defaultClient
$this->defaultClient = $defaultClient;
$this->producerIdPattern = $producerIdPattern;
- parent::__construct(static::$defaultName);
+ parent::__construct();
}
protected function configure(): void
@@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$producer = $this->getProducer($client);
} catch (NotFoundExceptionInterface $e) {
- throw new \LogicException(sprintf('Client "%s" is not supported.', $client), null, $e);
+ throw new \LogicException(sprintf('Client "%s" is not supported.', $client), previous: $e);
}
if ($topic) {
diff --git a/pkg/enqueue/Symfony/Client/RoutesCommand.php b/pkg/enqueue/Symfony/Client/RoutesCommand.php
index 5419f3beb..04b657ef7 100644
--- a/pkg/enqueue/Symfony/Client/RoutesCommand.php
+++ b/pkg/enqueue/Symfony/Client/RoutesCommand.php
@@ -6,6 +6,7 @@
use Enqueue\Client\Route;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableSeparator;
@@ -13,10 +14,9 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+#[AsCommand('enqueue:routes')]
class RoutesCommand extends Command
{
- protected static $defaultName = 'enqueue:routes';
-
/**
* @var ContainerInterface
*/
@@ -43,7 +43,7 @@ public function __construct(ContainerInterface $container, string $defaultClient
$this->defaultClient = $defaultClient;
$this->driverIdPatter = $driverIdPatter;
- parent::__construct(static::$defaultName);
+ parent::__construct();
}
protected function configure(): void
@@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$this->driver = $this->getDriver($input->getOption('client'));
} catch (NotFoundExceptionInterface $e) {
- throw new \LogicException(sprintf('Client "%s" is not supported.', $input->getOption('client')), null, $e);
+ throw new \LogicException(sprintf('Client "%s" is not supported.', $input->getOption('client')), previous: $e);
}
$routes = $this->driver->getRouteCollection()->all();
diff --git a/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php b/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php
index 65d52ee31..92d5ad022 100644
--- a/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php
+++ b/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php
@@ -5,16 +5,16 @@
use Enqueue\Client\DriverInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
+#[AsCommand('enqueue:setup-broker')]
class SetupBrokerCommand extends Command
{
- protected static $defaultName = 'enqueue:setup-broker';
-
/**
* @var ContainerInterface
*/
@@ -36,7 +36,7 @@ public function __construct(ContainerInterface $container, string $defaultClient
$this->defaultClient = $defaultClient;
$this->driverIdPattern = $driverIdPattern;
- parent::__construct(static::$defaultName);
+ parent::__construct();
}
protected function configure(): void
@@ -55,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$this->getDriver($client)->setupBroker(new ConsoleLogger($output));
} catch (NotFoundExceptionInterface $e) {
- throw new \LogicException(sprintf('Client "%s" is not supported.', $client), null, $e);
+ throw new \LogicException(sprintf('Client "%s" is not supported.', $client), previous: $e);
}
$output->writeln('Broker set up');
diff --git a/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php b/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php
index 2888f5636..bcc4f7bb2 100644
--- a/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php
+++ b/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php
@@ -10,9 +10,6 @@
trait SetupBrokerExtensionCommandTrait
{
- /**
- * {@inheritdoc}
- */
protected function configureSetupBrokerExtension()
{
$this
@@ -21,10 +18,7 @@ protected function configureSetupBrokerExtension()
}
/**
- * @param InputInterface $input
- * @param DriverInterface $driver
- *
- * @return ExtensionInterface
+ * @return ExtensionInterface|null
*/
protected function getSetupBrokerExtension(InputInterface $input, DriverInterface $driver)
{
diff --git a/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php b/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php
index 9ec8a36f3..34cb66d57 100644
--- a/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php
+++ b/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php
@@ -8,19 +8,19 @@
use Enqueue\ProcessorRegistryInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+#[AsCommand('enqueue:transport:consume')]
class ConfigurableConsumeCommand extends Command
{
+ use ChooseLoggerCommandTrait;
use LimitsExtensionsCommandTrait;
use QueueConsumerOptionsCommandTrait;
- use ChooseLoggerCommandTrait;
-
- protected static $defaultName = 'enqueue:transport:consume';
/**
* @var ContainerInterface
@@ -46,14 +46,14 @@ public function __construct(
ContainerInterface $container,
string $defaultTransport,
string $queueConsumerIdPattern = 'enqueue.transport.%s.queue_consumer',
- string $processorRegistryIdPattern = 'enqueue.transport.%s.processor_registry'
+ string $processorRegistryIdPattern = 'enqueue.transport.%s.processor_registry',
) {
$this->container = $container;
$this->defaultTransport = $defaultTransport;
$this->queueConsumerIdPattern = $queueConsumerIdPattern;
$this->processorRegistryIdPattern = $processorRegistryIdPattern;
- parent::__construct(static::$defaultName);
+ parent::__construct();
}
protected function configure(): void
@@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$consumer = $this->getQueueConsumer($transport);
} catch (NotFoundExceptionInterface $e) {
- throw new \LogicException(sprintf('Transport "%s" is not supported.', $transport), null, $e);
+ throw new \LogicException(sprintf('Transport "%s" is not supported.', $transport), previous: $e);
}
$this->setQueueConsumerOptions($consumer, $input);
diff --git a/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php b/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php
index b1a54c163..b69ae7269 100644
--- a/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php
+++ b/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php
@@ -7,18 +7,18 @@
use Enqueue\Consumption\QueueConsumerInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+#[AsCommand('enqueue:transport:consume')]
class ConsumeCommand extends Command
{
+ use ChooseLoggerCommandTrait;
use LimitsExtensionsCommandTrait;
use QueueConsumerOptionsCommandTrait;
- use ChooseLoggerCommandTrait;
-
- protected static $defaultName = 'enqueue:transport:consume';
/**
* @var ContainerInterface
@@ -41,7 +41,7 @@ public function __construct(ContainerInterface $container, string $defaultTransp
$this->defaultTransport = $defaultTransport;
$this->queueConsumerIdPattern = $queueConsumerIdPattern;
- parent::__construct(static::$defaultName);
+ parent::__construct();
}
protected function configure(): void
@@ -65,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// QueueConsumer must be pre configured outside of the command!
$consumer = $this->getQueueConsumer($transport);
} catch (NotFoundExceptionInterface $e) {
- throw new \LogicException(sprintf('Transport "%s" is not supported.', $transport), null, $e);
+ throw new \LogicException(sprintf('Transport "%s" is not supported.', $transport), previous: $e);
}
$this->setQueueConsumerOptions($consumer, $input);
diff --git a/pkg/enqueue/Symfony/Consumption/LimitsExtensionsCommandTrait.php b/pkg/enqueue/Symfony/Consumption/LimitsExtensionsCommandTrait.php
index d7363db09..d8351acc5 100644
--- a/pkg/enqueue/Symfony/Consumption/LimitsExtensionsCommandTrait.php
+++ b/pkg/enqueue/Symfony/Consumption/LimitsExtensionsCommandTrait.php
@@ -23,9 +23,6 @@ protected function configureLimitsExtensions()
}
/**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
* @throws \Exception
*
* @return ExtensionInterface[]
diff --git a/pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php b/pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php
index 9df852df9..fd736f226 100644
--- a/pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php
+++ b/pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php
@@ -8,9 +8,6 @@
trait QueueConsumerOptionsCommandTrait
{
- /**
- * {@inheritdoc}
- */
protected function configureQueueConsumerOptions()
{
$this
@@ -18,10 +15,6 @@ protected function configureQueueConsumerOptions()
;
}
- /**
- * @param QueueConsumerInterface $consumer
- * @param InputInterface $input
- */
protected function setQueueConsumerOptions(QueueConsumerInterface $consumer, InputInterface $input)
{
if (null !== $receiveTimeout = $input->getOption('receive-timeout')) {
diff --git a/pkg/enqueue/Symfony/DependencyInjection/BuildConsumptionExtensionsPass.php b/pkg/enqueue/Symfony/DependencyInjection/BuildConsumptionExtensionsPass.php
index 352682b19..99f274ec5 100644
--- a/pkg/enqueue/Symfony/DependencyInjection/BuildConsumptionExtensionsPass.php
+++ b/pkg/enqueue/Symfony/DependencyInjection/BuildConsumptionExtensionsPass.php
@@ -43,7 +43,7 @@ public function process(ContainerBuilder $container): void
}
}
- krsort($groupByPriority, SORT_NUMERIC);
+ krsort($groupByPriority, \SORT_NUMERIC);
$flatExtensions = [];
foreach ($groupByPriority as $extension) {
diff --git a/pkg/enqueue/Symfony/DependencyInjection/TransportFactory.php b/pkg/enqueue/Symfony/DependencyInjection/TransportFactory.php
index 54dba4bf7..944b1a30d 100644
--- a/pkg/enqueue/Symfony/DependencyInjection/TransportFactory.php
+++ b/pkg/enqueue/Symfony/DependencyInjection/TransportFactory.php
@@ -132,15 +132,15 @@ public function buildConnectionFactory(ContainerBuilder $container, array $confi
$container->register($factoryFactoryId, $config['factory_class'] ?? ConnectionFactoryFactory::class);
$factoryFactoryService = new Reference(
- array_key_exists('factory_service', $config) ? $config['factory_service'] : $factoryFactoryId
+ $config['factory_service'] ?? $factoryFactoryId
);
unset($config['factory_service'], $config['factory_class']);
- if (array_key_exists('connection_factory_class', $config)) {
- $connectionFactoryClass = $config['connection_factory_class'];
- unset($config['connection_factory_class']);
+ $connectionFactoryClass = $config['connection_factory_class'] ?? null;
+ unset($config['connection_factory_class']);
+ if (isset($connectionFactoryClass)) {
$container->register($factoryId, $connectionFactoryClass)
->addArgument($config)
;
diff --git a/pkg/enqueue/Symfony/DiUtils.php b/pkg/enqueue/Symfony/DiUtils.php
index 335ff04b9..be45287be 100644
--- a/pkg/enqueue/Symfony/DiUtils.php
+++ b/pkg/enqueue/Symfony/DiUtils.php
@@ -27,7 +27,7 @@ public function __construct(string $moduleName, string $configName)
public static function create(string $moduleName, string $configName): self
{
- return new static($moduleName, $configName);
+ return new self($moduleName, $configName);
}
public function getModuleName(): string
diff --git a/pkg/enqueue/Tests/ArrayProcessorRegistryTest.php b/pkg/enqueue/Tests/ArrayProcessorRegistryTest.php
index 897276d62..93ad3ece1 100644
--- a/pkg/enqueue/Tests/ArrayProcessorRegistryTest.php
+++ b/pkg/enqueue/Tests/ArrayProcessorRegistryTest.php
@@ -18,11 +18,6 @@ public function testShouldImplementProcessorRegistryInterface()
$this->assertClassImplements(ProcessorRegistryInterface::class, ArrayProcessorRegistry::class);
}
- public function testCouldBeConstructedWithoutAnyArgument()
- {
- new ArrayProcessorRegistry();
- }
-
public function testShouldThrowExceptionIfProcessorIsNotSet()
{
$registry = new ArrayProcessorRegistry();
diff --git a/pkg/enqueue/Tests/Client/ChainExtensionTest.php b/pkg/enqueue/Tests/Client/ChainExtensionTest.php
index a59005bc1..0f42bcf18 100644
--- a/pkg/enqueue/Tests/Client/ChainExtensionTest.php
+++ b/pkg/enqueue/Tests/Client/ChainExtensionTest.php
@@ -29,11 +29,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(ChainExtension::class);
}
- public function testCouldBeConstructedWithExtensionsArray()
- {
- new ChainExtension([$this->createExtension(), $this->createExtension()]);
- }
-
public function testThrowIfArrayContainsNotExtension()
{
$this->expectException(\LogicException::class);
diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php
index 050b4f2f5..a660126ad 100644
--- a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php
+++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php
@@ -10,23 +10,19 @@
use Enqueue\Consumption\Result;
use Enqueue\Null\NullMessage;
use Enqueue\Null\NullQueue;
+use Enqueue\Test\TestLogger;
use Interop\Queue\Consumer;
use Interop\Queue\Context as InteropContext;
use Interop\Queue\Destination;
use Interop\Queue\Message as TransportMessage;
use Interop\Queue\Processor;
+use Interop\Queue\Queue;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
class DelayRedeliveredMessageExtensionTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new DelayRedeliveredMessageExtension($this->createDriverMock(), 12345);
- }
-
public function testShouldSendDelayedMessageAndRejectOriginalMessage()
{
$queue = new NullQueue('queue');
@@ -54,20 +50,7 @@ public function testShouldSendDelayedMessageAndRejectOriginalMessage()
->willReturn($delayedMessage)
;
- $logger = $this->createLoggerMock();
- $logger
- ->expects(self::at(0))
- ->method('debug')
- ->with('[DelayRedeliveredMessageExtension] Send delayed message')
- ;
- $logger
- ->expects(self::at(1))
- ->method('debug')
- ->with(
- '[DelayRedeliveredMessageExtension] '.
- 'Reject redelivered original message by setting reject status to context.'
- )
- ;
+ $logger = new TestLogger();
$messageReceived = new MessageReceived(
$this->createContextMock(),
@@ -92,6 +75,16 @@ public function testShouldSendDelayedMessageAndRejectOriginalMessage()
$this->assertEquals([
'enqueue.redelivery_count' => 1,
], $delayedMessage->getProperties());
+
+ self::assertTrue(
+ $logger->hasDebugThatContains('[DelayRedeliveredMessageExtension] Send delayed message')
+ );
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[DelayRedeliveredMessageExtension] '.
+ 'Reject redelivered original message by setting reject status to context.'
+ )
+ );
}
public function testShouldDoNothingIfMessageIsNotRedelivered()
@@ -169,30 +162,20 @@ private function createProcessorMock(): Processor
}
/**
- * @param mixed $queue
- *
- * @return MockObject
+ * @return MockObject|Consumer
*/
- private function createConsumerStub($queue): Consumer
+ private function createConsumerStub(?Queue $queue): Consumer
{
$consumerMock = $this->createMock(Consumer::class);
$consumerMock
->expects($this->any())
->method('getQueue')
- ->willReturn($queue)
+ ->willReturn($queue ?? new NullQueue('queue'))
;
return $consumerMock;
}
- /**
- * @return MockObject
- */
- private function createLoggerMock(): LoggerInterface
- {
- return $this->createMock(LoggerInterface::class);
- }
-
private function createDriverSendResult(): DriverSendResult
{
return new DriverSendResult(
diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php
index 878778b30..b1e47c898 100644
--- a/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php
+++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php
@@ -15,6 +15,7 @@
use Interop\Queue\Consumer;
use Interop\Queue\Context as InteropContext;
use Interop\Queue\Processor;
+use Interop\Queue\Queue;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
@@ -33,11 +34,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(ExclusiveCommandExtension::class);
}
- public function testCouldBeConstructedWithDriverAsFirstArgument()
- {
- new ExclusiveCommandExtension($this->createDriverStub());
- }
-
public function testShouldDoNothingIfMessageHasTopicPropertySetOnPreReceive()
{
$message = new NullMessage();
@@ -243,15 +239,15 @@ public function testShouldDoNothingIfAnotherQueue()
}
/**
- * @return MockObject
+ * @return MockObject|DriverInterface
*/
- private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface
+ private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface
{
$driver = $this->createMock(DriverInterface::class);
$driver
->expects($this->any())
->method('getRouteCollection')
- ->willReturn($routeCollection)
+ ->willReturn($routeCollection ?? new RouteCollection([]))
;
return $driver;
@@ -274,17 +270,15 @@ private function createProcessorMock(): Processor
}
/**
- * @param mixed $queue
- *
- * @return MockObject
+ * @return MockObject|Consumer
*/
- private function createConsumerStub($queue): Consumer
+ private function createConsumerStub(?Queue $queue): Consumer
{
$consumerMock = $this->createMock(Consumer::class);
$consumerMock
->expects($this->any())
->method('getQueue')
- ->willReturn($queue)
+ ->willReturn($queue ?? new NullQueue('queue'))
;
return $consumerMock;
diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/FlushSpoolProducerExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/FlushSpoolProducerExtensionTest.php
index 63fb50c5a..6a782c524 100644
--- a/pkg/enqueue/Tests/Client/ConsumptionExtension/FlushSpoolProducerExtensionTest.php
+++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/FlushSpoolProducerExtensionTest.php
@@ -30,11 +30,6 @@ public function testShouldImplementEndExtensionInterface()
$this->assertClassImplements(EndExtensionInterface::class, FlushSpoolProducerExtension::class);
}
- public function testCouldBeConstructedWithSpoolProducerAsFirstArgument()
- {
- new FlushSpoolProducerExtension($this->createSpoolProducerMock());
- }
-
public function testShouldFlushSpoolProducerOnEnd()
{
$producer = $this->createSpoolProducerMock();
diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/LogExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/LogExtensionTest.php
index 063ea23af..db757676b 100644
--- a/pkg/enqueue/Tests/Client/ConsumptionExtension/LogExtensionTest.php
+++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/LogExtensionTest.php
@@ -55,11 +55,6 @@ public function testShouldSubClassOfLogExtension()
$this->assertClassExtends(\Enqueue\Consumption\Extension\LogExtension::class, LogExtension::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new LogExtension();
- }
-
public function testShouldLogStartOnStart()
{
$logger = $this->createLogger();
diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php
index 18760e9bf..d521aefca 100644
--- a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php
+++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php
@@ -13,6 +13,7 @@
use Interop\Queue\Consumer;
use Interop\Queue\Context as InteropContext;
use Interop\Queue\Processor;
+use Interop\Queue\Queue;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
@@ -26,11 +27,6 @@ public function testShouldImplementMessageReceivedExtensionInterface()
$this->assertClassImplements(MessageReceivedExtensionInterface::class, SetRouterPropertiesExtension::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new SetRouterPropertiesExtension($this->createDriverMock());
- }
-
public function testShouldSetRouterProcessorPropertyIfNotSetAndOnRouterQueue()
{
$config = Config::create('test', '.', '', '', 'router-queue', '', 'router-processor-name');
@@ -186,17 +182,15 @@ private function createProcessorMock(): Processor
}
/**
- * @param mixed $queue
- *
- * @return MockObject
+ * @return MockObject|Consumer
*/
- private function createConsumerStub($queue): Consumer
+ private function createConsumerStub(?Queue $queue): Consumer
{
$consumerMock = $this->createMock(Consumer::class);
$consumerMock
->expects($this->any())
->method('getQueue')
- ->willReturn($queue)
+ ->willReturn($queue ?? new NullQueue('queue'))
;
return $consumerMock;
diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php
index 4b241aa0e..fbd367975 100644
--- a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php
+++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php
@@ -21,11 +21,6 @@ public function testShouldImplementStartExtensionInterface()
$this->assertClassImplements(StartExtensionInterface::class, SetupBrokerExtension::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new SetupBrokerExtension($this->createDriverMock());
- }
-
public function testShouldSetupBroker()
{
$logger = new NullLogger();
diff --git a/pkg/enqueue/Tests/Client/DelegateProcessorTest.php b/pkg/enqueue/Tests/Client/DelegateProcessorTest.php
index 40ef17989..9743cf4f3 100644
--- a/pkg/enqueue/Tests/Client/DelegateProcessorTest.php
+++ b/pkg/enqueue/Tests/Client/DelegateProcessorTest.php
@@ -13,11 +13,6 @@
class DelegateProcessorTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new DelegateProcessor($this->createProcessorRegistryMock());
- }
-
public function testShouldThrowExceptionIfProcessorNameIsNotSet()
{
$this->expectException(\LogicException::class);
diff --git a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php
index 4e4cc62fd..2cfb170b9 100644
--- a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php
+++ b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php
@@ -2,6 +2,7 @@
namespace Enqueue\Tests\Client\Driver;
+use DMS\PHPUnitExtensions\ArraySubset\Assert;
use Enqueue\Client\Config;
use Enqueue\Client\Driver\AmqpDriver;
use Enqueue\Client\Driver\GenericDriver;
@@ -312,9 +313,6 @@ protected function createQueue(string $name): InteropQueue
return new AmqpQueue($name);
}
- /**
- * @return AmqpTopic
- */
protected function createTopic(string $name): AmqpTopic
{
return new AmqpTopic($name);
@@ -336,7 +334,7 @@ protected function getRouterTransportName(): string
protected function assertTransportMessage(InteropMessage $transportMessage): void
{
$this->assertSame('body', $transportMessage->getBody());
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'hkey' => 'hval',
'delivery_mode' => AmqpMessage::DELIVERY_MODE_PERSISTENT,
'content_type' => 'ContentType',
diff --git a/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php b/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php
index 98b6c2285..78f7f6e83 100644
--- a/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php
+++ b/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php
@@ -2,6 +2,7 @@
namespace Enqueue\Tests\Client\Driver;
+use DMS\PHPUnitExtensions\ArraySubset\Assert;
use Enqueue\Client\Config;
use Enqueue\Client\Driver\GenericDriver;
use Enqueue\Client\DriverInterface;
@@ -60,7 +61,7 @@ protected function createMessage(): InteropMessage
protected function assertTransportMessage(InteropMessage $transportMessage): void
{
$this->assertSame('body', $transportMessage->getBody());
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'hkey' => 'hval',
'message_id' => 'theMessageId',
'timestamp' => 1000,
diff --git a/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php b/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php
index 4f1c81566..d5ad498a9 100644
--- a/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php
+++ b/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php
@@ -2,6 +2,7 @@
namespace Enqueue\Tests\Client\Driver;
+use DMS\PHPUnitExtensions\ArraySubset\Assert;
use Enqueue\Client\Config;
use Enqueue\Client\DriverInterface;
use Enqueue\Client\Message;
@@ -1191,10 +1192,10 @@ protected function assertTransportMessage(InteropMessage $transportMessage): voi
protected function assertClientMessage(Message $clientMessage): void
{
$this->assertSame('body', $clientMessage->getBody());
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'hkey' => 'hval',
], $clientMessage->getHeaders());
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'pkey' => 'pval',
Config::CONTENT_TYPE => 'theContentType',
Config::EXPIRE => '22',
diff --git a/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php
index 2f6e20a82..b209d85bc 100644
--- a/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php
+++ b/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php
@@ -2,6 +2,7 @@
namespace Enqueue\Tests\Client\Driver;
+use DMS\PHPUnitExtensions\ArraySubset\Assert;
use Enqueue\Client\Config;
use Enqueue\Client\Driver\AmqpDriver;
use Enqueue\Client\Driver\GenericDriver;
@@ -91,9 +92,6 @@ protected function createQueue(string $name): InteropQueue
return new AmqpQueue($name);
}
- /**
- * @return AmqpTopic
- */
protected function createTopic(string $name): AmqpTopic
{
return new AmqpTopic($name);
@@ -115,7 +113,7 @@ protected function getRouterTransportName(): string
protected function assertTransportMessage(InteropMessage $transportMessage): void
{
$this->assertSame('body', $transportMessage->getBody());
- $this->assertArraySubset([
+ Assert::assertArraySubset([
'hkey' => 'hval',
'delivery_mode' => AmqpMessage::DELIVERY_MODE_PERSISTENT,
'content_type' => 'ContentType',
diff --git a/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php
index 4152f93cc..9fc72be1e 100644
--- a/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php
+++ b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php
@@ -18,13 +18,13 @@
use Enqueue\Stomp\StompMessage;
use Enqueue\Stomp\StompProducer;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\TestLogger;
use Interop\Queue\Context;
use Interop\Queue\Message as InteropMessage;
use Interop\Queue\Producer as InteropProducer;
use Interop\Queue\Queue as InteropQueue;
use Interop\Queue\Topic as InteropTopic;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
class RabbitMqStompDriverTest extends TestCase
{
@@ -281,14 +281,15 @@ public function testShouldNotSetupBrokerIfManagementPluginInstalledOptionIsNotEn
$this->createManagementClientMock()
);
- $logger = $this->createLoggerMock();
- $logger
- ->expects($this->once())
- ->method('debug')
- ->with('[RabbitMqStompDriver] Could not setup broker. The option `management_plugin_installed` is not enabled. Please enable that option and install rabbit management plugin')
- ;
+ $logger = new TestLogger();
$driver->setupBroker($logger);
+
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[RabbitMqStompDriver] Could not setup broker. The option `management_plugin_installed` is not enabled. Please enable that option and install rabbit management plugin'
+ )
+ );
}
public function testShouldSetupBroker()
@@ -366,29 +367,30 @@ public function testShouldSetupBroker()
$managementClient
);
- $logger = $this->createLoggerMock();
- $logger
- ->expects($this->at(0))
- ->method('debug')
- ->with('[RabbitMqStompDriver] Declare router exchange: aprefix.router')
- ;
- $logger
- ->expects($this->at(1))
- ->method('debug')
- ->with('[RabbitMqStompDriver] Declare router queue: aprefix.default')
- ;
- $logger
- ->expects($this->at(2))
- ->method('debug')
- ->with('[RabbitMqStompDriver] Bind router queue to exchange: aprefix.default -> aprefix.router')
- ;
- $logger
- ->expects($this->at(3))
- ->method('debug')
- ->with('[RabbitMqStompDriver] Declare processor queue: aprefix.default')
- ;
+ $logger = new TestLogger();
$driver->setupBroker($logger);
+
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[RabbitMqStompDriver] Declare router exchange: aprefix.router'
+ )
+ );
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[RabbitMqStompDriver] Declare router queue: aprefix.default'
+ )
+ );
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[RabbitMqStompDriver] Bind router queue to exchange: aprefix.default -> aprefix.router'
+ )
+ );
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[RabbitMqStompDriver] Declare processor queue: aprefix.default'
+ )
+ );
}
public function testSetupBrokerShouldCreateDelayExchangeIfEnabled()
@@ -458,19 +460,20 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled()
$managementClient
);
- $logger = $this->createLoggerMock();
- $logger
- ->expects($this->at(4))
- ->method('debug')
- ->with('[RabbitMqStompDriver] Declare delay exchange: aprefix.default.delayed')
- ;
- $logger
- ->expects($this->at(5))
- ->method('debug')
- ->with('[RabbitMqStompDriver] Bind processor queue to delay exchange: aprefix.default -> aprefix.default.delayed')
- ;
+ $logger = new TestLogger();
$driver->setupBroker($logger);
+
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[RabbitMqStompDriver] Declare delay exchange: aprefix.default.delayed'
+ )
+ );
+ self::assertTrue(
+ $logger->hasDebugThatContains(
+ '[RabbitMqStompDriver] Bind processor queue to delay exchange: aprefix.default -> aprefix.default.delayed'
+ )
+ );
}
protected function createDriver(...$args): DriverInterface
@@ -584,12 +587,4 @@ private function createManagementClientMock(): StompManagementClient
{
return $this->createMock(StompManagementClient::class);
}
-
- /**
- * @return \PHPUnit\Framework\MockObject\MockObject|LoggerInterface
- */
- private function createLoggerMock()
- {
- return $this->createMock(LoggerInterface::class);
- }
}
diff --git a/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php
index 659590ba3..c5e40e71d 100644
--- a/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php
+++ b/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php
@@ -19,9 +19,6 @@
use Interop\Queue\Queue as InteropQueue;
use PHPUnit\Framework\TestCase;
-/**
- * @group rdkafka
- */
class RdKafkaDriverTest extends TestCase
{
use ClassExtensionTrait;
@@ -102,9 +99,6 @@ protected function createQueue(string $name): InteropQueue
return new RdKafkaTopic($name);
}
- /**
- * @return RdKafkaTopic
- */
protected function createTopic(string $name): RdKafkaTopic
{
return new RdKafkaTopic($name);
diff --git a/pkg/enqueue/Tests/Client/DriverFactoryTest.php b/pkg/enqueue/Tests/Client/DriverFactoryTest.php
index cce6311e5..3d9d7b9b5 100644
--- a/pkg/enqueue/Tests/Client/DriverFactoryTest.php
+++ b/pkg/enqueue/Tests/Client/DriverFactoryTest.php
@@ -61,11 +61,6 @@ public function testShouldBeFinal()
$this->assertTrue($rc->isFinal());
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new DriverFactory();
- }
-
public function testThrowIfPackageThatSupportSchemeNotInstalled()
{
$scheme = 'scheme5b7aa7d7cd213';
@@ -110,7 +105,7 @@ public function testReturnsExpectedFactories(
string $connectionFactoryClass,
string $contextClass,
array $conifg,
- string $expectedDriverClass
+ string $expectedDriverClass,
) {
$connectionFactoryMock = $this->createMock($connectionFactoryClass);
$connectionFactoryMock
@@ -139,7 +134,7 @@ public static function provideDSN()
yield ['file:', FsConnectionFactory::class, FsContext::class, [], FsDriver::class];
// https://github.com/php-enqueue/enqueue-dev/issues/511
-// yield ['gearman:', GearmanConnectionFactory::class, NullContext::class, [], NullDriver::class];
+ // yield ['gearman:', GearmanConnectionFactory::class, NullContext::class, [], NullDriver::class];
yield ['gps:', GpsConnectionFactory::class, GpsContext::class, [], GpsDriver::class];
diff --git a/pkg/enqueue/Tests/Client/DriverPreSendTest.php b/pkg/enqueue/Tests/Client/DriverPreSendTest.php
index 85686b4c1..32af2a81f 100644
--- a/pkg/enqueue/Tests/Client/DriverPreSendTest.php
+++ b/pkg/enqueue/Tests/Client/DriverPreSendTest.php
@@ -19,15 +19,6 @@ public function testShouldBeFinal()
self::assertClassFinal(DriverPreSend::class);
}
- public function testCouldBeConstructedWithExpectedArguments()
- {
- new DriverPreSend(
- new Message(),
- $this->createProducerMock(),
- $this->createDriverMock()
- );
- }
-
public function testShouldAllowGetArgumentSetInConstructor()
{
$expectedMessage = new Message();
diff --git a/pkg/enqueue/Tests/Client/Extension/PrepareBodyExtensionTest.php b/pkg/enqueue/Tests/Client/Extension/PrepareBodyExtensionTest.php
index 454034abb..c3032ccc8 100644
--- a/pkg/enqueue/Tests/Client/Extension/PrepareBodyExtensionTest.php
+++ b/pkg/enqueue/Tests/Client/Extension/PrepareBodyExtensionTest.php
@@ -22,22 +22,16 @@ public function testShouldImplementExtensionInterface()
$this->assertTrue($rc->implementsInterface(PreSendCommandExtensionInterface::class));
}
- public function testCouldConstructedWithoutAnyArguments()
- {
- new PrepareBodyExtension();
- }
-
/**
* @dataProvider provideMessages
*
- * @param mixed $body
* @param mixed|null $contentType
*/
public function testShouldSendStringUnchangedAndAddPlainTextContentTypeIfEmpty(
$body,
$contentType,
string $expectedBody,
- string $expectedContentType
+ string $expectedContentType,
) {
$message = new Message($body);
$message->setContentType($contentType);
diff --git a/pkg/enqueue/Tests/Client/PostSendTest.php b/pkg/enqueue/Tests/Client/PostSendTest.php
index 04927700c..ba51710e7 100644
--- a/pkg/enqueue/Tests/Client/PostSendTest.php
+++ b/pkg/enqueue/Tests/Client/PostSendTest.php
@@ -21,17 +21,6 @@ public function testShouldBeFinal()
self::assertClassFinal(PostSend::class);
}
- public function testCouldBeConstructedWithExpectedArguments()
- {
- new PostSend(
- new Message(),
- $this->createProducerMock(),
- $this->createDriverMock(),
- $this->createDestinationMock(),
- $this->createTransportMessageMock()
- );
- }
-
public function testShouldAllowGetArgumentSetInConstructor()
{
$expectedMessage = new Message();
diff --git a/pkg/enqueue/Tests/Client/PreSendTest.php b/pkg/enqueue/Tests/Client/PreSendTest.php
index 408be1c69..01a7e5055 100644
--- a/pkg/enqueue/Tests/Client/PreSendTest.php
+++ b/pkg/enqueue/Tests/Client/PreSendTest.php
@@ -18,16 +18,6 @@ public function testShouldBeFinal()
self::assertClassFinal(PreSend::class);
}
- public function testCouldBeConstructedWithExpectedArguments()
- {
- new PreSend(
- 'aCommandOrTopic',
- new Message(),
- $this->createProducerMock(),
- $this->createDriverMock()
- );
- }
-
public function testShouldAllowGetArgumentSetInConstructor()
{
$expectedCommandOrTopic = 'theCommandOrTopic';
@@ -61,7 +51,7 @@ public function testCouldChangeTopic()
$this->createDriverMock()
);
- //guard
+ // guard
$this->assertSame('aCommandOrTopic', $context->getTopic());
$context->changeTopic('theChangedTopic');
@@ -78,7 +68,7 @@ public function testCouldChangeCommand()
$this->createDriverMock()
);
- //guard
+ // guard
$this->assertSame('aCommandOrTopic', $context->getCommand());
$context->changeCommand('theChangedCommand');
@@ -95,7 +85,7 @@ public function testCouldChangeBody()
$this->createDriverMock()
);
- //guard
+ // guard
$this->assertSame('aBody', $context->getMessage()->getBody());
$this->assertNull($context->getMessage()->getContentType());
diff --git a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php
index 8ac0704ca..9500e9d62 100644
--- a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php
+++ b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php
@@ -479,7 +479,7 @@ public function testShouldCallPostSendExtensionMethod()
$extension
->expects($this->at(0))
- ->method('onDriverPreSend')
+ ->method('onPostSend')
->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) {
$this->assertSame($message, $context->getMessage());
$this->assertSame($producer, $context->getProducer());
diff --git a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php
index 29a14b7d4..c92b49560 100644
--- a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php
+++ b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php
@@ -499,7 +499,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToApplicationRouter
$extension
->expects($this->at(0))
- ->method('onDriverPreSend')
+ ->method('onPostSend')
->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) {
$this->assertSame($message, $context->getMessage());
$this->assertSame($producer, $context->getProducer());
diff --git a/pkg/enqueue/Tests/Client/ProducerTest.php b/pkg/enqueue/Tests/Client/ProducerTest.php
index 558e70ee6..23b004ac3 100644
--- a/pkg/enqueue/Tests/Client/ProducerTest.php
+++ b/pkg/enqueue/Tests/Client/ProducerTest.php
@@ -3,7 +3,6 @@
namespace Enqueue\Tests\Client;
use Enqueue\Client\DriverInterface;
-use Enqueue\Client\ExtensionInterface;
use Enqueue\Client\Producer;
use Enqueue\Client\ProducerInterface;
use Enqueue\Rpc\RpcFactory;
@@ -24,20 +23,6 @@ public function testShouldBeFinal()
self::assertClassFinal(Producer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new Producer($this->createDriverMock(), $this->createRpcFactoryMock());
- }
-
- public function testCouldBeConstructedWithOptionalArguments()
- {
- new Producer(
- $this->createDriverMock(),
- $this->createRpcFactoryMock(),
- $this->createMock(ExtensionInterface::class)
- );
- }
-
/**
* @return \PHPUnit\Framework\MockObject\MockObject
*/
diff --git a/pkg/enqueue/Tests/Client/ResourcesTest.php b/pkg/enqueue/Tests/Client/ResourcesTest.php
index c2d2b117d..e79fb9dda 100644
--- a/pkg/enqueue/Tests/Client/ResourcesTest.php
+++ b/pkg/enqueue/Tests/Client/ResourcesTest.php
@@ -28,7 +28,7 @@ public function testShouldGetAvailableDriverInExpectedFormat()
{
$availableDrivers = Resources::getAvailableDrivers();
- $this->assertInternalType('array', $availableDrivers);
+ self::assertIsArray($availableDrivers);
$this->assertGreaterThan(0, count($availableDrivers));
$driverInfo = $availableDrivers[0];
@@ -50,7 +50,7 @@ public function testShouldGetAvailableDriverWithRequiredExtensionInExpectedForma
{
$availableDrivers = Resources::getAvailableDrivers();
- $this->assertInternalType('array', $availableDrivers);
+ self::assertIsArray($availableDrivers);
$this->assertGreaterThan(0, count($availableDrivers));
$driverInfo = $availableDrivers[1];
@@ -72,7 +72,7 @@ public function testShouldGetKnownDriversInExpectedFormat()
{
$knownDrivers = Resources::getAvailableDrivers();
- $this->assertInternalType('array', $knownDrivers);
+ self::assertIsArray($knownDrivers);
$this->assertGreaterThan(0, count($knownDrivers));
$driverInfo = $knownDrivers[0];
diff --git a/pkg/enqueue/Tests/Client/RouterProcessorTest.php b/pkg/enqueue/Tests/Client/RouterProcessorTest.php
index cdd44df7a..7d2971189 100644
--- a/pkg/enqueue/Tests/Client/RouterProcessorTest.php
+++ b/pkg/enqueue/Tests/Client/RouterProcessorTest.php
@@ -13,6 +13,7 @@
use Enqueue\Null\NullContext;
use Enqueue\Null\NullMessage;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Destination;
use Interop\Queue\Message as TransportMessage;
use Interop\Queue\Processor;
@@ -21,6 +22,7 @@
class RouterProcessorTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementProcessorInterface()
{
@@ -186,7 +188,7 @@ public function testShouldDoNotModifyOriginalMessage()
$result = $processor->process($message, new NullContext());
- //guard
+ // guard
$this->assertEquals(Result::ACK, $result->getStatus());
$this->assertSame('theBody', $message->getBody());
@@ -195,15 +197,15 @@ public function testShouldDoNotModifyOriginalMessage()
}
/**
- * @return \PHPUnit\Framework\MockObject\MockObject
+ * @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface
*/
- private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface
+ private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface
{
$driver = $this->createMock(DriverInterface::class);
$driver
->expects($this->any())
->method('getRouteCollection')
- ->willReturn($routeCollection)
+ ->willReturn($routeCollection ?? new RouteCollection([]))
;
return $driver;
diff --git a/pkg/enqueue/Tests/Client/SpoolProducerTest.php b/pkg/enqueue/Tests/Client/SpoolProducerTest.php
index 024fd6da2..014fe4962 100644
--- a/pkg/enqueue/Tests/Client/SpoolProducerTest.php
+++ b/pkg/enqueue/Tests/Client/SpoolProducerTest.php
@@ -18,11 +18,6 @@ public function testShouldImplementProducerInterface()
self::assertClassImplements(ProducerInterface::class, SpoolProducer::class);
}
- public function testCouldBeConstructedWithRealProducer()
- {
- new SpoolProducer($this->createProducerMock());
- }
-
public function testShouldQueueEventMessageOnSend()
{
$message = new Message();
diff --git a/pkg/enqueue/Tests/Client/TraceableProducerTest.php b/pkg/enqueue/Tests/Client/TraceableProducerTest.php
index ff5ee83eb..b0df066ce 100644
--- a/pkg/enqueue/Tests/Client/TraceableProducerTest.php
+++ b/pkg/enqueue/Tests/Client/TraceableProducerTest.php
@@ -2,6 +2,7 @@
namespace Enqueue\Tests\Client;
+use DMS\PHPUnitExtensions\ArraySubset\Assert;
use Enqueue\Client\Message;
use Enqueue\Client\ProducerInterface;
use Enqueue\Client\TraceableProducer;
@@ -17,11 +18,6 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(ProducerInterface::class, TraceableProducer::class);
}
- public function testCouldBeConstructedWithInternalMessageProducer()
- {
- new TraceableProducer($this->createProducerMock());
- }
-
public function testShouldPassAllArgumentsToInternalEventMessageProducerSendMethod()
{
$topic = 'theTopic';
@@ -45,7 +41,7 @@ public function testShouldCollectInfoIfStringGivenAsEventMessage()
$producer->sendEvent('aFooTopic', 'aFooBody');
- $this->assertArraySubset([
+ Assert::assertArraySubset([
[
'topic' => 'aFooTopic',
'command' => null,
@@ -70,7 +66,7 @@ public function testShouldCollectInfoIfArrayGivenAsEventMessage()
$producer->sendEvent('aFooTopic', ['foo' => 'fooVal', 'bar' => 'barVal']);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
[
'topic' => 'aFooTopic',
'command' => null,
@@ -106,7 +102,7 @@ public function testShouldCollectInfoIfEventMessageObjectGivenAsMessage()
$producer->sendEvent('aFooTopic', $message);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
[
'topic' => 'aFooTopic',
'command' => null,
@@ -168,7 +164,7 @@ public function testShouldCollectInfoIfStringGivenAsCommandMessage()
$producer->sendCommand('aFooCommand', 'aFooBody');
- $this->assertArraySubset([
+ Assert::assertArraySubset([
[
'topic' => null,
'command' => 'aFooCommand',
@@ -193,7 +189,7 @@ public function testShouldCollectInfoIfArrayGivenAsCommandMessage()
$producer->sendCommand('aFooCommand', ['foo' => 'fooVal', 'bar' => 'barVal']);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
[
'topic' => null,
'command' => 'aFooCommand',
@@ -229,7 +225,7 @@ public function testShouldCollectInfoIfCommandMessageObjectGivenAsMessage()
$producer->sendCommand('aFooCommand', $message);
- $this->assertArraySubset([
+ Assert::assertArraySubset([
[
'topic' => null,
'command' => 'aFooCommand',
@@ -275,9 +271,9 @@ public function testShouldAllowGetInfoSentToSameTopic()
$producer->sendEvent('aFooTopic', 'aFooBody');
$producer->sendEvent('aFooTopic', 'aFooBody');
- $this->assertArraySubset([
- ['topic' => 'aFooTopic', 'body' => 'aFooBody'],
- ['topic' => 'aFooTopic', 'body' => 'aFooBody'],
+ Assert::assertArraySubset([
+ ['topic' => 'aFooTopic', 'body' => 'aFooBody'],
+ ['topic' => 'aFooTopic', 'body' => 'aFooBody'],
], $producer->getTraces());
}
@@ -288,7 +284,7 @@ public function testShouldAllowGetInfoSentToDifferentTopics()
$producer->sendEvent('aFooTopic', 'aFooBody');
$producer->sendEvent('aBarTopic', 'aBarBody');
- $this->assertArraySubset([
+ Assert::assertArraySubset([
['topic' => 'aFooTopic', 'body' => 'aFooBody'],
['topic' => 'aBarTopic', 'body' => 'aBarBody'],
], $producer->getTraces());
@@ -301,11 +297,11 @@ public function testShouldAllowGetInfoSentToSpecialTopic()
$producer->sendEvent('aFooTopic', 'aFooBody');
$producer->sendEvent('aBarTopic', 'aBarBody');
- $this->assertArraySubset([
+ Assert::assertArraySubset([
['topic' => 'aFooTopic', 'body' => 'aFooBody'],
], $producer->getTopicTraces('aFooTopic'));
- $this->assertArraySubset([
+ Assert::assertArraySubset([
['topic' => 'aBarTopic', 'body' => 'aBarBody'],
], $producer->getTopicTraces('aBarTopic'));
}
@@ -317,7 +313,7 @@ public function testShouldAllowGetInfoSentToSameCommand()
$producer->sendCommand('aFooCommand', 'aFooBody');
$producer->sendCommand('aFooCommand', 'aFooBody');
- $this->assertArraySubset([
+ Assert::assertArraySubset([
['command' => 'aFooCommand', 'body' => 'aFooBody'],
['command' => 'aFooCommand', 'body' => 'aFooBody'],
], $producer->getTraces());
@@ -330,7 +326,7 @@ public function testShouldAllowGetInfoSentToDifferentCommands()
$producer->sendCommand('aFooCommand', 'aFooBody');
$producer->sendCommand('aBarCommand', 'aBarBody');
- $this->assertArraySubset([
+ Assert::assertArraySubset([
['command' => 'aFooCommand', 'body' => 'aFooBody'],
['command' => 'aBarCommand', 'body' => 'aBarBody'],
], $producer->getTraces());
@@ -343,11 +339,11 @@ public function testShouldAllowGetInfoSentToSpecialCommand()
$producer->sendCommand('aFooCommand', 'aFooBody');
$producer->sendCommand('aBarCommand', 'aBarBody');
- $this->assertArraySubset([
+ Assert::assertArraySubset([
['command' => 'aFooCommand', 'body' => 'aFooBody'],
], $producer->getCommandTraces('aFooCommand'));
- $this->assertArraySubset([
+ Assert::assertArraySubset([
['command' => 'aBarCommand', 'body' => 'aBarBody'],
], $producer->getCommandTraces('aBarCommand'));
}
@@ -358,7 +354,7 @@ public function testShouldAllowClearStoredTraces()
$producer->sendEvent('aFooTopic', 'aFooBody');
- //guard
+ // guard
$this->assertNotEmpty($producer->getTraces());
$producer->clearTraces();
diff --git a/pkg/enqueue/Tests/ConnectionFactoryFactoryTest.php b/pkg/enqueue/Tests/ConnectionFactoryFactoryTest.php
index 3fb4fb57b..b6b5b4d67 100644
--- a/pkg/enqueue/Tests/ConnectionFactoryFactoryTest.php
+++ b/pkg/enqueue/Tests/ConnectionFactoryFactoryTest.php
@@ -37,11 +37,9 @@ public function testShouldBeFinal()
$this->assertTrue($rc->isFinal());
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new ConnectionFactoryFactory();
- }
-
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldAcceptStringDSN()
{
$factory = new ConnectionFactoryFactory();
@@ -49,6 +47,9 @@ public function testShouldAcceptStringDSN()
$factory->create('null:');
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldAcceptArrayWithDsnKey()
{
$factory = new ConnectionFactoryFactory();
@@ -157,7 +158,7 @@ public static function provideDSN()
yield ['file:', FsConnectionFactory::class];
// https://github.com/php-enqueue/enqueue-dev/issues/511
-// yield ['gearman:', GearmanConnectionFactory::class];
+ // yield ['gearman:', GearmanConnectionFactory::class];
yield ['gps:', GpsConnectionFactory::class];
diff --git a/pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php b/pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php
index f134cfe9f..86adbd3a9 100644
--- a/pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php
+++ b/pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php
@@ -18,12 +18,6 @@ public function testShouldImplementProcessorInterface()
$this->assertClassImplements(Processor::class, CallbackProcessor::class);
}
- public function testCouldBeConstructedWithCallableAsArgument()
- {
- new CallbackProcessor(function () {
- });
- }
-
public function testShouldCallCallbackAndProxyItsReturnedValue()
{
$expectedMessage = new NullMessage();
diff --git a/pkg/enqueue/Tests/Consumption/ChainExtensionTest.php b/pkg/enqueue/Tests/Consumption/ChainExtensionTest.php
index 23bd4f979..198d00012 100644
--- a/pkg/enqueue/Tests/Consumption/ChainExtensionTest.php
+++ b/pkg/enqueue/Tests/Consumption/ChainExtensionTest.php
@@ -33,11 +33,6 @@ public function testShouldImplementExtensionInterface()
$this->assertClassImplements(ExtensionInterface::class, ChainExtension::class);
}
- public function testCouldBeConstructedWithExtensionsArray()
- {
- new ChainExtension([$this->createExtension(), $this->createExtension()]);
- }
-
public function testShouldProxyOnInitLoggerToAllInternalExtensions()
{
$context = new InitLogger(new NullLogger());
diff --git a/pkg/enqueue/Tests/Consumption/Exception/IllegalContextModificationExceptionTest.php b/pkg/enqueue/Tests/Consumption/Exception/IllegalContextModificationExceptionTest.php
index 0885b500e..241f4adf9 100644
--- a/pkg/enqueue/Tests/Consumption/Exception/IllegalContextModificationExceptionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Exception/IllegalContextModificationExceptionTest.php
@@ -20,9 +20,4 @@ public function testShouldExtendLogicException()
{
$this->assertClassExtends(\LogicException::class, IllegalContextModificationException::class);
}
-
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new IllegalContextModificationException();
- }
}
diff --git a/pkg/enqueue/Tests/Consumption/Exception/InvalidArgumentExceptionTest.php b/pkg/enqueue/Tests/Consumption/Exception/InvalidArgumentExceptionTest.php
index 296c76225..c1c5db362 100644
--- a/pkg/enqueue/Tests/Consumption/Exception/InvalidArgumentExceptionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Exception/InvalidArgumentExceptionTest.php
@@ -21,11 +21,6 @@ public function testShouldExtendLogicException()
$this->assertClassExtends(\LogicException::class, InvalidArgumentException::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new InvalidArgumentException();
- }
-
public function testThrowIfAssertInstanceOfNotSameAsExpected()
{
$this->expectException(InvalidArgumentException::class);
@@ -36,6 +31,9 @@ public function testThrowIfAssertInstanceOfNotSameAsExpected()
InvalidArgumentException::assertInstanceOf(new \SplStack(), \SplQueue::class);
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldDoNothingIfAssertDestinationInstanceOfSameAsExpected()
{
InvalidArgumentException::assertInstanceOf(new \SplQueue(), \SplQueue::class);
diff --git a/pkg/enqueue/Tests/Consumption/Exception/LogicExceptionTest.php b/pkg/enqueue/Tests/Consumption/Exception/LogicExceptionTest.php
index ddd258098..2655609ae 100644
--- a/pkg/enqueue/Tests/Consumption/Exception/LogicExceptionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Exception/LogicExceptionTest.php
@@ -20,9 +20,4 @@ public function testShouldExtendLogicException()
{
$this->assertClassExtends(\LogicException::class, LogicException::class);
}
-
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new LogicException();
- }
}
diff --git a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumedMessagesExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumedMessagesExtensionTest.php
index e1d4c50cd..137e30ba4 100644
--- a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumedMessagesExtensionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumedMessagesExtensionTest.php
@@ -16,11 +16,6 @@
class LimitConsumedMessagesExtensionTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new LimitConsumedMessagesExtension(12345);
- }
-
public function testOnPreConsumeShouldInterruptWhenLimitIsReached()
{
$logger = $this->createLoggerMock();
diff --git a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php
index 5a95486ec..25ac85895 100644
--- a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php
@@ -17,11 +17,6 @@
class LimitConsumerMemoryExtensionTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new LimitConsumerMemoryExtension(12345);
- }
-
public function testShouldThrowExceptionIfMemoryLimitIsNotInt()
{
$this->expectException(\InvalidArgumentException::class);
@@ -129,7 +124,7 @@ public function testOnPreConsumeShouldNotInterruptExecutionIfMemoryLimitIsNotRea
$this->assertFalse($context->isExecutionInterrupted());
// test
- $extension = new LimitConsumerMemoryExtension(PHP_INT_MAX);
+ $extension = new LimitConsumerMemoryExtension(\PHP_INT_MAX);
$extension->onPreConsume($context);
$this->assertFalse($context->isExecutionInterrupted());
@@ -150,7 +145,7 @@ public function testOnPostConsumeShouldNotInterruptExecutionIfMemoryLimitIsNotRe
$this->assertFalse($postConsume->isExecutionInterrupted());
// test
- $extension = new LimitConsumerMemoryExtension(PHP_INT_MAX);
+ $extension = new LimitConsumerMemoryExtension(\PHP_INT_MAX);
$extension->onPostConsume($postConsume);
$this->assertFalse($postConsume->isExecutionInterrupted());
@@ -171,7 +166,7 @@ public function testOnPostMessageReceivedShouldNotInterruptExecutionIfMemoryLimi
$this->assertFalse($postReceivedMessage->isExecutionInterrupted());
// test
- $extension = new LimitConsumerMemoryExtension(PHP_INT_MAX);
+ $extension = new LimitConsumerMemoryExtension(\PHP_INT_MAX);
$extension->onPostMessageReceived($postReceivedMessage);
$this->assertFalse($postReceivedMessage->isExecutionInterrupted());
diff --git a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumptionTimeExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumptionTimeExtensionTest.php
index fa730e384..fa6cb76a1 100644
--- a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumptionTimeExtensionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumptionTimeExtensionTest.php
@@ -17,11 +17,6 @@
class LimitConsumptionTimeExtensionTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new LimitConsumptionTimeExtension(new \DateTime('+1 day'));
- }
-
public function testOnPreConsumeShouldInterruptExecutionIfConsumptionTimeExceeded()
{
$context = new PreConsume(
diff --git a/pkg/enqueue/Tests/Consumption/Extension/LogExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LogExtensionTest.php
index 4bc4ae95f..006a2c549 100644
--- a/pkg/enqueue/Tests/Consumption/Extension/LogExtensionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Extension/LogExtensionTest.php
@@ -49,11 +49,6 @@ public function testShouldImplementPostMessageReceivedExtensionInterface()
$this->assertClassImplements(PostMessageReceivedExtensionInterface::class, LogExtension::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new LogExtension();
- }
-
public function testShouldLogStartOnStart()
{
$logger = $this->createLogger();
diff --git a/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php
index f3641adf4..666892e0e 100644
--- a/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php
@@ -20,11 +20,6 @@ public function testShouldImplementInitLoggerExtensionInterface()
$this->assertClassImplements(InitLoggerExtensionInterface::class, LoggerExtension::class);
}
- public function testCouldBeConstructedWithLoggerAsFirstArgument()
- {
- new LoggerExtension($this->createLogger());
- }
-
public function testShouldSetLoggerToContextOnInitLogger()
{
$logger = $this->createLogger();
@@ -47,7 +42,7 @@ public function testShouldAddInfoMessageOnStart()
$logger
->expects($this->once())
->method('debug')
- ->with(sprintf('Change logger from "%s" to "%s"', get_class($logger), get_class($previousLogger)))
+ ->with(sprintf('Change logger from "%s" to "%s"', $logger::class, $previousLogger::class))
;
$extension = new LoggerExtension($logger);
diff --git a/pkg/enqueue/Tests/Consumption/Extension/NicenessExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/NicenessExtensionTest.php
index a2937d0ca..734bc8417 100644
--- a/pkg/enqueue/Tests/Consumption/Extension/NicenessExtensionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Extension/NicenessExtensionTest.php
@@ -11,11 +11,6 @@
class NicenessExtensionTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new NicenessExtension(0);
- }
-
public function testShouldThrowExceptionOnInvalidArgument()
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/pkg/enqueue/Tests/Consumption/Extension/ReplyExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/ReplyExtensionTest.php
index 408895638..cb65816ce 100644
--- a/pkg/enqueue/Tests/Consumption/Extension/ReplyExtensionTest.php
+++ b/pkg/enqueue/Tests/Consumption/Extension/ReplyExtensionTest.php
@@ -25,11 +25,6 @@ public function testShouldImplementPostMessageReceivedExtensionInterface()
$this->assertClassImplements(PostMessageReceivedExtensionInterface::class, ReplyExtension::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new ReplyExtension();
- }
-
public function testShouldDoNothingIfReceivedMessageNotHaveReplyToSet()
{
$extension = new ReplyExtension();
diff --git a/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php b/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php
index 62066737c..73fba7bfd 100644
--- a/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php
+++ b/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php
@@ -3,6 +3,7 @@
namespace Enqueue\Tests\Consumption;
use Enqueue\Consumption\FallbackSubscriptionConsumer;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Consumer;
use Interop\Queue\Message as InteropMessage;
use Interop\Queue\Queue as InteropQueue;
@@ -11,6 +12,8 @@
class FallbackSubscriptionConsumerTest extends TestCase
{
+ use ReadAttributeTrait;
+
public function testShouldImplementSubscriptionConsumerInterface()
{
$rc = new \ReflectionClass(FallbackSubscriptionConsumer::class);
@@ -18,11 +21,6 @@ public function testShouldImplementSubscriptionConsumerInterface()
$this->assertTrue($rc->implementsInterface(SubscriptionConsumer::class));
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new FallbackSubscriptionConsumer();
- }
-
public function testShouldInitSubscribersPropertyWithEmptyArray()
{
$subscriptionConsumer = new FallbackSubscriptionConsumer();
@@ -66,6 +64,9 @@ public function testThrowsIfTrySubscribeAnotherConsumerToAlreadySubscribedQueue(
$subscriptionConsumer->subscribe($barConsumer, $barCallback);
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldAllowSubscribeSameConsumerAndCallbackSecondTime()
{
$subscriptionConsumer = new FallbackSubscriptionConsumer();
@@ -146,34 +147,18 @@ public function testShouldConsumeMessagesFromTwoQueuesInExpectedOrder()
$fourthMessage = $this->createMessageStub('fourth');
$fifthMessage = $this->createMessageStub('fifth');
- $fooMessages = [null, $firstMessage, null, $secondMessage, $thirdMessage];
-
$fooConsumer = $this->createConsumerStub('foo_queue');
$fooConsumer
->expects($this->any())
->method('receiveNoWait')
- ->willReturnCallback(function () use (&$fooMessages) {
- if (empty($fooMessages)) {
- return null;
- }
-
- return array_shift($fooMessages);
- })
+ ->willReturnOnConsecutiveCalls(null, $firstMessage, null, $secondMessage, $thirdMessage)
;
- $barMessages = [$fourthMessage, null, null, $fifthMessage];
-
$barConsumer = $this->createConsumerStub('bar_queue');
$barConsumer
->expects($this->any())
->method('receiveNoWait')
- ->willReturnCallback(function () use (&$barMessages) {
- if (empty($barMessages)) {
- return null;
- }
-
- return array_shift($barMessages);
- })
+ ->willReturnOnConsecutiveCalls($fourthMessage, null, null, $fifthMessage)
;
$actualOrder = [];
diff --git a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php
index 9e25ab931..2bcc253e7 100644
--- a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php
+++ b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php
@@ -21,6 +21,7 @@
use Enqueue\Consumption\QueueConsumer;
use Enqueue\Consumption\Result;
use Enqueue\Null\NullQueue;
+use Enqueue\Test\ReadAttributeTrait;
use Enqueue\Tests\Consumption\Mock\BreakCycleExtension;
use Enqueue\Tests\Consumption\Mock\DummySubscriptionConsumer;
use Interop\Queue\Consumer;
@@ -36,20 +37,7 @@
class QueueConsumerTest extends TestCase
{
- public function testCouldBeConstructedWithAllArguments()
- {
- new QueueConsumer($this->createContextStub(), null, [], null, 0);
- }
-
- public function testCouldBeConstructedWithContextOnly()
- {
- new QueueConsumer($this->createContextStub());
- }
-
- public function testCouldBeConstructedWithContextAndSingleExtension()
- {
- new QueueConsumer($this->createContextStub(), $this->createExtension());
- }
+ use ReadAttributeTrait;
public function testShouldSetEmptyArrayToBoundProcessorsPropertyInConstructor()
{
@@ -177,7 +165,7 @@ public function testShouldAllowBindCallbackToQueueName()
$boundProcessors = $this->readAttribute($consumer, 'boundProcessors');
- $this->assertInternalType('array', $boundProcessors);
+ self::assertIsArray($boundProcessors);
$this->assertCount(1, $boundProcessors);
$this->assertArrayHasKey($queueName, $boundProcessors);
@@ -203,7 +191,6 @@ public function testShouldUseContextSubscriptionConsumerIfSupport()
$contextSubscriptionConsumer
->expects($this->once())
->method('consume')
- ->willReturn(null)
;
$fallbackSubscriptionConsumer = $this->createSubscriptionConsumerMock();
@@ -251,7 +238,6 @@ public function testShouldUseFallbackSubscriptionConsumerIfNotSupported()
$fallbackSubscriptionConsumer
->expects($this->once())
->method('consume')
- ->willReturn(null)
;
$contextMock = $this->createContextWithoutSubscriptionConsumerMock();
@@ -288,7 +274,6 @@ public function testShouldSubscribeToGivenQueueWithExpectedTimeout()
->expects($this->once())
->method('consume')
->with(12345)
- ->willReturn(null)
;
$contextMock = $this->createContextWithoutSubscriptionConsumerMock();
@@ -319,7 +304,6 @@ public function testShouldSubscribeToGivenQueueAndQuitAfterFifthConsumeCycle()
$subscriptionConsumerMock
->expects($this->exactly(5))
->method('consume')
- ->willReturn(null)
;
$contextMock = $this->createContextWithoutSubscriptionConsumerMock();
@@ -1471,7 +1455,7 @@ private function createContextWithoutSubscriptionConsumerMock(): InteropContext
/**
* @return \PHPUnit\Framework\MockObject\MockObject|InteropContext
*/
- private function createContextStub(Consumer $consumer = null): InteropContext
+ private function createContextStub(?Consumer $consumer = null): InteropContext
{
$context = $this->createContextWithoutSubscriptionConsumerMock();
$context
@@ -1538,6 +1522,9 @@ private function createExtension()
*/
private function createConsumerStub($queue = null): Consumer
{
+ if (null === $queue) {
+ $queue = 'queue';
+ }
if (is_string($queue)) {
$queue = new NullQueue($queue);
}
diff --git a/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php
index 7282aa42e..14f7b1006 100644
--- a/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php
+++ b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php
@@ -9,9 +9,12 @@
use Enqueue\Dbal\ManagerRegistryConnectionFactory;
use Enqueue\Doctrine\DoctrineConnectionFactoryFactory;
use PHPUnit\Framework\TestCase;
+use Prophecy\PhpUnit\ProphecyTrait;
class DoctrineConnectionFactoryFactoryTest extends TestCase
{
+ use ProphecyTrait;
+
/**
* @var ManagerRegistry|\Prophecy\Prophecy\ObjectProphecy
*/
@@ -25,7 +28,7 @@ class DoctrineConnectionFactoryFactoryTest extends TestCase
*/
private $factory;
- protected function setUp()
+ protected function setUp(): void
{
$this->registry = $this->prophesize(ManagerRegistry::class);
$this->fallbackFactory = $this->prophesize(ConnectionFactoryFactoryInterface::class);
diff --git a/pkg/enqueue/Tests/Mocks/JsonSerializableObject.php b/pkg/enqueue/Tests/Mocks/JsonSerializableObject.php
index 5b74106dc..84885c316 100644
--- a/pkg/enqueue/Tests/Mocks/JsonSerializableObject.php
+++ b/pkg/enqueue/Tests/Mocks/JsonSerializableObject.php
@@ -4,7 +4,8 @@
class JsonSerializableObject implements \JsonSerializable
{
- public function jsonSerialize()
+ #[\ReturnTypeWillChange]
+ public function jsonSerialize(): array
{
return ['foo' => 'fooVal'];
}
diff --git a/pkg/enqueue/Tests/ResourcesTest.php b/pkg/enqueue/Tests/ResourcesTest.php
index 214a0836f..ec713fd03 100644
--- a/pkg/enqueue/Tests/ResourcesTest.php
+++ b/pkg/enqueue/Tests/ResourcesTest.php
@@ -28,7 +28,7 @@ public function testShouldGetAvailableConnectionsInExpectedFormat()
{
$availableConnections = Resources::getAvailableConnections();
- $this->assertInternalType('array', $availableConnections);
+ self::assertIsArray($availableConnections);
$this->assertArrayHasKey(RedisConnectionFactory::class, $availableConnections);
$connectionInfo = $availableConnections[RedisConnectionFactory::class];
@@ -46,7 +46,7 @@ public function testShouldGetKnownConnectionsInExpectedFormat()
{
$availableConnections = Resources::getKnownConnections();
- $this->assertInternalType('array', $availableConnections);
+ self::assertIsArray($availableConnections);
$this->assertArrayHasKey(RedisConnectionFactory::class, $availableConnections);
$connectionInfo = $availableConnections[RedisConnectionFactory::class];
@@ -93,12 +93,12 @@ public function testShouldAllowRegisterConnectionThatIsNotInstalled()
Resources::addConnection('theConnectionClass', ['foo'], [], 'foo');
$knownConnections = Resources::getKnownConnections();
- $this->assertInternalType('array', $knownConnections);
+ self::assertIsArray($knownConnections);
$this->assertArrayHasKey('theConnectionClass', $knownConnections);
$availableConnections = Resources::getAvailableConnections();
- $this->assertInternalType('array', $availableConnections);
+ self::assertIsArray($availableConnections);
$this->assertArrayNotHasKey('theConnectionClass', $availableConnections);
}
@@ -115,7 +115,7 @@ public function testShouldAllowGetPreviouslyRegisteredConnection()
$availableConnections = Resources::getAvailableConnections();
- $this->assertInternalType('array', $availableConnections);
+ self::assertIsArray($availableConnections);
$this->assertArrayHasKey($connectionClass, $availableConnections);
$connectionInfo = $availableConnections[$connectionClass];
@@ -133,7 +133,7 @@ public function testShouldHaveRegisteredWampConfiguration()
{
$availableConnections = Resources::getKnownConnections();
- $this->assertInternalType('array', $availableConnections);
+ self::assertIsArray($availableConnections);
$this->assertArrayHasKey(WampConnectionFactory::class, $availableConnections);
$connectionInfo = $availableConnections[WampConnectionFactory::class];
diff --git a/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php b/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php
index 8a2e089f7..ae878fc53 100644
--- a/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php
+++ b/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php
@@ -23,11 +23,6 @@ public function testShouldImplementProcessorInterface()
$this->assertClassImplements(Processor::class, RouteRecipientListProcessor::class);
}
- public function testCouldBeConstructedWithRouterAsFirstArgument()
- {
- new RouteRecipientListProcessor($this->createRecipientListRouterMock());
- }
-
public function testShouldProduceRecipientsMessagesAndAckOriginalMessage()
{
$fooRecipient = new Recipient(new NullQueue('aName'), new NullMessage());
diff --git a/pkg/enqueue/Tests/Rpc/RpcClientTest.php b/pkg/enqueue/Tests/Rpc/RpcClientTest.php
index e2035c4d5..db4813c88 100644
--- a/pkg/enqueue/Tests/Rpc/RpcClientTest.php
+++ b/pkg/enqueue/Tests/Rpc/RpcClientTest.php
@@ -15,11 +15,6 @@
class RpcClientTest extends TestCase
{
- public function testCouldBeConstructedWithContextAsFirstArgument()
- {
- new RpcClient($this->createContextMock());
- }
-
public function testShouldSetReplyToIfNotSet()
{
$context = new NullContext();
diff --git a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php
index be7de228e..3758ca96a 100644
--- a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php
@@ -22,6 +22,7 @@
use Interop\Queue\Queue;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
@@ -39,16 +40,22 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(ConsumeCommand::class);
}
- public function testCouldBeConstructedWithRequiredAttributes()
+ public function testShouldHaveAsCommandAttributeWithCommandName()
{
- new ConsumeCommand($this->createMock(ContainerInterface::class), 'default');
- }
+ $commandClass = ConsumeCommand::class;
- public function testShouldHaveCommandName()
- {
- $command = new ConsumeCommand($this->createMock(ContainerInterface::class), 'default');
+ $reflectionClass = new \ReflectionClass($commandClass);
+
+ $attributes = $reflectionClass->getAttributes(AsCommand::class);
- $this->assertEquals('enqueue:consume', $command->getName());
+ $this->assertNotEmpty($attributes, 'The command does not have the AsCommand attribute.');
+
+ // Get the first attribute instance (assuming there is only one AsCommand attribute)
+ $asCommandAttribute = $attributes[0];
+
+ // Verify the 'name' parameter value
+ $attributeInstance = $asCommandAttribute->newInstance();
+ $this->assertEquals('enqueue:consume', $attributeInstance->name, 'The command name is not set correctly in the AsCommand attribute.');
}
public function testShouldHaveExpectedOptions()
@@ -605,13 +612,13 @@ private function createQueueConsumerMock()
/**
* @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface
*/
- private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface
+ private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface
{
$driverMock = $this->createMock(DriverInterface::class);
$driverMock
->expects($this->any())
->method('getRouteCollection')
- ->willReturn($routeCollection)
+ ->willReturn($routeCollection ?? new RouteCollection([]))
;
$driverMock
@@ -641,7 +648,7 @@ private function createContextWithoutSubscriptionConsumerMock(): InteropContext
/**
* @return \PHPUnit\Framework\MockObject\MockObject|InteropContext
*/
- private function createContextStub(Consumer $consumer = null): InteropContext
+ private function createContextStub(?Consumer $consumer = null): InteropContext
{
$context = $this->createContextWithoutSubscriptionConsumerMock();
$context
@@ -677,6 +684,9 @@ private function createExtension()
*/
private function createConsumerStub($queue = null): Consumer
{
+ if (null === $queue) {
+ $queue = 'queue';
+ }
if (is_string($queue)) {
$queue = new NullQueue($queue);
}
diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPassTest.php
index 8dcffe45a..568de6488 100644
--- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPassTest.php
@@ -23,11 +23,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(AnalyzeRouteCollectionPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new AnalyzeRouteCollectionPass();
- }
-
public function testThrowIfEnqueueClientsParameterNotSet()
{
$pass = new AnalyzeRouteCollectionPass();
diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php
index af69293d1..753790369 100644
--- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php
@@ -25,11 +25,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(BuildClientExtensionsPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new BuildClientExtensionsPass();
- }
-
public function testThrowIfEnqueueClientsParameterNotSet()
{
$pass = new BuildClientExtensionsPass();
@@ -72,7 +67,7 @@ public function testShouldRegisterClientExtension()
$pass = new BuildClientExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
new Reference('aBarExtension'),
@@ -99,7 +94,7 @@ public function testShouldIgnoreOtherClientExtensions()
$pass = new BuildClientExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $extensions->getArgument(0));
@@ -125,7 +120,7 @@ public function testShouldAddExtensionIfClientAll()
$pass = new BuildClientExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $extensions->getArgument(0));
@@ -151,7 +146,7 @@ public function testShouldTreatTagsWithoutClientAsDefaultClient()
$pass = new BuildClientExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
new Reference('aBarExtension'),
@@ -247,7 +242,7 @@ public function testShouldMergeWithAddedPreviously()
$pass = new BuildClientExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertCount(4, $extensions->getArgument(0));
}
@@ -275,12 +270,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingExtensi
$pass = new BuildClientExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $fooExtensions->getArgument(0));
+ self::assertIsArray($fooExtensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $fooExtensions->getArgument(0));
- $this->assertInternalType('array', $barExtensions->getArgument(0));
+ self::assertIsArray($barExtensions->getArgument(0));
$this->assertEquals([
new Reference('aBarExtension'),
], $barExtensions->getArgument(0));
diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php
index 346c0cbdb..e1ed297c6 100644
--- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php
@@ -29,11 +29,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(BuildCommandSubscriberRoutesPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new BuildCommandSubscriberRoutesPass();
- }
-
public function testThrowIfEnqueueClientsParameterNotSet()
{
$pass = new BuildCommandSubscriberRoutesPass();
@@ -96,7 +91,7 @@ public function testShouldRegisterProcessorWithMatchedName()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -120,7 +115,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -144,7 +139,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -159,14 +154,14 @@ public function testShouldRegisterProcessorIfCommandsIsString()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.command_subscriber')
;
$pass = new BuildCommandSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -193,7 +188,7 @@ public function testThrowIfCommandSubscriberReturnsNothing()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.command_subscriber')
;
@@ -215,14 +210,14 @@ public function testShouldRegisterProcessorIfCommandsAreStrings()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.command_subscriber')
;
$pass = new BuildCommandSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(2, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -259,14 +254,14 @@ public function testShouldRegisterProcessorIfParamSingleCommandArray()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.command_subscriber')
;
$pass = new BuildCommandSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
@@ -298,14 +293,14 @@ public function testShouldRegisterProcessorIfCommandsAreParamArrays()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.command_subscriber')
;
$pass = new BuildCommandSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(2, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -340,7 +335,7 @@ public function testThrowIfCommandSubscriberParamsInvalid()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.command_subscriber')
;
@@ -365,14 +360,14 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.command_subscriber')
;
$pass = new BuildCommandSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(3, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -415,14 +410,14 @@ public function testShouldRegister08CommandProcessor()
$container->setParameter('enqueue.clients', ['default']);
$container->setParameter('enqueue.default_client', 'default');
$container->setDefinition('enqueue.client.default.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.command_subscriber')
;
$pass = new BuildCommandSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -443,11 +438,12 @@ public function testShouldRegister08CommandProcessor()
private function createCommandSubscriberProcessor($commandSubscriberReturns = ['aCommand'])
{
- $processor = new class() implements Processor, CommandSubscriberInterface {
+ $processor = new class implements Processor, CommandSubscriberInterface {
public static $return;
public function process(InteropMessage $message, Context $context)
{
+ return self::ACK;
}
public static function getSubscribedCommand()
diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php
index db991e982..c2975051b 100644
--- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php
@@ -25,11 +25,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(BuildConsumptionExtensionsPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new BuildConsumptionExtensionsPass();
- }
-
public function testThrowIfEnqueueClientsParameterNotSet()
{
$pass = new BuildConsumptionExtensionsPass();
@@ -72,7 +67,7 @@ public function testShouldRegisterClientExtension()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
new Reference('aBarExtension'),
@@ -99,7 +94,7 @@ public function testShouldIgnoreOtherClientExtensions()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $extensions->getArgument(0));
@@ -125,7 +120,7 @@ public function testShouldAddExtensionIfClientAll()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $extensions->getArgument(0));
@@ -151,7 +146,7 @@ public function testShouldTreatTagsWithoutClientAsDefaultClient()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
new Reference('aBarExtension'),
@@ -247,7 +242,7 @@ public function testShouldMergeWithAddedPreviously()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertCount(4, $extensions->getArgument(0));
}
@@ -275,12 +270,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingExtensi
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $fooExtensions->getArgument(0));
+ self::assertIsArray($fooExtensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $fooExtensions->getArgument(0));
- $this->assertInternalType('array', $barExtensions->getArgument(0));
+ self::assertIsArray($barExtensions->getArgument(0));
$this->assertEquals([
new Reference('aBarExtension'),
], $barExtensions->getArgument(0));
diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRegistryPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRegistryPassTest.php
index 4d95ca07d..5c9ac4840 100644
--- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRegistryPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRegistryPassTest.php
@@ -26,11 +26,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(BuildProcessorRegistryPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new BuildProcessorRegistryPass();
- }
-
public function testThrowIfEnqueueClientsParameterNotSet()
{
$pass = new BuildProcessorRegistryPass();
@@ -136,7 +131,7 @@ private function assertLocatorServices(ContainerBuilder $container, $locatorId,
$locatorId = (string) $locatorId;
$this->assertTrue($container->hasDefinition($locatorId));
- $this->assertRegExp('/\.?service_locator\..*?\.enqueue\./', $locatorId);
+ $this->assertMatchesRegularExpression('/\.?service_locator\..*?\.enqueue\./', $locatorId);
$match = [];
if (false == preg_match('/(\.?service_locator\..*?)\.enqueue\./', $locatorId, $match)) {
diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php
index 74553e6eb..0351c45f5 100644
--- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php
@@ -25,11 +25,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(BuildProcessorRoutesPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new BuildProcessorRoutesPass();
- }
-
public function testThrowIfEnqueueClientsParameterNotSet()
{
$pass = new BuildProcessorRoutesPass();
@@ -112,7 +107,7 @@ public function testShouldRegisterProcessorWithMatchedName()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -136,7 +131,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -160,7 +155,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -180,7 +175,7 @@ public function testShouldRegisterAsTopicProcessor()
$pass = new BuildProcessorRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -212,7 +207,7 @@ public function testShouldRegisterAsCommandProcessor()
$pass = new BuildProcessorRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -244,7 +239,7 @@ public function testShouldRegisterWithCustomProcessorName()
$pass = new BuildProcessorRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -279,7 +274,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection()
$pass = new BuildProcessorRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(3, $routeCollection->getArgument(0));
$this->assertEquals(
diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php
index 65b64dcc8..a954d9a41 100644
--- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php
@@ -29,11 +29,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(BuildTopicSubscriberRoutesPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new BuildTopicSubscriberRoutesPass();
- }
-
public function testThrowIfEnqueueClientsParameterNotSet()
{
$pass = new BuildTopicSubscriberRoutesPass();
@@ -96,7 +91,7 @@ public function testShouldRegisterProcessorWithMatchedName()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -120,7 +115,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -144,7 +139,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll()
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
}
@@ -159,14 +154,14 @@ public function testShouldRegisterProcessorIfTopicsIsString()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.topic_subscriber')
;
$pass = new BuildTopicSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(1, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -193,7 +188,7 @@ public function testThrowIfTopicSubscriberReturnsNothing()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.topic_subscriber')
;
@@ -215,14 +210,14 @@ public function testShouldRegisterProcessorIfTopicsAreStrings()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.topic_subscriber')
;
$pass = new BuildTopicSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(2, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -258,14 +253,14 @@ public function testShouldRegisterProcessorIfTopicsAreParamArrays()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.topic_subscriber')
;
$pass = new BuildTopicSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(2, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -300,7 +295,7 @@ public function testThrowIfTopicSubscriberParamsInvalid()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.topic_subscriber')
;
@@ -325,14 +320,14 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection()
$container->setParameter('enqueue.clients', ['foo']);
$container->setParameter('enqueue.default_client', 'foo');
$container->setDefinition('enqueue.client.foo.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.topic_subscriber')
;
$pass = new BuildTopicSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(3, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -372,14 +367,14 @@ public function testShouldRegister08TopicSubscriber()
$container->setParameter('enqueue.clients', ['default']);
$container->setParameter('enqueue.default_client', 'default');
$container->setDefinition('enqueue.client.default.route_collection', $routeCollection);
- $container->register('aFooProcessor', get_class($processor))
+ $container->register('aFooProcessor', $processor::class)
->addTag('enqueue.topic_subscriber')
;
$pass = new BuildTopicSubscriberRoutesPass();
$pass->process($container);
- $this->assertInternalType('array', $routeCollection->getArgument(0));
+ self::assertIsArray($routeCollection->getArgument(0));
$this->assertCount(2, $routeCollection->getArgument(0));
$this->assertEquals(
@@ -407,11 +402,12 @@ public function testShouldRegister08TopicSubscriber()
private function createTopicSubscriberProcessor($topicSubscriberReturns = ['aTopic'])
{
- $processor = new class() implements Processor, TopicSubscriberInterface {
+ $processor = new class implements Processor, TopicSubscriberInterface {
public static $return;
public function process(InteropMessage $message, Context $context)
{
+ return self::ACK;
}
public static function getSubscribedTopics()
diff --git a/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php b/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php
index e7ca3ffd5..539d332ee 100644
--- a/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php
@@ -23,7 +23,7 @@ public function testShouldSubscribeOnKernelTerminateEvent()
{
$events = FlushSpoolProducerListener::getSubscribedEvents();
- $this->assertInternalType('array', $events);
+ self::assertIsArray($events);
$this->assertArrayHasKey(KernelEvents::TERMINATE, $events);
$this->assertEquals('flushMessages', $events[KernelEvents::TERMINATE]);
@@ -33,17 +33,12 @@ public function testShouldSubscribeOnConsoleTerminateEvent()
{
$events = FlushSpoolProducerListener::getSubscribedEvents();
- $this->assertInternalType('array', $events);
+ self::assertIsArray($events);
$this->assertArrayHasKey(ConsoleEvents::TERMINATE, $events);
$this->assertEquals('flushMessages', $events[ConsoleEvents::TERMINATE]);
}
- public function testCouldBeConstructedWithSpoolProducerAsFirstArgument()
- {
- new FlushSpoolProducerListener($this->createSpoolProducerMock());
- }
-
public function testShouldFlushSpoolProducerOnFlushMessagesCall()
{
$producerMock = $this->createSpoolProducerMock();
diff --git a/pkg/enqueue/Tests/Symfony/Client/ProduceCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ProduceCommandTest.php
index 0dffc3d42..daa909175 100644
--- a/pkg/enqueue/Tests/Symfony/Client/ProduceCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/ProduceCommandTest.php
@@ -9,6 +9,7 @@
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
@@ -26,16 +27,22 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(ProduceCommand::class);
}
- public function testCouldBeConstructedWithContainerAsFirstArgument()
+ public function testShouldHaveAsCommandAttributeWithCommandName()
{
- new ProduceCommand($this->createMock(ContainerInterface::class), 'default');
- }
+ $commandClass = ProduceCommand::class;
- public function testShouldHaveCommandName()
- {
- $command = new ProduceCommand($this->createMock(ContainerInterface::class), 'default');
+ $reflectionClass = new \ReflectionClass($commandClass);
+
+ $attributes = $reflectionClass->getAttributes(AsCommand::class);
+
+ $this->assertNotEmpty($attributes, 'The command does not have the AsCommand attribute.');
+
+ // Get the first attribute instance (assuming there is only one AsCommand attribute)
+ $asCommandAttribute = $attributes[0];
- $this->assertEquals('enqueue:produce', $command->getName());
+ // Verify the 'name' parameter value
+ $attributeInstance = $asCommandAttribute->newInstance();
+ $this->assertEquals('enqueue:produce', $attributeInstance->name, 'The command name is not set correctly in the AsCommand attribute.');
}
public function testShouldHaveExpectedOptions()
diff --git a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php
index d9935bdf4..89bd7f745 100644
--- a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php
@@ -11,6 +11,7 @@
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
@@ -28,16 +29,22 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(RoutesCommand::class);
}
- public function testCouldBeConstructedWithConfigAndRouteCollectionAsArguments()
+ public function testShouldHaveAsCommandAttributeWithCommandName()
{
- new RoutesCommand($this->createMock(ContainerInterface::class), 'default');
- }
+ $commandClass = RoutesCommand::class;
- public function testShouldHaveCommandName()
- {
- $command = new RoutesCommand($this->createMock(ContainerInterface::class), 'default');
+ $reflectionClass = new \ReflectionClass($commandClass);
+
+ $attributes = $reflectionClass->getAttributes(AsCommand::class);
+
+ $this->assertNotEmpty($attributes, 'The command does not have the AsCommand attribute.');
+
+ // Get the first attribute instance (assuming there is only one AsCommand attribute)
+ $asCommandAttribute = $attributes[0];
- $this->assertEquals('enqueue:routes', $command->getName());
+ // Verify the 'name' parameter value
+ $attributeInstance = $asCommandAttribute->newInstance();
+ $this->assertEquals('enqueue:routes', $attributeInstance->name, 'The command name is not set correctly in the AsCommand attribute.');
}
public function testShouldHaveCommandAliases()
@@ -116,7 +123,7 @@ public function testShouldUseFooDriver()
'--client' => 'foo',
]);
- $this->assertContains('Found 1 routes', $tester->getDisplay());
+ $this->assertStringContainsString('Found 1 routes', $tester->getDisplay());
}
public function testThrowIfClientNotFound()
@@ -331,7 +338,7 @@ public function testShouldOutputRouteOptions()
}
/**
- * @return \PHPUnit\Framework\MockObject\MockObject
+ * @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface
*/
private function createDriverStub(Config $config, RouteCollection $routeCollection): DriverInterface
{
diff --git a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php
index 358206dc7..c81c4e1b6 100644
--- a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php
@@ -8,6 +8,7 @@
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
@@ -25,16 +26,22 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(SetupBrokerCommand::class);
}
- public function testCouldBeConstructedWithContainerAsFirstArgument()
+ public function testShouldHaveAsCommandAttributeWithCommandName()
{
- new SetupBrokerCommand($this->createMock(ContainerInterface::class), 'default');
- }
+ $commandClass = SetupBrokerCommand::class;
- public function testShouldHaveCommandName()
- {
- $command = new SetupBrokerCommand($this->createMock(ContainerInterface::class), 'default');
+ $reflectionClass = new \ReflectionClass($commandClass);
+
+ $attributes = $reflectionClass->getAttributes(AsCommand::class);
+
+ $this->assertNotEmpty($attributes, 'The command does not have the AsCommand attribute.');
+
+ // Get the first attribute instance (assuming there is only one AsCommand attribute)
+ $asCommandAttribute = $attributes[0];
- $this->assertEquals('enqueue:setup-broker', $command->getName());
+ // Verify the 'name' parameter value
+ $attributeInstance = $asCommandAttribute->newInstance();
+ $this->assertEquals('enqueue:setup-broker', $attributeInstance->name, 'The command name is not set correctly in the AsCommand attribute.');
}
public function testShouldHaveCommandAliases()
@@ -78,7 +85,7 @@ public function testShouldCallDriverSetupBrokerMethod()
$tester = new CommandTester($command);
$tester->execute([]);
- $this->assertContains('Broker set up', $tester->getDisplay());
+ $this->assertStringContainsString('Broker set up', $tester->getDisplay());
}
public function testShouldCallRequestedClientDriverSetupBrokerMethod()
@@ -105,7 +112,7 @@ public function testShouldCallRequestedClientDriverSetupBrokerMethod()
'--client' => 'foo',
]);
- $this->assertContains('Broker set up', $tester->getDisplay());
+ $this->assertStringContainsString('Broker set up', $tester->getDisplay());
}
public function testShouldThrowIfClientNotFound()
diff --git a/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php
index 8f23acdbc..21c491eb5 100644
--- a/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php
@@ -29,18 +29,6 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(SimpleConsumeCommand::class);
}
- public function testCouldBeConstructedWithRequiredAttributes()
- {
- new SimpleConsumeCommand($this->createQueueConsumerMock(), $this->createDriverStub(), $this->createDelegateProcessorMock());
- }
-
- public function testShouldHaveCommandName()
- {
- $command = new SimpleConsumeCommand($this->createQueueConsumerMock(), $this->createDriverStub(), $this->createDelegateProcessorMock());
-
- $this->assertEquals('enqueue:consume', $command->getName());
- }
-
public function testShouldHaveExpectedOptions()
{
$command = new SimpleConsumeCommand($this->createQueueConsumerMock(), $this->createDriverStub(), $this->createDelegateProcessorMock());
@@ -122,13 +110,13 @@ private function createQueueConsumerMock()
/**
* @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface
*/
- private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface
+ private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface
{
$driverMock = $this->createMock(DriverInterface::class);
$driverMock
->expects($this->any())
->method('getRouteCollection')
- ->willReturn($routeCollection)
+ ->willReturn($routeCollection ?? new RouteCollection([]))
;
$driverMock
diff --git a/pkg/enqueue/Tests/Symfony/Client/SimpleProduceCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SimpleProduceCommandTest.php
index 71ac20f38..3ff81bfd5 100644
--- a/pkg/enqueue/Tests/Symfony/Client/SimpleProduceCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/SimpleProduceCommandTest.php
@@ -23,18 +23,6 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(SimpleProduceCommand::class);
}
- public function testCouldBeConstructedWithContainerAsFirstArgument()
- {
- new SimpleProduceCommand($this->createProducerMock());
- }
-
- public function testShouldHaveCommandName()
- {
- $command = new SimpleProduceCommand($this->createProducerMock());
-
- $this->assertEquals('enqueue:produce', $command->getName());
- }
-
public function testShouldHaveExpectedOptions()
{
$command = new SimpleProduceCommand($this->createProducerMock());
diff --git a/pkg/enqueue/Tests/Symfony/Client/SimpleRoutesCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SimpleRoutesCommandTest.php
index 469334b02..20ee454cc 100644
--- a/pkg/enqueue/Tests/Symfony/Client/SimpleRoutesCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/SimpleRoutesCommandTest.php
@@ -25,18 +25,6 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(SimpleRoutesCommand::class);
}
- public function testCouldBeConstructedWithConfigAndRouteCollectionAsArguments()
- {
- new SimpleRoutesCommand($this->createDriverMock());
- }
-
- public function testShouldHaveCommandName()
- {
- $command = new SimpleRoutesCommand($this->createDriverMock());
-
- $this->assertEquals('enqueue:routes', $command->getName());
- }
-
public function testShouldHaveCommandAliases()
{
$command = new SimpleRoutesCommand($this->createDriverMock());
diff --git a/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php
index 0d30582e1..3702dbf18 100644
--- a/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php
@@ -23,18 +23,6 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(SimpleSetupBrokerCommand::class);
}
- public function testCouldBeConstructedWithContainerAsFirstArgument()
- {
- new SimpleSetupBrokerCommand($this->createClientDriverMock());
- }
-
- public function testShouldHaveCommandName()
- {
- $command = new SimpleSetupBrokerCommand($this->createClientDriverMock());
-
- $this->assertEquals('enqueue:setup-broker', $command->getName());
- }
-
public function testShouldHaveCommandAliases()
{
$command = new SimpleSetupBrokerCommand($this->createClientDriverMock());
@@ -74,7 +62,7 @@ public function testShouldCallDriverSetupBrokerMethod()
$tester = new CommandTester($command);
$tester->execute([]);
- $this->assertContains('Broker set up', $tester->getDisplay());
+ $this->assertStringContainsString('Broker set up', $tester->getDisplay());
}
/**
diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php
index c788d5e75..251e264e2 100644
--- a/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php
@@ -15,6 +15,7 @@
use Interop\Queue\Queue as InteropQueue;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
@@ -32,16 +33,22 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(ConfigurableConsumeCommand::class);
}
- public function testCouldBeConstructedWithRequiredAttributes()
+ public function testShouldHaveAsCommandAttributeWithCommandName()
{
- new ConfigurableConsumeCommand($this->createMock(ContainerInterface::class), 'default');
- }
+ $commandClass = ConfigurableConsumeCommand::class;
- public function testShouldHaveCommandName()
- {
- $command = new ConfigurableConsumeCommand($this->createMock(ContainerInterface::class), 'default');
+ $reflectionClass = new \ReflectionClass($commandClass);
+
+ $attributes = $reflectionClass->getAttributes(AsCommand::class);
+
+ $this->assertNotEmpty($attributes, 'The command does not have the AsCommand attribute.');
+
+ // Get the first attribute instance (assuming there is only one AsCommand attribute)
+ $asCommandAttribute = $attributes[0];
- $this->assertEquals('enqueue:transport:consume', $command->getName());
+ // Verify the 'name' parameter value
+ $attributeInstance = $asCommandAttribute->newInstance();
+ $this->assertEquals('enqueue:transport:consume', $attributeInstance->name, 'The command name is not set correctly in the AsCommand attribute.');
}
public function testShouldHaveExpectedOptions()
@@ -192,8 +199,8 @@ public function testShouldExecuteConsumptionWithSeveralCustomQueues()
public function testShouldExecuteConsumptionWhenProcessorImplementsQueueSubscriberInterface()
{
- $processor = new class() implements Processor, QueueSubscriberInterface {
- public function process(InteropMessage $message, Context $context)
+ $processor = new class implements Processor, QueueSubscriberInterface {
+ public function process(InteropMessage $message, Context $context): void
{
}
diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php
index c2f2257c0..f07bef03b 100644
--- a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php
@@ -17,6 +17,7 @@
use Interop\Queue\Queue;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
@@ -34,16 +35,22 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(ConsumeCommand::class);
}
- public function testCouldBeConstructedWithRequiredAttributes()
+ public function testShouldHaveAsCommandAttributeWithCommandName()
{
- new ConsumeCommand($this->createMock(ContainerInterface::class), 'default');
- }
+ $commandClass = ConsumeCommand::class;
- public function testShouldHaveCommandName()
- {
- $command = new ConsumeCommand($this->createMock(ContainerInterface::class), 'default');
+ $reflectionClass = new \ReflectionClass($commandClass);
+
+ $attributes = $reflectionClass->getAttributes(AsCommand::class);
- $this->assertEquals('enqueue:transport:consume', $command->getName());
+ $this->assertNotEmpty($attributes, 'The command does not have the AsCommand attribute.');
+
+ // Get the first attribute instance (assuming there is only one AsCommand attribute)
+ $asCommandAttribute = $attributes[0];
+
+ // Verify the 'name' parameter value
+ $attributeInstance = $asCommandAttribute->newInstance();
+ $this->assertEquals('enqueue:transport:consume', $attributeInstance->name, 'The command name is not set correctly in the AsCommand attribute.');
}
public function testShouldHaveExpectedOptions()
@@ -185,7 +192,7 @@ private function createContextWithoutSubscriptionConsumerMock(): InteropContext
/**
* @return \PHPUnit\Framework\MockObject\MockObject|InteropContext
*/
- private function createContextStub(Consumer $consumer = null): InteropContext
+ private function createContextStub(?Consumer $consumer = null): InteropContext
{
$context = $this->createContextWithoutSubscriptionConsumerMock();
$context
@@ -221,6 +228,9 @@ private function createExtension()
*/
private function createConsumerStub($queue = null): Consumer
{
+ if (null === $queue) {
+ $queue = 'queue';
+ }
if (is_string($queue)) {
$queue = new NullQueue($queue);
}
diff --git a/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php b/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php
index e92912355..f47a32161 100644
--- a/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php
+++ b/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php
@@ -109,8 +109,6 @@ public function testShouldAddThreeLimitExtensions()
}
/**
- * @param mixed $inputValue
- * @param bool $enabled
* @dataProvider provideNicenessValues
*/
public function testShouldAddNicenessExtension($inputValue, bool $enabled)
diff --git a/pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php b/pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php
index 56b3c9319..a210b0e6b 100644
--- a/pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php
+++ b/pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php
@@ -11,6 +11,7 @@ class QueueSubscriberProcessor implements Processor, QueueSubscriberInterface
{
public function process(InteropMessage $message, Context $context)
{
+ return self::ACK;
}
public static function getSubscribedQueues()
diff --git a/pkg/enqueue/Tests/Symfony/Consumption/SimpleConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/SimpleConsumeCommandTest.php
index 19b9d76f8..eeb38bf19 100644
--- a/pkg/enqueue/Tests/Symfony/Consumption/SimpleConsumeCommandTest.php
+++ b/pkg/enqueue/Tests/Symfony/Consumption/SimpleConsumeCommandTest.php
@@ -24,18 +24,6 @@ public function testShouldNotBeFinal()
$this->assertClassNotFinal(SimpleConsumeCommand::class);
}
- public function testCouldBeConstructedWithRequiredAttributes()
- {
- new SimpleConsumeCommand($this->createQueueConsumerMock());
- }
-
- public function testShouldHaveCommandName()
- {
- $command = new SimpleConsumeCommand($this->createQueueConsumerMock());
-
- $this->assertEquals('enqueue:transport:consume', $command->getName());
- }
-
public function testShouldHaveExpectedOptions()
{
$command = new SimpleConsumeCommand($this->createQueueConsumerMock());
diff --git a/pkg/enqueue/Tests/Symfony/ContainerProcessorRegistryTest.php b/pkg/enqueue/Tests/Symfony/ContainerProcessorRegistryTest.php
index bf6e3cd01..5504e8ef6 100644
--- a/pkg/enqueue/Tests/Symfony/ContainerProcessorRegistryTest.php
+++ b/pkg/enqueue/Tests/Symfony/ContainerProcessorRegistryTest.php
@@ -23,11 +23,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(ContainerProcessorRegistry::class);
}
- public function testCouldBeConstructedWithContainerAsFirstArgument()
- {
- new ContainerProcessorRegistry($this->createContainerMock());
- }
-
public function testShouldAllowGetProcessor()
{
$processorMock = $this->createProcessorMock();
@@ -69,7 +64,11 @@ public function testThrowErrorIfServiceDoesNotImplementProcessorReturnType()
$registry = new ContainerProcessorRegistry($containerMock);
$this->expectException(\TypeError::class);
- $this->expectExceptionMessage('Return value of Enqueue\Symfony\ContainerProcessorRegistry::get() must implement interface Interop\Queue\Processor, instance of stdClass returned');
+ // Exception messages vary slightly between versions
+ $this->expectExceptionMessageMatches(
+ '/Enqueue\\\\Symfony\\\\ContainerProcessorRegistry::get\(\).+ Interop\\\\Queue\\\\Processor,.*stdClass returned/'
+ );
+
$registry->get('processor-name');
}
diff --git a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php
index b26b4481f..bdccd338c 100644
--- a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php
@@ -25,11 +25,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(BuildConsumptionExtensionsPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new BuildConsumptionExtensionsPass();
- }
-
public function testThrowIfEnqueueTransportsParameterNotSet()
{
$pass = new BuildConsumptionExtensionsPass();
@@ -72,7 +67,7 @@ public function testShouldRegisterTransportExtension()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
new Reference('aBarExtension'),
@@ -99,7 +94,7 @@ public function testShouldIgnoreOtherTransportExtensions()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $extensions->getArgument(0));
@@ -125,7 +120,7 @@ public function testShouldAddExtensionIfTransportAll()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $extensions->getArgument(0));
@@ -151,7 +146,7 @@ public function testShouldTreatTagsWithoutTransportAsDefaultTransport()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
new Reference('aBarExtension'),
@@ -247,7 +242,7 @@ public function testShouldMergeWithAddedPreviously()
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $extensions->getArgument(0));
+ self::assertIsArray($extensions->getArgument(0));
$this->assertCount(4, $extensions->getArgument(0));
}
@@ -275,12 +270,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingRegistr
$pass = new BuildConsumptionExtensionsPass();
$pass->process($container);
- $this->assertInternalType('array', $fooExtensions->getArgument(0));
+ self::assertIsArray($fooExtensions->getArgument(0));
$this->assertEquals([
new Reference('aFooExtension'),
], $fooExtensions->getArgument(0));
- $this->assertInternalType('array', $barExtensions->getArgument(0));
+ self::assertIsArray($barExtensions->getArgument(0));
$this->assertEquals([
new Reference('aBarExtension'),
], $barExtensions->getArgument(0));
diff --git a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildProcessorRegistryPassTest.php b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildProcessorRegistryPassTest.php
index 989d048cf..134c216dc 100644
--- a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildProcessorRegistryPassTest.php
+++ b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildProcessorRegistryPassTest.php
@@ -26,11 +26,6 @@ public function testShouldBeFinal()
$this->assertClassFinal(BuildProcessorRegistryPass::class);
}
- public function testCouldBeConstructedWithoutArguments()
- {
- new BuildProcessorRegistryPass();
- }
-
public function testThrowIfEnqueueTransportsParameterNotSet()
{
$pass = new BuildProcessorRegistryPass();
@@ -199,7 +194,7 @@ private function assertLocatorServices(ContainerBuilder $container, $locatorId,
$locatorId = (string) $locatorId;
$this->assertTrue($container->hasDefinition($locatorId));
- $this->assertRegExp('/\.?service_locator\..*?\.enqueue\./', $locatorId);
+ $this->assertMatchesRegularExpression('/\.?service_locator\..*?\.enqueue\./', $locatorId);
$match = [];
if (false == preg_match('/(\.?service_locator\..*?)\.enqueue\./', $locatorId, $match)) {
diff --git a/pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php b/pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php
index 68868716b..909407452 100644
--- a/pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php
+++ b/pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php
@@ -148,7 +148,7 @@ public function testThrowIfFactoryClassAndFactoryServiceSetAtTheSameTime()
'dsn' => 'foo:',
'factory_class' => 'aFactoryClass',
'factory_service' => 'aFactoryService',
- ], ]]);
+ ], ]]);
}
public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTime()
@@ -166,7 +166,7 @@ public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTi
'dsn' => 'foo:',
'connection_factory_class' => 'aFactoryClass',
'factory_service' => 'aFactoryService',
- ], ]]);
+ ], ]]);
}
public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSameTime()
@@ -183,7 +183,7 @@ public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSame
'dsn' => 'foo:',
'connection_factory_class' => 'aFactoryClass',
'factory_service' => 'aFactoryService',
- ], ]]);
+ ], ]]);
}
public function testShouldAllowSetFactoryClass()
@@ -197,7 +197,7 @@ public function testShouldAllowSetFactoryClass()
'transport' => [
'dsn' => 'foo:',
'factory_class' => 'theFactoryClass',
- ], ]]);
+ ], ]]);
$this->assertArrayHasKey('factory_class', $config['transport']);
$this->assertSame('theFactoryClass', $config['transport']['factory_class']);
@@ -214,7 +214,7 @@ public function testShouldAllowSetFactoryService()
'transport' => [
'dsn' => 'foo:',
'factory_service' => 'theFactoryService',
- ], ]]);
+ ], ]]);
$this->assertArrayHasKey('factory_service', $config['transport']);
$this->assertSame('theFactoryService', $config['transport']['factory_service']);
@@ -231,7 +231,7 @@ public function testShouldAllowSetConnectionFactoryClass()
'transport' => [
'dsn' => 'foo:',
'connection_factory_class' => 'theFactoryClass',
- ], ]]);
+ ], ]]);
$this->assertArrayHasKey('connection_factory_class', $config['transport']);
$this->assertSame('theFactoryClass', $config['transport']['connection_factory_class']);
@@ -259,7 +259,14 @@ public function testShouldBuildConnectionFactoryFromDSN()
$transport = new TransportFactory('default');
- $transport->buildConnectionFactory($container, ['dsn' => 'foo://bar/baz']);
+ $config = [
+ 'dsn' => 'foo://bar/baz',
+ 'connection_factory_class' => null,
+ 'factory_service' => null,
+ 'factory_class' => null,
+ ];
+
+ $transport->buildConnectionFactory($container, $config);
$this->assertTrue($container->hasDefinition('enqueue.transport.default.connection_factory'));
diff --git a/pkg/enqueue/Tests/Symfony/LazyProducerTest.php b/pkg/enqueue/Tests/Symfony/LazyProducerTest.php
index 1b15ce2ce..c8ba596a8 100644
--- a/pkg/enqueue/Tests/Symfony/LazyProducerTest.php
+++ b/pkg/enqueue/Tests/Symfony/LazyProducerTest.php
@@ -20,11 +20,6 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(ProducerInterface::class, LazyProducer::class);
}
- public function testCouldBeConstructedWithContainerAndServiceId()
- {
- new LazyProducer($this->createContainerMock(), 'realProducerId');
- }
-
public function testShouldNotCallRealProducerInConstructor()
{
$containerMock = $this->createContainerMock();
diff --git a/pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php b/pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php
index b612978e7..1a77ce0cf 100644
--- a/pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php
+++ b/pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php
@@ -6,7 +6,8 @@ class JsonSerializableClass implements \JsonSerializable
{
public $keyPublic = 'public';
- public function jsonSerialize()
+ #[\ReturnTypeWillChange]
+ public function jsonSerialize(): array
{
return [
'key' => 'value',
diff --git a/pkg/enqueue/Tests/Util/JSONTest.php b/pkg/enqueue/Tests/Util/JSONTest.php
index a6f583387..1a3df4211 100644
--- a/pkg/enqueue/Tests/Util/JSONTest.php
+++ b/pkg/enqueue/Tests/Util/JSONTest.php
@@ -39,8 +39,6 @@ public function nonStringDataProvider()
/**
* @dataProvider nonStringDataProvider
- *
- * @param mixed $value
*/
public function testShouldThrowExceptionIfInputIsNotString($value)
{
diff --git a/pkg/enqueue/Tests/Util/UUIDTest.php b/pkg/enqueue/Tests/Util/UUIDTest.php
index ac3090315..f21693e78 100644
--- a/pkg/enqueue/Tests/Util/UUIDTest.php
+++ b/pkg/enqueue/Tests/Util/UUIDTest.php
@@ -11,7 +11,7 @@ public function testShouldGenerateUniqueId()
{
$uuid = UUID::generate();
- $this->assertInternalType('string', $uuid);
+ $this->assertIsString($uuid);
$this->assertEquals(36, strlen($uuid));
}
diff --git a/pkg/enqueue/Tests/Util/VarExportTest.php b/pkg/enqueue/Tests/Util/VarExportTest.php
index 1d2384ac9..b71e78a65 100644
--- a/pkg/enqueue/Tests/Util/VarExportTest.php
+++ b/pkg/enqueue/Tests/Util/VarExportTest.php
@@ -7,16 +7,8 @@
class VarExportTest extends TestCase
{
- public function testCouldBeConstructedWithValueAsArgument()
- {
- new VarExport('aVal');
- }
-
/**
* @dataProvider provideValues
- *
- * @param mixed $value
- * @param mixed $expected
*/
public function testShouldConvertValueToStringUsingVarExportFunction($value, $expected)
{
diff --git a/pkg/enqueue/Tests/fix_composer_json.php b/pkg/enqueue/Tests/fix_composer_json.php
index dfbec62fb..324f1840b 100644
--- a/pkg/enqueue/Tests/fix_composer_json.php
+++ b/pkg/enqueue/Tests/fix_composer_json.php
@@ -8,4 +8,4 @@
$composerJson['config']['platform']['ext-rdkafka'] = '3.3';
$composerJson['config']['platform']['ext-gearman'] = '2';
-file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, JSON_PRETTY_PRINT));
+file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, \JSON_PRETTY_PRINT));
diff --git a/pkg/enqueue/Util/JSON.php b/pkg/enqueue/Util/JSON.php
index f85738e1d..67411af16 100644
--- a/pkg/enqueue/Util/JSON.php
+++ b/pkg/enqueue/Util/JSON.php
@@ -14,10 +14,7 @@ class JSON
public static function decode($string)
{
if (!is_string($string)) {
- throw new \InvalidArgumentException(sprintf(
- 'Accept only string argument but got: "%s"',
- is_object($string) ? get_class($string) : gettype($string)
- ));
+ throw new \InvalidArgumentException(sprintf('Accept only string argument but got: "%s"', is_object($string) ? $string::class : gettype($string)));
}
// PHP7 fix - empty string and null cause syntax error
@@ -26,32 +23,22 @@ public static function decode($string)
}
$decoded = json_decode($string, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return $decoded;
}
/**
- * @param mixed $value
- *
* @return string
*/
public static function encode($value)
{
- $encoded = json_encode($value, JSON_UNESCAPED_UNICODE);
-
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'Could not encode value into json. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ $encoded = json_encode($value, \JSON_UNESCAPED_UNICODE);
+
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return $encoded;
diff --git a/pkg/enqueue/Util/Stringify.php b/pkg/enqueue/Util/Stringify.php
index 39b1f1305..d8a48a8d6 100644
--- a/pkg/enqueue/Util/Stringify.php
+++ b/pkg/enqueue/Util/Stringify.php
@@ -7,14 +7,8 @@
*/
class Stringify
{
- /**
- * @var mixed
- */
private $value;
- /**
- * @param mixed $value
- */
public function __construct($value)
{
$this->value = $value;
@@ -26,11 +20,11 @@ public function __toString(): string
return $this->value;
}
- return json_encode($this->value, JSON_UNESCAPED_SLASHES);
+ return json_encode($this->value, \JSON_UNESCAPED_SLASHES);
}
public static function that($value): self
{
- return new static($value);
+ return new self($value);
}
}
diff --git a/pkg/enqueue/Util/VarExport.php b/pkg/enqueue/Util/VarExport.php
index 4a48afadd..9a914706d 100644
--- a/pkg/enqueue/Util/VarExport.php
+++ b/pkg/enqueue/Util/VarExport.php
@@ -7,14 +7,8 @@
*/
class VarExport
{
- /**
- * @var mixed
- */
private $value;
- /**
- * @param mixed $value
- */
public function __construct($value)
{
$this->value = $value;
diff --git a/pkg/enqueue/composer.json b/pkg/enqueue/composer.json
index ed9603057..c336c4bad 100644
--- a/pkg/enqueue/composer.json
+++ b/pkg/enqueue/composer.json
@@ -6,23 +6,23 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
- "queue-interop/amqp-interop": "^0.8",
+ "php": "^8.1",
+ "queue-interop/amqp-interop": "^0.8.2",
"queue-interop/queue-interop": "^0.8",
"enqueue/null": "^0.10",
"enqueue/dsn": "^0.10",
- "ramsey/uuid": "^2|^3.5|^4",
- "psr/log": "^1",
- "psr/container": "^1"
+ "ramsey/uuid": "^3.5|^4",
+ "psr/log": "^1.0 || ^2.0 || ^3.0",
+ "psr/container": "^1.1 || ^2.0"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
- "symfony/console": "^4.3|^5",
- "symfony/dependency-injection": "^4.3|^5",
- "symfony/config": "^4.3|^5",
- "symfony/event-dispatcher": "^4.3|^5",
- "symfony/http-kernel": "^4.3|^5",
- "symfony/yaml": "^4.3|^5",
+ "phpunit/phpunit": "^9.5",
+ "symfony/console": "^5.41|^6.0",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/event-dispatcher": "^5.4|^6.0",
+ "symfony/http-kernel": "^5.4|^6.0",
+ "symfony/yaml": "^5.4|^6.0",
"enqueue/amqp-ext": "0.10.x-dev",
"enqueue/amqp-lib": "0.10.x-dev",
"enqueue/amqp-bunny": "0.10.x-dev",
@@ -42,9 +42,9 @@
"enqueue/dsn": "0.10.x-dev"
},
"suggest": {
- "symfony/console": "^2.8|^3|^4|^5 If you want to use cli commands",
- "symfony/dependency-injection": "^4.3|^5",
- "symfony/config": "^4.3|^5",
+ "symfony/console": "^5.4|^6.0 If you want to use cli commands",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/config": "^5.4|^6.0",
"enqueue/amqp-ext": "AMQP transport (based on php extension)",
"enqueue/stomp": "STOMP transport",
"enqueue/fs": "Filesystem transport",
diff --git a/pkg/fs/.github/workflows/ci.yml b/pkg/fs/.github/workflows/ci.yml
new file mode 100644
index 000000000..65cfbbb2d
--- /dev/null
+++ b/pkg/fs/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/fs/.travis.yml b/pkg/fs/.travis.yml
deleted file mode 100644
index b910c0fcf..000000000
--- a/pkg/fs/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/fs/FsConnectionFactory.php b/pkg/fs/FsConnectionFactory.php
index ad13e9eb6..9c4ba17e5 100644
--- a/pkg/fs/FsConnectionFactory.php
+++ b/pkg/fs/FsConnectionFactory.php
@@ -74,11 +74,7 @@ private function parseDsn(string $dsn): array
$supportedSchemes = ['file'];
if (false == in_array($dsn->getSchemeProtocol(), $supportedSchemes, true)) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be one of "%s"',
- $dsn->getSchemeProtocol(),
- implode('", "', $supportedSchemes)
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be one of "%s"', $dsn->getSchemeProtocol(), implode('", "', $supportedSchemes)));
}
return array_filter(array_replace($dsn->getQuery(), [
diff --git a/pkg/fs/FsConsumer.php b/pkg/fs/FsConsumer.php
index 46e7b96ba..614461eb2 100644
--- a/pkg/fs/FsConsumer.php
+++ b/pkg/fs/FsConsumer.php
@@ -112,7 +112,7 @@ public function receiveNoWait(): ?Message
while ($count) {
$frame = $this->readFrame($file, 1);
- //guards
+ // guards
if ($frame && false == ('|' == $frame[0] || ' ' == $frame[0])) {
throw new \LogicException(sprintf('The frame could start from either " " or "|". The malformed frame starts with "%s".', $frame[0]));
}
@@ -188,13 +188,13 @@ private function readFrame($file, int $frameNumber): string
$frameSize = 64;
$offset = $frameNumber * $frameSize;
- fseek($file, -$offset, SEEK_END);
+ fseek($file, -$offset, \SEEK_END);
$frame = fread($file, $frameSize);
if ('' == $frame) {
return '';
}
- if (false !== strpos($frame, '|{')) {
+ if (str_contains($frame, '|{')) {
return $frame;
}
diff --git a/pkg/fs/FsContext.php b/pkg/fs/FsContext.php
index 480074e03..c735e13aa 100644
--- a/pkg/fs/FsContext.php
+++ b/pkg/fs/FsContext.php
@@ -83,7 +83,7 @@ public function createQueue(string $queueName): Queue
public function declareDestination(FsDestination $destination): void
{
- //InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class);
+ // InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class);
set_error_handler(function ($severity, $message, $file, $line) {
throw new \ErrorException($message, 0, $severity, $file, $line);
@@ -105,7 +105,7 @@ public function workWithFile(FsDestination $destination, string $mode, callable
set_error_handler(function ($severity, $message, $file, $line) {
throw new \ErrorException($message, 0, $severity, $file, $line);
- }, E_ALL & ~E_USER_DEPRECATED);
+ }, \E_ALL & ~\E_USER_DEPRECATED);
try {
$file = fopen((string) $destination->getFileInfo(), $mode);
diff --git a/pkg/fs/FsMessage.php b/pkg/fs/FsMessage.php
index d66ee52cd..45312e52c 100644
--- a/pkg/fs/FsMessage.php
+++ b/pkg/fs/FsMessage.php
@@ -96,7 +96,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', (string) $correlationId);
}
@@ -106,7 +106,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', (string) $messageId);
}
@@ -123,12 +123,12 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -150,12 +150,8 @@ public function jsonSerialize(): array
public static function jsonUnserialize(string $json): self
{
$data = json_decode($json, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return new self($data['body'], $data['properties'], $data['headers']);
diff --git a/pkg/fs/FsProducer.php b/pkg/fs/FsProducer.php
index 55ff88cc3..067e54b36 100644
--- a/pkg/fs/FsProducer.php
+++ b/pkg/fs/FsProducer.php
@@ -53,12 +53,8 @@ public function send(Destination $destination, Message $message): void
$rawMessage = str_replace('|{', '\|\{', $rawMessage);
$rawMessage = '|'.$rawMessage;
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'Could not encode value into json. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
$rawMessage = str_repeat(' ', 64 - (strlen($rawMessage) % 64)).$rawMessage;
@@ -67,7 +63,7 @@ public function send(Destination $destination, Message $message): void
});
}
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $deliveryDelay) {
return $this;
@@ -81,7 +77,7 @@ public function getDeliveryDelay(): ?int
return null;
}
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
@@ -95,7 +91,7 @@ public function getPriority(): ?int
return null;
}
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
diff --git a/pkg/fs/LegacyFilesystemLock.php b/pkg/fs/LegacyFilesystemLock.php
index a765d2ced..328fb7098 100644
--- a/pkg/fs/LegacyFilesystemLock.php
+++ b/pkg/fs/LegacyFilesystemLock.php
@@ -19,9 +19,6 @@ public function __construct()
$this->lockHandlers = [];
}
- /**
- * {@inheritdoc}
- */
public function lock(FsDestination $destination)
{
$lockHandler = $this->getLockHandler($destination);
@@ -31,9 +28,6 @@ public function lock(FsDestination $destination)
}
}
- /**
- * {@inheritdoc}
- */
public function release(FsDestination $destination)
{
$lockHandler = $this->getLockHandler($destination);
@@ -51,8 +45,6 @@ public function releaseAll()
}
/**
- * @param FsDestination $destination
- *
* @return LockHandler
*/
private function getLockHandler(FsDestination $destination)
@@ -161,7 +153,7 @@ public function lock($blocking = false)
// On Windows, even if PHP doc says the contrary, LOCK_NB works, see
// https://bugs.php.net/54129
- if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
+ if (!flock($this->handle, \LOCK_EX | ($blocking ? 0 : \LOCK_NB))) {
fclose($this->handle);
$this->handle = null;
@@ -177,7 +169,7 @@ public function lock($blocking = false)
public function release()
{
if ($this->handle) {
- flock($this->handle, LOCK_UN | LOCK_NB);
+ flock($this->handle, \LOCK_UN | \LOCK_NB);
fclose($this->handle);
$this->handle = null;
}
diff --git a/pkg/fs/Lock.php b/pkg/fs/Lock.php
index 91125faa8..16349f22c 100644
--- a/pkg/fs/Lock.php
+++ b/pkg/fs/Lock.php
@@ -10,15 +10,10 @@ interface Lock
* Returns the control If the look has been obtained
* If not, should throw CannotObtainLockException exception.
*
- * @param FsDestination $destination
- *
* @throws CannotObtainLockException if look could not be obtained
*/
public function lock(FsDestination $destination);
- /**
- * @param FsDestination $destination
- */
public function release(FsDestination $destination);
public function releaseAll();
diff --git a/pkg/fs/README.md b/pkg/fs/README.md
index b1e5411d5..1f2e0b88a 100644
--- a/pkg/fs/README.md
+++ b/pkg/fs/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Enqueue Filesystem Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/fs)
+[](https://github.com/php-enqueue/fs/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/fs)
[](https://packagist.org/packages/enqueue/fs)
diff --git a/pkg/fs/Tests/FsConnectionFactoryConfigTest.php b/pkg/fs/Tests/FsConnectionFactoryConfigTest.php
index 59193d26d..0b3411f2c 100644
--- a/pkg/fs/Tests/FsConnectionFactoryConfigTest.php
+++ b/pkg/fs/Tests/FsConnectionFactoryConfigTest.php
@@ -4,6 +4,7 @@
use Enqueue\Fs\FsConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@
class FsConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
@@ -49,9 +51,6 @@ public function testThrowIfArrayConfigGivenWithEmptyPath()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
diff --git a/pkg/fs/Tests/FsConnectionFactoryTest.php b/pkg/fs/Tests/FsConnectionFactoryTest.php
index 35558573a..2df442342 100644
--- a/pkg/fs/Tests/FsConnectionFactoryTest.php
+++ b/pkg/fs/Tests/FsConnectionFactoryTest.php
@@ -5,11 +5,13 @@
use Enqueue\Fs\FsConnectionFactory;
use Enqueue\Fs\FsContext;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
class FsConnectionFactoryTest extends \PHPUnit\Framework\TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
diff --git a/pkg/fs/Tests/FsConsumerTest.php b/pkg/fs/Tests/FsConsumerTest.php
index 086bb55fe..67f03ae98 100644
--- a/pkg/fs/Tests/FsConsumerTest.php
+++ b/pkg/fs/Tests/FsConsumerTest.php
@@ -20,11 +20,6 @@ public function testShouldImplementConsumerInterface()
$this->assertClassImplements(Consumer::class, FsConsumer::class);
}
- public function testCouldBeConstructedWithContextAndDestinationAndPreFetchCountAsArguments()
- {
- new FsConsumer($this->createContextMock(), new FsDestination(TempFile::generate()), 1);
- }
-
public function testShouldReturnDestinationSetInConstructorOnGetQueue()
{
$destination = new FsDestination(TempFile::generate());
@@ -50,6 +45,9 @@ public function testShouldAllowGetPreviouslySetPreFetchCount()
$this->assertSame(456, $consumer->getPreFetchCount());
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldDoNothingOnAcknowledge()
{
$consumer = new FsConsumer($this->createContextMock(), new FsDestination(TempFile::generate()), 123);
@@ -57,6 +55,9 @@ public function testShouldDoNothingOnAcknowledge()
$consumer->acknowledge(new FsMessage());
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldDoNothingOnReject()
{
$consumer = new FsConsumer($this->createContextMock(), new FsDestination(TempFile::generate()), 123);
diff --git a/pkg/fs/Tests/FsContextTest.php b/pkg/fs/Tests/FsContextTest.php
index 377ec0007..9d5a5f1fc 100644
--- a/pkg/fs/Tests/FsContextTest.php
+++ b/pkg/fs/Tests/FsContextTest.php
@@ -9,6 +9,7 @@
use Enqueue\Fs\FsProducer;
use Enqueue\Null\NullQueue;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Context;
use Interop\Queue\Exception\InvalidDestinationException;
use Makasim\File\TempFile;
@@ -16,17 +17,13 @@
class FsContextTest extends \PHPUnit\Framework\TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementContextInterface()
{
$this->assertClassImplements(Context::class, FsContext::class);
}
- public function testCouldBeConstructedWithExpectedArguments()
- {
- new FsContext(sys_get_temp_dir(), 1, 0666, 100);
- }
-
public function testShouldAllowCreateEmptyMessage()
{
$context = new FsContext(sys_get_temp_dir(), 1, 0666, 100);
@@ -120,6 +117,9 @@ public function testShouldThrowIfNotFsDestinationGivenOnCreateConsumer()
$this->assertInstanceOf(FsConsumer::class, $consumer);
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldCreateConsumer()
{
$tmpFile = new TempFile(sys_get_temp_dir().'/foo');
@@ -190,7 +190,7 @@ public function testShouldCreateFileOnFilesystemIfNotExistOnDeclareDestination()
$queue = $context->createQueue($tmpFile->getFilename());
- $this->assertFileNotExists((string) $tmpFile);
+ $this->assertFileDoesNotExist((string) $tmpFile);
$context->declareDestination($queue);
diff --git a/pkg/fs/Tests/FsMessageTest.php b/pkg/fs/Tests/FsMessageTest.php
index c2f788d04..90655b620 100644
--- a/pkg/fs/Tests/FsMessageTest.php
+++ b/pkg/fs/Tests/FsMessageTest.php
@@ -89,7 +89,7 @@ public function testCouldBeUnserializedFromJson()
$json = json_encode($message);
- //guard
+ // guard
$this->assertNotEmpty($json);
$unserializedMessage = FsMessage::jsonUnserialize($json);
diff --git a/pkg/fs/Tests/FsProducerTest.php b/pkg/fs/Tests/FsProducerTest.php
index 28700d52f..266854c7b 100644
--- a/pkg/fs/Tests/FsProducerTest.php
+++ b/pkg/fs/Tests/FsProducerTest.php
@@ -23,11 +23,6 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(Producer::class, FsProducer::class);
}
- public function testCouldBeConstructedWithContextAsFirstArgument()
- {
- new FsProducer($this->createContextMock());
- }
-
public function testThrowIfDestinationNotFsOnSend()
{
$producer = new FsProducer($this->createContextMock());
diff --git a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php
index 1ae462731..b96091e7f 100644
--- a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php
+++ b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php
@@ -17,14 +17,14 @@ class FsCommonUseCasesTest extends \PHPUnit\Framework\TestCase
*/
private $fsContext;
- public function setUp()
+ protected function setUp(): void
{
$this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext();
new TempFile(sys_get_temp_dir().'/fs_test_queue');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->fsContext->close();
}
@@ -111,7 +111,7 @@ public function testConsumerReceiveMessageWithZeroTimeout()
$topic = $this->fsContext->createTopic('fs_test_queue_exchange');
$consumer = $this->fsContext->createConsumer($topic);
- //guard
+ // guard
$this->assertNull($consumer->receive(1000));
$message = $this->fsContext->createMessage(__METHOD__);
diff --git a/pkg/fs/Tests/Functional/FsConsumerTest.php b/pkg/fs/Tests/Functional/FsConsumerTest.php
index 9dd7a0103..3be009b02 100644
--- a/pkg/fs/Tests/Functional/FsConsumerTest.php
+++ b/pkg/fs/Tests/Functional/FsConsumerTest.php
@@ -15,14 +15,14 @@ class FsConsumerTest extends TestCase
*/
private $fsContext;
- public function setUp()
+ protected function setUp(): void
{
$this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext();
$this->fsContext->purgeQueue($this->fsContext->createQueue('fs_test_queue'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->fsContext->close();
}
@@ -159,7 +159,7 @@ public function testShouldThrowExceptionWhenFrameSizeNotDivideExactly()
$context->workWithFile($queue, 'a+', function (FsDestination $destination, $file) {
$msg = '|{"body":""}';
- //guard
+ // guard
$this->assertNotSame(0, strlen($msg) % 64);
fwrite($file, $msg);
diff --git a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php
index 98895a62d..334a8fe7d 100644
--- a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php
+++ b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php
@@ -25,14 +25,14 @@ class FsConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase
*/
private $fsContext;
- public function setUp()
+ protected function setUp(): void
{
$this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext();
new TempFile(sys_get_temp_dir().'/fs_test_queue');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->fsContext->close();
}
diff --git a/pkg/fs/Tests/Functional/FsContextTest.php b/pkg/fs/Tests/Functional/FsContextTest.php
index 287fd6c04..806b9f56a 100644
--- a/pkg/fs/Tests/Functional/FsContextTest.php
+++ b/pkg/fs/Tests/Functional/FsContextTest.php
@@ -14,7 +14,7 @@ class FsContextTest extends TestCase
*/
private $fsContext;
- public function tearDown(): void
+ protected function tearDown(): void
{
$fs = new Filesystem();
$fs->remove(sys_get_temp_dir().'/enqueue');
diff --git a/pkg/fs/Tests/Functional/FsProducerTest.php b/pkg/fs/Tests/Functional/FsProducerTest.php
index 6f7e4b4fa..75625cfdd 100644
--- a/pkg/fs/Tests/Functional/FsProducerTest.php
+++ b/pkg/fs/Tests/Functional/FsProducerTest.php
@@ -14,7 +14,7 @@ class FsProducerTest extends TestCase
*/
private $fsContext;
- public function setUp()
+ protected function setUp(): void
{
$this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext();
@@ -22,7 +22,7 @@ public function setUp()
file_put_contents(sys_get_temp_dir().'/fs_test_queue', '');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->fsContext->close();
}
diff --git a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php
index 046a25f9c..3a0327d7c 100644
--- a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php
+++ b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php
@@ -20,7 +20,7 @@ class FsRpcUseCasesTest extends TestCase
*/
private $fsContext;
- public function setUp()
+ protected function setUp(): void
{
$this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext();
@@ -28,7 +28,7 @@ public function setUp()
new TempFile(sys_get_temp_dir().'/fs_reply_queue');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->fsContext->close();
}
diff --git a/pkg/fs/Tests/LegacyFilesystemLockTest.php b/pkg/fs/Tests/LegacyFilesystemLockTest.php
index 77d729886..519712881 100644
--- a/pkg/fs/Tests/LegacyFilesystemLockTest.php
+++ b/pkg/fs/Tests/LegacyFilesystemLockTest.php
@@ -6,12 +6,14 @@
use Enqueue\Fs\LegacyFilesystemLock;
use Enqueue\Fs\Lock;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Makasim\File\TempFile;
use PHPUnit\Framework\TestCase;
class LegacyFilesystemLockTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementLockInterface()
{
diff --git a/pkg/fs/Tests/Spec/FsMessageTest.php b/pkg/fs/Tests/Spec/FsMessageTest.php
index 20dd4beca..f1ece8ecb 100644
--- a/pkg/fs/Tests/Spec/FsMessageTest.php
+++ b/pkg/fs/Tests/Spec/FsMessageTest.php
@@ -7,9 +7,6 @@
class FsMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new FsMessage();
diff --git a/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php
index 3dd1697c7..d6a76ca94 100644
--- a/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php
+++ b/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php
@@ -9,8 +9,6 @@
class FsSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec
{
/**
- * {@inheritdoc}
- *
* @return FsContext
*/
protected function createContext()
diff --git a/pkg/fs/composer.json b/pkg/fs/composer.json
index 19d2fd841..4dd2ff806 100644
--- a/pkg/fs/composer.json
+++ b/pkg/fs/composer.json
@@ -6,19 +6,19 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8",
"enqueue/dsn": "^0.10",
- "symfony/filesystem": "^4.3|^5",
+ "symfony/filesystem": "^5.4|^6.0",
"makasim/temp-file": "^0.2@stable"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/null": "0.10.x-dev",
"enqueue/test": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6",
- "symfony/dependency-injection": "^4.3|^5",
- "symfony/yaml": "^4.3|^5"
+ "queue-interop/queue-spec": "^0.6.2",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/yaml": "^5.4|^6.0"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/gearman/.github/workflows/ci.yml b/pkg/gearman/.github/workflows/ci.yml
new file mode 100644
index 000000000..28ae81b0f
--- /dev/null
+++ b/pkg/gearman/.github/workflows/ci.yml
@@ -0,0 +1,30 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+ extensions: gearman
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/gearman/.travis.yml b/pkg/gearman/.travis.yml
deleted file mode 100644
index 7e96cb089..000000000
--- a/pkg/gearman/.travis.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - sudo apt-get update
- - sudo apt-get install libgearman-dev -y --no-install-recommends --no-install-suggests
- - export GEARMAN_PACKAGE=gearman-2.0.3
- - curl -L -O https://github.com/wcgallego/pecl-gearman/archive/$GEARMAN_PACKAGE.tar.gz
- - tar zxvf $GEARMAN_PACKAGE.tar.gz
- - pushd pecl-gearman-$GEARMAN_PACKAGE
- - phpize
- - ./configure
- - make
- - make install
- - echo 'extension=gearman.so' > gearman.ini
- - phpenv config-add gearman.ini
- - popd
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/gearman/GearmanConsumer.php b/pkg/gearman/GearmanConsumer.php
index 68f15e045..e834fe469 100644
--- a/pkg/gearman/GearmanConsumer.php
+++ b/pkg/gearman/GearmanConsumer.php
@@ -25,12 +25,21 @@ class GearmanConsumer implements Consumer
*/
private $context;
+ /**
+ * Message content.
+ */
+ private $message;
+
public function __construct(GearmanContext $context, GearmanDestination $destination)
{
$this->context = $context;
$this->destination = $destination;
$this->worker = $context->createWorker();
+
+ $this->worker->addFunction($this->destination->getName(), function (\GearmanJob $job) {
+ $this->message = GearmanMessage::jsonUnserialize($job->workload());
+ });
}
/**
@@ -53,18 +62,14 @@ public function receive(int $timeout = 0): ?Message
$this->worker->setTimeout($timeout);
try {
- $message = null;
-
- $this->worker->addFunction($this->destination->getName(), function (\GearmanJob $job) use (&$message) {
- $message = GearmanMessage::jsonUnserialize($job->workload());
- });
+ $this->message = null;
$this->worker->work();
} finally {
restore_error_handler();
}
- return $message;
+ return $this->message;
}
/**
diff --git a/pkg/gearman/GearmanMessage.php b/pkg/gearman/GearmanMessage.php
index 625566d62..ee93a78dd 100644
--- a/pkg/gearman/GearmanMessage.php
+++ b/pkg/gearman/GearmanMessage.php
@@ -101,7 +101,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', (string) $correlationId);
}
@@ -111,7 +111,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', (string) $messageId);
}
@@ -128,12 +128,12 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -155,12 +155,8 @@ public function jsonSerialize(): array
public static function jsonUnserialize(string $json): self
{
$data = json_decode($json, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return new self($data['body'], $data['properties'], $data['headers']);
@@ -171,7 +167,7 @@ public function getJob(): ?\GearmanJob
return $this->job;
}
- public function setJob(\GearmanJob $job = null): void
+ public function setJob(?\GearmanJob $job = null): void
{
$this->job = $job;
}
diff --git a/pkg/gearman/GearmanProducer.php b/pkg/gearman/GearmanProducer.php
index c297e71b2..870bdcb03 100644
--- a/pkg/gearman/GearmanProducer.php
+++ b/pkg/gearman/GearmanProducer.php
@@ -40,7 +40,7 @@ public function send(Destination $destination, Message $message): void
}
}
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $deliveryDelay) {
return $this;
@@ -54,7 +54,7 @@ public function getDeliveryDelay(): ?int
return null;
}
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
@@ -68,7 +68,7 @@ public function getPriority(): ?int
return null;
}
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
if (null === $timeToLive) {
return $this;
diff --git a/pkg/gearman/README.md b/pkg/gearman/README.md
index 9c6efde8a..4aedb72d2 100644
--- a/pkg/gearman/README.md
+++ b/pkg/gearman/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Gearman Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/gearman)
+[](https://github.com/php-enqueue/gearman/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/gearman)
[](https://packagist.org/packages/enqueue/gearman)
diff --git a/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php b/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php
index bb8ab7ad6..8fc7a6b1e 100644
--- a/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php
+++ b/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php
@@ -4,6 +4,7 @@
use Enqueue\Gearman\GearmanConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@
class GearmanConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
use SkipIfGearmanExtensionIsNotInstalledTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
@@ -40,9 +42,6 @@ public function testThrowIfDsnCouldNotBeParsed()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
diff --git a/pkg/gearman/Tests/GearmanContextTest.php b/pkg/gearman/Tests/GearmanContextTest.php
index 484ab00a0..8a36ad80b 100644
--- a/pkg/gearman/Tests/GearmanContextTest.php
+++ b/pkg/gearman/Tests/GearmanContextTest.php
@@ -12,6 +12,7 @@
/**
* @group functional
+ * @group gearman
*/
class GearmanContextTest extends TestCase
{
@@ -23,11 +24,6 @@ public function testShouldImplementContextInterface()
$this->assertClassImplements(Context::class, GearmanContext::class);
}
- public function testCouldBeConstructedWithConnectionConfigAsFirstArgument()
- {
- new GearmanContext(['host' => 'aHost', 'port' => 'aPort']);
- }
-
public function testThrowNotImplementedOnCreateTemporaryQueue()
{
$context = new GearmanContext(['host' => 'aHost', 'port' => 'aPort']);
diff --git a/pkg/gearman/Tests/GearmanProducerTest.php b/pkg/gearman/Tests/GearmanProducerTest.php
index afb6181a3..2a7baa4de 100644
--- a/pkg/gearman/Tests/GearmanProducerTest.php
+++ b/pkg/gearman/Tests/GearmanProducerTest.php
@@ -18,11 +18,6 @@ class GearmanProducerTest extends TestCase
use ClassExtensionTrait;
use SkipIfGearmanExtensionIsNotInstalledTrait;
- public function testCouldBeConstructedWithGearmanClientAsFirstArgument()
- {
- new GearmanProducer($this->createGearmanClientMock());
- }
-
public function testThrowIfDestinationInvalid()
{
$producer = new GearmanProducer($this->createGearmanClientMock());
diff --git a/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php b/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php
index 99419eb15..9c680bb67 100644
--- a/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php
+++ b/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php
@@ -4,7 +4,7 @@
trait SkipIfGearmanExtensionIsNotInstalledTrait
{
- public function setUp()
+ public function setUp(): void
{
if (false == class_exists(\GearmanClient::class)) {
$this->markTestSkipped('The gearman extension is not installed');
diff --git a/pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php b/pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php
index 148bf66d2..05418febc 100644
--- a/pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php
@@ -10,9 +10,6 @@ class GearmanConnectionFactoryTest extends ConnectionFactorySpec
{
use SkipIfGearmanExtensionIsNotInstalledTrait;
- /**
- * {@inheritdoc}
- */
protected function createConnectionFactory()
{
return new GearmanConnectionFactory();
diff --git a/pkg/gearman/Tests/Spec/GearmanContextTest.php b/pkg/gearman/Tests/Spec/GearmanContextTest.php
index 431465cc5..d5f879f12 100644
--- a/pkg/gearman/Tests/Spec/GearmanContextTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanContextTest.php
@@ -7,12 +7,10 @@
/**
* @group functional
+ * @group gearman
*/
class GearmanContextTest extends ContextSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return (new GearmanConnectionFactory(getenv('GEARMAN_DSN')))->createContext();
diff --git a/pkg/gearman/Tests/Spec/GearmanMessageTest.php b/pkg/gearman/Tests/Spec/GearmanMessageTest.php
index 7ad01d6db..37aa71e62 100644
--- a/pkg/gearman/Tests/Spec/GearmanMessageTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanMessageTest.php
@@ -10,9 +10,6 @@ class GearmanMessageTest extends MessageSpec
{
use SkipIfGearmanExtensionIsNotInstalledTrait;
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new GearmanMessage();
diff --git a/pkg/gearman/Tests/Spec/GearmanQueueTest.php b/pkg/gearman/Tests/Spec/GearmanQueueTest.php
index 3d486849e..abf6be603 100644
--- a/pkg/gearman/Tests/Spec/GearmanQueueTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanQueueTest.php
@@ -10,9 +10,6 @@ class GearmanQueueTest extends QueueSpec
{
use SkipIfGearmanExtensionIsNotInstalledTrait;
- /**
- * {@inheritdoc}
- */
protected function createQueue()
{
return new GearmanDestination(self::EXPECTED_QUEUE_NAME);
diff --git a/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php
index 80b13f8df..10a284987 100644
--- a/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php
@@ -9,12 +9,10 @@
/**
* @group functional
+ * @group gearman
*/
class GearmanSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new GearmanConnectionFactory(getenv('GEARMAN_DSN'));
@@ -23,8 +21,7 @@ protected function createContext()
}
/**
- * @param Context $context
- * @param string $queueName
+ * @param string $queueName
*
* @return Queue
*/
diff --git a/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php
index 590b8ede5..e2164ea7a 100644
--- a/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php
@@ -8,12 +8,10 @@
/**
* @group functional
+ * @group gearman
*/
class GearmanSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new GearmanConnectionFactory(getenv('GEARMAN_DSN'));
@@ -21,9 +19,6 @@ protected function createContext()
return $factory->createContext();
}
- /**
- * {@inheritdoc}
- */
protected function createQueue(Context $context, $queueName)
{
return $context->createQueue($queueName.time());
diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php
index c90432e00..32463cce1 100644
--- a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php
@@ -8,19 +8,17 @@
/**
* @group functional
+ * @group gearman
*/
class GearmanSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec
{
private $time;
- public function setUp()
+ protected function setUp(): void
{
$this->time = time();
}
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new GearmanConnectionFactory(getenv('GEARMAN_DSN'));
@@ -28,17 +26,11 @@ protected function createContext()
return $factory->createContext();
}
- /**
- * {@inheritdoc}
- */
protected function createQueue(Context $context, $queueName)
{
return $context->createQueue($queueName.$this->time);
}
- /**
- * {@inheritdoc}
- */
protected function createTopic(Context $context, $topicName)
{
return $context->createTopic($topicName.$this->time);
diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php
index 469f9e997..993dc3f25 100644
--- a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php
@@ -8,19 +8,17 @@
/**
* @group functional
+ * @group gearman
*/
class GearmanSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec
{
private $time;
- public function setUp()
+ protected function setUp(): void
{
$this->time = time();
}
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new GearmanConnectionFactory(getenv('GEARMAN_DSN'));
@@ -28,17 +26,11 @@ protected function createContext()
return $factory->createContext();
}
- /**
- * {@inheritdoc}
- */
protected function createQueue(Context $context, $queueName)
{
return $context->createQueue($queueName.$this->time);
}
- /**
- * {@inheritdoc}
- */
protected function createTopic(Context $context, $topicName)
{
return $context->createTopic($topicName.$this->time);
diff --git a/pkg/gearman/Tests/Spec/GearmanTopicTest.php b/pkg/gearman/Tests/Spec/GearmanTopicTest.php
index 336c37f7d..826344e8b 100644
--- a/pkg/gearman/Tests/Spec/GearmanTopicTest.php
+++ b/pkg/gearman/Tests/Spec/GearmanTopicTest.php
@@ -10,9 +10,6 @@ class GearmanTopicTest extends TopicSpec
{
use SkipIfGearmanExtensionIsNotInstalledTrait;
- /**
- * {@inheritdoc}
- */
protected function createTopic()
{
return new GearmanDestination(self::EXPECTED_TOPIC_NAME);
diff --git a/pkg/gearman/composer.json b/pkg/gearman/composer.json
index a2b2eeccd..e8805849f 100644
--- a/pkg/gearman/composer.json
+++ b/pkg/gearman/composer.json
@@ -6,15 +6,15 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"ext-gearman": "^2.0",
"queue-interop/queue-interop": "^0.8"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/gps/.github/workflows/ci.yml b/pkg/gps/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/gps/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/gps/.travis.yml b/pkg/gps/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/gps/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/gps/GpsConnectionFactory.php b/pkg/gps/GpsConnectionFactory.php
index c15854763..e45f8cbe3 100644
--- a/pkg/gps/GpsConnectionFactory.php
+++ b/pkg/gps/GpsConnectionFactory.php
@@ -88,10 +88,7 @@ private function parseDsn(string $dsn): array
$dsn = Dsn::parseFirst($dsn);
if ('gps' !== $dsn->getSchemeProtocol()) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be "gps"',
- $dsn->getSchemeProtocol()
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "gps"', $dsn->getSchemeProtocol()));
}
$emulatorHost = $dsn->getString('emulatorHost');
diff --git a/pkg/gps/GpsContext.php b/pkg/gps/GpsContext.php
index 77e6200cf..27625992a 100644
--- a/pkg/gps/GpsContext.php
+++ b/pkg/gps/GpsContext.php
@@ -52,11 +52,7 @@ public function __construct($client, array $options = [])
} elseif (is_callable($client)) {
$this->clientFactory = $client;
} else {
- throw new \InvalidArgumentException(sprintf(
- 'The $client argument must be either %s or callable that returns %s once called.',
- PubSubClient::class,
- PubSubClient::class
- ));
+ throw new \InvalidArgumentException(sprintf('The $client argument must be either %s or callable that returns %s once called.', PubSubClient::class, PubSubClient::class));
}
}
@@ -148,11 +144,7 @@ public function getClient(): PubSubClient
if (false == $this->client) {
$client = call_user_func($this->clientFactory);
if (false == $client instanceof PubSubClient) {
- throw new \LogicException(sprintf(
- 'The factory must return instance of %s. It returned %s',
- PubSubClient::class,
- is_object($client) ? get_class($client) : gettype($client)
- ));
+ throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', PubSubClient::class, is_object($client) ? $client::class : gettype($client)));
}
$this->client = $client;
diff --git a/pkg/gps/GpsMessage.php b/pkg/gps/GpsMessage.php
index 5e83e078c..b7e2bf484 100644
--- a/pkg/gps/GpsMessage.php
+++ b/pkg/gps/GpsMessage.php
@@ -103,7 +103,7 @@ public function isRedelivered(): bool
return $this->redelivered;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', $correlationId);
}
@@ -113,7 +113,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', $messageId);
}
@@ -130,12 +130,12 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -157,15 +157,11 @@ public function jsonSerialize(): array
public static function jsonUnserialize(string $json): self
{
$data = json_decode($json, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
- return new self($data['body'], $data['properties'], $data['headers']);
+ return new self($data['body'] ?? $json, $data['properties'] ?? [], $data['headers'] ?? []);
}
public function getNativeMessage(): ?GoogleMessage
@@ -173,7 +169,7 @@ public function getNativeMessage(): ?GoogleMessage
return $this->nativeMessage;
}
- public function setNativeMessage(GoogleMessage $message = null): void
+ public function setNativeMessage(?GoogleMessage $message = null): void
{
$this->nativeMessage = $message;
}
diff --git a/pkg/gps/GpsProducer.php b/pkg/gps/GpsProducer.php
index 86c9052c0..7e307636f 100644
--- a/pkg/gps/GpsProducer.php
+++ b/pkg/gps/GpsProducer.php
@@ -37,12 +37,17 @@ public function send(Destination $destination, Message $message): void
/** @var Topic $topic */
$topic = $this->context->getClient()->topic($destination->getTopicName());
- $topic->publish([
- 'data' => json_encode($message),
- ]);
+
+ $params = ['data' => json_encode($message)];
+
+ if (count($message->getHeaders()) > 0) {
+ $params['attributes'] = $message->getHeaders();
+ }
+
+ $topic->publish($params);
}
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $deliveryDelay) {
return $this;
@@ -56,7 +61,7 @@ public function getDeliveryDelay(): ?int
return null;
}
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
@@ -70,7 +75,7 @@ public function getPriority(): ?int
return null;
}
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
if (null === $timeToLive) {
return $this;
diff --git a/pkg/gps/README.md b/pkg/gps/README.md
index fc80363ae..4f2a0e6ac 100644
--- a/pkg/gps/README.md
+++ b/pkg/gps/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Google Pub/Sub Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/gps)
+[](https://github.com/php-enqueue/gps/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/gps)
[](https://packagist.org/packages/enqueue/gps)
diff --git a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php
index a1700f64f..474149497 100644
--- a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php
+++ b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php
@@ -4,6 +4,7 @@
use Enqueue\Gps\GpsConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@
class GpsConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
@@ -39,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
diff --git a/pkg/gps/Tests/GpsMessageTest.php b/pkg/gps/Tests/GpsMessageTest.php
index d84cd99d9..8182333cc 100644
--- a/pkg/gps/Tests/GpsMessageTest.php
+++ b/pkg/gps/Tests/GpsMessageTest.php
@@ -29,7 +29,7 @@ public function testCouldBeUnserializedFromJson()
$json = json_encode($message);
- //guard
+ // guard
$this->assertNotEmpty($json);
$unserializedMessage = GpsMessage::jsonUnserialize($json);
@@ -38,6 +38,31 @@ public function testCouldBeUnserializedFromJson()
$this->assertEquals($message, $unserializedMessage);
}
+ public function testMessageEntityCouldBeUnserializedFromJson()
+ {
+ $json = '{"body":"theBody","properties":{"thePropFoo":"thePropFooVal"},"headers":{"theHeaderFoo":"theHeaderFooVal"}}';
+
+ $unserializedMessage = GpsMessage::jsonUnserialize($json);
+
+ $this->assertInstanceOf(GpsMessage::class, $unserializedMessage);
+ $decoded = json_decode($json, true);
+ $this->assertEquals($decoded['body'], $unserializedMessage->getBody());
+ $this->assertEquals($decoded['properties'], $unserializedMessage->getProperties());
+ $this->assertEquals($decoded['headers'], $unserializedMessage->getHeaders());
+ }
+
+ public function testMessagePayloadCouldBeUnserializedFromJson()
+ {
+ $json = '{"theBodyPropFoo":"theBodyPropVal"}';
+
+ $unserializedMessage = GpsMessage::jsonUnserialize($json);
+
+ $this->assertInstanceOf(GpsMessage::class, $unserializedMessage);
+ $this->assertEquals($json, $unserializedMessage->getBody());
+ $this->assertEquals([], $unserializedMessage->getProperties());
+ $this->assertEquals([], $unserializedMessage->getHeaders());
+ }
+
public function testThrowIfMalformedJsonGivenOnUnsterilizedFromJson()
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/pkg/gps/Tests/GpsProducerTest.php b/pkg/gps/Tests/GpsProducerTest.php
index 1e1bfae41..3079d3c7c 100644
--- a/pkg/gps/Tests/GpsProducerTest.php
+++ b/pkg/gps/Tests/GpsProducerTest.php
@@ -33,7 +33,39 @@ public function testShouldSendMessage()
$gtopic
->expects($this->once())
->method('publish')
- ->with($this->identicalTo(['data' => '{"body":"","properties":[],"headers":[]}']))
+ ->with($this->identicalTo([
+ 'data' => '{"body":"","properties":[],"headers":[]}',
+ ]));
+
+ $client = $this->createPubSubClientMock();
+ $client
+ ->expects($this->once())
+ ->method('topic')
+ ->with('topic-name')
+ ->willReturn($gtopic)
+ ;
+
+ $context = $this->createContextMock();
+ $context
+ ->expects($this->once())
+ ->method('getClient')
+ ->willReturn($client)
+ ;
+
+ $producer = new GpsProducer($context);
+ $producer->send($topic, $message);
+ }
+
+ public function testShouldSendMessageWithHeaders()
+ {
+ $topic = new GpsTopic('topic-name');
+ $message = new GpsMessage('', [], ['key1' => 'value1']);
+
+ $gtopic = $this->createGTopicMock();
+ $gtopic
+ ->expects($this->once())
+ ->method('publish')
+ ->with($this->identicalTo(['data' => '{"body":"","properties":[],"headers":{"key1":"value1"}}', 'attributes' => ['key1' => 'value1']]))
;
$client = $this->createPubSubClientMock();
diff --git a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php
index 30485b072..4bcaf357b 100644
--- a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php
+++ b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php
@@ -23,7 +23,6 @@ protected function createContext()
/**
* @param GpsContext $context
- * @param mixed $queueName
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php
index 240c71a3b..3a96bb533 100644
--- a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php
@@ -23,7 +23,6 @@ protected function createContext()
/**
* @param GpsContext $context
- * @param mixed $queueName
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/gps/composer.json b/pkg/gps/composer.json
index 7a9868f2f..e7654be8d 100644
--- a/pkg/gps/composer.json
+++ b/pkg/gps/composer.json
@@ -6,15 +6,15 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8",
- "google/cloud-pubsub": "^1.0",
+ "google/cloud-pubsub": "^1.4.3",
"enqueue/dsn": "^0.10"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/job-queue/.github/workflows/ci.yml b/pkg/job-queue/.github/workflows/ci.yml
new file mode 100644
index 000000000..28a9a9c02
--- /dev/null
+++ b/pkg/job-queue/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-dist"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/job-queue/.travis.yml b/pkg/job-queue/.travis.yml
deleted file mode 100644
index 623b55fe0..000000000
--- a/pkg/job-queue/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - travis_retry composer install --prefer-dist
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/job-queue/CalculateRootJobStatusProcessor.php b/pkg/job-queue/CalculateRootJobStatusProcessor.php
index b9b0c4dfb..96e7db2e8 100644
--- a/pkg/job-queue/CalculateRootJobStatusProcessor.php
+++ b/pkg/job-queue/CalculateRootJobStatusProcessor.php
@@ -38,7 +38,7 @@ public function __construct(
JobStorage $jobStorage,
CalculateRootJobStatusService $calculateRootJobStatusCase,
ProducerInterface $producer,
- LoggerInterface $logger
+ LoggerInterface $logger,
) {
$this->jobStorage = $jobStorage;
$this->calculateRootJobStatusService = $calculateRootJobStatusCase;
diff --git a/pkg/job-queue/CalculateRootJobStatusService.php b/pkg/job-queue/CalculateRootJobStatusService.php
index af4631e2a..41dd350b9 100644
--- a/pkg/job-queue/CalculateRootJobStatusService.php
+++ b/pkg/job-queue/CalculateRootJobStatusService.php
@@ -12,17 +12,12 @@ class CalculateRootJobStatusService
*/
private $jobStorage;
- /**
- * @param JobStorage $jobStorage
- */
public function __construct(JobStorage $jobStorage)
{
$this->jobStorage = $jobStorage;
}
/**
- * @param Job $job
- *
* @return bool true if root job was stopped
*/
public function calculate(Job $job)
@@ -74,6 +69,7 @@ protected function calculateRootJobStatus(array $jobs)
$success = 0;
foreach ($jobs as $job) {
+ $this->jobStorage->refreshJobEntity($job);
switch ($job->getStatus()) {
case Job::STATUS_NEW:
$new++;
@@ -91,11 +87,7 @@ protected function calculateRootJobStatus(array $jobs)
$success++;
break;
default:
- throw new \LogicException(sprintf(
- 'Got unsupported job status: id: "%s" status: "%s"',
- $job->getId(),
- $job->getStatus()
- ));
+ throw new \LogicException(sprintf('Got unsupported job status: id: "%s" status: "%s"', $job->getId(), $job->getStatus()));
}
}
diff --git a/pkg/job-queue/Commands.php b/pkg/job-queue/Commands.php
index 57966c30c..ae744c991 100644
--- a/pkg/job-queue/Commands.php
+++ b/pkg/job-queue/Commands.php
@@ -4,5 +4,5 @@
class Commands
{
- const CALCULATE_ROOT_JOB_STATUS = 'enqueue.message_queue.job.calculate_root_job_status';
+ public const CALCULATE_ROOT_JOB_STATUS = 'enqueue.message_queue.job.calculate_root_job_status';
}
diff --git a/pkg/job-queue/DependentJobContext.php b/pkg/job-queue/DependentJobContext.php
index 34deba656..04b898fd3 100644
--- a/pkg/job-queue/DependentJobContext.php
+++ b/pkg/job-queue/DependentJobContext.php
@@ -14,9 +14,6 @@ class DependentJobContext
*/
private $dependentJobs;
- /**
- * @param Job $job
- */
public function __construct(Job $job)
{
$this->job = $job;
diff --git a/pkg/job-queue/DependentJobProcessor.php b/pkg/job-queue/DependentJobProcessor.php
index 6126be08f..ac3055b5f 100644
--- a/pkg/job-queue/DependentJobProcessor.php
+++ b/pkg/job-queue/DependentJobProcessor.php
@@ -30,11 +30,6 @@ class DependentJobProcessor implements Processor, TopicSubscriberInterface
*/
private $logger;
- /**
- * @param JobStorage $jobStorage
- * @param ProducerInterface $producer
- * @param LoggerInterface $logger
- */
public function __construct(JobStorage $jobStorage, ProducerInterface $producer, LoggerInterface $logger)
{
$this->jobStorage = $jobStorage;
@@ -42,9 +37,6 @@ public function __construct(JobStorage $jobStorage, ProducerInterface $producer,
$this->logger = $logger;
}
- /**
- * {@inheritdoc}
- */
public function process(Message $message, Context $context)
{
$data = JSON::decode($message->getBody());
diff --git a/pkg/job-queue/DependentJobService.php b/pkg/job-queue/DependentJobService.php
index b6066d669..9ab500ba8 100644
--- a/pkg/job-queue/DependentJobService.php
+++ b/pkg/job-queue/DependentJobService.php
@@ -20,8 +20,6 @@ public function __construct(JobStorage $jobStorage)
}
/**
- * @param Job $job
- *
* @return DependentJobContext
*/
public function createDependentJobContext(Job $job)
@@ -29,16 +27,10 @@ public function createDependentJobContext(Job $job)
return new DependentJobContext($job);
}
- /**
- * @param DependentJobContext $context
- */
public function saveDependentJob(DependentJobContext $context)
{
if (!$context->getJob()->isRoot()) {
- throw new \LogicException(sprintf(
- 'Only root jobs allowed but got child. jobId: "%s"',
- $context->getJob()->getId()
- ));
+ throw new \LogicException(sprintf('Only root jobs allowed but got child. jobId: "%s"', $context->getJob()->getId()));
}
$this->jobStorage->saveJob($context->getJob(), function (Job $job) use ($context) {
diff --git a/pkg/job-queue/Doctrine/JobStorage.php b/pkg/job-queue/Doctrine/JobStorage.php
index 385ee4d38..4db585696 100644
--- a/pkg/job-queue/Doctrine/JobStorage.php
+++ b/pkg/job-queue/Doctrine/JobStorage.php
@@ -58,13 +58,18 @@ public function findJobById($id)
{
$qb = $this->getEntityRepository()->createQueryBuilder('job');
- return $qb
+ $job = $qb
->addSelect('rootJob')
->leftJoin('job.rootJob', 'rootJob')
->where('job = :id')
->setParameter('id', $id)
->getQuery()->getOneOrNullResult()
;
+ if ($job) {
+ $this->refreshJobEntity($job);
+ }
+
+ return $job;
}
/**
@@ -119,11 +124,11 @@ public function createJob()
/**
* @throws DuplicateJobException
*/
- public function saveJob(Job $job, \Closure $lockCallback = null)
+ public function saveJob(Job $job, ?\Closure $lockCallback = null)
{
$class = $this->getEntityRepository()->getClassName();
if (!$job instanceof $class) {
- throw new \LogicException(sprintf('Got unexpected job instance: expected: "%s", actual" "%s"', $class, get_class($job)));
+ throw new \LogicException(sprintf('Got unexpected job instance: expected: "%s", actual" "%s"', $class, $job::class));
}
if ($lockCallback) {
@@ -179,6 +184,14 @@ public function saveJob(Job $job, \Closure $lockCallback = null)
}
}
+ /**
+ * @param Job $job
+ */
+ public function refreshJobEntity($job)
+ {
+ $this->getEntityManager()->refresh($job);
+ }
+
/**
* @return EntityRepository
*/
diff --git a/pkg/job-queue/Doctrine/mapping/Job.orm.xml b/pkg/job-queue/Doctrine/mapping/Job.orm.xml
index e6fcbdde5..d6f481562 100644
--- a/pkg/job-queue/Doctrine/mapping/Job.orm.xml
+++ b/pkg/job-queue/Doctrine/mapping/Job.orm.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/pkg/job-queue/Job.php b/pkg/job-queue/Job.php
index 0468d7fdb..ddf53c2e3 100644
--- a/pkg/job-queue/Job.php
+++ b/pkg/job-queue/Job.php
@@ -4,11 +4,11 @@
class Job
{
- const STATUS_NEW = 'enqueue.job_queue.status.new';
- const STATUS_RUNNING = 'enqueue.job_queue.status.running';
- const STATUS_SUCCESS = 'enqueue.job_queue.status.success';
- const STATUS_FAILED = 'enqueue.job_queue.status.failed';
- const STATUS_CANCELLED = 'enqueue.job_queue.status.cancelled';
+ public const STATUS_NEW = 'enqueue.job_queue.status.new';
+ public const STATUS_RUNNING = 'enqueue.job_queue.status.running';
+ public const STATUS_SUCCESS = 'enqueue.job_queue.status.success';
+ public const STATUS_FAILED = 'enqueue.job_queue.status.failed';
+ public const STATUS_CANCELLED = 'enqueue.job_queue.status.cancelled';
/**
* @var int
@@ -216,8 +216,6 @@ public function getRootJob()
* Do not call from the outside.
*
* @internal
- *
- * @param Job $rootJob
*/
public function setRootJob(self $rootJob)
{
@@ -237,8 +235,6 @@ public function getCreatedAt()
* Do not call from the outside.
*
* @internal
- *
- * @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt)
{
@@ -258,8 +254,6 @@ public function getStartedAt()
* Do not call from the outside.
*
* @internal
- *
- * @param \DateTime $startedAt
*/
public function setStartedAt(\DateTime $startedAt)
{
@@ -279,8 +273,6 @@ public function getStoppedAt()
* Do not call from the outside.
*
* @internal
- *
- * @param \DateTime $stoppedAt
*/
public function setStoppedAt(\DateTime $stoppedAt)
{
@@ -324,9 +316,6 @@ public function getData()
return $this->data;
}
- /**
- * @param array $data
- */
public function setData(array $data)
{
$this->data = $data;
diff --git a/pkg/job-queue/JobProcessor.php b/pkg/job-queue/JobProcessor.php
index 8f197f742..06698f45c 100644
--- a/pkg/job-queue/JobProcessor.php
+++ b/pkg/job-queue/JobProcessor.php
@@ -17,10 +17,6 @@ class JobProcessor
*/
private $producer;
- /**
- * @param JobStorage $jobStorage
- * @param ProducerInterface $producer
- */
public function __construct(JobStorage $jobStorage, ProducerInterface $producer)
{
$this->jobStorage = $jobStorage;
@@ -74,7 +70,6 @@ public function findOrCreateRootJob($ownerId, $jobName, $unique = false)
/**
* @param string $jobName
- * @param Job $rootJob
*
* @return Job
*/
@@ -104,9 +99,6 @@ public function findOrCreateChildJob($jobName, Job $rootJob)
return $job;
}
- /**
- * @param Job $job
- */
public function startChildJob(Job $job)
{
if ($job->isRoot()) {
@@ -116,11 +108,7 @@ public function startChildJob(Job $job)
$job = $this->jobStorage->findJobById($job->getId());
if (Job::STATUS_NEW !== $job->getStatus()) {
- throw new \LogicException(sprintf(
- 'Can start only new jobs: id: "%s", status: "%s"',
- $job->getId(),
- $job->getStatus()
- ));
+ throw new \LogicException(sprintf('Can start only new jobs: id: "%s", status: "%s"', $job->getId(), $job->getStatus()));
}
$job->setStatus(Job::STATUS_RUNNING);
@@ -131,9 +119,6 @@ public function startChildJob(Job $job)
$this->sendCalculateRootJobStatusEvent($job);
}
- /**
- * @param Job $job
- */
public function successChildJob(Job $job)
{
if ($job->isRoot()) {
@@ -143,11 +128,7 @@ public function successChildJob(Job $job)
$job = $this->jobStorage->findJobById($job->getId());
if (Job::STATUS_RUNNING !== $job->getStatus()) {
- throw new \LogicException(sprintf(
- 'Can success only running jobs. id: "%s", status: "%s"',
- $job->getId(),
- $job->getStatus()
- ));
+ throw new \LogicException(sprintf('Can success only running jobs. id: "%s", status: "%s"', $job->getId(), $job->getStatus()));
}
$job->setStatus(Job::STATUS_SUCCESS);
@@ -158,9 +139,6 @@ public function successChildJob(Job $job)
$this->sendCalculateRootJobStatusEvent($job);
}
- /**
- * @param Job $job
- */
public function failChildJob(Job $job)
{
if ($job->isRoot()) {
@@ -170,11 +148,7 @@ public function failChildJob(Job $job)
$job = $this->jobStorage->findJobById($job->getId());
if (Job::STATUS_RUNNING !== $job->getStatus()) {
- throw new \LogicException(sprintf(
- 'Can fail only running jobs. id: "%s", status: "%s"',
- $job->getId(),
- $job->getStatus()
- ));
+ throw new \LogicException(sprintf('Can fail only running jobs. id: "%s", status: "%s"', $job->getId(), $job->getStatus()));
}
$job->setStatus(Job::STATUS_FAILED);
@@ -185,9 +159,6 @@ public function failChildJob(Job $job)
$this->sendCalculateRootJobStatusEvent($job);
}
- /**
- * @param Job $job
- */
public function cancelChildJob(Job $job)
{
if ($job->isRoot()) {
@@ -197,11 +168,7 @@ public function cancelChildJob(Job $job)
$job = $this->jobStorage->findJobById($job->getId());
if (!in_array($job->getStatus(), [Job::STATUS_NEW, Job::STATUS_RUNNING], true)) {
- throw new \LogicException(sprintf(
- 'Can cancel only new or running jobs. id: "%s", status: "%s"',
- $job->getId(),
- $job->getStatus()
- ));
+ throw new \LogicException(sprintf('Can cancel only new or running jobs. id: "%s", status: "%s"', $job->getId(), $job->getStatus()));
}
$job->setStatus(Job::STATUS_CANCELLED);
@@ -217,7 +184,6 @@ public function cancelChildJob(Job $job)
}
/**
- * @param Job $job
* @param bool $force
*/
public function interruptRootJob(Job $job, $force = false)
@@ -245,8 +211,6 @@ public function interruptRootJob(Job $job, $force = false)
/**
* @see https://github.com/php-enqueue/enqueue-dev/pull/222#issuecomment-336102749 See for rationale
- *
- * @param Job $job
*/
protected function saveJob(Job $job)
{
@@ -255,8 +219,6 @@ protected function saveJob(Job $job)
/**
* @see https://github.com/php-enqueue/enqueue-dev/pull/222#issuecomment-336102749 See for rationale
- *
- * @param Job $job
*/
protected function sendCalculateRootJobStatusEvent(Job $job)
{
diff --git a/pkg/job-queue/JobRunner.php b/pkg/job-queue/JobRunner.php
index afd445c67..e21e524d6 100644
--- a/pkg/job-queue/JobRunner.php
+++ b/pkg/job-queue/JobRunner.php
@@ -14,24 +14,17 @@ class JobRunner
*/
private $rootJob;
- /**
- * @param JobProcessor $jobProcessor
- * @param Job $rootJob
- */
- public function __construct(JobProcessor $jobProcessor, Job $rootJob = null)
+ public function __construct(JobProcessor $jobProcessor, ?Job $rootJob = null)
{
$this->jobProcessor = $jobProcessor;
$this->rootJob = $rootJob;
}
/**
- * @param string $ownerId
- * @param string $name
- * @param callable $runCallback
+ * @param string $ownerId
+ * @param string $name
*
* @throws \Throwable|\Exception if $runCallback triggers an exception
- *
- * @return mixed
*/
public function runUnique($ownerId, $name, callable $runCallback)
{
@@ -54,11 +47,7 @@ public function runUnique($ownerId, $name, callable $runCallback)
try {
$this->jobProcessor->failChildJob($childJob);
} catch (\Throwable $t) {
- throw new OrphanJobException(sprintf(
- 'Job cleanup failed. ID: "%s" Name: "%s"',
- $childJob->getId(),
- $childJob->getName()
- ), 0, $e);
+ throw new OrphanJobException(sprintf('Job cleanup failed. ID: "%s" Name: "%s"', $childJob->getId(), $childJob->getName()), 0, $e);
}
throw $e;
@@ -74,10 +63,7 @@ public function runUnique($ownerId, $name, callable $runCallback)
}
/**
- * @param string $name
- * @param callable $startCallback
- *
- * @return mixed
+ * @param string $name
*/
public function createDelayed($name, callable $startCallback)
{
@@ -89,10 +75,7 @@ public function createDelayed($name, callable $startCallback)
}
/**
- * @param string $jobId
- * @param callable $runCallback
- *
- * @return mixed
+ * @param string $jobId
*/
public function runDelayed($jobId, callable $runCallback)
{
diff --git a/pkg/job-queue/README.md b/pkg/job-queue/README.md
index e02a724aa..6fe624105 100644
--- a/pkg/job-queue/README.md
+++ b/pkg/job-queue/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Job Queue.
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/job-queue)
+[](https://github.com/php-enqueue/job-queue/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/job-queue)
[](https://packagist.org/packages/enqueue/job-queue)
diff --git a/pkg/job-queue/Test/DbalPersistedConnection.php b/pkg/job-queue/Test/DbalPersistedConnection.php
index f1ec03035..470a65176 100644
--- a/pkg/job-queue/Test/DbalPersistedConnection.php
+++ b/pkg/job-queue/Test/DbalPersistedConnection.php
@@ -22,9 +22,6 @@ class DbalPersistedConnection extends Connection
*/
protected static $persistedTransactionNestingLevels;
- /**
- * {@inheritdoc}
- */
public function connect()
{
if ($this->isConnected()) {
@@ -33,7 +30,6 @@ public function connect()
if ($this->hasPersistedConnection()) {
$this->_conn = $this->getPersistedConnection();
- $this->setConnected(true);
} else {
parent::connect();
$this->persistConnection($this->_conn);
@@ -42,44 +38,25 @@ public function connect()
return true;
}
- /**
- * {@inheritdoc}
- */
public function beginTransaction()
{
$this->wrapTransactionNestingLevel('beginTransaction');
+
+ return true;
}
- /**
- * {@inheritdoc}
- */
public function commit()
{
$this->wrapTransactionNestingLevel('commit');
+
+ return true;
}
- /**
- * {@inheritdoc}
- */
public function rollBack()
{
$this->wrapTransactionNestingLevel('rollBack');
- }
-
- /**
- * @param bool $connected
- */
- protected function setConnected($connected)
- {
- $rc = new \ReflectionClass(Connection::class);
- $rp = $rc->hasProperty('isConnected') ?
- $rc->getProperty('isConnected') :
- $rc->getProperty('_isConnected')
- ;
- $rp->setAccessible(true);
- $rp->setValue($this, $connected);
- $rp->setAccessible(false);
+ return true;
}
/**
@@ -102,9 +79,6 @@ protected function persistTransactionNestingLevel($level)
static::$persistedTransactionNestingLevels[$this->getConnectionId()] = $level;
}
- /**
- * @param DriverConnection $connection
- */
protected function persistConnection(DriverConnection $connection)
{
static::$persistedConnections[$this->getConnectionId()] = $connection;
diff --git a/pkg/job-queue/Test/JobRunner.php b/pkg/job-queue/Test/JobRunner.php
index 62d9f9a52..6194fbcee 100644
--- a/pkg/job-queue/Test/JobRunner.php
+++ b/pkg/job-queue/Test/JobRunner.php
@@ -26,9 +26,6 @@ public function __construct()
{
}
- /**
- * {@inheritdoc}
- */
public function runUnique($ownerId, $jobName, \Closure $runCallback)
{
$this->runUniqueJobs[] = ['ownerId' => $ownerId, 'jobName' => $jobName, 'runCallback' => $runCallback];
@@ -36,11 +33,6 @@ public function runUnique($ownerId, $jobName, \Closure $runCallback)
return call_user_func($runCallback, $this, new Job());
}
- /**
- * {@inheritdoc}
- *
- * @return mixed
- */
public function createDelayed($jobName, \Closure $startCallback)
{
$this->createDelayedJobs[] = ['jobName' => $jobName, 'runCallback' => $startCallback];
@@ -48,11 +40,6 @@ public function createDelayed($jobName, \Closure $startCallback)
return call_user_func($startCallback, $this, new Job());
}
- /**
- * {@inheritdoc}
- *
- * @return mixed
- */
public function runDelayed($jobId, \Closure $runCallback)
{
$this->runDelayedJobs[] = ['jobId' => $jobId, 'runCallback' => $runCallback];
diff --git a/pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php b/pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php
index 2e5a6ac4c..8509f0544 100644
--- a/pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php
+++ b/pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php
@@ -17,16 +17,6 @@
class CalculateRootJobStatusProcessorTest extends \PHPUnit\Framework\TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new CalculateRootJobStatusProcessor(
- $this->createJobStorageMock(),
- $this->createCalculateRootJobStatusCaseMock(),
- $this->createProducerMock(),
- $this->createLoggerMock()
- );
- }
-
public function testShouldReturnSubscribedTopicNames()
{
$this->assertEquals(
diff --git a/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php b/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php
index bcb62531a..a0f1b4c86 100644
--- a/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php
+++ b/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php
@@ -9,11 +9,6 @@
class CalculateRootJobStatusServiceTest extends \PHPUnit\Framework\TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new CalculateRootJobStatusService($this->createJobStorageMock());
- }
-
public function stopStatusProvider()
{
return [
@@ -25,8 +20,6 @@ public function stopStatusProvider()
/**
* @dataProvider stopStatusProvider
- *
- * @param mixed $status
*/
public function testShouldDoNothingIfRootJobHasStopState($status)
{
@@ -75,8 +68,6 @@ public function testShouldCalculateRootJobStatus()
/**
* @dataProvider stopStatusProvider
- *
- * @param mixed $stopStatus
*/
public function testShouldCalculateRootJobStatusAndSetStoppedAtTimeIfGotStopStatus($stopStatus)
{
@@ -102,7 +93,10 @@ public function testShouldCalculateRootJobStatusAndSetStoppedAtTimeIfGotStopStat
$case->calculate($childJob);
$this->assertEquals($stopStatus, $rootJob->getStatus());
- $this->assertEquals(new \DateTime(), $rootJob->getStoppedAt(), '', 1);
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $rootJob->getStoppedAt()->getTimestamp()
+ );
}
public function testShouldSetStoppedAtOnlyIfWasNotSet()
@@ -129,7 +123,10 @@ public function testShouldSetStoppedAtOnlyIfWasNotSet()
$case = new CalculateRootJobStatusService($em);
$case->calculate($childJob);
- $this->assertEquals(new \DateTime('2012-12-12 12:12:12'), $rootJob->getStoppedAt());
+ $this->assertEquals(
+ (new \DateTime('2012-12-12 12:12:12'))->getTimestamp(),
+ $rootJob->getStoppedAt()->getTimestamp()
+ );
}
public function testShouldThrowIfInvalidStatus()
@@ -355,7 +352,7 @@ public function testShouldSetStatusSuccessIfAllAreSuccess()
}
/**
- * @return MockObject|\Enqueue\JobQueue\Doctrine\JobStorage
+ * @return MockObject|JobStorage
*/
private function createJobStorageMock()
{
diff --git a/pkg/job-queue/Tests/DependentJobContextTest.php b/pkg/job-queue/Tests/DependentJobContextTest.php
index 32340d687..35942a974 100644
--- a/pkg/job-queue/Tests/DependentJobContextTest.php
+++ b/pkg/job-queue/Tests/DependentJobContextTest.php
@@ -7,11 +7,6 @@
class DependentJobContextTest extends \PHPUnit\Framework\TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new DependentJobContext(new Job());
- }
-
public function testShouldReturnJob()
{
$job = new Job();
diff --git a/pkg/job-queue/Tests/DependentJobProcessorTest.php b/pkg/job-queue/Tests/DependentJobProcessorTest.php
index fff9517a4..dcebf0d49 100644
--- a/pkg/job-queue/Tests/DependentJobProcessorTest.php
+++ b/pkg/job-queue/Tests/DependentJobProcessorTest.php
@@ -326,7 +326,7 @@ private function createContextMock()
}
/**
- * @return MockObject|\Enqueue\JobQueue\Doctrine\JobStorage
+ * @return MockObject|JobStorage
*/
private function createJobStorageMock()
{
diff --git a/pkg/job-queue/Tests/DependentJobServiceTest.php b/pkg/job-queue/Tests/DependentJobServiceTest.php
index 149856308..c2a1c7b1a 100644
--- a/pkg/job-queue/Tests/DependentJobServiceTest.php
+++ b/pkg/job-queue/Tests/DependentJobServiceTest.php
@@ -10,11 +10,6 @@
class DependentJobServiceTest extends \PHPUnit\Framework\TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new DependentJobService($this->createJobStorageMock());
- }
-
public function testShouldThrowIfJobIsNotRootJob()
{
$job = new Job();
@@ -68,7 +63,7 @@ public function testShouldSaveDependentJobs()
}
/**
- * @return MockObject|\Enqueue\JobQueue\Doctrine\JobStorage
+ * @return MockObject|JobStorage
*/
private function createJobStorageMock()
{
diff --git a/pkg/job-queue/Tests/Doctrine/JobStorageTest.php b/pkg/job-queue/Tests/Doctrine/JobStorageTest.php
index 38d72a81c..73f130d52 100644
--- a/pkg/job-queue/Tests/Doctrine/JobStorageTest.php
+++ b/pkg/job-queue/Tests/Doctrine/JobStorageTest.php
@@ -15,11 +15,6 @@
class JobStorageTest extends \PHPUnit\Framework\TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new JobStorage($this->createDoctrineMock(), 'entity-class', 'unique_table');
- }
-
public function testShouldCreateJobObject()
{
$repository = $this->createRepositoryMock();
diff --git a/pkg/job-queue/Tests/Functional/Entity/Job.php b/pkg/job-queue/Tests/Functional/Entity/Job.php
index b6e0308a4..ad90e58a0 100644
--- a/pkg/job-queue/Tests/Functional/Entity/Job.php
+++ b/pkg/job-queue/Tests/Functional/Entity/Job.php
@@ -6,97 +6,47 @@
use Doctrine\ORM\Mapping as ORM;
use Enqueue\JobQueue\Job as BaseJob;
-/**
- * @ORM\Entity
- * @ORM\Table(name="enqueue_job_queue")
- */
+#[ORM\Entity]
+#[ORM\Table(name: 'enqueue_job_queue')]
class Job extends BaseJob
{
- /**
- * @var int
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
+ #[ORM\Column(name: 'id', type: 'integer')]
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;
- /**
- * @var string
- *
- * @ORM\Column(name="owner_id", type="string", nullable=true)
- */
+ #[ORM\Column(name: 'owner_id', type: 'string', nullable: true)]
protected $ownerId;
- /**
- * @var string
- *
- * @ORM\Column(name="name", type="string", nullable=false)
- */
+ #[ORM\Column(name: 'name', type: 'string', nullable: false)]
protected $name;
- /**
- * @var string
- *
- * @ORM\Column(name="status", type="string", nullable=false)
- */
+ #[ORM\Column(name: 'status', type: 'string', nullable: false)]
protected $status;
- /**
- * @var bool
- *
- * @ORM\Column(name="interrupted", type="boolean")
- */
+ #[ORM\Column(name: 'interrupted', type: 'boolean')]
protected $interrupted;
- /**
- * @var bool;
- *
- * @ORM\Column(name="`unique`", type="boolean")
- */
+ #[ORM\Column(name: '`unique`', type: 'boolean')]
protected $unique;
- /**
- * @var Job
- *
- * @ORM\ManyToOne(targetEntity="Job", inversedBy="childJobs")
- * @ORM\JoinColumn(name="root_job_id", referencedColumnName="id", onDelete="CASCADE")
- */
+ #[ORM\ManyToOne(targetEntity: 'Job', inversedBy: 'childJobs')]
+ #[ORM\JoinColumn(name: 'root_job_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected $rootJob;
- /**
- * @var Job[]
- *
- * @ORM\OneToMany(targetEntity="Job", mappedBy="rootJob")
- */
+ #[ORM\OneToMany(mappedBy: 'rootJob', targetEntity: 'Job')]
protected $childJobs;
- /**
- * @var \DateTime
- *
- * @ORM\Column(name="created_at", type="datetime", nullable=false)
- */
+ #[ORM\Column(name: 'created_at', type: 'datetime', nullable: false)]
protected $createdAt;
- /**
- * @var \DateTime
- *
- * @ORM\Column(name="started_at", type="datetime", nullable=true)
- */
+ #[ORM\Column(name: 'started_at', type: 'datetime', nullable: true)]
protected $startedAt;
- /**
- * @var \DateTime
- *
- * @ORM\Column(name="stopped_at", type="datetime", nullable=true)
- */
+ #[ORM\Column(name: 'stopped_at', type: 'datetime', nullable: true)]
protected $stoppedAt;
- /**
- * @var array
- *
- * @ORM\Column(name="data", type="json_array", nullable=true)
- */
+ #[ORM\Column(name: 'data', type: 'json', nullable: true)]
protected $data;
public function __construct()
diff --git a/pkg/job-queue/Tests/Functional/Entity/JobUnique.php b/pkg/job-queue/Tests/Functional/Entity/JobUnique.php
index 4d8a33745..6d10ea2a5 100644
--- a/pkg/job-queue/Tests/Functional/Entity/JobUnique.php
+++ b/pkg/job-queue/Tests/Functional/Entity/JobUnique.php
@@ -4,15 +4,11 @@
use Doctrine\ORM\Mapping as ORM;
-/**
- * @ORM\Entity
- * @ORM\Table(name="enqueue_job_queue_unique")
- */
+#[ORM\Entity]
+#[ORM\Table(name: 'enqueue_job_queue_unique')]
class JobUnique
{
- /**
- * @ORM\Id
- * @ORM\Column(name="name", type="string", nullable=false)
- */
+ #[ORM\Id]
+ #[ORM\Column(name: 'name', type: 'string', nullable: false)]
protected $name;
}
diff --git a/pkg/job-queue/Tests/Functional/Job/JobStorageTest.php b/pkg/job-queue/Tests/Functional/Job/JobStorageTest.php
index c2c8fb94d..e884c31e8 100644
--- a/pkg/job-queue/Tests/Functional/Job/JobStorageTest.php
+++ b/pkg/job-queue/Tests/Functional/Job/JobStorageTest.php
@@ -142,7 +142,7 @@ private function getEntityManager()
}
/**
- * @return \Enqueue\JobQueue\Doctrine\JobStorage
+ * @return JobStorage
*/
private function getJobStorage()
{
diff --git a/pkg/job-queue/Tests/Functional/WebTestCase.php b/pkg/job-queue/Tests/Functional/WebTestCase.php
index 2f8e17cea..781bb5da4 100644
--- a/pkg/job-queue/Tests/Functional/WebTestCase.php
+++ b/pkg/job-queue/Tests/Functional/WebTestCase.php
@@ -18,7 +18,7 @@ abstract class WebTestCase extends BaseWebTestCase
*/
protected static $container;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -40,10 +40,7 @@ protected function tearDown(): void
static::ensureKernelShutdown();
}
- /**
- * @return string
- */
- public static function getKernelClass()
+ public static function getKernelClass(): string
{
require_once __DIR__.'/app/AppKernel.php';
@@ -61,9 +58,9 @@ protected function startTransaction()
protected function rollbackTransaction()
{
- //the error can be thrown during setUp
- //It would be caught by phpunit and tearDown called.
- //In this case we could not rollback since container may not exist.
+ // the error can be thrown during setUp
+ // It would be caught by phpunit and tearDown called.
+ // In this case we could not rollback since container may not exist.
if (false == static::$container) {
return;
}
diff --git a/pkg/job-queue/Tests/Functional/app/AppKernel.php b/pkg/job-queue/Tests/Functional/app/AppKernel.php
index ce21df0b8..b51969f68 100644
--- a/pkg/job-queue/Tests/Functional/app/AppKernel.php
+++ b/pkg/job-queue/Tests/Functional/app/AppKernel.php
@@ -1,50 +1,42 @@
load(__DIR__.'/config/config-sf5.yml');
+
+ return;
+ }
+
$loader->load(__DIR__.'/config/config.yml');
}
- protected function getContainerClass()
+ protected function getContainerClass(): string
{
return parent::getContainerClass().'JobQueue';
}
diff --git a/pkg/job-queue/Tests/Functional/app/config/config-sf5.yml b/pkg/job-queue/Tests/Functional/app/config/config-sf5.yml
new file mode 100644
index 000000000..dd3467e11
--- /dev/null
+++ b/pkg/job-queue/Tests/Functional/app/config/config-sf5.yml
@@ -0,0 +1,33 @@
+parameters:
+ locale: 'en'
+ secret: 'ThisTokenIsNotSoSecretChangeIt'
+
+framework:
+ #esi: ~
+ #translator: { fallback: "%locale%" }
+ test: ~
+ assets: false
+ session:
+ # the only option incompatible with Symfony 6
+ storage_id: session.storage.mock_file
+ secret: "%secret%"
+ router: { resource: "%kernel.project_dir%/config/routing.yml" }
+ default_locale: "%locale%"
+
+doctrine:
+ dbal:
+ url: "%env(DOCTRINE_DSN)%"
+ driver: pdo_mysql
+ charset: UTF8
+ wrapper_class: "Enqueue\\JobQueue\\Test\\DbalPersistedConnection"
+ orm:
+ auto_generate_proxy_classes: true
+ auto_mapping: true
+ mappings:
+ TestEntity:
+ mapping: true
+ type: annotation
+ dir: '%kernel.project_dir%/Tests/Functional/Entity'
+ alias: 'EnqueueJobQueue'
+ prefix: 'Enqueue\JobQueue\Tests\Functional\Entity'
+ is_bundle: false
diff --git a/pkg/job-queue/Tests/Functional/app/config/config.yml b/pkg/job-queue/Tests/Functional/app/config/config.yml
index b6d642b82..0121acdbf 100644
--- a/pkg/job-queue/Tests/Functional/app/config/config.yml
+++ b/pkg/job-queue/Tests/Functional/app/config/config.yml
@@ -8,7 +8,7 @@ framework:
test: ~
assets: false
session:
- storage_id: session.storage.mock_file
+ storage_factory_id: session.storage.factory.mock_file
secret: "%secret%"
router: { resource: "%kernel.project_dir%/config/routing.yml" }
default_locale: "%locale%"
@@ -25,7 +25,7 @@ doctrine:
mappings:
TestEntity:
mapping: true
- type: annotation
+ type: attribute
dir: '%kernel.project_dir%/Tests/Functional/Entity'
alias: 'EnqueueJobQueue'
prefix: 'Enqueue\JobQueue\Tests\Functional\Entity'
diff --git a/pkg/job-queue/Tests/JobProcessorTest.php b/pkg/job-queue/Tests/JobProcessorTest.php
index f4e937c02..9f1c7b2fd 100644
--- a/pkg/job-queue/Tests/JobProcessorTest.php
+++ b/pkg/job-queue/Tests/JobProcessorTest.php
@@ -13,11 +13,6 @@
class JobProcessorTest extends TestCase
{
- public function testCouldBeCreatedWithRequiredArguments()
- {
- new JobProcessor($this->createJobStorage(), $this->createProducerMock());
- }
-
public function testCreateRootJobShouldThrowIfOwnerIdIsEmpty()
{
$processor = new JobProcessor($this->createJobStorage(), $this->createProducerMock());
@@ -60,8 +55,14 @@ public function testShouldCreateRootJobAndReturnIt()
$this->assertSame($job, $result);
$this->assertEquals(Job::STATUS_NEW, $job->getStatus());
- $this->assertEquals(new \DateTime(), $job->getCreatedAt(), '', 1);
- $this->assertEquals(new \DateTime(), $job->getStartedAt(), '', 1);
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $job->getCreatedAt()->getTimestamp()
+ );
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $job->getStartedAt()->getTimestamp()
+ );
$this->assertNull($job->getStoppedAt());
$this->assertEquals('job-name', $job->getName());
$this->assertEquals('owner-id', $job->getOwnerId());
@@ -183,7 +184,10 @@ public function testCreateChildJobShouldCreateAndSaveJobAndPublishRecalculateRoo
$this->assertSame($job, $result);
$this->assertEquals(Job::STATUS_NEW, $job->getStatus());
- $this->assertEquals(new \DateTime(), $job->getCreatedAt(), '', 1);
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $job->getCreatedAt()->getTimestamp()
+ );
$this->assertNull($job->getStartedAt());
$this->assertNull($job->getStoppedAt());
$this->assertEquals('job-name', $job->getName());
@@ -256,7 +260,10 @@ public function testStartJobShouldUpdateJobWithRunningStatusAndStartAtTime()
$processor->startChildJob($job);
$this->assertEquals(Job::STATUS_RUNNING, $job->getStatus());
- $this->assertEquals(new \DateTime(), $job->getStartedAt(), '', 1);
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $job->getStartedAt()->getTimestamp()
+ );
}
public function testSuccessChildJobShouldThrowIfRootJob()
@@ -325,7 +332,10 @@ public function testSuccessJobShouldUpdateJobWithSuccessStatusAndStopAtTime()
$processor->successChildJob($job);
$this->assertEquals(Job::STATUS_SUCCESS, $job->getStatus());
- $this->assertEquals(new \DateTime(), $job->getStoppedAt(), '', 1);
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $job->getStoppedAt()->getTimestamp()
+ );
}
public function testFailChildJobShouldThrowIfRootJob()
@@ -394,7 +404,10 @@ public function testFailJobShouldUpdateJobWithFailStatusAndStopAtTime()
$processor->failChildJob($job);
$this->assertEquals(Job::STATUS_FAILED, $job->getStatus());
- $this->assertEquals(new \DateTime(), $job->getStoppedAt(), '', 1);
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $job->getStoppedAt()->getTimestamp()
+ );
}
public function testCancelChildJobShouldThrowIfRootJob()
@@ -463,8 +476,14 @@ public function testCancelJobShouldUpdateJobWithCancelStatusAndStoppedAtTimeAndS
$processor->cancelChildJob($job);
$this->assertEquals(Job::STATUS_CANCELLED, $job->getStatus());
- $this->assertEquals(new \DateTime(), $job->getStoppedAt(), '', 1);
- $this->assertEquals(new \DateTime(), $job->getStartedAt(), '', 1);
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $job->getStoppedAt()->getTimestamp()
+ );
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $job->getStartedAt()->getTimestamp()
+ );
}
public function testInterruptRootJobShouldThrowIfNotRootJob()
@@ -536,7 +555,10 @@ public function testInterruptRootJobShouldUpdateJobAndSetInterruptedTrueAndStopp
$processor->interruptRootJob($rootJob, true);
$this->assertTrue($rootJob->isInterrupted());
- $this->assertEquals(new \DateTime(), $rootJob->getStoppedAt(), '', 1);
+ $this->assertEquals(
+ (new \DateTime())->getTimestamp(),
+ $rootJob->getStoppedAt()->getTimestamp()
+ );
}
/**
diff --git a/pkg/job-queue/Topics.php b/pkg/job-queue/Topics.php
index 61b424b25..891ea26f7 100644
--- a/pkg/job-queue/Topics.php
+++ b/pkg/job-queue/Topics.php
@@ -4,5 +4,5 @@
class Topics
{
- const ROOT_JOB_STOPPED = 'enqueue.message_queue.job.root_job_stopped';
+ public const ROOT_JOB_STOPPED = 'enqueue.message_queue.job.root_job_stopped';
}
diff --git a/pkg/job-queue/composer.json b/pkg/job-queue/composer.json
index 08b9889c2..6616069b3 100644
--- a/pkg/job-queue/composer.json
+++ b/pkg/job-queue/composer.json
@@ -6,21 +6,21 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"enqueue/enqueue": "^0.10",
"enqueue/null": "^0.10",
"queue-interop/queue-interop": "^0.8",
- "doctrine/orm": "~2.4",
- "doctrine/dbal": "<2.10"
+ "doctrine/orm": "^2.12",
+ "doctrine/dbal": "^2.12 | ^3.0"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
- "doctrine/doctrine-bundle": "~1.2|^2",
- "symfony/browser-kit": "^4.3|^5",
- "symfony/expression-language": "^4.3|^5",
- "symfony/framework-bundle": "^4.3|^5",
- "symfony/yaml": "^4.3|^5"
+ "doctrine/doctrine-bundle": "^2.3.2",
+ "symfony/browser-kit": "^5.4|^6.0",
+ "symfony/expression-language": "^5.4|^6.0",
+ "symfony/framework-bundle": "^5.4|^6.0",
+ "symfony/yaml": "^5.4|^6.0"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/mongodb/.github/workflows/ci.yml b/pkg/mongodb/.github/workflows/ci.yml
new file mode 100644
index 000000000..415baf634
--- /dev/null
+++ b/pkg/mongodb/.github/workflows/ci.yml
@@ -0,0 +1,30 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+ extensions: mongodb
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/mongodb/.travis.yml b/pkg/mongodb/.travis.yml
deleted file mode 100644
index 6415d29e8..000000000
--- a/pkg/mongodb/.travis.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-sudo: false
-
-language: php
-
-php:
- - '7.1'
-
-git:
- depth: 10
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-services:
- - mongodb
-
-before_install:
- - echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
-
diff --git a/pkg/mongodb/JSON.php b/pkg/mongodb/JSON.php
index 84cac50da..481b7f9ff 100644
--- a/pkg/mongodb/JSON.php
+++ b/pkg/mongodb/JSON.php
@@ -14,10 +14,7 @@ class JSON
public static function decode($string)
{
if (!is_string($string)) {
- throw new \InvalidArgumentException(sprintf(
- 'Accept only string argument but got: "%s"',
- is_object($string) ? get_class($string) : gettype($string)
- ));
+ throw new \InvalidArgumentException(sprintf('Accept only string argument but got: "%s"', is_object($string) ? $string::class : gettype($string)));
}
// PHP7 fix - empty string and null cause syntax error
@@ -26,32 +23,22 @@ public static function decode($string)
}
$decoded = json_decode($string, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return $decoded;
}
/**
- * @param mixed $value
- *
* @return string
*/
public static function encode($value)
{
- $encoded = json_encode($value, JSON_UNESCAPED_UNICODE);
-
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'Could not encode value into json. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ $encoded = json_encode($value, \JSON_UNESCAPED_UNICODE);
+
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return $encoded;
diff --git a/pkg/mongodb/MongodbConnectionFactory.php b/pkg/mongodb/MongodbConnectionFactory.php
index 3d7624904..3d34f7369 100644
--- a/pkg/mongodb/MongodbConnectionFactory.php
+++ b/pkg/mongodb/MongodbConnectionFactory.php
@@ -89,7 +89,7 @@ public static function parseDsn(string $dsn): array
// see: https://github.com/php-enqueue/enqueue-dev/issues/1027
if (isset($parsedUrl['path']) && '/' !== $parsedUrl['path']) {
$pathParts = explode('/', $parsedUrl['path']);
- //DB name
+ // DB name
if ($pathParts[1]) {
$config['dbname'] = $pathParts[1];
}
@@ -97,7 +97,7 @@ public static function parseDsn(string $dsn): array
if (isset($parsedUrl['query'])) {
$queryParts = null;
parse_str($parsedUrl['query'], $queryParts);
- //get enqueue attributes values
+ // get enqueue attributes values
if (!empty($queryParts['polling_interval'])) {
$config['polling_interval'] = (int) $queryParts['polling_interval'];
}
diff --git a/pkg/mongodb/MongodbContext.php b/pkg/mongodb/MongodbContext.php
index e6f5a579c..2e52ebdb2 100644
--- a/pkg/mongodb/MongodbContext.php
+++ b/pkg/mongodb/MongodbContext.php
@@ -161,5 +161,6 @@ public function createCollection(): void
$collection->createIndex(['queue' => 1], ['name' => 'enqueue_queue']);
$collection->createIndex(['priority' => -1, 'published_at' => 1], ['name' => 'enqueue_priority']);
$collection->createIndex(['delayed_until' => 1], ['name' => 'enqueue_delayed']);
+ $collection->createIndex(['queue' => 1, 'priority' => -1, 'published_at' => 1, 'delayed_until' => 1], ['name' => 'enqueue_combined']);
}
}
diff --git a/pkg/mongodb/MongodbMessage.php b/pkg/mongodb/MongodbMessage.php
index fbfbd75d6..fadc5dd4e 100644
--- a/pkg/mongodb/MongodbMessage.php
+++ b/pkg/mongodb/MongodbMessage.php
@@ -65,7 +65,7 @@ public function __construct(string $body = '', array $properties = [], array $he
$this->redelivered = false;
}
- public function setId(string $id = null): void
+ public function setId(?string $id = null): void
{
$this->id = $id;
}
@@ -135,7 +135,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -150,7 +150,7 @@ public function getPriority(): ?int
return $this->priority;
}
- public function setPriority(int $priority = null): void
+ public function setPriority(?int $priority = null): void
{
$this->priority = $priority;
}
@@ -163,7 +163,7 @@ public function getDeliveryDelay(): ?int
/**
* In milliseconds.
*/
- public function setDeliveryDelay(int $deliveryDelay = null): void
+ public function setDeliveryDelay(?int $deliveryDelay = null): void
{
$this->deliveryDelay = $deliveryDelay;
}
@@ -176,12 +176,12 @@ public function getTimeToLive(): ?int
/**
* In milliseconds.
*/
- public function setTimeToLive(int $timeToLive = null): void
+ public function setTimeToLive(?int $timeToLive = null): void
{
$this->timeToLive = $timeToLive;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', $correlationId);
}
@@ -191,7 +191,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id', null);
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', $messageId);
}
@@ -208,7 +208,7 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
@@ -221,7 +221,7 @@ public function getPublishedAt(): ?int
/**
* In milliseconds.
*/
- public function setPublishedAt(int $publishedAt = null): void
+ public function setPublishedAt(?int $publishedAt = null): void
{
$this->publishedAt = $publishedAt;
}
diff --git a/pkg/mongodb/MongodbProducer.php b/pkg/mongodb/MongodbProducer.php
index d26696cf8..ed28a6681 100644
--- a/pkg/mongodb/MongodbProducer.php
+++ b/pkg/mongodb/MongodbProducer.php
@@ -77,7 +77,7 @@ public function send(Destination $destination, Message $message): void
$delay = $message->getDeliveryDelay();
if ($delay) {
if (!is_int($delay)) {
- throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? get_class($delay) : gettype($delay)));
+ throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? $delay::class : gettype($delay)));
}
if ($delay <= 0) {
@@ -90,7 +90,7 @@ public function send(Destination $destination, Message $message): void
$timeToLive = $message->getTimeToLive();
if ($timeToLive) {
if (!is_int($timeToLive)) {
- throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? get_class($timeToLive) : gettype($timeToLive)));
+ throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? $timeToLive::class : gettype($timeToLive)));
}
if ($timeToLive <= 0) {
@@ -111,7 +111,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return self
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
$this->deliveryDelay = $deliveryDelay;
@@ -126,7 +126,7 @@ public function getDeliveryDelay(): ?int
/**
* @return self
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;
@@ -141,7 +141,7 @@ public function getPriority(): ?int
/**
* @return self
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
diff --git a/pkg/mongodb/MongodbSubscriptionConsumer.php b/pkg/mongodb/MongodbSubscriptionConsumer.php
index 59063dd82..9fa6245f4 100644
--- a/pkg/mongodb/MongodbSubscriptionConsumer.php
+++ b/pkg/mongodb/MongodbSubscriptionConsumer.php
@@ -21,9 +21,6 @@ class MongodbSubscriptionConsumer implements SubscriptionConsumer
*/
private $subscribers;
- /**
- * @param MongodbContext $context
- */
public function __construct(MongodbContext $context)
{
$this->context = $context;
@@ -92,7 +89,7 @@ public function consume(int $timeout = 0): void
public function subscribe(Consumer $consumer, callable $callback): void
{
if (false == $consumer instanceof MongodbConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, $consumer::class));
}
$queueName = $consumer->getQueue()->getQueueName();
@@ -113,7 +110,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
public function unsubscribe(Consumer $consumer): void
{
if (false == $consumer instanceof MongodbConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, $consumer::class));
}
$queueName = $consumer->getQueue()->getQueueName();
diff --git a/pkg/mongodb/README.md b/pkg/mongodb/README.md
index c57f15fc7..2e9bbd1fc 100644
--- a/pkg/mongodb/README.md
+++ b/pkg/mongodb/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Mongodb Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/mongodb)
+[](https://github.com/php-enqueue/mongodb/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/mongodb)
[](https://packagist.org/packages/enqueue/mongodb)
diff --git a/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php b/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php
index 6e7f01e5c..b6b644beb 100644
--- a/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php
+++ b/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php
@@ -19,7 +19,7 @@ class MongodbConsumerTest extends TestCase
*/
private $context;
- public function setUp()
+ protected function setUp(): void
{
$this->context = $this->buildMongodbContext();
}
diff --git a/pkg/mongodb/Tests/MongodbConnectionFactoryTest.php b/pkg/mongodb/Tests/MongodbConnectionFactoryTest.php
index c15b0fa43..d5dd9ca45 100644
--- a/pkg/mongodb/Tests/MongodbConnectionFactoryTest.php
+++ b/pkg/mongodb/Tests/MongodbConnectionFactoryTest.php
@@ -5,6 +5,7 @@
use Enqueue\Mongodb\MongodbConnectionFactory;
use Enqueue\Mongodb\MongodbContext;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
@@ -14,6 +15,7 @@
class MongodbConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
diff --git a/pkg/mongodb/Tests/MongodbConsumerTest.php b/pkg/mongodb/Tests/MongodbConsumerTest.php
index cd2ee06f8..6cd597514 100644
--- a/pkg/mongodb/Tests/MongodbConsumerTest.php
+++ b/pkg/mongodb/Tests/MongodbConsumerTest.php
@@ -25,11 +25,6 @@ public function testShouldImplementConsumerInterface()
$this->assertClassImplements(Consumer::class, MongodbConsumer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new MongodbConsumer($this->createContextMock(), new MongodbDestination('queue'));
- }
-
public function testShouldReturnInstanceOfDestination()
{
$destination = new MongodbDestination('queue');
@@ -39,6 +34,9 @@ public function testShouldReturnInstanceOfDestination()
$this->assertSame($destination, $consumer->getQueue());
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testCouldCallAcknowledgedMethod()
{
$consumer = new MongodbConsumer($this->createContextMock(), new MongodbDestination('queue'));
@@ -183,7 +181,7 @@ public function isRedelivered(): bool
throw new \BadMethodCallException('This should not be called directly');
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
}
@@ -192,7 +190,7 @@ public function getCorrelationId(): ?string
throw new \BadMethodCallException('This should not be called directly');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
}
@@ -206,11 +204,11 @@ public function getTimestamp(): ?int
throw new \BadMethodCallException('This should not be called directly');
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
}
diff --git a/pkg/mongodb/Tests/MongodbContextTest.php b/pkg/mongodb/Tests/MongodbContextTest.php
index 32835c90e..8cdef79ff 100644
--- a/pkg/mongodb/Tests/MongodbContextTest.php
+++ b/pkg/mongodb/Tests/MongodbContextTest.php
@@ -8,6 +8,7 @@
use Enqueue\Mongodb\MongodbMessage;
use Enqueue\Mongodb\MongodbProducer;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Context;
use Interop\Queue\Destination;
use Interop\Queue\Exception\InvalidDestinationException;
@@ -21,17 +22,13 @@
class MongodbContextTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementContextInterface()
{
$this->assertClassImplements(Context::class, MongodbContext::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new MongodbContext($this->createClientMock());
- }
-
public function testCouldBeConstructedWithEmptyConfiguration()
{
$context = new MongodbContext($this->createClientMock(), []);
diff --git a/pkg/mongodb/Tests/MongodbProducerTest.php b/pkg/mongodb/Tests/MongodbProducerTest.php
index 8e8900cfd..6987b1a76 100644
--- a/pkg/mongodb/Tests/MongodbProducerTest.php
+++ b/pkg/mongodb/Tests/MongodbProducerTest.php
@@ -23,11 +23,6 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(Producer::class, MongodbProducer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new MongodbProducer($this->createContextMock());
- }
-
public function testShouldThrowIfDestinationOfInvalidType()
{
$this->expectException(InvalidDestinationException::class);
diff --git a/pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php b/pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php
index 7d3cb44f4..d982e0418 100644
--- a/pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php
+++ b/pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php
@@ -7,6 +7,7 @@
use Enqueue\Mongodb\MongodbConsumer;
use Enqueue\Mongodb\MongodbContext;
use Enqueue\Mongodb\MongodbSubscriptionConsumer;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Consumer;
use Interop\Queue\Queue;
use Interop\Queue\SubscriptionConsumer;
@@ -14,6 +15,8 @@
class MongodbSubscriptionConsumerTest extends TestCase
{
+ use ReadAttributeTrait;
+
public function testShouldImplementSubscriptionConsumerInterface()
{
$rc = new \ReflectionClass(MongodbSubscriptionConsumer::class);
@@ -21,11 +24,6 @@ public function testShouldImplementSubscriptionConsumerInterface()
$this->assertTrue($rc->implementsInterface(SubscriptionConsumer::class));
}
- public function testCouldBeConstructedWithMongodbContextAsFirstArgument()
- {
- new MongodbSubscriptionConsumer($this->createMongodbContextMock());
- }
-
public function testShouldAddConsumerAndCallbackToSubscribersPropertyOnSubscribe()
{
$subscriptionConsumer = new MongodbSubscriptionConsumer($this->createMongodbContextMock());
@@ -62,6 +60,9 @@ public function testThrowsIfTrySubscribeAnotherConsumerToAlreadySubscribedQueue(
$subscriptionConsumer->subscribe($barConsumer, $barCallback);
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldAllowSubscribeSameConsumerAndCallbackSecondTime()
{
$subscriptionConsumer = new MongodbSubscriptionConsumer($this->createMongodbContextMock());
diff --git a/pkg/mongodb/Tests/Spec/MongodbConnectionFactoryTest.php b/pkg/mongodb/Tests/Spec/MongodbConnectionFactoryTest.php
index 359b23eff..9f0d195ba 100644
--- a/pkg/mongodb/Tests/Spec/MongodbConnectionFactoryTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbConnectionFactoryTest.php
@@ -10,9 +10,6 @@
*/
class MongodbConnectionFactoryTest extends ConnectionFactorySpec
{
- /**
- * {@inheritdoc}
- */
protected function createConnectionFactory()
{
return new MongodbConnectionFactory();
diff --git a/pkg/mongodb/Tests/Spec/MongodbContextTest.php b/pkg/mongodb/Tests/Spec/MongodbContextTest.php
index 22f2f3210..dfd5de3cb 100644
--- a/pkg/mongodb/Tests/Spec/MongodbContextTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbContextTest.php
@@ -13,9 +13,6 @@ class MongodbContextTest extends ContextSpec
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildMongodbContext();
diff --git a/pkg/mongodb/Tests/Spec/MongodbMessageTest.php b/pkg/mongodb/Tests/Spec/MongodbMessageTest.php
index 5efccfa01..92983d430 100644
--- a/pkg/mongodb/Tests/Spec/MongodbMessageTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbMessageTest.php
@@ -10,9 +10,6 @@
*/
class MongodbMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new MongodbMessage();
diff --git a/pkg/mongodb/Tests/Spec/MongodbProducerTest.php b/pkg/mongodb/Tests/Spec/MongodbProducerTest.php
index 9b4e18793..68b6007ec 100644
--- a/pkg/mongodb/Tests/Spec/MongodbProducerTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbProducerTest.php
@@ -13,9 +13,6 @@ class MongodbProducerTest extends ProducerSpec
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createProducer()
{
return $this->buildMongodbContext()->createProducer();
diff --git a/pkg/mongodb/Tests/Spec/MongodbQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbQueueTest.php
index f737d765f..25e437ba6 100644
--- a/pkg/mongodb/Tests/Spec/MongodbQueueTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbQueueTest.php
@@ -10,9 +10,6 @@
*/
class MongodbQueueTest extends QueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createQueue()
{
return new MongodbDestination(self::EXPECTED_QUEUE_NAME);
diff --git a/pkg/mongodb/Tests/Spec/MongodbRequeueMessageTest.php b/pkg/mongodb/Tests/Spec/MongodbRequeueMessageTest.php
index 454d357ad..8a9072470 100644
--- a/pkg/mongodb/Tests/Spec/MongodbRequeueMessageTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbRequeueMessageTest.php
@@ -13,9 +13,6 @@ class MongodbRequeueMessageTest extends RequeueMessageSpec
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildMongodbContext();
diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php
index a5eb3511d..f54513fae 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php
@@ -13,9 +13,6 @@ class MongodbSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDel
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildMongodbContext();
diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php
index 9869d6e06..6aadef7ba 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php
@@ -18,7 +18,7 @@ class MongodbSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceiveP
private $publishedAt;
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -34,8 +34,6 @@ protected function createContext()
}
/**
- * {@inheritdoc}
- *
* @param MongodbContext $context
*
* @return MongodbMessage
diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php
index d87ac10e9..f16e80b60 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php
@@ -13,9 +13,6 @@ class MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiv
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildMongodbContext();
diff --git a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php
index 992c0626e..c9b9cb2d1 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php
@@ -13,9 +13,6 @@ class MongodbSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildMongodbContext();
diff --git a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php
index c539386f7..a416d3c11 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php
@@ -13,9 +13,6 @@ class MongodbSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildMongodbContext();
diff --git a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php
index ea4febcc2..43ae34c6b 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php
@@ -13,9 +13,6 @@ class MongodbSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitF
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildMongodbContext();
diff --git a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php
index 1e1be32c1..0fe9f0e56 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php
@@ -13,9 +13,6 @@ class MongodbSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitF
{
use MongodbExtensionTrait;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildMongodbContext();
diff --git a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
index 664990a68..2fe16e860 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
@@ -20,8 +20,6 @@ class MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subs
/**
* @return MongodbContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param MongodbContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php
index 1071c1267..b18e0bf0d 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php
@@ -20,8 +20,6 @@ class MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest extends Subscripti
/**
* @return MongodbContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param MongodbContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php
index 321e16bba..3acfa94ed 100644
--- a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php
@@ -20,8 +20,6 @@ class MongodbSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerSto
/**
* @return MongodbContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -30,8 +28,6 @@ protected function createContext()
/**
* @param MongodbContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/mongodb/Tests/Spec/MongodbTopicTest.php b/pkg/mongodb/Tests/Spec/MongodbTopicTest.php
index ec524e519..ab5c025a2 100644
--- a/pkg/mongodb/Tests/Spec/MongodbTopicTest.php
+++ b/pkg/mongodb/Tests/Spec/MongodbTopicTest.php
@@ -10,9 +10,6 @@
*/
class MongodbTopicTest extends TopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createTopic()
{
return new MongodbDestination(self::EXPECTED_TOPIC_NAME);
diff --git a/pkg/mongodb/composer.json b/pkg/mongodb/composer.json
index 055abe0a2..f64d53ef3 100644
--- a/pkg/mongodb/composer.json
+++ b/pkg/mongodb/composer.json
@@ -10,14 +10,14 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8",
"mongodb/mongodb": "^1.2",
"ext-mongodb": "^1.5"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
- "queue-interop/queue-spec": "^0.6",
+ "phpunit/phpunit": "^9.5",
+ "queue-interop/queue-spec": "^0.6.2",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev"
},
diff --git a/pkg/monitoring/.github/workflows/ci.yml b/pkg/monitoring/.github/workflows/ci.yml
new file mode 100644
index 000000000..5448d7b1a
--- /dev/null
+++ b/pkg/monitoring/.github/workflows/ci.yml
@@ -0,0 +1,27 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/monitoring/.travis.yml b/pkg/monitoring/.travis.yml
deleted file mode 100644
index 02ba7238b..000000000
--- a/pkg/monitoring/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/monitoring/ConsumedMessageStats.php b/pkg/monitoring/ConsumedMessageStats.php
index 928bce0de..077ceebdf 100644
--- a/pkg/monitoring/ConsumedMessageStats.php
+++ b/pkg/monitoring/ConsumedMessageStats.php
@@ -6,10 +6,10 @@
class ConsumedMessageStats implements Stats
{
- const STATUS_ACK = 'acknowledged';
- const STATUS_REJECTED = 'rejected';
- const STATUS_REQUEUED = 'requeued';
- const STATUS_FAILED = 'failed';
+ public const STATUS_ACK = 'acknowledged';
+ public const STATUS_REJECTED = 'rejected';
+ public const STATUS_REQUEUED = 'requeued';
+ public const STATUS_FAILED = 'failed';
/**
* @var string
@@ -102,12 +102,12 @@ public function __construct(
array $properties,
bool $redelivered,
string $status,
- string $errorClass = null,
- string $errorMessage = null,
- int $errorCode = null,
- string $errorFile = null,
- int $errorLine = null,
- string $trace = null
+ ?string $errorClass = null,
+ ?string $errorMessage = null,
+ ?int $errorCode = null,
+ ?string $errorFile = null,
+ ?int $errorLine = null,
+ ?string $trace = null,
) {
$this->consumerId = $consumerId;
$this->timestampMs = $timestampMs;
diff --git a/pkg/monitoring/ConsumerMonitoringExtension.php b/pkg/monitoring/ConsumerMonitoringExtension.php
index af5ce9871..31e97697d 100644
--- a/pkg/monitoring/ConsumerMonitoringExtension.php
+++ b/pkg/monitoring/ConsumerMonitoringExtension.php
@@ -19,8 +19,8 @@
use Enqueue\Consumption\ProcessorExceptionExtensionInterface;
use Enqueue\Consumption\Result;
use Enqueue\Consumption\StartExtensionInterface;
+use Enqueue\Util\UUID;
use Psr\Log\LoggerInterface;
-use Ramsey\Uuid\Uuid;
class ConsumerMonitoringExtension implements StartExtensionInterface, PreSubscribeExtensionInterface, PreConsumeExtensionInterface, EndExtensionInterface, ProcessorExceptionExtensionInterface, MessageReceivedExtensionInterface, MessageResultExtensionInterface
{
@@ -82,7 +82,7 @@ public function __construct(StatsStorage $storage)
public function onStart(Start $context): void
{
- $this->consumerId = Uuid::uuid4()->toString();
+ $this->consumerId = UUID::generate();
$this->queues = [];
diff --git a/pkg/monitoring/ConsumerStats.php b/pkg/monitoring/ConsumerStats.php
index d1a745d14..d281b532d 100644
--- a/pkg/monitoring/ConsumerStats.php
+++ b/pkg/monitoring/ConsumerStats.php
@@ -121,12 +121,12 @@ public function __construct(
int $requeued,
int $memoryUsage,
float $systemLoad,
- string $errorClass = null,
- string $errorMessage = null,
- int $errorCode = null,
- string $errorFile = null,
- int $errorLine = null,
- string $trace = null
+ ?string $errorClass = null,
+ ?string $errorMessage = null,
+ ?int $errorCode = null,
+ ?string $errorFile = null,
+ ?int $errorLine = null,
+ ?string $trace = null,
) {
$this->consumerId = $consumerId;
$this->timestampMs = $timestampMs;
diff --git a/pkg/monitoring/DatadogStorage.php b/pkg/monitoring/DatadogStorage.php
index 82e841a3f..c10cbc671 100644
--- a/pkg/monitoring/DatadogStorage.php
+++ b/pkg/monitoring/DatadogStorage.php
@@ -30,7 +30,7 @@ public function __construct($config = 'datadog:')
$this->config = $this->prepareConfig($config);
if (null === $this->datadog) {
- if (true === filter_var($this->config['batched'], FILTER_VALIDATE_BOOLEAN)) {
+ if (true === filter_var($this->config['batched'], \FILTER_VALIDATE_BOOLEAN)) {
$this->datadog = new BatchedDogStatsd($this->config);
} else {
$this->datadog = new DogStatsd($this->config);
@@ -104,10 +104,7 @@ private function parseDsn(string $dsn): array
$dsn = Dsn::parseFirst($dsn);
if ('datadog' !== $dsn->getSchemeProtocol()) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be "datadog"',
- $dsn->getSchemeProtocol()
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "datadog"', $dsn->getSchemeProtocol()));
}
return array_filter(array_replace($dsn->getQuery(), [
@@ -132,11 +129,6 @@ private function parseDsn(string $dsn): array
});
}
- /**
- * @param $config
- *
- * @return array
- */
private function prepareConfig($config): array
{
if (empty($config)) {
diff --git a/pkg/monitoring/InfluxDbStorage.php b/pkg/monitoring/InfluxDbStorage.php
index ff5f6c3b0..e39cccfd2 100644
--- a/pkg/monitoring/InfluxDbStorage.php
+++ b/pkg/monitoring/InfluxDbStorage.php
@@ -67,9 +67,9 @@ public function __construct($config = 'influxdb:')
// and causes library to use defaults.
@trigger_error(
sprintf('Passing %s as %s argument is deprecated. Pass it as "client" array property or use createWithClient instead',
- Client::class,
- __METHOD__
- ), E_USER_DEPRECATED);
+ Client::class,
+ __METHOD__
+ ), \E_USER_DEPRECATED);
$this->client = $config;
$config = [];
} else {
@@ -91,12 +91,7 @@ public function __construct($config = 'influxdb:')
if (null !== $config['client']) {
if (!$config['client'] instanceof Client) {
- throw new \InvalidArgumentException(sprintf(
- '%s configuration property is expected to be an instance of %s class. %s was passed instead.',
- 'client',
- Client::class,
- gettype($config['client'])
- ));
+ throw new \InvalidArgumentException(sprintf('%s configuration property is expected to be an instance of %s class. %s was passed instead.', 'client', Client::class, gettype($config['client'])));
}
$this->client = $config['client'];
}
@@ -105,10 +100,7 @@ public function __construct($config = 'influxdb:')
}
/**
- * @param Client $client
* @param string $config
- *
- * @return InfluxDbStorage
*/
public static function createWithClient(Client $client, $config = 'influxdb:'): self
{
@@ -117,7 +109,7 @@ public static function createWithClient(Client $client, $config = 'influxdb:'):
}
$config['client'] = $client;
- return new static($config);
+ return new self($config);
}
public function pushConsumerStats(ConsumerStats $stats): void
@@ -254,10 +246,7 @@ private static function parseDsn(string $dsn): array
$dsn = Dsn::parseFirst($dsn);
if (false === in_array($dsn->getSchemeProtocol(), ['influxdb'], true)) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be "influxdb"',
- $dsn->getSchemeProtocol()
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "influxdb"', $dsn->getSchemeProtocol()));
}
return array_filter(array_replace($dsn->getQuery(), [
diff --git a/pkg/monitoring/JsonSerializer.php b/pkg/monitoring/JsonSerializer.php
index 1edb60e61..8d046092a 100644
--- a/pkg/monitoring/JsonSerializer.php
+++ b/pkg/monitoring/JsonSerializer.php
@@ -22,12 +22,8 @@ public function toString(Stats $stats): string
$json = json_encode($data);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return $json;
diff --git a/pkg/monitoring/README.md b/pkg/monitoring/README.md
index c14410cb9..dfd33f056 100644
--- a/pkg/monitoring/README.md
+++ b/pkg/monitoring/README.md
@@ -18,7 +18,7 @@ Queue Monitoring tool. Track sent, consumed messages. Consumers performances.
* Provides integration for Enqueue
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/monitoring)
+[](https://github.com/php-enqueue/monitoring/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/monitoring)
[](https://packagist.org/packages/enqueue/monitoring)
diff --git a/pkg/monitoring/Resources.php b/pkg/monitoring/Resources.php
index 2a5995fa3..409d9861f 100644
--- a/pkg/monitoring/Resources.php
+++ b/pkg/monitoring/Resources.php
@@ -7,7 +7,7 @@ final class Resources
/**
* @var array
*/
- private static $knownStorages = null;
+ private static $knownStorages;
private function __construct()
{
diff --git a/pkg/monitoring/SentMessageStats.php b/pkg/monitoring/SentMessageStats.php
index 6106d3df8..f8ddc73be 100644
--- a/pkg/monitoring/SentMessageStats.php
+++ b/pkg/monitoring/SentMessageStats.php
@@ -48,7 +48,7 @@ public function __construct(
?string $messageId,
?string $correlationId,
array $headers,
- array $properties
+ array $properties,
) {
$this->timestampMs = $timestampMs;
$this->destination = $destination;
diff --git a/pkg/monitoring/WampStorage.php b/pkg/monitoring/WampStorage.php
index 44623d4e5..0d5ba1801 100644
--- a/pkg/monitoring/WampStorage.php
+++ b/pkg/monitoring/WampStorage.php
@@ -195,10 +195,7 @@ private function parseDsn(string $dsn): array
$dsn = Dsn::parseFirst($dsn);
if (false === in_array($dsn->getSchemeProtocol(), ['wamp', 'ws'], true)) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be "wamp"',
- $dsn->getSchemeProtocol()
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "wamp"', $dsn->getSchemeProtocol()));
}
return array_filter(array_replace($dsn->getQuery(), [
diff --git a/pkg/monitoring/composer.json b/pkg/monitoring/composer.json
index b31dc7831..13b57a5f2 100644
--- a/pkg/monitoring/composer.json
+++ b/pkg/monitoring/composer.json
@@ -6,18 +6,18 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"enqueue/enqueue": "^0.10",
- "ramsey/uuid": "^3|^4",
"enqueue/dsn": "^0.10"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"influxdb/influxdb-php": "^1.14",
"datadog/php-datadogstatsd": "^1.3",
- "thruway/client": "^0.5",
- "thruway/pawl-transport": "^0.5"
+ "thruway/client": "^0.5.5",
+ "thruway/pawl-transport": "^0.5",
+ "voryx/thruway-common": "^1.0.1"
},
"suggest": {
"thruway/client": "Client for Thruway and the WAMP (Web Application Messaging Protocol).",
diff --git a/pkg/null/.github/workflows/ci.yml b/pkg/null/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/null/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/null/.travis.yml b/pkg/null/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/null/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/null/NullMessage.php b/pkg/null/NullMessage.php
index bd48a387e..93fc57c3d 100644
--- a/pkg/null/NullMessage.php
+++ b/pkg/null/NullMessage.php
@@ -97,7 +97,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$headers = $this->getHeaders();
$headers['correlation_id'] = (string) $correlationId;
@@ -110,7 +110,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$headers = $this->getHeaders();
$headers['message_id'] = (string) $messageId;
@@ -130,7 +130,7 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$headers = $this->getHeaders();
$headers['timestamp'] = (int) $timestamp;
@@ -138,7 +138,7 @@ public function setTimestamp(int $timestamp = null): void
$this->setHeaders($headers);
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
diff --git a/pkg/null/NullProducer.php b/pkg/null/NullProducer.php
index 47235e7f6..1349de9ba 100644
--- a/pkg/null/NullProducer.php
+++ b/pkg/null/NullProducer.php
@@ -23,7 +23,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return NullProducer
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
$this->deliveryDelay = $deliveryDelay;
@@ -38,7 +38,7 @@ public function getDeliveryDelay(): ?int
/**
* @return NullProducer
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;
@@ -53,7 +53,7 @@ public function getPriority(): ?int
/**
* @return NullProducer
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
diff --git a/pkg/null/README.md b/pkg/null/README.md
index 46a57b650..7d78ae0d6 100644
--- a/pkg/null/README.md
+++ b/pkg/null/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Enqueue Null Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/null)
+[](https://github.com/php-enqueue/null/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/null)
[](https://packagist.org/packages/enqueue/null)
diff --git a/pkg/null/Tests/NullConnectionFactoryTest.php b/pkg/null/Tests/NullConnectionFactoryTest.php
index 80cfcc904..bbf377e85 100644
--- a/pkg/null/Tests/NullConnectionFactoryTest.php
+++ b/pkg/null/Tests/NullConnectionFactoryTest.php
@@ -17,11 +17,6 @@ public function testShouldImplementConnectionFactoryInterface()
$this->assertClassImplements(ConnectionFactory::class, NullConnectionFactory::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new NullConnectionFactory();
- }
-
public function testShouldReturnNullContextOnCreateContextCall()
{
$factory = new NullConnectionFactory();
diff --git a/pkg/null/Tests/NullConsumerTest.php b/pkg/null/Tests/NullConsumerTest.php
index 6419e9c39..f4de53311 100644
--- a/pkg/null/Tests/NullConsumerTest.php
+++ b/pkg/null/Tests/NullConsumerTest.php
@@ -18,11 +18,6 @@ public function testShouldImplementMessageConsumerInterface()
$this->assertClassImplements(Consumer::class, NullConsumer::class);
}
- public function testCouldBeConstructedWithQueueAsArgument()
- {
- new NullConsumer(new NullQueue('aName'));
- }
-
public function testShouldAlwaysReturnNullOnReceive()
{
$consumer = new NullConsumer(new NullQueue('theQueueName'));
@@ -41,6 +36,9 @@ public function testShouldAlwaysReturnNullOnReceiveNoWait()
$this->assertNull($consumer->receiveNoWait());
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldDoNothingOnAcknowledge()
{
$consumer = new NullConsumer(new NullQueue('theQueueName'));
@@ -48,6 +46,9 @@ public function testShouldDoNothingOnAcknowledge()
$consumer->acknowledge(new NullMessage());
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldDoNothingOnReject()
{
$consumer = new NullConsumer(new NullQueue('theQueueName'));
diff --git a/pkg/null/Tests/NullContextTest.php b/pkg/null/Tests/NullContextTest.php
index 4e5150990..f0da566d2 100644
--- a/pkg/null/Tests/NullContextTest.php
+++ b/pkg/null/Tests/NullContextTest.php
@@ -21,11 +21,6 @@ public function testShouldImplementSessionInterface()
$this->assertClassImplements(Context::class, NullContext::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new NullContext();
- }
-
public function testShouldAllowCreateMessageWithoutAnyArguments()
{
$context = new NullContext();
diff --git a/pkg/null/Tests/NullProducerTest.php b/pkg/null/Tests/NullProducerTest.php
index 289dab6c0..140d683ba 100644
--- a/pkg/null/Tests/NullProducerTest.php
+++ b/pkg/null/Tests/NullProducerTest.php
@@ -18,11 +18,9 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(Producer::class, NullProducer::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new NullProducer();
- }
-
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldDoNothingOnSend()
{
$producer = new NullProducer();
diff --git a/pkg/null/Tests/NullQueueTest.php b/pkg/null/Tests/NullQueueTest.php
index 0dfaf2f28..cb29ca180 100644
--- a/pkg/null/Tests/NullQueueTest.php
+++ b/pkg/null/Tests/NullQueueTest.php
@@ -16,11 +16,6 @@ public function testShouldImplementQueueInterface()
$this->assertClassImplements(Queue::class, NullQueue::class);
}
- public function testCouldBeConstructedWithNameAsArgument()
- {
- new NullQueue('aName');
- }
-
public function testShouldAllowGetNameSetInConstructor()
{
$queue = new NullQueue('theName');
diff --git a/pkg/null/Tests/NullTopicTest.php b/pkg/null/Tests/NullTopicTest.php
index a40545120..27c4b58de 100644
--- a/pkg/null/Tests/NullTopicTest.php
+++ b/pkg/null/Tests/NullTopicTest.php
@@ -16,11 +16,6 @@ public function testShouldImplementTopicInterface()
$this->assertClassImplements(Topic::class, NullTopic::class);
}
- public function testCouldBeConstructedWithNameAsArgument()
- {
- new NullTopic('aName');
- }
-
public function testShouldAllowGetNameSetInConstructor()
{
$topic = new NullTopic('theName');
diff --git a/pkg/null/Tests/Spec/NullMessageTest.php b/pkg/null/Tests/Spec/NullMessageTest.php
index 34c6863ed..6bacc9294 100644
--- a/pkg/null/Tests/Spec/NullMessageTest.php
+++ b/pkg/null/Tests/Spec/NullMessageTest.php
@@ -7,9 +7,6 @@
class NullMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new NullMessage();
diff --git a/pkg/null/composer.json b/pkg/null/composer.json
index e2ef6c29e..a09910a47 100644
--- a/pkg/null/composer.json
+++ b/pkg/null/composer.json
@@ -6,13 +6,13 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/pheanstalk/.github/workflows/ci.yml b/pkg/pheanstalk/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/pheanstalk/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/pheanstalk/.travis.yml b/pkg/pheanstalk/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/pheanstalk/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/pheanstalk/PheanstalkMessage.php b/pkg/pheanstalk/PheanstalkMessage.php
index cf4ea1905..5bff1a7a6 100644
--- a/pkg/pheanstalk/PheanstalkMessage.php
+++ b/pkg/pheanstalk/PheanstalkMessage.php
@@ -103,7 +103,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', (string) $correlationId);
}
@@ -113,7 +113,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', (string) $messageId);
}
@@ -130,12 +130,12 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -187,12 +187,8 @@ public function jsonSerialize(): array
public static function jsonUnserialize(string $json): self
{
$data = json_decode($json, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return new self($data['body'], $data['properties'], $data['headers']);
@@ -203,7 +199,7 @@ public function getJob(): ?Job
return $this->job;
}
- public function setJob(Job $job = null): void
+ public function setJob(?Job $job = null): void
{
$this->job = $job;
}
diff --git a/pkg/pheanstalk/PheanstalkProducer.php b/pkg/pheanstalk/PheanstalkProducer.php
index 030beedf8..0c8ffd8ff 100644
--- a/pkg/pheanstalk/PheanstalkProducer.php
+++ b/pkg/pheanstalk/PheanstalkProducer.php
@@ -48,7 +48,7 @@ public function send(Destination $destination, Message $message): void
InvalidMessageException::assertMessageInstanceOf($message, PheanstalkMessage::class);
$rawMessage = json_encode($message);
- if (JSON_ERROR_NONE !== json_last_error()) {
+ if (\JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
@@ -73,7 +73,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return PheanstalkProducer
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
$this->deliveryDelay = $deliveryDelay;
@@ -88,7 +88,7 @@ public function getDeliveryDelay(): ?int
/**
* @return PheanstalkProducer
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;
@@ -103,7 +103,7 @@ public function getPriority(): ?int
/**
* @return PheanstalkProducer
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
diff --git a/pkg/pheanstalk/README.md b/pkg/pheanstalk/README.md
index d7beebdf8..6461741cf 100644
--- a/pkg/pheanstalk/README.md
+++ b/pkg/pheanstalk/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Beanstalk Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/pheanstalk)
+[](https://github.com/php-enqueue/pheanstalk/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/pheanstalk)
[](https://packagist.org/packages/enqueue/pheanstalk)
diff --git a/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php b/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php
index 231ec0d77..a7bc7fc34 100644
--- a/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php
+++ b/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php
@@ -4,6 +4,7 @@
use Enqueue\Pheanstalk\PheanstalkConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@
class PheanstalkConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
@@ -39,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
diff --git a/pkg/pheanstalk/Tests/PheanstalkConsumerTest.php b/pkg/pheanstalk/Tests/PheanstalkConsumerTest.php
index c0138c726..c79b20bbd 100644
--- a/pkg/pheanstalk/Tests/PheanstalkConsumerTest.php
+++ b/pkg/pheanstalk/Tests/PheanstalkConsumerTest.php
@@ -14,14 +14,6 @@ class PheanstalkConsumerTest extends TestCase
{
use ClassExtensionTrait;
- public function testCouldBeConstructedWithDestinationAndPheanstalkAsArguments()
- {
- new PheanstalkConsumer(
- new PheanstalkDestination('aQueueName'),
- $this->createPheanstalkMock()
- );
- }
-
public function testShouldReturnQueueSetInConstructor()
{
$destination = new PheanstalkDestination('aQueueName');
@@ -54,7 +46,7 @@ public function testShouldReceiveFromQueueAndReturnNullIfNoMessageInQueue()
public function testShouldReceiveFromQueueAndReturnMessageIfMessageInQueue()
{
$destination = new PheanstalkDestination('theQueueName');
- $message = new PheanstalkMessage('theBody', ['foo' => 'fooVal'], ['bar' => 'barVal']);
+ $message = new PheanstalkMessage('theBody', ['foo' => 'fooVal'], ['bar' => 'barVal']);
$job = new Job('theJobId', json_encode($message));
diff --git a/pkg/pheanstalk/Tests/PheanstalkContextTest.php b/pkg/pheanstalk/Tests/PheanstalkContextTest.php
index 9f5ac5812..3b7bfbeb7 100644
--- a/pkg/pheanstalk/Tests/PheanstalkContextTest.php
+++ b/pkg/pheanstalk/Tests/PheanstalkContextTest.php
@@ -21,11 +21,6 @@ public function testShouldImplementContextInterface()
$this->assertClassImplements(Context::class, PheanstalkContext::class);
}
- public function testCouldBeConstructedWithPheanstalkAsFirstArgument()
- {
- new PheanstalkContext($this->createPheanstalkMock());
- }
-
public function testThrowNotImplementedOnCreateTemporaryQueue()
{
$context = new PheanstalkContext($this->createPheanstalkMock());
diff --git a/pkg/pheanstalk/Tests/PheanstalkProducerTest.php b/pkg/pheanstalk/Tests/PheanstalkProducerTest.php
index 7a736c09e..b9a69176c 100644
--- a/pkg/pheanstalk/Tests/PheanstalkProducerTest.php
+++ b/pkg/pheanstalk/Tests/PheanstalkProducerTest.php
@@ -18,11 +18,6 @@ class PheanstalkProducerTest extends TestCase
{
use ClassExtensionTrait;
- public function testCouldBeConstructedWithPheanstalkAsFirstArgument()
- {
- new PheanstalkProducer($this->createPheanstalkMock());
- }
-
public function testThrowIfDestinationInvalid()
{
$producer = new PheanstalkProducer($this->createPheanstalkMock());
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkConnectionFactoryTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkConnectionFactoryTest.php
index e05152599..4d9148447 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkConnectionFactoryTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkConnectionFactoryTest.php
@@ -7,9 +7,6 @@
class PheanstalkConnectionFactoryTest extends ConnectionFactorySpec
{
- /**
- * {@inheritdoc}
- */
protected function createConnectionFactory()
{
return new PheanstalkConnectionFactory();
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkContextTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkContextTest.php
index d69a41ef6..d6ea514f4 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkContextTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkContextTest.php
@@ -8,9 +8,6 @@
class PheanstalkContextTest extends ContextSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return new PheanstalkContext($this->createMock(Pheanstalk::class));
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkMessageTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkMessageTest.php
index 30fb1cf1b..692e0db54 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkMessageTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkMessageTest.php
@@ -7,9 +7,6 @@
class PheanstalkMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new PheanstalkMessage();
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkQueueTest.php
index a71dc4687..0a770b2e2 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkQueueTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkQueueTest.php
@@ -7,9 +7,6 @@
class PheanstalkQueueTest extends QueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createQueue()
{
return new PheanstalkDestination(self::EXPECTED_QUEUE_NAME);
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveFromQueueTest.php
index 45d0040b4..282ac364c 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveFromQueueTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveFromQueueTest.php
@@ -12,9 +12,6 @@
*/
class PheanstalkSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new PheanstalkConnectionFactory(getenv('BEANSTALKD_DSN'));
@@ -23,8 +20,7 @@ protected function createContext()
}
/**
- * @param Context $context
- * @param string $queueName
+ * @param string $queueName
*
* @return Queue
*/
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveNoWaitFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveNoWaitFromQueueTest.php
index 8226b512e..de464e5bf 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveNoWaitFromQueueTest.php
@@ -11,9 +11,6 @@
*/
class PheanstalkSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new PheanstalkConnectionFactory(getenv('BEANSTALKD_DSN'));
@@ -21,9 +18,6 @@ protected function createContext()
return $factory->createContext();
}
- /**
- * {@inheritdoc}
- */
protected function createQueue(Context $context, $queueName)
{
return $context->createQueue($queueName.time());
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php
index a6a5f925a..4c30d7796 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php
@@ -13,14 +13,11 @@ class PheanstalkSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceive
{
private $time;
- public function setUp()
+ protected function setUp(): void
{
$this->time = time();
}
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new PheanstalkConnectionFactory(getenv('BEANSTALKD_DSN'));
@@ -28,17 +25,11 @@ protected function createContext()
return $factory->createContext();
}
- /**
- * {@inheritdoc}
- */
protected function createQueue(Context $context, $queueName)
{
return $context->createQueue($queueName.$this->time);
}
- /**
- * {@inheritdoc}
- */
protected function createTopic(Context $context, $topicName)
{
return $context->createTopic($topicName.$this->time);
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php
index 2bf9f9542..58e8b71f4 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php
@@ -13,14 +13,11 @@ class PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndR
{
private $time;
- public function setUp()
+ protected function setUp(): void
{
$this->time = time();
}
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
$factory = new PheanstalkConnectionFactory(getenv('BEANSTALKD_DSN'));
@@ -28,17 +25,11 @@ protected function createContext()
return $factory->createContext();
}
- /**
- * {@inheritdoc}
- */
protected function createQueue(Context $context, $queueName)
{
return $context->createQueue($queueName.$this->time);
}
- /**
- * {@inheritdoc}
- */
protected function createTopic(Context $context, $topicName)
{
return $context->createTopic($topicName.$this->time);
diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkTopicTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkTopicTest.php
index d15d51083..4b0028261 100644
--- a/pkg/pheanstalk/Tests/Spec/PheanstalkTopicTest.php
+++ b/pkg/pheanstalk/Tests/Spec/PheanstalkTopicTest.php
@@ -7,9 +7,6 @@
class PheanstalkTopicTest extends TopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createTopic()
{
return new PheanstalkDestination(self::EXPECTED_TOPIC_NAME);
diff --git a/pkg/pheanstalk/composer.json b/pkg/pheanstalk/composer.json
index 7d7907ef1..c810971c8 100644
--- a/pkg/pheanstalk/composer.json
+++ b/pkg/pheanstalk/composer.json
@@ -6,15 +6,15 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
- "pda/pheanstalk": "^3",
+ "php": "^8.1",
+ "pda/pheanstalk": "^3.1",
"queue-interop/queue-interop": "^0.8"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/rdkafka/.github/workflows/ci.yml b/pkg/rdkafka/.github/workflows/ci.yml
new file mode 100644
index 000000000..9e0ceb121
--- /dev/null
+++ b/pkg/rdkafka/.github/workflows/ci.yml
@@ -0,0 +1,31 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with: # ext-rdkafka not needed for tests, and a pain to install on CI;
+ composer-options: "--ignore-platform-req=ext-rdkafka"
+
+ - run: sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/rdkafka/.travis.yml b/pkg/rdkafka/.travis.yml
deleted file mode 100644
index 8210653a3..000000000
--- a/pkg/rdkafka/.travis.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - php Tests/fix_composer_json.php
- - composer self-update
- - composer install
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/rdkafka/JsonSerializer.php b/pkg/rdkafka/JsonSerializer.php
index ae161ca08..1d25ea55e 100644
--- a/pkg/rdkafka/JsonSerializer.php
+++ b/pkg/rdkafka/JsonSerializer.php
@@ -14,12 +14,8 @@ public function toString(RdKafkaMessage $message): string
'headers' => $message->getHeaders(),
]);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return $json;
@@ -28,12 +24,8 @@ public function toString(RdKafkaMessage $message): string
public function toMessage(string $string): RdKafkaMessage
{
$data = json_decode($string, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return new RdKafkaMessage($data['body'], $data['properties'], $data['headers']);
diff --git a/pkg/rdkafka/README.md b/pkg/rdkafka/README.md
index 1502f35c7..94f24e510 100644
--- a/pkg/rdkafka/README.md
+++ b/pkg/rdkafka/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# RdKafka Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/rdkafka)
+[](https://github.com/php-enqueue/rdkafka/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/rdkafka)
[](https://packagist.org/packages/enqueue/rdkafka)
diff --git a/pkg/rdkafka/RdKafkaConsumer.php b/pkg/rdkafka/RdKafkaConsumer.php
index 3aa568edb..8b6cf12c6 100644
--- a/pkg/rdkafka/RdKafkaConsumer.php
+++ b/pkg/rdkafka/RdKafkaConsumer.php
@@ -66,7 +66,12 @@ public function setCommitAsync(bool $async): void
$this->commitAsync = $async;
}
- public function setOffset(int $offset = null): void
+ public function getOffset(): ?int
+ {
+ return $this->offset;
+ }
+
+ public function setOffset(?int $offset = null): void
{
if ($this->subscribed) {
throw new \LogicException('The consumer has already subscribed.');
@@ -162,11 +167,11 @@ private function doReceive(int $timeout): ?RdKafkaMessage
}
switch ($kafkaMessage->err) {
- case RD_KAFKA_RESP_ERR__PARTITION_EOF:
- case RD_KAFKA_RESP_ERR__TIMED_OUT:
- case RD_KAFKA_RESP_ERR__TRANSPORT:
+ case \RD_KAFKA_RESP_ERR__PARTITION_EOF:
+ case \RD_KAFKA_RESP_ERR__TIMED_OUT:
+ case \RD_KAFKA_RESP_ERR__TRANSPORT:
return null;
- case RD_KAFKA_RESP_ERR_NO_ERROR:
+ case \RD_KAFKA_RESP_ERR_NO_ERROR:
$message = $this->serializer->toMessage($kafkaMessage->payload);
$message->setKey($kafkaMessage->key);
$message->setPartition($kafkaMessage->partition);
diff --git a/pkg/rdkafka/RdKafkaContext.php b/pkg/rdkafka/RdKafkaContext.php
index 9930b56ee..a252fcfd5 100644
--- a/pkg/rdkafka/RdKafkaContext.php
+++ b/pkg/rdkafka/RdKafkaContext.php
@@ -173,9 +173,9 @@ public static function getLibrdKafkaVersion(): string
if (!defined('RD_KAFKA_VERSION')) {
throw new \RuntimeException('RD_KAFKA_VERSION constant is not defined. Phprdkafka is probably not installed');
}
- $major = (RD_KAFKA_VERSION & 0xFF000000) >> 24;
- $minor = (RD_KAFKA_VERSION & 0x00FF0000) >> 16;
- $patch = (RD_KAFKA_VERSION & 0x0000FF00) >> 8;
+ $major = (\RD_KAFKA_VERSION & 0xFF000000) >> 24;
+ $minor = (\RD_KAFKA_VERSION & 0x00FF0000) >> 16;
+ $patch = (\RD_KAFKA_VERSION & 0x0000FF00) >> 8;
return "$major.$minor.$patch";
}
diff --git a/pkg/rdkafka/RdKafkaMessage.php b/pkg/rdkafka/RdKafkaMessage.php
index 0785a5644..7c6d0d005 100644
--- a/pkg/rdkafka/RdKafkaMessage.php
+++ b/pkg/rdkafka/RdKafkaMessage.php
@@ -112,7 +112,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', (string) $correlationId);
}
@@ -122,7 +122,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', (string) $messageId);
}
@@ -139,12 +139,12 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -159,7 +159,7 @@ public function getPartition(): ?int
return $this->partition;
}
- public function setPartition(int $partition = null): void
+ public function setPartition(?int $partition = null): void
{
$this->partition = $partition;
}
@@ -169,7 +169,7 @@ public function getKey(): ?string
return $this->key;
}
- public function setKey(string $key = null): void
+ public function setKey(?string $key = null): void
{
$this->key = $key;
}
@@ -179,7 +179,7 @@ public function getKafkaMessage(): ?VendorMessage
return $this->kafkaMessage;
}
- public function setKafkaMessage(VendorMessage $message = null): void
+ public function setKafkaMessage(?VendorMessage $message = null): void
{
$this->kafkaMessage = $message;
}
diff --git a/pkg/rdkafka/RdKafkaProducer.php b/pkg/rdkafka/RdKafkaProducer.php
index db21b9311..24589b3e7 100644
--- a/pkg/rdkafka/RdKafkaProducer.php
+++ b/pkg/rdkafka/RdKafkaProducer.php
@@ -37,9 +37,9 @@ public function send(Destination $destination, Message $message): void
InvalidDestinationException::assertDestinationInstanceOf($destination, RdKafkaTopic::class);
InvalidMessageException::assertMessageInstanceOf($message, RdKafkaMessage::class);
- $partition = $message->getPartition() ?: $destination->getPartition() ?: RD_KAFKA_PARTITION_UA;
+ $partition = $message->getPartition() ?? $destination->getPartition() ?? \RD_KAFKA_PARTITION_UA;
$payload = $this->serializer->toString($message);
- $key = $message->getKey() ?: $destination->getKey() ?: null;
+ $key = $message->getKey() ?? $destination->getKey() ?? null;
$topic = $this->producer->newTopic($destination->getTopicName(), $destination->getConf());
@@ -53,24 +53,24 @@ public function send(Destination $destination, Message $message): void
trigger_error(
'Phprdkafka <= 3.1.0 is incompatible with librdkafka 1.0.0 when calling `producev`. '.
'Falling back to `produce` (without message headers) instead.',
- E_USER_WARNING
+ \E_USER_WARNING
);
} else {
- $topic->producev($partition, 0 /* must be 0 */, $payload, $key, $message->getHeaders());
+ $topic->producev($partition, 0 /* must be 0 */ , $payload, $key, $message->getHeaders());
$this->producer->poll(0);
return;
}
}
- $topic->produce($partition, 0 /* must be 0 */, $payload, $key);
+ $topic->produce($partition, 0 /* must be 0 */ , $payload, $key);
$this->producer->poll(0);
}
/**
* @return RdKafkaProducer
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $deliveryDelay) {
return $this;
@@ -87,7 +87,7 @@ public function getDeliveryDelay(): ?int
/**
* @return RdKafkaProducer
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
@@ -101,7 +101,7 @@ public function getPriority(): ?int
return null;
}
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
if (null === $timeToLive) {
return $this;
@@ -115,11 +115,13 @@ public function getTimeToLive(): ?int
return null;
}
- public function flush(int $timeout): void
+ public function flush(int $timeout): ?int
{
// Flush method is exposed in phprdkafka 4.0
if (method_exists($this->producer, 'flush')) {
- $this->producer->flush($timeout);
+ return $this->producer->flush($timeout);
}
+
+ return null;
}
}
diff --git a/pkg/rdkafka/RdKafkaTopic.php b/pkg/rdkafka/RdKafkaTopic.php
index a7bde1021..572f4d024 100644
--- a/pkg/rdkafka/RdKafkaTopic.php
+++ b/pkg/rdkafka/RdKafkaTopic.php
@@ -50,7 +50,7 @@ public function getConf(): ?TopicConf
return $this->conf;
}
- public function setConf(TopicConf $conf = null): void
+ public function setConf(?TopicConf $conf = null): void
{
$this->conf = $conf;
}
@@ -60,7 +60,7 @@ public function getPartition(): ?int
return $this->partition;
}
- public function setPartition(int $partition = null): void
+ public function setPartition(?int $partition = null): void
{
$this->partition = $partition;
}
@@ -70,7 +70,7 @@ public function getKey(): ?string
return $this->key;
}
- public function setKey(string $key = null): void
+ public function setKey(?string $key = null): void
{
$this->key = $key;
}
diff --git a/pkg/rdkafka/SerializerAwareTrait.php b/pkg/rdkafka/SerializerAwareTrait.php
index d640f93cb..1cd1fac20 100644
--- a/pkg/rdkafka/SerializerAwareTrait.php
+++ b/pkg/rdkafka/SerializerAwareTrait.php
@@ -11,9 +11,6 @@ trait SerializerAwareTrait
*/
private $serializer;
- /**
- * @param Serializer $serializer
- */
public function setSerializer(Serializer $serializer)
{
$this->serializer = $serializer;
diff --git a/pkg/rdkafka/Tests/JsonSerializerTest.php b/pkg/rdkafka/Tests/JsonSerializerTest.php
index 6513a2257..6c9bbef84 100644
--- a/pkg/rdkafka/Tests/JsonSerializerTest.php
+++ b/pkg/rdkafka/Tests/JsonSerializerTest.php
@@ -8,9 +8,6 @@
use Enqueue\Test\ClassExtensionTrait;
use PHPUnit\Framework\TestCase;
-/**
- * @group rdkafka
- */
class JsonSerializerTest extends TestCase
{
use ClassExtensionTrait;
@@ -20,11 +17,6 @@ public function testShouldImplementSerializerInterface()
$this->assertClassImplements(Serializer::class, JsonSerializer::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new JsonSerializer();
- }
-
public function testShouldConvertMessageToJsonString()
{
$serializer = new JsonSerializer();
@@ -42,8 +34,8 @@ public function testThrowIfFailedToEncodeMessageToJson()
$resource = fopen(__FILE__, 'r');
- //guard
- $this->assertInternalType('resource', $resource);
+ // guard
+ $this->assertIsResource($resource);
$message = new RdKafkaMessage('theBody', ['aProp' => $resource]);
diff --git a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php
index d3a6a5dab..7ecb1bd7f 100644
--- a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php
+++ b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php
@@ -4,6 +4,7 @@
use Enqueue\RdKafka\RdKafkaConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@
class RdKafkaConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
@@ -31,15 +33,12 @@ public function testThrowIfSchemeIsNotSupported()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
$factory = new RdKafkaConnectionFactory($config);
- $config = $this->getObjectAttribute($factory, 'config');
+ $config = $this->readAttribute($factory, 'config');
$this->assertNotEmpty($config['global']['group.id']);
diff --git a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php
index 47fdc1715..d7121da65 100644
--- a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php
+++ b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php
@@ -3,13 +3,13 @@
namespace Enqueue\RdKafka\Tests;
use Enqueue\RdKafka\RdKafkaConnectionFactory;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
-/**
- * @group rdkafka
- */
class RdKafkaConnectionFactoryTest extends TestCase
{
+ use ReadAttributeTrait;
+
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
$this->expectException(\LogicException::class);
@@ -38,7 +38,7 @@ public function testShouldBeExpectedDefaultConfig()
{
$factory = new RdKafkaConnectionFactory(null);
- $config = $this->getObjectAttribute($factory, 'config');
+ $config = $this->readAttribute($factory, 'config');
$this->assertNotEmpty($config['global']['group.id']);
@@ -55,7 +55,7 @@ public function testShouldBeExpectedDefaultDsnConfig()
{
$factory = new RdKafkaConnectionFactory('kafka:');
- $config = $this->getObjectAttribute($factory, 'config');
+ $config = $this->readAttribute($factory, 'config');
$this->assertNotEmpty($config['global']['group.id']);
@@ -70,9 +70,6 @@ public function testShouldBeExpectedDefaultDsnConfig()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
diff --git a/pkg/rdkafka/Tests/RdKafkaConsumerTest.php b/pkg/rdkafka/Tests/RdKafkaConsumerTest.php
index b40916c15..e577dfcca 100644
--- a/pkg/rdkafka/Tests/RdKafkaConsumerTest.php
+++ b/pkg/rdkafka/Tests/RdKafkaConsumerTest.php
@@ -11,21 +11,8 @@
use RdKafka\KafkaConsumer;
use RdKafka\Message;
-/**
- * @group rdkafka
- */
class RdKafkaConsumerTest extends TestCase
{
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new RdKafkaConsumer(
- $this->createKafkaConsumerMock(),
- $this->createContextMock(),
- new RdKafkaTopic(''),
- $this->createSerializerMock()
- );
- }
-
public function testShouldReturnQueueSetInConstructor()
{
$destination = new RdKafkaTopic('');
@@ -45,7 +32,7 @@ public function testShouldReceiveFromQueueAndReturnNullIfNoMessageInQueue()
$destination = new RdKafkaTopic('dest');
$kafkaMessage = new Message();
- $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT;
+ $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT;
$kafkaConsumer = $this->createKafkaConsumerMock();
$kafkaConsumer
@@ -74,7 +61,7 @@ public function testShouldPassProperlyConfiguredTopicPartitionOnAssign()
$destination = new RdKafkaTopic('dest');
$kafkaMessage = new Message();
- $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT;
+ $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT;
$kafkaConsumer = $this->createKafkaConsumerMock();
$kafkaConsumer
@@ -104,7 +91,7 @@ public function testShouldSubscribeOnFirstReceiveOnly()
$destination = new RdKafkaTopic('dest');
$kafkaMessage = new Message();
- $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT;
+ $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT;
$kafkaConsumer = $this->createKafkaConsumerMock();
$kafkaConsumer
@@ -135,7 +122,7 @@ public function testShouldAssignWhenOffsetIsSet()
$destination->setPartition(1);
$kafkaMessage = new Message();
- $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT;
+ $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT;
$kafkaConsumer = $this->createKafkaConsumerMock();
$kafkaConsumer
@@ -167,7 +154,7 @@ public function testThrowOnOffsetChangeAfterSubscribing()
$destination = new RdKafkaTopic('dest');
$kafkaMessage = new Message();
- $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT;
+ $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT;
$kafkaConsumer = $this->createKafkaConsumerMock();
$kafkaConsumer
@@ -198,11 +185,12 @@ public function testShouldReceiveFromQueueAndReturnMessageIfMessageInQueue()
{
$destination = new RdKafkaTopic('dest');
- $expectedMessage = new RdKafkaMessage('theBody', ['foo' => 'fooVal'], ['bar' => 'barVal']);
+ $expectedMessage = new RdKafkaMessage('theBody', ['foo' => 'fooVal'], ['bar' => 'barVal']);
$kafkaMessage = new Message();
- $kafkaMessage->err = RD_KAFKA_RESP_ERR_NO_ERROR;
+ $kafkaMessage->err = \RD_KAFKA_RESP_ERR_NO_ERROR;
$kafkaMessage->payload = 'theSerializedMessage';
+ $kafkaMessage->partition = 0;
$kafkaConsumer = $this->createKafkaConsumerMock();
$kafkaConsumer
@@ -263,7 +251,7 @@ public function testShouldAllowGetPreviouslySetSerializer()
$expectedSerializer = $this->createSerializerMock();
- //guard
+ // guard
$this->assertNotSame($consumer->getSerializer(), $expectedSerializer);
$consumer->setSerializer($expectedSerializer);
diff --git a/pkg/rdkafka/Tests/RdKafkaContextTest.php b/pkg/rdkafka/Tests/RdKafkaContextTest.php
index 227eea792..dc1b597de 100644
--- a/pkg/rdkafka/Tests/RdKafkaContextTest.php
+++ b/pkg/rdkafka/Tests/RdKafkaContextTest.php
@@ -10,9 +10,6 @@
use Interop\Queue\Exception\TemporaryQueueNotSupportedException;
use PHPUnit\Framework\TestCase;
-/**
- * @group rdkafka
- */
class RdKafkaContextTest extends TestCase
{
public function testThrowNotImplementedOnCreateTemporaryQueue()
diff --git a/pkg/rdkafka/Tests/RdKafkaMessageTest.php b/pkg/rdkafka/Tests/RdKafkaMessageTest.php
index c2e5c224a..9bcc34642 100644
--- a/pkg/rdkafka/Tests/RdKafkaMessageTest.php
+++ b/pkg/rdkafka/Tests/RdKafkaMessageTest.php
@@ -6,9 +6,6 @@
use PHPUnit\Framework\TestCase;
use RdKafka\Message;
-/**
- * @group rdkafka
- */
class RdKafkaMessageTest extends TestCase
{
public function testCouldSetGetPartition()
diff --git a/pkg/rdkafka/Tests/RdKafkaProducerTest.php b/pkg/rdkafka/Tests/RdKafkaProducerTest.php
index 467f1a43e..6295fbc1b 100644
--- a/pkg/rdkafka/Tests/RdKafkaProducerTest.php
+++ b/pkg/rdkafka/Tests/RdKafkaProducerTest.php
@@ -15,16 +15,8 @@
use RdKafka\ProducerTopic;
use RdKafka\TopicConf;
-/**
- * @group rdkafka
- */
class RdKafkaProducerTest extends TestCase
{
- public function testCouldBeConstructedWithKafkaProducerAndSerializerAsArguments()
- {
- new RdKafkaProducer($this->createKafkaProducerMock(), $this->createSerializerMock());
- }
-
public function testThrowIfDestinationInvalid()
{
$producer = new RdKafkaProducer($this->createKafkaProducerMock(), $this->createSerializerMock());
@@ -54,7 +46,7 @@ public function testShouldUseSerializerToEncodeMessageAndPutToExpectedTube()
->expects($this->once())
->method('producev')
->with(
- RD_KAFKA_PARTITION_UA,
+ \RD_KAFKA_PARTITION_UA,
0,
'theSerializedMessage',
'key',
@@ -172,7 +164,7 @@ public function testShouldAllowGetPreviouslySetSerializer()
$expectedSerializer = $this->createSerializerMock();
- //guard
+ // guard
$this->assertNotSame($producer->getSerializer(), $expectedSerializer);
$producer->setSerializer($expectedSerializer);
@@ -191,7 +183,7 @@ public function testShouldAllowSerializersToSerializeKeys()
->expects($this->once())
->method('producev')
->with(
- RD_KAFKA_PARTITION_UA,
+ \RD_KAFKA_PARTITION_UA,
0,
'theSerializedMessage',
'theSerializedKey'
@@ -225,6 +217,164 @@ public function testShouldAllowSerializersToSerializeKeys()
$producer->send(new RdKafkaTopic('theQueueName'), $message);
}
+ public function testShouldGetPartitionFromMessage(): void
+ {
+ $partition = 1;
+
+ $kafkaTopic = $this->createKafkaTopicMock();
+ $kafkaTopic
+ ->expects($this->once())
+ ->method('producev')
+ ->with(
+ $partition,
+ 0,
+ 'theSerializedMessage',
+ 'theSerializedKey'
+ )
+ ;
+
+ $kafkaProducer = $this->createKafkaProducerMock();
+ $kafkaProducer
+ ->expects($this->once())
+ ->method('newTopic')
+ ->willReturn($kafkaTopic)
+ ;
+ $kafkaProducer
+ ->expects($this->once())
+ ->method('poll')
+ ->with(0)
+ ;
+ $messageHeaders = ['bar' => 'barVal'];
+ $message = new RdKafkaMessage('theBody', ['foo' => 'fooVal'], $messageHeaders);
+ $message->setKey('key');
+ $message->setPartition($partition);
+
+ $serializer = $this->createSerializerMock();
+ $serializer
+ ->expects($this->once())
+ ->method('toString')
+ ->willReturnCallback(function () use ($message) {
+ $message->setKey('theSerializedKey');
+
+ return 'theSerializedMessage';
+ })
+ ;
+
+ $destination = new RdKafkaTopic('theQueueName');
+
+ $producer = new RdKafkaProducer($kafkaProducer, $serializer);
+ $producer->send($destination, $message);
+ }
+
+ public function testShouldGetPartitionFromDestination(): void
+ {
+ $partition = 2;
+
+ $kafkaTopic = $this->createKafkaTopicMock();
+ $kafkaTopic
+ ->expects($this->once())
+ ->method('producev')
+ ->with(
+ $partition,
+ 0,
+ 'theSerializedMessage',
+ 'theSerializedKey'
+ )
+ ;
+
+ $kafkaProducer = $this->createKafkaProducerMock();
+ $kafkaProducer
+ ->expects($this->once())
+ ->method('newTopic')
+ ->willReturn($kafkaTopic)
+ ;
+ $kafkaProducer
+ ->expects($this->once())
+ ->method('poll')
+ ->with(0)
+ ;
+ $messageHeaders = ['bar' => 'barVal'];
+ $message = new RdKafkaMessage('theBody', ['foo' => 'fooVal'], $messageHeaders);
+ $message->setKey('key');
+
+ $serializer = $this->createSerializerMock();
+ $serializer
+ ->expects($this->once())
+ ->method('toString')
+ ->willReturnCallback(function () use ($message) {
+ $message->setKey('theSerializedKey');
+
+ return 'theSerializedMessage';
+ })
+ ;
+
+ $destination = new RdKafkaTopic('theQueueName');
+ $destination->setPartition($partition);
+
+ $producer = new RdKafkaProducer($kafkaProducer, $serializer);
+ $producer->send($destination, $message);
+ }
+
+ public function testShouldAllowFalsyKeyFromMessage(): void
+ {
+ $key = 0;
+
+ $kafkaTopic = $this->createKafkaTopicMock();
+ $kafkaTopic
+ ->expects($this->once())
+ ->method('producev')
+ ->with(
+ \RD_KAFKA_PARTITION_UA,
+ 0,
+ '',
+ $key
+ )
+ ;
+
+ $kafkaProducer = $this->createKafkaProducerMock();
+ $kafkaProducer
+ ->expects($this->once())
+ ->method('newTopic')
+ ->willReturn($kafkaTopic)
+ ;
+
+ $message = new RdKafkaMessage();
+ $message->setKey($key);
+
+ $producer = new RdKafkaProducer($kafkaProducer, $this->createSerializerMock());
+ $producer->send(new RdKafkaTopic(''), $message);
+ }
+
+ public function testShouldAllowFalsyKeyFromDestination(): void
+ {
+ $key = 0;
+
+ $kafkaTopic = $this->createKafkaTopicMock();
+ $kafkaTopic
+ ->expects($this->once())
+ ->method('producev')
+ ->with(
+ \RD_KAFKA_PARTITION_UA,
+ 0,
+ '',
+ $key
+ )
+ ;
+
+ $kafkaProducer = $this->createKafkaProducerMock();
+ $kafkaProducer
+ ->expects($this->once())
+ ->method('newTopic')
+ ->willReturn($kafkaTopic)
+ ;
+
+ $destination = new RdKafkaTopic('');
+ $destination->setKey($key);
+
+ $producer = new RdKafkaProducer($kafkaProducer, $this->createSerializerMock());
+ $producer->send($destination, new RdKafkaMessage());
+ }
+
/**
* @return \PHPUnit\Framework\MockObject\MockObject|ProducerTopic
*/
diff --git a/pkg/rdkafka/Tests/RdKafkaTopicTest.php b/pkg/rdkafka/Tests/RdKafkaTopicTest.php
index 5ed22885a..d0bc8cc13 100644
--- a/pkg/rdkafka/Tests/RdKafkaTopicTest.php
+++ b/pkg/rdkafka/Tests/RdKafkaTopicTest.php
@@ -6,9 +6,6 @@
use PHPUnit\Framework\TestCase;
use RdKafka\TopicConf;
-/**
- * @group rdkafka
- */
class RdKafkaTopicTest extends TestCase
{
public function testCouldSetGetPartition()
diff --git a/pkg/rdkafka/Tests/Spec/RdKafkaConnectionFactoryTest.php b/pkg/rdkafka/Tests/Spec/RdKafkaConnectionFactoryTest.php
index 3327c952d..a582aadca 100644
--- a/pkg/rdkafka/Tests/Spec/RdKafkaConnectionFactoryTest.php
+++ b/pkg/rdkafka/Tests/Spec/RdKafkaConnectionFactoryTest.php
@@ -5,9 +5,6 @@
use Enqueue\RdKafka\RdKafkaConnectionFactory;
use Interop\Queue\Spec\ConnectionFactorySpec;
-/**
- * @group rdkafka
- */
class RdKafkaConnectionFactoryTest extends ConnectionFactorySpec
{
protected function createConnectionFactory()
diff --git a/pkg/rdkafka/Tests/Spec/RdKafkaContextTest.php b/pkg/rdkafka/Tests/Spec/RdKafkaContextTest.php
index fe9625677..d049ca74f 100644
--- a/pkg/rdkafka/Tests/Spec/RdKafkaContextTest.php
+++ b/pkg/rdkafka/Tests/Spec/RdKafkaContextTest.php
@@ -5,9 +5,6 @@
use Enqueue\RdKafka\RdKafkaContext;
use Interop\Queue\Spec\ContextSpec;
-/**
- * @group rdkafka
- */
class RdKafkaContextTest extends ContextSpec
{
protected function createContext()
diff --git a/pkg/rdkafka/Tests/Spec/RdKafkaMessageTest.php b/pkg/rdkafka/Tests/Spec/RdKafkaMessageTest.php
index a29780b0f..9e230d1b6 100644
--- a/pkg/rdkafka/Tests/Spec/RdKafkaMessageTest.php
+++ b/pkg/rdkafka/Tests/Spec/RdKafkaMessageTest.php
@@ -5,14 +5,8 @@
use Enqueue\RdKafka\RdKafkaMessage;
use Interop\Queue\Spec\MessageSpec;
-/**
- * @group rdkafka
- */
class RdKafkaMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new RdKafkaMessage();
diff --git a/pkg/rdkafka/Tests/Spec/RdKafkaQueueTest.php b/pkg/rdkafka/Tests/Spec/RdKafkaQueueTest.php
index 93bc7ac14..863f3e3c5 100644
--- a/pkg/rdkafka/Tests/Spec/RdKafkaQueueTest.php
+++ b/pkg/rdkafka/Tests/Spec/RdKafkaQueueTest.php
@@ -5,9 +5,6 @@
use Enqueue\RdKafka\RdKafkaTopic;
use Interop\Queue\Spec\QueueSpec;
-/**
- * @group rdkafka
- */
class RdKafkaQueueTest extends QueueSpec
{
protected function createQueue()
diff --git a/pkg/rdkafka/Tests/Spec/RdKafkaSendToAndReceiveFromTopicTest.php b/pkg/rdkafka/Tests/Spec/RdKafkaSendToAndReceiveFromTopicTest.php
index d756f23e2..9a969d420 100644
--- a/pkg/rdkafka/Tests/Spec/RdKafkaSendToAndReceiveFromTopicTest.php
+++ b/pkg/rdkafka/Tests/Spec/RdKafkaSendToAndReceiveFromTopicTest.php
@@ -7,8 +7,8 @@
use Interop\Queue\Spec\SendToAndReceiveFromTopicSpec;
/**
- * @group rdkafka
* @group functional
+ *
* @retry 5
*/
class RdKafkaSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
diff --git a/pkg/rdkafka/Tests/Spec/RdKafkaTopicTest.php b/pkg/rdkafka/Tests/Spec/RdKafkaTopicTest.php
index 26aacc78d..08d427883 100644
--- a/pkg/rdkafka/Tests/Spec/RdKafkaTopicTest.php
+++ b/pkg/rdkafka/Tests/Spec/RdKafkaTopicTest.php
@@ -5,14 +5,8 @@
use Enqueue\RdKafka\RdKafkaTopic;
use Interop\Queue\Spec\TopicSpec;
-/**
- * @group rdkafka
- */
class RdKafkaTopicTest extends TopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createTopic()
{
return new RdKafkaTopic(self::EXPECTED_TOPIC_NAME);
diff --git a/pkg/rdkafka/Tests/bootstrap.php b/pkg/rdkafka/Tests/bootstrap.php
index bf112623e..60f8101ef 100644
--- a/pkg/rdkafka/Tests/bootstrap.php
+++ b/pkg/rdkafka/Tests/bootstrap.php
@@ -8,7 +8,7 @@
if (false == file_exists($kafkaStubsDir)) {
$kafkaStubsDir = __DIR__.'/../../../vendor/kwn/php-rdkafka-stubs';
if (false == file_exists($kafkaStubsDir)) {
- throw new \LogicException('The kafka extension is not loaded and stubs could not be found as well');
+ throw new LogicException('The kafka extension is not loaded and stubs could not be found as well');
}
}
diff --git a/pkg/rdkafka/Tests/fix_composer_json.php b/pkg/rdkafka/Tests/fix_composer_json.php
deleted file mode 100644
index b778f6f69..000000000
--- a/pkg/rdkafka/Tests/fix_composer_json.php
+++ /dev/null
@@ -1,9 +0,0 @@
-> $HOME/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/redis/JsonSerializer.php b/pkg/redis/JsonSerializer.php
index 7e064a221..ff67ed880 100644
--- a/pkg/redis/JsonSerializer.php
+++ b/pkg/redis/JsonSerializer.php
@@ -14,12 +14,8 @@ public function toString(RedisMessage $message): string
'headers' => $message->getHeaders(),
]);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return $json;
@@ -28,12 +24,8 @@ public function toString(RedisMessage $message): string
public function toMessage(string $string): RedisMessage
{
$data = json_decode($string, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return new RedisMessage($data['body'], $data['properties'], $data['headers']);
diff --git a/pkg/redis/PhpRedis.php b/pkg/redis/PhpRedis.php
index 241677f68..9e820a283 100644
--- a/pkg/redis/PhpRedis.php
+++ b/pkg/redis/PhpRedis.php
@@ -94,27 +94,25 @@ public function connect(): void
return;
}
- $supportedSchemes = ['redis', 'tcp', 'unix'];
+ $supportedSchemes = ['redis', 'rediss', 'tcp', 'unix'];
if (false == in_array($this->config['scheme'], $supportedSchemes, true)) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported by php extension. It must be one of "%s"',
- $this->config['scheme'],
- implode('", "', $supportedSchemes)
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported by php extension. It must be one of "%s"', $this->config['scheme'], implode('", "', $supportedSchemes)));
}
$this->redis = new \Redis();
$connectionMethod = $this->config['persistent'] ? 'pconnect' : 'connect';
+ $host = 'rediss' === $this->config['scheme'] ? 'tls://'.$this->config['host'] : $this->config['host'];
+
$result = call_user_func(
[$this->redis, $connectionMethod],
- 'unix' === $this->config['scheme'] ? $this->config['path'] : $this->config['host'],
+ 'unix' === $this->config['scheme'] ? $this->config['path'] : $host,
$this->config['port'],
$this->config['timeout'],
$this->config['persistent'] ? ($this->config['phpredis_persistent_id'] ?? null) : null,
- $this->config['phpredis_retry_interval'] ?? null,
- $this->config['read_write_timeout']
+ (int) ($this->config['phpredis_retry_interval'] ?? 0),
+ (float) $this->config['read_write_timeout'] ?? 0
);
if (false == $result) {
diff --git a/pkg/redis/README.md b/pkg/redis/README.md
index 0206e1e5b..7b368bb35 100644
--- a/pkg/redis/README.md
+++ b/pkg/redis/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Redis Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/redis)
+[](https://github.com/php-enqueue/redis/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/redis)
[](https://packagist.org/packages/enqueue/redis)
diff --git a/pkg/redis/Redis.php b/pkg/redis/Redis.php
index 362f5e8d0..04165af9d 100644
--- a/pkg/redis/Redis.php
+++ b/pkg/redis/Redis.php
@@ -7,41 +7,21 @@
interface Redis
{
/**
- * @param string $script
- * @param array $keys
- * @param array $args
- *
* @throws ServerException
- *
- * @return mixed
*/
public function eval(string $script, array $keys = [], array $args = []);
/**
- * @param string $key
- * @param string $value
- * @param float $score
- *
* @throws ServerException
- *
- * @return int
*/
public function zadd(string $key, string $value, float $score): int;
/**
- * @param string $key
- * @param string $value
- *
* @throws ServerException
- *
- * @return int
*/
public function zrem(string $key, string $value): int;
/**
- * @param string $key
- * @param string $value
- *
* @throws ServerException
*
* @return int length of the list
@@ -53,17 +33,11 @@ public function lpush(string $key, string $value): int;
* @param int $timeout in seconds
*
* @throws ServerException
- *
- * @return RedisResult|null
*/
public function brpop(array $keys, int $timeout): ?RedisResult;
/**
- * @param string $key
- *
* @throws ServerException
- *
- * @return RedisResult|null
*/
public function rpop(string $key): ?RedisResult;
@@ -75,8 +49,6 @@ public function connect(): void;
public function disconnect(): void;
/**
- * @param string $key
- *
* @throws ServerException
*/
public function del(string $key): void;
diff --git a/pkg/redis/RedisConsumer.php b/pkg/redis/RedisConsumer.php
index 6ff23f41e..ca3733d4b 100644
--- a/pkg/redis/RedisConsumer.php
+++ b/pkg/redis/RedisConsumer.php
@@ -34,17 +34,11 @@ public function __construct(RedisContext $context, RedisDestination $queue)
$this->queue = $queue;
}
- /**
- * @return int
- */
public function getRedeliveryDelay(): ?int
{
return $this->redeliveryDelay;
}
- /**
- * @param int $delay
- */
public function setRedeliveryDelay(int $delay): void
{
$this->redeliveryDelay = $delay;
@@ -103,7 +97,7 @@ public function reject(Message $message, bool $requeue = false): void
if ($requeue) {
$message = $this->getContext()->getSerializer()->toMessage($message->getReservedKey());
- $message->setHeader('attempts', 0);
+ $message->setRedelivered(true);
if ($message->getTimeToLive()) {
$message->setHeader('expires_at', time() + $message->getTimeToLive());
diff --git a/pkg/redis/RedisConsumerHelperTrait.php b/pkg/redis/RedisConsumerHelperTrait.php
index 9939986ed..063ff1fbd 100644
--- a/pkg/redis/RedisConsumerHelperTrait.php
+++ b/pkg/redis/RedisConsumerHelperTrait.php
@@ -15,10 +15,6 @@ abstract protected function getContext(): RedisContext;
/**
* @param RedisDestination[] $queues
- * @param int $timeout
- * @param int $redeliveryDelay
- *
- * @return RedisMessage|null
*/
protected function receiveMessage(array $queues, int $timeout, int $redeliveryDelay): ?RedisMessage
{
diff --git a/pkg/redis/RedisContext.php b/pkg/redis/RedisContext.php
index 344bb20c5..346375f8d 100644
--- a/pkg/redis/RedisContext.php
+++ b/pkg/redis/RedisContext.php
@@ -38,7 +38,6 @@ class RedisContext implements Context
* Callable must return instance of Redis once called.
*
* @param Redis|callable $redis
- * @param int $redeliveryDelay
*/
public function __construct($redis, int $redeliveryDelay)
{
@@ -47,11 +46,7 @@ public function __construct($redis, int $redeliveryDelay)
} elseif (is_callable($redis)) {
$this->redisFactory = $redis;
} else {
- throw new \InvalidArgumentException(sprintf(
- 'The $redis argument must be either %s or callable that returns %s once called.',
- Redis::class,
- Redis::class
- ));
+ throw new \InvalidArgumentException(sprintf('The $redis argument must be either %s or callable that returns %s once called.', Redis::class, Redis::class));
}
$this->redeliveryDelay = $redeliveryDelay;
@@ -159,11 +154,7 @@ public function getRedis(): Redis
if (false == $this->redis) {
$redis = call_user_func($this->redisFactory);
if (false == $redis instanceof Redis) {
- throw new \LogicException(sprintf(
- 'The factory must return instance of %s. It returned %s',
- Redis::class,
- is_object($redis) ? get_class($redis) : gettype($redis)
- ));
+ throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', Redis::class, is_object($redis) ? $redis::class : gettype($redis)));
}
$this->redis = $redis;
diff --git a/pkg/redis/RedisMessage.php b/pkg/redis/RedisMessage.php
index 74c65475a..708bdbc97 100644
--- a/pkg/redis/RedisMessage.php
+++ b/pkg/redis/RedisMessage.php
@@ -107,7 +107,7 @@ public function isRedelivered(): bool
return $this->redelivered;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', $correlationId);
}
@@ -117,7 +117,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', $messageId);
}
@@ -134,12 +134,12 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -149,17 +149,11 @@ public function getReplyTo(): ?string
return $this->getHeader('reply_to');
}
- /**
- * @return int
- */
public function getAttempts(): int
{
return (int) $this->getHeader('attempts', 0);
}
- /**
- * @return int
- */
public function getTimeToLive(): ?int
{
return $this->getHeader('time_to_live');
@@ -168,7 +162,7 @@ public function getTimeToLive(): ?int
/**
* Set time to live in milliseconds.
*/
- public function setTimeToLive(int $timeToLive = null): void
+ public function setTimeToLive(?int $timeToLive = null): void
{
$this->setHeader('time_to_live', $timeToLive);
}
@@ -181,38 +175,26 @@ public function getDeliveryDelay(): ?int
/**
* Set delay in milliseconds.
*/
- public function setDeliveryDelay(int $deliveryDelay = null): void
+ public function setDeliveryDelay(?int $deliveryDelay = null): void
{
$this->setHeader('delivery_delay', $deliveryDelay);
}
- /**
- * @return string
- */
public function getReservedKey(): ?string
{
return $this->reservedKey;
}
- /**
- * @param string $reservedKey
- */
public function setReservedKey(string $reservedKey)
{
$this->reservedKey = $reservedKey;
}
- /**
- * @return string
- */
public function getKey(): ?string
{
return $this->key;
}
- /**
- * @param string $key
- */
public function setKey(string $key): void
{
$this->key = $key;
diff --git a/pkg/redis/RedisProducer.php b/pkg/redis/RedisProducer.php
index cc7d63230..3ad3e5bb2 100644
--- a/pkg/redis/RedisProducer.php
+++ b/pkg/redis/RedisProducer.php
@@ -29,9 +29,6 @@ class RedisProducer implements Producer
*/
private $deliveryDelay;
- /**
- * @param RedisContext $context
- */
public function __construct(RedisContext $context)
{
$this->context = $context;
@@ -74,7 +71,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return self
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
$this->deliveryDelay = $deliveryDelay;
@@ -89,7 +86,7 @@ public function getDeliveryDelay(): ?int
/**
* @return RedisProducer
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
@@ -106,7 +103,7 @@ public function getPriority(): ?int
/**
* @return self
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
diff --git a/pkg/redis/RedisSubscriptionConsumer.php b/pkg/redis/RedisSubscriptionConsumer.php
index c59cab4da..d0b34634d 100644
--- a/pkg/redis/RedisSubscriptionConsumer.php
+++ b/pkg/redis/RedisSubscriptionConsumer.php
@@ -28,26 +28,17 @@ class RedisSubscriptionConsumer implements SubscriptionConsumer
*/
private $redeliveryDelay = 300;
- /**
- * @param RedisContext $context
- */
public function __construct(RedisContext $context)
{
$this->context = $context;
$this->subscribers = [];
}
- /**
- * @return int
- */
public function getRedeliveryDelay(): ?int
{
return $this->redeliveryDelay;
}
- /**
- * @param int $delay
- */
public function setRedeliveryDelay(int $delay): void
{
$this->redeliveryDelay = $delay;
@@ -89,7 +80,7 @@ public function consume(int $timeout = 0): void
public function subscribe(Consumer $consumer, callable $callback): void
{
if (false == $consumer instanceof RedisConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, $consumer::class));
}
$queueName = $consumer->getQueue()->getQueueName();
@@ -111,7 +102,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
public function unsubscribe(Consumer $consumer): void
{
if (false == $consumer instanceof RedisConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, $consumer::class));
}
$queueName = $consumer->getQueue()->getQueueName();
diff --git a/pkg/redis/SerializerAwareTrait.php b/pkg/redis/SerializerAwareTrait.php
index 8d0fbe548..bcd94eed5 100644
--- a/pkg/redis/SerializerAwareTrait.php
+++ b/pkg/redis/SerializerAwareTrait.php
@@ -11,9 +11,6 @@ trait SerializerAwareTrait
*/
private $serializer;
- /**
- * @param Serializer $serializer
- */
public function setSerializer(Serializer $serializer)
{
$this->serializer = $serializer;
diff --git a/pkg/redis/Tests/Functional/CommonUseCasesTrait.php b/pkg/redis/Tests/Functional/CommonUseCasesTrait.php
index b80ea9763..bdab87b31 100644
--- a/pkg/redis/Tests/Functional/CommonUseCasesTrait.php
+++ b/pkg/redis/Tests/Functional/CommonUseCasesTrait.php
@@ -91,7 +91,7 @@ public function testConsumerReceiveMessageWithZeroTimeout()
$consumer = $this->getContext()->createConsumer($topic);
- //guard
+ // guard
$this->assertNull($consumer->receive(1000));
$message = $this->getContext()->createMessage(__METHOD__);
diff --git a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php
index a63672da8..9ac2a037b 100644
--- a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php
+++ b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php
@@ -11,15 +11,15 @@
*/
class PRedisCommonUseCasesTest extends TestCase
{
- use RedisExtension;
use CommonUseCasesTrait;
+ use RedisExtension;
/**
* @var RedisContext
*/
private $context;
- public function setUp()
+ protected function setUp(): void
{
$this->context = $this->buildPRedisContext();
@@ -27,14 +27,11 @@ public function setUp()
$this->context->deleteTopic($this->context->createTopic('enqueue.test_topic'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->context->close();
}
- /**
- * {@inheritdoc}
- */
protected function getContext()
{
return $this->context;
diff --git a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php
index f748020f1..e61cd1f0f 100644
--- a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php
+++ b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php
@@ -11,15 +11,15 @@
*/
class PRedisConsumptionUseCasesTest extends TestCase
{
- use RedisExtension;
use ConsumptionUseCasesTrait;
+ use RedisExtension;
/**
* @var RedisContext
*/
private $context;
- public function setUp()
+ protected function setUp(): void
{
$this->context = $this->buildPRedisContext();
@@ -27,14 +27,11 @@ public function setUp()
$this->context->deleteQueue($this->context->createQueue('enqueue.test_queue_reply'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->context->close();
}
- /**
- * {@inheritdoc}
- */
protected function getContext()
{
return $this->context;
diff --git a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php
index 41b403565..f36843ec9 100644
--- a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php
+++ b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php
@@ -11,15 +11,15 @@
*/
class PhpRedisCommonUseCasesTest extends TestCase
{
- use RedisExtension;
use CommonUseCasesTrait;
+ use RedisExtension;
/**
* @var RedisContext
*/
private $context;
- public function setUp()
+ protected function setUp(): void
{
$this->context = $this->buildPhpRedisContext();
@@ -27,14 +27,11 @@ public function setUp()
$this->context->deleteTopic($this->context->createTopic('enqueue.test_topic'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->context->close();
}
- /**
- * {@inheritdoc}
- */
protected function getContext()
{
return $this->context;
diff --git a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php
index d48e4bcb4..073c1aff9 100644
--- a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php
+++ b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php
@@ -11,15 +11,15 @@
*/
class PhpRedisConsumptionUseCasesTest extends TestCase
{
- use RedisExtension;
use ConsumptionUseCasesTrait;
+ use RedisExtension;
/**
* @var RedisContext
*/
private $context;
- public function setUp()
+ protected function setUp(): void
{
$this->context = $this->buildPhpRedisContext();
@@ -27,14 +27,11 @@ public function setUp()
$this->context->deleteQueue($this->context->createQueue('enqueue.test_queue_reply'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->context->close();
}
- /**
- * {@inheritdoc}
- */
protected function getContext()
{
return $this->context;
diff --git a/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php b/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php
index eee32baac..37e831823 100644
--- a/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php
+++ b/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php
@@ -5,6 +5,7 @@
use Enqueue\Redis\Redis;
use Enqueue\Redis\RedisConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -13,6 +14,7 @@
class RedisConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
@@ -49,20 +51,8 @@ public function testCouldBeCreatedWithRedisInstance()
$this->assertSame($redisMock, $context->getRedis());
}
- public function testThrowIfRedissConnectionUsedWithPhpRedisExtension()
- {
- $factory = new RedisConnectionFactory('rediss+phpredis:?lazy=0');
-
- $this->expectException(\LogicException::class);
- $this->expectExceptionMessage('The given scheme protocol "rediss" is not supported by php extension. It must be one of "redis", "tcp", "unix"');
- $factory->createContext();
- }
-
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
@@ -202,7 +192,7 @@ public static function provideConfigs()
],
];
- //check normal redis connection for php redis extension
+ // check normal redis connection for php redis extension
yield [
'redis+phpredis://localhost:1234?foo=bar',
[
@@ -225,7 +215,7 @@ public static function provideConfigs()
],
];
- //check normal redis connection for predis library
+ // check normal redis connection for predis library
yield [
'redis+predis://localhost:1234?foo=bar',
[
@@ -248,7 +238,7 @@ public static function provideConfigs()
],
];
- //check tls connection for predis library
+ // check tls connection for predis library
yield [
'rediss+predis://localhost:1234?foo=bar&async=1',
[
@@ -271,6 +261,29 @@ public static function provideConfigs()
],
];
+ // check tls connection for predis library
+ yield [
+ 'rediss+phpredis://localhost:1234?foo=bar&async=1',
+ [
+ 'host' => 'localhost',
+ 'scheme' => 'rediss',
+ 'port' => 1234,
+ 'timeout' => 5.,
+ 'database' => null,
+ 'password' => null,
+ 'scheme_extensions' => ['phpredis'],
+ 'path' => null,
+ 'async' => true,
+ 'persistent' => false,
+ 'lazy' => true,
+ 'read_write_timeout' => null,
+ 'predis_options' => null,
+ 'ssl' => null,
+ 'foo' => 'bar',
+ 'redelivery_delay' => 300,
+ ],
+ ];
+
yield [
['host' => 'localhost', 'port' => 1234, 'foo' => 'bar'],
[
@@ -360,7 +373,6 @@ public static function provideConfigs()
];
// from predis doc
-
yield [
'tls://127.0.0.1?ssl[cafile]=private.pem&ssl[verify_peer]=1',
[
diff --git a/pkg/redis/Tests/RedisConnectionFactoryTest.php b/pkg/redis/Tests/RedisConnectionFactoryTest.php
index 049feaef9..1f9b3a259 100644
--- a/pkg/redis/Tests/RedisConnectionFactoryTest.php
+++ b/pkg/redis/Tests/RedisConnectionFactoryTest.php
@@ -5,12 +5,14 @@
use Enqueue\Redis\RedisConnectionFactory;
use Enqueue\Redis\RedisContext;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
class RedisConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
@@ -26,6 +28,6 @@ public function testShouldCreateLazyContext()
$this->assertInstanceOf(RedisContext::class, $context);
$this->assertAttributeEquals(null, 'redis', $context);
- $this->assertInternalType('callable', $this->readAttribute($context, 'redisFactory'));
+ self::assertIsCallable($this->readAttribute($context, 'redisFactory'));
}
}
diff --git a/pkg/redis/Tests/RedisConsumerTest.php b/pkg/redis/Tests/RedisConsumerTest.php
index ed67bd73b..56373c18a 100644
--- a/pkg/redis/Tests/RedisConsumerTest.php
+++ b/pkg/redis/Tests/RedisConsumerTest.php
@@ -22,11 +22,6 @@ public function testShouldImplementConsumerInterface()
$this->assertClassImplements(Consumer::class, RedisConsumer::class);
}
- public function testCouldBeConstructedWithContextAndDestinationAndPreFetchCountAsArguments()
- {
- new RedisConsumer($this->createContextMock(), new RedisDestination('aQueue'));
- }
-
public function testShouldReturnDestinationSetInConstructorOnGetQueue()
{
$destination = new RedisDestination('aQueue');
@@ -112,6 +107,7 @@ public function testShouldSendSameMessageToDestinationOnReQueue()
$message = new RedisMessage();
$message->setBody('text');
+ $message->setHeader('attempts', 0);
$message->setReservedKey($serializer->toString($message));
$consumer = new RedisConsumer($contextMock, new RedisDestination('aQueue'));
diff --git a/pkg/redis/Tests/RedisContextTest.php b/pkg/redis/Tests/RedisContextTest.php
index 0115f27b8..6395e954e 100644
--- a/pkg/redis/Tests/RedisContextTest.php
+++ b/pkg/redis/Tests/RedisContextTest.php
@@ -25,18 +25,6 @@ public function testShouldImplementContextInterface()
$this->assertClassImplements(Context::class, RedisContext::class);
}
- public function testCouldBeConstructedWithRedisAsFirstArgument()
- {
- new RedisContext($this->createRedisMock(), 300);
- }
-
- public function testCouldBeConstructedWithRedisFactoryAsFirstArgument()
- {
- new RedisContext(function () {
- return $this->createRedisMock();
- }, 300);
- }
-
public function testThrowIfNeitherRedisNorFactoryGiven()
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/pkg/redis/Tests/RedisProducerTest.php b/pkg/redis/Tests/RedisProducerTest.php
index fa7260311..40e03bae2 100644
--- a/pkg/redis/Tests/RedisProducerTest.php
+++ b/pkg/redis/Tests/RedisProducerTest.php
@@ -25,11 +25,6 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(Producer::class, RedisProducer::class);
}
- public function testCouldBeConstructedWithRedisAsFirstArgument()
- {
- new RedisProducer($this->createContextMock());
- }
-
public function testThrowIfDestinationNotRedisDestinationOnSend()
{
$producer = new RedisProducer($this->createContextMock());
@@ -67,7 +62,7 @@ public function testShouldCallLPushOnSend()
$this->assertNotEmpty($message['headers']['message_id']);
$this->assertSame(0, $message['headers']['attempts']);
- return true;
+ return 1;
})
;
@@ -104,7 +99,7 @@ public function testShouldCallZaddOnSendWithDeliveryDelay()
->with(
'aDestination:delayed',
$this->isJson(),
- $this->equalTo(time() + 5, 1)
+ $this->equalTo(time() + 5)
)
;
diff --git a/pkg/redis/Tests/RedisSubscriptionConsumerTest.php b/pkg/redis/Tests/RedisSubscriptionConsumerTest.php
index ac8300cd2..8d00fcc14 100644
--- a/pkg/redis/Tests/RedisSubscriptionConsumerTest.php
+++ b/pkg/redis/Tests/RedisSubscriptionConsumerTest.php
@@ -5,6 +5,7 @@
use Enqueue\Redis\RedisConsumer;
use Enqueue\Redis\RedisContext;
use Enqueue\Redis\RedisSubscriptionConsumer;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Consumer;
use Interop\Queue\Queue;
use Interop\Queue\SubscriptionConsumer;
@@ -12,6 +13,8 @@
class RedisSubscriptionConsumerTest extends TestCase
{
+ use ReadAttributeTrait;
+
public function testShouldImplementSubscriptionConsumerInterface()
{
$rc = new \ReflectionClass(RedisSubscriptionConsumer::class);
@@ -19,11 +22,6 @@ public function testShouldImplementSubscriptionConsumerInterface()
$this->assertTrue($rc->implementsInterface(SubscriptionConsumer::class));
}
- public function testCouldBeConstructedWithRedisContextAsFirstArgument()
- {
- new RedisSubscriptionConsumer($this->createRedisContextMock());
- }
-
public function testShouldAddConsumerAndCallbackToSubscribersPropertyOnSubscribe()
{
$subscriptionConsumer = new RedisSubscriptionConsumer($this->createRedisContextMock());
@@ -60,6 +58,9 @@ public function testThrowsIfTrySubscribeAnotherConsumerToAlreadySubscribedQueue(
$subscriptionConsumer->subscribe($barConsumer, $barCallback);
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testShouldAllowSubscribeSameConsumerAndCallbackSecondTime()
{
$subscriptionConsumer = new RedisSubscriptionConsumer($this->createRedisContextMock());
diff --git a/pkg/redis/Tests/Spec/JsonSerializerTest.php b/pkg/redis/Tests/Spec/JsonSerializerTest.php
index 7516090a9..a15859d35 100644
--- a/pkg/redis/Tests/Spec/JsonSerializerTest.php
+++ b/pkg/redis/Tests/Spec/JsonSerializerTest.php
@@ -20,11 +20,6 @@ public function testShouldImplementSerializerInterface()
$this->assertClassImplements(Serializer::class, JsonSerializer::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new JsonSerializer();
- }
-
public function testShouldConvertMessageToJsonString()
{
$serializer = new JsonSerializer();
@@ -42,8 +37,8 @@ public function testThrowIfFailedToEncodeMessageToJson()
$resource = fopen(__FILE__, 'r');
- //guard
- $this->assertInternalType('resource', $resource);
+ // guard
+ $this->assertIsResource($resource);
$message = new RedisMessage('theBody', ['aProp' => $resource]);
diff --git a/pkg/redis/Tests/Spec/RedisConnectionFactoryTest.php b/pkg/redis/Tests/Spec/RedisConnectionFactoryTest.php
index e086bccab..f15282f11 100644
--- a/pkg/redis/Tests/Spec/RedisConnectionFactoryTest.php
+++ b/pkg/redis/Tests/Spec/RedisConnectionFactoryTest.php
@@ -10,9 +10,6 @@
*/
class RedisConnectionFactoryTest extends ConnectionFactorySpec
{
- /**
- * {@inheritdoc}
- */
protected function createConnectionFactory()
{
return new RedisConnectionFactory();
diff --git a/pkg/redis/Tests/Spec/RedisContextTest.php b/pkg/redis/Tests/Spec/RedisContextTest.php
index 3377fb89b..4f48e24ae 100644
--- a/pkg/redis/Tests/Spec/RedisContextTest.php
+++ b/pkg/redis/Tests/Spec/RedisContextTest.php
@@ -13,9 +13,6 @@ class RedisContextTest extends ContextSpec
{
use RedisExtension;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildPhpRedisContext();
diff --git a/pkg/redis/Tests/Spec/RedisMessageTest.php b/pkg/redis/Tests/Spec/RedisMessageTest.php
index bb8af845d..b0cc828e9 100644
--- a/pkg/redis/Tests/Spec/RedisMessageTest.php
+++ b/pkg/redis/Tests/Spec/RedisMessageTest.php
@@ -10,9 +10,6 @@
*/
class RedisMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new RedisMessage();
diff --git a/pkg/redis/Tests/Spec/RedisProducerTest.php b/pkg/redis/Tests/Spec/RedisProducerTest.php
index fa9fbfefb..3434820e9 100644
--- a/pkg/redis/Tests/Spec/RedisProducerTest.php
+++ b/pkg/redis/Tests/Spec/RedisProducerTest.php
@@ -13,9 +13,6 @@ class RedisProducerTest extends ProducerSpec
{
use RedisExtension;
- /**
- * {@inheritdoc}
- */
protected function createProducer()
{
return $this->buildPhpRedisContext()->createProducer();
diff --git a/pkg/redis/Tests/Spec/RedisQueueTest.php b/pkg/redis/Tests/Spec/RedisQueueTest.php
index ab7b9937b..a8cd3b442 100644
--- a/pkg/redis/Tests/Spec/RedisQueueTest.php
+++ b/pkg/redis/Tests/Spec/RedisQueueTest.php
@@ -10,9 +10,6 @@
*/
class RedisQueueTest extends QueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createQueue()
{
return new RedisDestination(self::EXPECTED_QUEUE_NAME);
diff --git a/pkg/redis/Tests/Spec/RedisRequeueMessageTest.php b/pkg/redis/Tests/Spec/RedisRequeueMessageTest.php
index c84bc84b5..69bd2c6ef 100644
--- a/pkg/redis/Tests/Spec/RedisRequeueMessageTest.php
+++ b/pkg/redis/Tests/Spec/RedisRequeueMessageTest.php
@@ -13,9 +13,6 @@ class RedisRequeueMessageTest extends RequeueMessageSpec
{
use RedisExtension;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildPhpRedisContext();
diff --git a/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromQueueTest.php b/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromQueueTest.php
index 5535d949a..7bb61ab5d 100644
--- a/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromQueueTest.php
+++ b/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromQueueTest.php
@@ -13,9 +13,6 @@ class RedisSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
use RedisExtension;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildPhpRedisContext();
diff --git a/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromTopicTest.php b/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromTopicTest.php
index 2967ba977..37545f032 100644
--- a/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromTopicTest.php
+++ b/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromTopicTest.php
@@ -13,9 +13,6 @@ class RedisSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
use RedisExtension;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildPhpRedisContext();
diff --git a/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromQueueTest.php b/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromQueueTest.php
index e03139f7e..01aea7ff1 100644
--- a/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromQueueTest.php
@@ -13,9 +13,6 @@ class RedisSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFro
{
use RedisExtension;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildPhpRedisContext();
diff --git a/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromTopicTest.php b/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromTopicTest.php
index fe103234b..2c8fbac7a 100644
--- a/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromTopicTest.php
+++ b/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromTopicTest.php
@@ -13,9 +13,6 @@ class RedisSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFro
{
use RedisExtension;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildPhpRedisContext();
diff --git a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
index 16dbd8f98..78d33045f 100644
--- a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
+++ b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
@@ -18,8 +18,6 @@ class RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscr
/**
* @return RedisContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param RedisContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeUntilUnsubscribedTest.php
index b227e3405..84872093b 100644
--- a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeUntilUnsubscribedTest.php
+++ b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeUntilUnsubscribedTest.php
@@ -18,8 +18,6 @@ class RedisSubscriptionConsumerConsumeUntilUnsubscribedTest extends Subscription
/**
* @return RedisContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param RedisContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerStopOnFalseTest.php b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerStopOnFalseTest.php
index 5a033a872..490d58eab 100644
--- a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerStopOnFalseTest.php
+++ b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerStopOnFalseTest.php
@@ -18,8 +18,6 @@ class RedisSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopO
/**
* @return RedisContext
- *
- * {@inheritdoc}
*/
protected function createContext()
{
@@ -28,8 +26,6 @@ protected function createContext()
/**
* @param RedisContext $context
- *
- * {@inheritdoc}
*/
protected function createQueue(Context $context, $queueName)
{
diff --git a/pkg/redis/Tests/Spec/RedisTopicTest.php b/pkg/redis/Tests/Spec/RedisTopicTest.php
index 52001aa66..da94ffa1b 100644
--- a/pkg/redis/Tests/Spec/RedisTopicTest.php
+++ b/pkg/redis/Tests/Spec/RedisTopicTest.php
@@ -10,9 +10,6 @@
*/
class RedisTopicTest extends TopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createTopic()
{
return new RedisDestination(self::EXPECTED_TOPIC_NAME);
diff --git a/pkg/redis/composer.json b/pkg/redis/composer.json
index 135f5a0c9..c48323201 100644
--- a/pkg/redis/composer.json
+++ b/pkg/redis/composer.json
@@ -6,17 +6,17 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8",
"enqueue/dsn": "^0.10",
- "ramsey/uuid": "^3|^4"
+ "ramsey/uuid": "^3.5|^4"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"predis/predis": "^1.1",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/simple-client/.github/workflows/ci.yml b/pkg/simple-client/.github/workflows/ci.yml
new file mode 100644
index 000000000..604442a2f
--- /dev/null
+++ b/pkg/simple-client/.github/workflows/ci.yml
@@ -0,0 +1,31 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['8.1', '8.2', '8.3', '8.4']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - run: php Tests/fix_composer_json.php
+
+ - uses: "ramsey/composer-install@v3"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/simple-client/.travis.yml b/pkg/simple-client/.travis.yml
deleted file mode 100644
index ebe714611..000000000
--- a/pkg/simple-client/.travis.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - php Tests/fix_composer_json.php
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/simple-client/README.md b/pkg/simple-client/README.md
index c9e0b4fa7..8ecb67059 100644
--- a/pkg/simple-client/README.md
+++ b/pkg/simple-client/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Message Queue. Simple client
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/simple-client)
+[](https://github.com/php-enqueue/simple-client/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/simple-client)
[](https://packagist.org/packages/enqueue/simple-client)
diff --git a/pkg/simple-client/SimpleClient.php b/pkg/simple-client/SimpleClient.php
index 9158364b9..bbfd8b91b 100644
--- a/pkg/simple-client/SimpleClient.php
+++ b/pkg/simple-client/SimpleClient.php
@@ -114,10 +114,9 @@ final class SimpleClient
* ]
* ]
*
- *
* @param string|array $config
*/
- public function __construct($config, LoggerInterface $logger = null)
+ public function __construct($config, ?LoggerInterface $logger = null)
{
if (is_string($config)) {
$config = [
@@ -134,7 +133,7 @@ public function __construct($config, LoggerInterface $logger = null)
/**
* @param callable|Processor $processor
*/
- public function bindTopic(string $topic, $processor, string $processorName = null): void
+ public function bindTopic(string $topic, $processor, ?string $processorName = null): void
{
if (is_callable($processor)) {
$processor = new CallbackProcessor($processor);
@@ -144,7 +143,7 @@ public function bindTopic(string $topic, $processor, string $processorName = nul
throw new \LogicException('The processor must be either callable or instance of Processor');
}
- $processorName = $processorName ?: uniqid(get_class($processor));
+ $processorName = $processorName ?: uniqid($processor::class);
$this->driver->getRouteCollection()->add(new Route($topic, Route::TOPIC, $processorName));
$this->processorRegistry->add($processorName, $processor);
@@ -153,7 +152,7 @@ public function bindTopic(string $topic, $processor, string $processorName = nul
/**
* @param callable|Processor $processor
*/
- public function bindCommand(string $command, $processor, string $processorName = null): void
+ public function bindCommand(string $command, $processor, ?string $processorName = null): void
{
if (is_callable($processor)) {
$processor = new CallbackProcessor($processor);
@@ -163,7 +162,7 @@ public function bindCommand(string $command, $processor, string $processorName =
throw new \LogicException('The processor must be either callable or instance of Processor');
}
- $processorName = $processorName ?: uniqid(get_class($processor));
+ $processorName = $processorName ?: uniqid($processor::class);
$this->driver->getRouteCollection()->add(new Route($command, Route::COMMAND, $processorName));
$this->processorRegistry->add($processorName, $processor);
@@ -185,7 +184,7 @@ public function sendEvent(string $topic, $message): void
$this->producer->sendEvent($topic, $message);
}
- public function consume(ExtensionInterface $runtimeExtension = null): void
+ public function consume(?ExtensionInterface $runtimeExtension = null): void
{
$this->setupBroker();
diff --git a/pkg/simple-client/Tests/Functional/SimpleClientTest.php b/pkg/simple-client/Tests/Functional/SimpleClientTest.php
index 13320fb67..ce75457af 100644
--- a/pkg/simple-client/Tests/Functional/SimpleClientTest.php
+++ b/pkg/simple-client/Tests/Functional/SimpleClientTest.php
@@ -85,8 +85,6 @@ public function testShouldWorkWithStringDsnConstructorArgument()
/**
* @dataProvider transportConfigDataProvider
- *
- * @param mixed $config
*/
public function testSendEventWithOneSubscriber($config, string $timeLimit)
{
@@ -125,8 +123,6 @@ public function testSendEventWithOneSubscriber($config, string $timeLimit)
/**
* @dataProvider transportConfigDataProvider
- *
- * @param mixed $config
*/
public function testSendEventWithTwoSubscriber($config, string $timeLimit)
{
@@ -168,8 +164,6 @@ public function testSendEventWithTwoSubscriber($config, string $timeLimit)
/**
* @dataProvider transportConfigDataProvider
- *
- * @param mixed $config
*/
public function testSendCommand($config, string $timeLimit)
{
diff --git a/pkg/simple-client/Tests/fix_composer_json.php b/pkg/simple-client/Tests/fix_composer_json.php
index f025f6081..01f73c95e 100644
--- a/pkg/simple-client/Tests/fix_composer_json.php
+++ b/pkg/simple-client/Tests/fix_composer_json.php
@@ -6,4 +6,4 @@
$composerJson['config']['platform']['ext-amqp'] = '1.9.3';
-file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, JSON_PRETTY_PRINT));
+file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, \JSON_PRETTY_PRINT));
diff --git a/pkg/simple-client/composer.json b/pkg/simple-client/composer.json
index 3b525bf16..03bda03b4 100644
--- a/pkg/simple-client/composer.json
+++ b/pkg/simple-client/composer.json
@@ -6,19 +6,19 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"enqueue/enqueue": "^0.10",
- "queue-interop/amqp-interop": "^0.8",
+ "queue-interop/amqp-interop": "^0.8.2",
"queue-interop/queue-interop": "^0.8",
- "symfony/config": "^4.3|^5"
+ "symfony/config": "^6.0|^7.0"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/amqp-ext": "0.10.x-dev",
"enqueue/fs": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "symfony/yaml": "^4.3|^5"
+ "symfony/yaml": "^5.4|^6.0"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/sns/.github/workflows/ci.yml b/pkg/sns/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/sns/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/sns/.travis.yml b/pkg/sns/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/sns/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/sns/README.md b/pkg/sns/README.md
index 62fa9986c..bfc7a4012 100644
--- a/pkg/sns/README.md
+++ b/pkg/sns/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Amazon SNS Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/sns)
+[](https://github.com/php-enqueue/sns/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/sns)
[](https://packagist.org/packages/enqueue/sns)
diff --git a/pkg/sns/SnsClient.php b/pkg/sns/SnsClient.php
index 2d33faf25..7c4a81693 100644
--- a/pkg/sns/SnsClient.php
+++ b/pkg/sns/SnsClient.php
@@ -60,6 +60,11 @@ public function unsubscribe(array $args): Result
return $this->callApi('unsubscribe', $args);
}
+ public function setSubscriptionAttributes(array $args): Result
+ {
+ return $this->callApi('setSubscriptionAttributes', $args);
+ }
+
public function listSubscriptionsByTopic(array $args): Result
{
return $this->callApi('ListSubscriptionsByTopic', $args);
@@ -135,11 +140,6 @@ private function resolveClient(): void
}
}
- throw new \LogicException(sprintf(
- 'The input client must be an instance of "%s" or "%s" or a callable that returns one of those. Got "%s"',
- AwsSnsClient::class,
- MultiRegionClient::class,
- is_object($client) ? get_class($client) : gettype($client)
- ));
+ throw new \LogicException(sprintf('The input client must be an instance of "%s" or "%s" or a callable that returns one of those. Got "%s"', AwsSnsClient::class, MultiRegionClient::class, is_object($client) ? $client::class : gettype($client)));
}
}
diff --git a/pkg/sns/SnsConnectionFactory.php b/pkg/sns/SnsConnectionFactory.php
index ffef39803..8a815abad 100644
--- a/pkg/sns/SnsConnectionFactory.php
+++ b/pkg/sns/SnsConnectionFactory.php
@@ -24,13 +24,14 @@ class SnsConnectionFactory implements ConnectionFactory
/**
* $config = [
- * 'key' => null AWS credentials. If no credentials are provided, the SDK will attempt to load them from the environment.
+ * 'key' => null, AWS credentials. If no credentials are provided, the SDK will attempt to load them from the environment.
* 'secret' => null, AWS credentials. If no credentials are provided, the SDK will attempt to load them from the environment.
* 'token' => null, AWS credentials. If no credentials are provided, the SDK will attempt to load them from the environment.
* 'region' => null, (string, required) Region to connect to. See http://docs.aws.amazon.com/general/latest/gr/rande.html for a list of available regions.
* 'version' => '2012-11-05', (string, required) The version of the webservice to utilize
* 'lazy' => true, Enable lazy connection (boolean)
- * 'endpoint' => null (string, default=null) The full URI of the webservice. This is only required when connecting to a custom endpoint e.g. localstack
+ * 'endpoint' => null, (string, default=null) The full URI of the webservice. This is only required when connecting to a custom endpoint e.g. localstack
+ * 'topic_arns' => [], (array) The list of existing topic arns: key - topic name; value - arn
* ].
*
* or
@@ -51,19 +52,19 @@ public function __construct($config = 'sns:')
if (empty($config)) {
$config = [];
- } elseif (is_string($config)) {
+ } elseif (\is_string($config)) {
$config = $this->parseDsn($config);
- } elseif (is_array($config)) {
- if (array_key_exists('dsn', $config)) {
- $config = array_replace_recursive($config, $this->parseDsn($config['dsn']));
+ } elseif (\is_array($config)) {
+ if (\array_key_exists('dsn', $config)) {
+ $config = \array_replace_recursive($config, $this->parseDsn($config['dsn']));
unset($config['dsn']);
}
} else {
- throw new \LogicException(sprintf('The config must be either an array of options, a DSN string, null or instance of %s', AwsSnsClient::class));
+ throw new \LogicException(\sprintf('The config must be either an array of options, a DSN string, null or instance of %s', AwsSnsClient::class));
}
- $this->config = array_replace($this->defaultConfig(), $config);
+ $this->config = \array_replace($this->defaultConfig(), $config);
}
/**
@@ -89,6 +90,10 @@ private function establishConnection(): SnsClient
$config['endpoint'] = $this->config['endpoint'];
}
+ if (isset($this->config['profile'])) {
+ $config['profile'] = $this->config['profile'];
+ }
+
if ($this->config['key'] && $this->config['secret']) {
$config['credentials'] = [
'key' => $this->config['key'],
@@ -100,6 +105,10 @@ private function establishConnection(): SnsClient
}
}
+ if (isset($this->config['http'])) {
+ $config['http'] = $this->config['http'];
+ }
+
$establishConnection = function () use ($config) {
return (new Sdk(['Sns' => $config]))->createMultiRegionSns();
};
@@ -117,13 +126,10 @@ private function parseDsn(string $dsn): array
$dsn = Dsn::parseFirst($dsn);
if ('sns' !== $dsn->getSchemeProtocol()) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be "sns"',
- $dsn->getSchemeProtocol()
- ));
+ throw new \LogicException(\sprintf('The given scheme protocol "%s" is not supported. It must be "sns"', $dsn->getSchemeProtocol()));
}
- return array_filter(array_replace($dsn->getQuery(), [
+ return \array_filter(\array_replace($dsn->getQuery(), [
'key' => $dsn->getString('key'),
'secret' => $dsn->getString('secret'),
'token' => $dsn->getString('token'),
@@ -131,6 +137,8 @@ private function parseDsn(string $dsn): array
'version' => $dsn->getString('version'),
'lazy' => $dsn->getBool('lazy'),
'endpoint' => $dsn->getString('endpoint'),
+ 'topic_arns' => $dsn->getArray('topic_arns', [])->toArray(),
+ 'http' => $dsn->getArray('http', [])->toArray(),
]), function ($value) { return null !== $value; });
}
@@ -144,6 +152,8 @@ private function defaultConfig(): array
'version' => '2010-03-31',
'lazy' => true,
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
];
}
}
diff --git a/pkg/sns/SnsContext.php b/pkg/sns/SnsContext.php
index b489f8d57..2e19164d9 100644
--- a/pkg/sns/SnsContext.php
+++ b/pkg/sns/SnsContext.php
@@ -35,8 +35,7 @@ public function __construct(SnsClient $client, array $config)
{
$this->client = $client;
$this->config = $config;
-
- $this->topicArns = [];
+ $this->topicArns = $config['topic_arns'] ?? [];
}
/**
@@ -77,6 +76,11 @@ public function declareTopic(SnsDestination $destination): void
$this->topicArns[$destination->getTopicName()] = (string) $result->get('TopicArn');
}
+ public function setTopicArn(SnsDestination $destination, string $arn): void
+ {
+ $this->topicArns[$destination->getTopicName()] = $arn;
+ }
+
public function deleteTopic(SnsDestination $destination): void
{
$this->client->deleteTopic($this->getTopicArn($destination));
@@ -141,6 +145,16 @@ public function getSubscriptions(SnsDestination $destination): array
return $subscriptions;
}
+ public function setSubscriptionAttributes(SnsSubscribe $subscribe): void
+ {
+ foreach ($this->getSubscriptions($subscribe->getTopic()) as $subscription) {
+ $this->client->setSubscriptionAttributes(array_merge(
+ $subscribe->getAttributes(),
+ ['SubscriptionArn' => $subscription['SubscriptionArn']],
+ ));
+ }
+ }
+
public function getTopicArn(SnsDestination $destination): string
{
if (false == array_key_exists($destination->getTopicName(), $this->topicArns)) {
diff --git a/pkg/sns/SnsDestination.php b/pkg/sns/SnsDestination.php
index 0db9d914e..adcb08f43 100644
--- a/pkg/sns/SnsDestination.php
+++ b/pkg/sns/SnsDestination.php
@@ -34,7 +34,7 @@ public function getTopicName(): string
/**
* The policy that defines who can access your topic. By default, only the topic owner can publish or subscribe to the topic.
*/
- public function setPolicy(string $policy = null): void
+ public function setPolicy(?string $policy = null): void
{
$this->setAttribute('Policy', $policy);
}
@@ -47,7 +47,7 @@ public function getPolicy(): ?string
/**
* The display name to use for a topic with SMS subscriptions.
*/
- public function setDisplayName(string $displayName = null): void
+ public function setDisplayName(?string $displayName = null): void
{
$this->setAttribute('DisplayName', $displayName);
}
@@ -60,7 +60,7 @@ public function getDisplayName(): ?string
/**
* The display name to use for a topic with SMS subscriptions.
*/
- public function setDeliveryPolicy(int $deliveryPolicy = null): void
+ public function setDeliveryPolicy(?int $deliveryPolicy = null): void
{
$this->setAttribute('DeliveryPolicy', $deliveryPolicy);
}
@@ -70,6 +70,34 @@ public function getDeliveryPolicy(): ?int
return $this->getAttribute('DeliveryPolicy');
}
+ /**
+ * Only FIFO.
+ *
+ * Designates a topic as FIFO. You can provide this attribute only during queue creation.
+ * You can't change it for an existing topic. When you set this attribute, you must provide aMessageGroupId
+ * explicitly.
+ * For more information, see https://docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html
+ */
+ public function setFifoTopic(bool $enable): void
+ {
+ $value = $enable ? 'true' : null;
+
+ $this->setAttribute('FifoTopic', $value);
+ }
+
+ /**
+ * Only FIFO.
+ *
+ * Enables content-based deduplication.
+ * For more information, see: https://docs.aws.amazon.com/sns/latest/dg/fifo-message-dedup.html
+ */
+ public function setContentBasedDeduplication(bool $enable): void
+ {
+ $value = $enable ? 'true' : null;
+
+ $this->setAttribute('ContentBasedDeduplication', $value);
+ }
+
public function getAttributes(): array
{
return $this->attributes;
diff --git a/pkg/sns/SnsMessage.php b/pkg/sns/SnsMessage.php
index f7311d0b0..4122209e8 100644
--- a/pkg/sns/SnsMessage.php
+++ b/pkg/sns/SnsMessage.php
@@ -42,31 +42,32 @@ class SnsMessage implements Message
*/
private $targetArn;
+ /**
+ * @var string|null
+ */
+ private $messageGroupId;
+
+ /**
+ * @var string|null
+ */
+ private $messageDeduplicationId;
+
/**
* SnsMessage constructor.
*
* See AWS documentation for message attribute structure.
*
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-sns-2010-03-31.html#shape-messageattributevalue
- *
- * @param string $body
- * @param array $properties
- * @param array $headers
- * @param array|null $messageAttributes
- * @param string|null $messageStructure
- * @param string|null $phoneNumber
- * @param string|null $subject
- * @param string|null $targetArn
*/
public function __construct(
string $body = '',
array $properties = [],
array $headers = [],
- array $messageAttributes = null,
- string $messageStructure = null,
- string $phoneNumber = null,
- string $subject = null,
- string $targetArn = null
+ ?array $messageAttributes = null,
+ ?string $messageStructure = null,
+ ?string $phoneNumber = null,
+ ?string $subject = null,
+ ?string $targetArn = null,
) {
$this->body = $body;
$this->properties = $properties;
@@ -79,89 +80,58 @@ public function __construct(
$this->redelivered = false;
}
- /**
- * @return string|null
- */
public function getSnsMessageId(): ?string
{
return $this->snsMessageId;
}
- /**
- * @param string|null $snsMessageId
- */
public function setSnsMessageId(?string $snsMessageId): void
{
$this->snsMessageId = $snsMessageId;
}
- /**
- * @return string|null
- */
public function getMessageStructure(): ?string
{
return $this->messageStructure;
}
- /**
- * @param string|null $messageStructure
- */
public function setMessageStructure(?string $messageStructure): void
{
$this->messageStructure = $messageStructure;
}
- /**
- * @return string|null
- */
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
- /**
- * @param string|null $phoneNumber
- */
public function setPhoneNumber(?string $phoneNumber): void
{
$this->phoneNumber = $phoneNumber;
}
- /**
- * @return string|null
- */
public function getSubject(): ?string
{
return $this->subject;
}
- /**
- * @param string|null $subject
- */
public function setSubject(?string $subject): void
{
$this->subject = $subject;
}
- /**
- * @return array|null
- */
public function getMessageAttributes(): ?array
{
return $this->messageAttributes;
}
- /**
- * @param array|null $messageAttributes
- */
public function setMessageAttributes(?array $messageAttributes): void
{
$this->messageAttributes = $messageAttributes;
}
/**
- * @param string $name
- * @param null $default
+ * @param null $default
*
* @return array|null
*/
@@ -177,9 +147,6 @@ public function getAttribute(string $name, $default = null)
* 'DataType' => '', // REQUIRED
* 'StringValue' => '',
* ].
- *
- * @param string $name
- * @param array|null $attribute
*/
public function setAttribute(string $name, ?array $attribute): void
{
@@ -191,7 +158,6 @@ public function setAttribute(string $name, ?array $attribute): void
}
/**
- * @param string $name
* @param string $dataType String, String.Array, Number, or Binary
* @param string|resource|StreamInterface $value
*/
@@ -205,19 +171,52 @@ public function addAttribute(string $name, string $dataType, $value): void
];
}
- /**
- * @return string|null
- */
public function getTargetArn(): ?string
{
return $this->targetArn;
}
- /**
- * @param string|null $targetArn
- */
public function setTargetArn(?string $targetArn): void
{
$this->targetArn = $targetArn;
}
+
+ /**
+ * Only FIFO.
+ *
+ * The tag that specifies that a message belongs to a specific message group. Messages that belong to the same
+ * message group are processed in a FIFO manner (however, messages in different message groups might be processed
+ * out of order).
+ * To interleave multiple ordered streams within a single queue, use MessageGroupId values (for example, session
+ * data for multiple users). In this scenario, multiple readers can process the queue, but the session data
+ * of each user is processed in a FIFO fashion.
+ * For more information, see: https://docs.aws.amazon.com/sns/latest/dg/fifo-message-grouping.html
+ */
+ public function setMessageGroupId(?string $id = null): void
+ {
+ $this->messageGroupId = $id;
+ }
+
+ public function getMessageGroupId(): ?string
+ {
+ return $this->messageGroupId;
+ }
+
+ /**
+ * Only FIFO.
+ *
+ * The token used for deduplication of sent messages. If a message with a particular MessageDeduplicationId is
+ * sent successfully, any messages sent with the same MessageDeduplicationId are accepted successfully but
+ * aren't delivered during the 5-minute deduplication interval.
+ * For more information, see https://docs.aws.amazon.com/sns/latest/dg/fifo-message-dedup.html
+ */
+ public function setMessageDeduplicationId(?string $id = null): void
+ {
+ $this->messageDeduplicationId = $id;
+ }
+
+ public function getMessageDeduplicationId(): ?string
+ {
+ return $this->messageDeduplicationId;
+ }
}
diff --git a/pkg/sns/SnsProducer.php b/pkg/sns/SnsProducer.php
index d4eba04d0..ac7e38b5b 100644
--- a/pkg/sns/SnsProducer.php
+++ b/pkg/sns/SnsProducer.php
@@ -77,6 +77,14 @@ public function send(Destination $destination, Message $message): void
$arguments['TargetArn'] = $targetArn;
}
+ if ($messageGroupId = $message->getMessageGroupId()) {
+ $arguments['MessageGroupId'] = $messageGroupId;
+ }
+
+ if ($messageDeduplicationId = $message->getMessageDeduplicationId()) {
+ $arguments['MessageDeduplicationId'] = $messageDeduplicationId;
+ }
+
$result = $this->context->getSnsClient()->publish($arguments);
if (false == $result->hasKey('MessageId')) {
@@ -91,7 +99,7 @@ public function send(Destination $destination, Message $message): void
*
* @return SnsProducer
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $deliveryDelay) {
return $this;
@@ -110,7 +118,7 @@ public function getDeliveryDelay(): ?int
*
* @return SnsProducer
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
@@ -129,7 +137,7 @@ public function getPriority(): ?int
*
* @return SnsProducer
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
if (null === $timeToLive) {
return $this;
diff --git a/pkg/sns/SnsSubscribe.php b/pkg/sns/SnsSubscribe.php
index 70addb7e0..52991d81f 100644
--- a/pkg/sns/SnsSubscribe.php
+++ b/pkg/sns/SnsSubscribe.php
@@ -6,7 +6,7 @@
class SnsSubscribe
{
- const PROTOCOL_SQS = 'sqs';
+ public const PROTOCOL_SQS = 'sqs';
/**
* @var SnsDestination
@@ -23,14 +23,8 @@ class SnsSubscribe
*/
private $protocol;
- /**
- * @var
- */
private $returnSubscriptionArn;
- /**
- * @var
- */
private $attributes;
public function __construct(
@@ -38,7 +32,7 @@ public function __construct(
string $endpoint,
string $protocol,
bool $returnSubscriptionArn = false,
- array $attributes = []
+ array $attributes = [],
) {
$this->topic = $topic;
$this->endpoint = $endpoint;
diff --git a/pkg/sns/SnsUnsubscribe.php b/pkg/sns/SnsUnsubscribe.php
index cd5733651..ad6b93d45 100644
--- a/pkg/sns/SnsUnsubscribe.php
+++ b/pkg/sns/SnsUnsubscribe.php
@@ -24,7 +24,7 @@ class SnsUnsubscribe
public function __construct(
SnsDestination $topic,
string $endpoint,
- string $protocol
+ string $protocol,
) {
$this->topic = $topic;
$this->endpoint = $endpoint;
diff --git a/pkg/sns/Tests/SnsClientTest.php b/pkg/sns/Tests/SnsClientTest.php
index e56a18790..a029f4fd0 100644
--- a/pkg/sns/Tests/SnsClientTest.php
+++ b/pkg/sns/Tests/SnsClientTest.php
@@ -16,8 +16,7 @@ public function testShouldAllowGetAwsClientIfSingleClientProvided()
$awsClient = (new Sdk(['Sns' => [
'key' => '',
'secret' => '',
- 'token' => '',
- 'region' => '',
+ 'region' => 'us-west-2',
'version' => '2010-03-31',
'endpoint' => 'http://localhost',
]]))->createSns();
@@ -32,8 +31,7 @@ public function testShouldAllowGetAwsClientIfMultipleClientProvided()
$awsClient = (new Sdk(['Sns' => [
'key' => '',
'secret' => '',
- 'token' => '',
- 'region' => '',
+ 'region' => 'us-west-2',
'version' => '2010-03-31',
'endpoint' => 'http://localhost',
]]))->createMultiRegionSns();
diff --git a/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php b/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php
index d9cbff390..305a6518d 100644
--- a/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php
+++ b/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php
@@ -4,6 +4,7 @@
use Enqueue\Sns\SnsConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@
class SnsConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
@@ -39,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
@@ -62,6 +61,8 @@ public static function provideConfigs()
'version' => '2010-03-31',
'lazy' => true,
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
],
];
@@ -75,6 +76,8 @@ public static function provideConfigs()
'version' => '2010-03-31',
'lazy' => true,
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
],
];
@@ -88,6 +91,8 @@ public static function provideConfigs()
'version' => '2010-03-31',
'lazy' => true,
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
],
];
@@ -101,6 +106,8 @@ public static function provideConfigs()
'version' => '2010-03-31',
'lazy' => false,
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
],
];
@@ -114,6 +121,8 @@ public static function provideConfigs()
'version' => '2010-03-31',
'lazy' => false,
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
],
];
@@ -127,6 +136,8 @@ public static function provideConfigs()
'version' => '2010-03-31',
'lazy' => false,
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
],
];
@@ -146,6 +157,44 @@ public static function provideConfigs()
'version' => '2010-03-31',
'lazy' => false,
'endpoint' => 'http://localstack:1111',
+ 'topic_arns' => [],
+ 'http' => [],
+ ],
+ ];
+
+ yield [
+ ['dsn' => 'sns:?topic_arns[topic1]=arn:aws:sns:us-east-1:123456789012:topic1&topic_arns[topic2]=arn:aws:sns:us-west-2:123456789012:topic2'],
+ [
+ 'key' => null,
+ 'secret' => null,
+ 'token' => null,
+ 'region' => null,
+ 'version' => '2010-03-31',
+ 'lazy' => true,
+ 'endpoint' => null,
+ 'topic_arns' => [
+ 'topic1' => 'arn:aws:sns:us-east-1:123456789012:topic1',
+ 'topic2' => 'arn:aws:sns:us-west-2:123456789012:topic2',
+ ],
+ 'http' => [],
+ ],
+ ];
+
+ yield [
+ ['dsn' => 'sns:?http[timeout]=5&http[connect_timeout]=2'],
+ [
+ 'key' => null,
+ 'secret' => null,
+ 'token' => null,
+ 'region' => null,
+ 'version' => '2010-03-31',
+ 'lazy' => true,
+ 'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [
+ 'timeout' => '5',
+ 'connect_timeout' => '2',
+ ],
],
];
}
diff --git a/pkg/sns/Tests/SnsConnectionFactoryTest.php b/pkg/sns/Tests/SnsConnectionFactoryTest.php
index 104c4dc18..4e9ad6ec9 100644
--- a/pkg/sns/Tests/SnsConnectionFactoryTest.php
+++ b/pkg/sns/Tests/SnsConnectionFactoryTest.php
@@ -7,12 +7,14 @@
use Enqueue\Sns\SnsConnectionFactory;
use Enqueue\Sns\SnsContext;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
class SnsConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
@@ -31,6 +33,8 @@ public function testCouldBeConstructedWithEmptyConfiguration()
'region' => null,
'version' => '2010-03-31',
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
], 'config', $factory);
}
@@ -46,6 +50,8 @@ public function testCouldBeConstructedWithCustomConfiguration()
'region' => null,
'version' => '2010-03-31',
'endpoint' => null,
+ 'topic_arns' => [],
+ 'http' => [],
], 'config', $factory);
}
diff --git a/pkg/sns/Tests/SnsProducerTest.php b/pkg/sns/Tests/SnsProducerTest.php
index 5f8784905..1c6be7f85 100644
--- a/pkg/sns/Tests/SnsProducerTest.php
+++ b/pkg/sns/Tests/SnsProducerTest.php
@@ -27,11 +27,6 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(Producer::class, SnsProducer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new SnsProducer($this->createSnsContextMock());
- }
-
public function testShouldThrowIfBodyOfInvalidType()
{
$this->expectException(InvalidMessageException::class);
diff --git a/pkg/sns/Tests/Spec/SnsContextTest.php b/pkg/sns/Tests/Spec/SnsContextTest.php
index 631d4acf1..9592d403f 100644
--- a/pkg/sns/Tests/Spec/SnsContextTest.php
+++ b/pkg/sns/Tests/Spec/SnsContextTest.php
@@ -2,13 +2,16 @@
namespace Enqueue\Sns\Tests\Spec;
+use Aws\Result;
use Enqueue\Sns\SnsClient;
use Enqueue\Sns\SnsContext;
+use Enqueue\Sns\SnsDestination;
+use Enqueue\Sns\SnsSubscribe;
use Interop\Queue\Spec\ContextSpec;
class SnsContextTest extends ContextSpec
{
- public function testShouldCreateConsumerOnCreateConsumerMethodCall()
+ public function testShouldCreateConsumerOnCreateConsumerMethodCall(): void
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('SNS transport does not support consumption. You should consider using SQS instead.');
@@ -16,10 +19,36 @@ public function testShouldCreateConsumerOnCreateConsumerMethodCall()
parent::testShouldCreateConsumerOnCreateConsumerMethodCall();
}
+ public function testSetsSubscriptionAttributes(): void
+ {
+ $client = $this->createMock(SnsClient::class);
+ $client->expects($this->once())
+ ->method('listSubscriptionsByTopic')
+ ->willReturn(new Result(['Subscriptions' => [
+ ['SubscriptionArn' => 'arn1'],
+ ['SubscriptionArn' => 'arn2'],
+ ]]));
+ $client->expects($this->exactly(2))
+ ->method('setSubscriptionAttributes')
+ ->withConsecutive(
+ [$this->equalTo(['attr1' => 'value1', 'SubscriptionArn' => 'arn1'])],
+ [$this->equalTo(['attr1' => 'value1', 'SubscriptionArn' => 'arn2'])],
+ );
+
+ $context = new SnsContext($client, ['topic_arns' => ['topic1' => 'topicArn1']]);
+ $context->setSubscriptionAttributes(new SnsSubscribe(
+ new SnsDestination('topic1'),
+ 'endpoint1',
+ 'protocol1',
+ false,
+ ['attr1' => 'value1'],
+ ));
+ }
+
protected function createContext()
{
$client = $this->createMock(SnsClient::class);
- return new SnsContext($client, []);
+ return new SnsContext($client, ['topic_arns' => []]);
}
}
diff --git a/pkg/sns/composer.json b/pkg/sns/composer.json
index 7fb27bffc..6873037e3 100644
--- a/pkg/sns/composer.json
+++ b/pkg/sns/composer.json
@@ -6,15 +6,15 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8",
"enqueue/dsn": "^0.10",
- "aws/aws-sdk-php": "~3.26"
+ "aws/aws-sdk-php": "^3.290"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/sns/examples/consume.php b/pkg/sns/examples/consume.php
index 7976e7501..6698cd21e 100644
--- a/pkg/sns/examples/consume.php
+++ b/pkg/sns/examples/consume.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\Sns\SnsConnectionFactory;
@@ -26,7 +26,7 @@
while (true) {
if ($m = $consumer->receive(20000)) {
$consumer->acknowledge($m);
- echo 'Received message: '.$m->getBody().PHP_EOL;
+ echo 'Received message: '.$m->getBody().\PHP_EOL;
}
}
diff --git a/pkg/sns/examples/produce.php b/pkg/sns/examples/produce.php
index d37fce79f..3e59c5232 100644
--- a/pkg/sns/examples/produce.php
+++ b/pkg/sns/examples/produce.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\Sns\SnsConnectionFactory;
diff --git a/pkg/snsqs/.github/workflows/ci.yml b/pkg/snsqs/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/snsqs/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/snsqs/.travis.yml b/pkg/snsqs/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/snsqs/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/snsqs/README.md b/pkg/snsqs/README.md
index ec5151f01..94a22776d 100644
--- a/pkg/snsqs/README.md
+++ b/pkg/snsqs/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Amazon SNS-SQS Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/snsqs)
+[](https://github.com/php-enqueue/snsqs/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/snsqs)
[](https://packagist.org/packages/enqueue/snsqs)
diff --git a/pkg/snsqs/SnsQsConnectionFactory.php b/pkg/snsqs/SnsQsConnectionFactory.php
index abb154a9b..65812beb3 100644
--- a/pkg/snsqs/SnsQsConnectionFactory.php
+++ b/pkg/snsqs/SnsQsConnectionFactory.php
@@ -83,10 +83,7 @@ private function parseDsn(string $dsn): void
$dsn = Dsn::parseFirst($dsn);
if ('snsqs' !== $dsn->getSchemeProtocol()) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be "snsqs"',
- $dsn->getSchemeProtocol()
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "snsqs"', $dsn->getSchemeProtocol()));
}
$this->parseOptions($dsn->getQuery());
diff --git a/pkg/snsqs/SnsQsConsumer.php b/pkg/snsqs/SnsQsConsumer.php
index 82209896e..45237d145 100644
--- a/pkg/snsqs/SnsQsConsumer.php
+++ b/pkg/snsqs/SnsQsConsumer.php
@@ -35,6 +35,34 @@ public function __construct(SnsQsContext $context, SqsConsumer $consumer, SnsQsQ
$this->queue = $queue;
}
+ public function getVisibilityTimeout(): ?int
+ {
+ return $this->consumer->getVisibilityTimeout();
+ }
+
+ /**
+ * The duration (in seconds) that the received messages are hidden from subsequent retrieve
+ * requests after being retrieved by a ReceiveMessage request.
+ */
+ public function setVisibilityTimeout(?int $visibilityTimeout = null): void
+ {
+ $this->consumer->setVisibilityTimeout($visibilityTimeout);
+ }
+
+ public function getMaxNumberOfMessages(): int
+ {
+ return $this->consumer->getMaxNumberOfMessages();
+ }
+
+ /**
+ * The maximum number of messages to return. Amazon SQS never returns more messages than this value
+ * (however, fewer messages might be returned). Valid values are 1 to 10. Default is 1.
+ */
+ public function setMaxNumberOfMessages(int $maxNumberOfMessages): void
+ {
+ $this->consumer->setMaxNumberOfMessages($maxNumberOfMessages);
+ }
+
public function getQueue(): Queue
{
return $this->queue;
@@ -107,6 +135,7 @@ private function convertMessage(SqsMessage $sqsMessage): SnsQsMessage
}
$message->setBody($sqsMessage->getBody());
+ $message->setHeaders($sqsMessage->getHeaders());
$message->setProperties($sqsMessage->getProperties());
return $message;
diff --git a/pkg/snsqs/SnsQsContext.php b/pkg/snsqs/SnsQsContext.php
index d520cdb10..d26a0fc6d 100644
--- a/pkg/snsqs/SnsQsContext.php
+++ b/pkg/snsqs/SnsQsContext.php
@@ -53,11 +53,7 @@ public function __construct($snsContext, $sqsContext)
} elseif (is_callable($snsContext)) {
$this->snsContextFactory = $snsContext;
} else {
- throw new \InvalidArgumentException(sprintf(
- 'The $snsContext argument must be either %s or callable that returns %s once called.',
- SnsContext::class,
- SnsContext::class
- ));
+ throw new \InvalidArgumentException(sprintf('The $snsContext argument must be either %s or callable that returns %s once called.', SnsContext::class, SnsContext::class));
}
if ($sqsContext instanceof SqsContext) {
@@ -65,11 +61,7 @@ public function __construct($snsContext, $sqsContext)
} elseif (is_callable($sqsContext)) {
$this->sqsContextFactory = $sqsContext;
} else {
- throw new \InvalidArgumentException(sprintf(
- 'The $sqsContext argument must be either %s or callable that returns %s once called.',
- SqsContext::class,
- SqsContext::class
- ));
+ throw new \InvalidArgumentException(sprintf('The $sqsContext argument must be either %s or callable that returns %s once called.', SqsContext::class, SqsContext::class));
}
}
@@ -137,6 +129,11 @@ public function declareTopic(SnsQsTopic $topic): void
$this->getSnsContext()->declareTopic($topic);
}
+ public function setTopicArn(SnsQsTopic $topic, string $arn): void
+ {
+ $this->getSnsContext()->setTopicArn($topic, $arn);
+ }
+
public function deleteTopic(SnsQsTopic $topic): void
{
$this->getSnsContext()->deleteTopic($topic);
@@ -176,16 +173,23 @@ public function close(): void
$this->getSqsContext()->close();
}
+ public function setSubscriptionAttributes(SnsQsTopic $topic, SnsQsQueue $queue, array $attributes): void
+ {
+ $this->getSnsContext()->setSubscriptionAttributes(new SnsSubscribe(
+ $topic,
+ $this->getSqsContext()->getQueueArn($queue),
+ SnsSubscribe::PROTOCOL_SQS,
+ false,
+ $attributes,
+ ));
+ }
+
private function getSnsContext(): SnsContext
{
if (null === $this->snsContext) {
$context = call_user_func($this->snsContextFactory);
if (false == $context instanceof SnsContext) {
- throw new \LogicException(sprintf(
- 'The factory must return instance of %s. It returned %s',
- SnsContext::class,
- is_object($context) ? get_class($context) : gettype($context)
- ));
+ throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', SnsContext::class, is_object($context) ? $context::class : gettype($context)));
}
$this->snsContext = $context;
@@ -199,11 +203,7 @@ private function getSqsContext(): SqsContext
if (null === $this->sqsContext) {
$context = call_user_func($this->sqsContextFactory);
if (false == $context instanceof SqsContext) {
- throw new \LogicException(sprintf(
- 'The factory must return instance of %s. It returned %s',
- SqsContext::class,
- is_object($context) ? get_class($context) : gettype($context)
- ));
+ throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', SqsContext::class, is_object($context) ? $context::class : gettype($context)));
}
$this->sqsContext = $context;
diff --git a/pkg/snsqs/SnsQsMessage.php b/pkg/snsqs/SnsQsMessage.php
index e34a103ff..900ad9125 100644
--- a/pkg/snsqs/SnsQsMessage.php
+++ b/pkg/snsqs/SnsQsMessage.php
@@ -17,12 +17,37 @@ class SnsQsMessage implements Message
*/
private $sqsMessage;
- public function __construct(string $body = '', array $properties = [], array $headers = [])
- {
+ /**
+ * @var array|null
+ */
+ private $messageAttributes;
+
+ /**
+ * @var string|null
+ */
+ private $messageGroupId;
+
+ /**
+ * @var string|null
+ */
+ private $messageDeduplicationId;
+
+ /**
+ * See AWS documentation for message attribute structure.
+ *
+ * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-sns-2010-03-31.html#shape-messageattributevalue
+ */
+ public function __construct(
+ string $body = '',
+ array $properties = [],
+ array $headers = [],
+ ?array $messageAttributes = null,
+ ) {
$this->body = $body;
$this->properties = $properties;
$this->headers = $headers;
$this->redelivered = false;
+ $this->messageAttributes = $messageAttributes;
}
public function setSqsMessage(SqsMessage $message): void
@@ -34,4 +59,50 @@ public function getSqsMessage(): SqsMessage
{
return $this->sqsMessage;
}
+
+ public function getMessageAttributes(): ?array
+ {
+ return $this->messageAttributes;
+ }
+
+ public function setMessageAttributes(?array $messageAttributes): void
+ {
+ $this->messageAttributes = $messageAttributes;
+ }
+
+ /**
+ * Only FIFO.
+ *
+ * The token used for deduplication of sent messages. If a message with a particular MessageDeduplicationId is sent successfully,
+ * any messages sent with the same MessageDeduplicationId are accepted successfully but aren't delivered during the 5-minute
+ * deduplication interval. For more information, see http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing.
+ */
+ public function setMessageDeduplicationId(?string $id = null): void
+ {
+ $this->messageDeduplicationId = $id;
+ }
+
+ public function getMessageDeduplicationId(): ?string
+ {
+ return $this->messageDeduplicationId;
+ }
+
+ /**
+ * Only FIFO.
+ *
+ * The tag that specifies that a message belongs to a specific message group. Messages that belong to the same message group
+ * are processed in a FIFO manner (however, messages in different message groups might be processed out of order).
+ * To interleave multiple ordered streams within a single queue, use MessageGroupId values (for example, session data
+ * for multiple users). In this scenario, multiple readers can process the queue, but the session data
+ * of each user is processed in a FIFO fashion.
+ */
+ public function setMessageGroupId(?string $id = null): void
+ {
+ $this->messageGroupId = $id;
+ }
+
+ public function getMessageGroupId(): ?string
+ {
+ return $this->messageGroupId;
+ }
}
diff --git a/pkg/snsqs/SnsQsProducer.php b/pkg/snsqs/SnsQsProducer.php
index bdce7f895..a80e1eb2b 100644
--- a/pkg/snsqs/SnsQsProducer.php
+++ b/pkg/snsqs/SnsQsProducer.php
@@ -51,11 +51,7 @@ public function send(Destination $destination, Message $message): void
InvalidMessageException::assertMessageInstanceOf($message, SnsQsMessage::class);
if (false == $destination instanceof SnsQsTopic && false == $destination instanceof SnsQsQueue) {
- throw new InvalidDestinationException(sprintf(
- 'The destination must be an instance of [%s|%s] but got %s.',
- SnsQsTopic::class, SnsQsQueue::class,
- is_object($destination) ? get_class($destination) : gettype($destination)
- ));
+ throw new InvalidDestinationException(sprintf('The destination must be an instance of [%s|%s] but got %s.', SnsQsTopic::class, SnsQsQueue::class, is_object($destination) ? $destination::class : gettype($destination)));
}
if ($destination instanceof SnsQsTopic) {
@@ -64,6 +60,9 @@ public function send(Destination $destination, Message $message): void
$message->getProperties(),
$message->getHeaders()
);
+ $snsMessage->setMessageAttributes($message->getMessageAttributes());
+ $snsMessage->setMessageGroupId($message->getMessageGroupId());
+ $snsMessage->setMessageDeduplicationId($message->getMessageDeduplicationId());
$this->getSnsProducer()->send($destination, $snsMessage);
} else {
@@ -73,18 +72,17 @@ public function send(Destination $destination, Message $message): void
$message->getHeaders()
);
+ $sqsMessage->setMessageGroupId($message->getMessageGroupId());
+ $sqsMessage->setMessageDeduplicationId($message->getMessageDeduplicationId());
+
$this->getSqsProducer()->send($destination, $sqsMessage);
}
}
/**
* Delivery delay is supported by SQSProducer.
- *
- * @param int|null $deliveryDelay
- *
- * @return Producer
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
$this->getSqsProducer()->setDeliveryDelay($deliveryDelay);
@@ -93,15 +91,13 @@ public function setDeliveryDelay(int $deliveryDelay = null): Producer
/**
* Delivery delay is supported by SQSProducer.
- *
- * @return int|null
*/
public function getDeliveryDelay(): ?int
{
return $this->getSqsProducer()->getDeliveryDelay();
}
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
$this->getSnsProducer()->setPriority($priority);
$this->getSqsProducer()->setPriority($priority);
@@ -114,7 +110,7 @@ public function getPriority(): ?int
return $this->getSnsProducer()->getPriority();
}
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->getSnsProducer()->setTimeToLive($timeToLive);
$this->getSqsProducer()->setTimeToLive($timeToLive);
diff --git a/pkg/snsqs/Tests/SnsQsConsumerTest.php b/pkg/snsqs/Tests/SnsQsConsumerTest.php
new file mode 100644
index 000000000..a16e133b3
--- /dev/null
+++ b/pkg/snsqs/Tests/SnsQsConsumerTest.php
@@ -0,0 +1,72 @@
+createMock(SnsQsContext::class);
+ $context->expects($this->once())
+ ->method('createMessage')
+ ->willReturn(new SnsQsMessage());
+
+ $sqsConsumer = $this->createMock(SqsConsumer::class);
+ $sqsConsumer->expects($this->once())
+ ->method('receive')
+ ->willReturn(new SqsMessage(json_encode([
+ 'Type' => 'Notification',
+ 'TopicArn' => 'arn:aws:sns:us-east-2:12345:topic-name',
+ 'Message' => 'The Body',
+ 'MessageAttributes' => [
+ 'Headers' => [
+ 'Type' => 'String',
+ 'Value' => '[{"headerKey":"headerVal"},{"propKey": "propVal"}]',
+ ],
+ ],
+ ])));
+
+ $consumer = new SnsQsConsumer($context, $sqsConsumer, new SnsQsQueue('queue'));
+ $result = $consumer->receive();
+
+ $this->assertInstanceOf(SnsQsMessage::class, $result);
+ $this->assertSame('The Body', $result->getBody());
+ $this->assertSame(['headerKey' => 'headerVal'], $result->getHeaders());
+ $this->assertSame(['propKey' => 'propVal'], $result->getProperties());
+ }
+
+ public function testReceivesSqsMessage(): void
+ {
+ $context = $this->createMock(SnsQsContext::class);
+ $context->expects($this->once())
+ ->method('createMessage')
+ ->willReturn(new SnsQsMessage());
+
+ $sqsConsumer = $this->createMock(SqsConsumer::class);
+ $sqsConsumer->expects($this->once())
+ ->method('receive')
+ ->willReturn(new SqsMessage(
+ 'The Body',
+ ['propKey' => 'propVal'],
+ ['headerKey' => 'headerVal'],
+ ));
+
+ $consumer = new SnsQsConsumer($context, $sqsConsumer, new SnsQsQueue('queue'));
+ $result = $consumer->receive();
+
+ $this->assertInstanceOf(SnsQsMessage::class, $result);
+ $this->assertSame('The Body', $result->getBody());
+ $this->assertSame(['headerKey' => 'headerVal'], $result->getHeaders());
+ $this->assertSame(['propKey' => 'propVal'], $result->getProperties());
+ }
+}
diff --git a/pkg/snsqs/Tests/SnsQsProducerTest.php b/pkg/snsqs/Tests/SnsQsProducerTest.php
index dd82e4895..59798dc11 100644
--- a/pkg/snsqs/Tests/SnsQsProducerTest.php
+++ b/pkg/snsqs/Tests/SnsQsProducerTest.php
@@ -3,12 +3,14 @@
namespace Enqueue\SnsQs\Tests;
use Enqueue\Sns\SnsContext;
+use Enqueue\Sns\SnsMessage;
use Enqueue\Sns\SnsProducer;
use Enqueue\SnsQs\SnsQsMessage;
use Enqueue\SnsQs\SnsQsProducer;
use Enqueue\SnsQs\SnsQsQueue;
use Enqueue\SnsQs\SnsQsTopic;
use Enqueue\Sqs\SqsContext;
+use Enqueue\Sqs\SqsMessage;
use Enqueue\Sqs\SqsProducer;
use Enqueue\Test\ClassExtensionTrait;
use Interop\Queue\Destination;
@@ -18,21 +20,18 @@
use Interop\Queue\Producer;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
+use Prophecy\PhpUnit\ProphecyTrait;
class SnsQsProducerTest extends TestCase
{
use ClassExtensionTrait;
+ use ProphecyTrait;
public function testShouldImplementProducerInterface()
{
$this->assertClassImplements(Producer::class, SnsQsProducer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new SnsQsProducer($this->createSnsContextMock(), $this->createSqsContextMock());
- }
-
public function testShouldThrowIfMessageIsInvalidType()
{
$this->expectException(InvalidMessageException::class);
@@ -89,6 +88,7 @@ public function testShouldGetDeliveryDelayFromSQSProducer()
public function testShouldSendSnsTopicMessageToSnsProducer()
{
$snsMock = $this->createSnsContextMock();
+ $snsMock->method('createMessage')->willReturn(new SnsMessage());
$destination = new SnsQsTopic('');
$snsProducerStub = $this->prophesize(SnsProducer::class);
@@ -100,20 +100,91 @@ public function testShouldSendSnsTopicMessageToSnsProducer()
$producer->send($destination, new SnsQsMessage());
}
+ public function testShouldSendSnsTopicMessageWithAttributesToSnsProducer()
+ {
+ $snsMock = $this->createSnsContextMock();
+ $snsMock->method('createMessage')->willReturn(new SnsMessage());
+ $destination = new SnsQsTopic('');
+
+ $snsProducerStub = $this->prophesize(SnsProducer::class);
+ $snsProducerStub->send(
+ $destination,
+ Argument::that(function (SnsMessage $snsMessage) {
+ return $snsMessage->getMessageAttributes() === ['foo' => 'bar'];
+ })
+ )->shouldBeCalledOnce();
+
+ $snsMock->method('createProducer')->willReturn($snsProducerStub->reveal());
+
+ $producer = new SnsQsProducer($snsMock, $this->createSqsContextMock());
+ $producer->send($destination, new SnsQsMessage('', [], [], ['foo' => 'bar']));
+ }
+
+ public function testShouldSendToSnsTopicMessageWithGroupIdAndDeduplicationId()
+ {
+ $snsMock = $this->createSnsContextMock();
+ $snsMock->method('createMessage')->willReturn(new SnsMessage());
+ $destination = new SnsQsTopic('');
+
+ $snsProducerStub = $this->prophesize(SnsProducer::class);
+ $snsProducerStub->send(
+ $destination,
+ Argument::that(function (SnsMessage $snsMessage) {
+ return 'group-id' === $snsMessage->getMessageGroupId()
+ && 'deduplication-id' === $snsMessage->getMessageDeduplicationId();
+ })
+ )->shouldBeCalledOnce();
+
+ $snsMock->method('createProducer')->willReturn($snsProducerStub->reveal());
+
+ $snsMessage = new SnsQsMessage();
+ $snsMessage->setMessageGroupId('group-id');
+ $snsMessage->setMessageDeduplicationId('deduplication-id');
+
+ $producer = new SnsQsProducer($snsMock, $this->createSqsContextMock());
+ $producer->send($destination, $snsMessage);
+ }
+
public function testShouldSendSqsMessageToSqsProducer()
{
$sqsMock = $this->createSqsContextMock();
+ $sqsMock->method('createMessage')->willReturn(new SqsMessage());
$destination = new SnsQsQueue('');
- $snsProducerStub = $this->prophesize(SqsProducer::class);
- $snsProducerStub->send($destination, Argument::any())->shouldBeCalledOnce();
+ $sqsProducerStub = $this->prophesize(SqsProducer::class);
+ $sqsProducerStub->send($destination, Argument::any())->shouldBeCalledOnce();
- $sqsMock->method('createProducer')->willReturn($snsProducerStub->reveal());
+ $sqsMock->method('createProducer')->willReturn($sqsProducerStub->reveal());
$producer = new SnsQsProducer($this->createSnsContextMock(), $sqsMock);
$producer->send($destination, new SnsQsMessage());
}
+ public function testShouldSendToSqsProducerMessageWithGroupIdAndDeduplicationId()
+ {
+ $sqsMock = $this->createSqsContextMock();
+ $sqsMock->method('createMessage')->willReturn(new SqsMessage());
+ $destination = new SnsQsQueue('');
+
+ $sqsProducerStub = $this->prophesize(SqsProducer::class);
+ $sqsProducerStub->send(
+ $destination,
+ Argument::that(function (SqsMessage $sqsMessage) {
+ return 'group-id' === $sqsMessage->getMessageGroupId()
+ && 'deduplication-id' === $sqsMessage->getMessageDeduplicationId();
+ })
+ )->shouldBeCalledOnce();
+
+ $sqsMock->method('createProducer')->willReturn($sqsProducerStub->reveal());
+
+ $sqsMessage = new SnsQsMessage();
+ $sqsMessage->setMessageGroupId('group-id');
+ $sqsMessage->setMessageDeduplicationId('deduplication-id');
+
+ $producer = new SnsQsProducer($this->createSnsContextMock(), $sqsMock);
+ $producer->send($destination, $sqsMessage);
+ }
+
/**
* @return \PHPUnit\Framework\MockObject\MockObject|SnsContext
*/
diff --git a/pkg/snsqs/Tests/Spec/SnsQsContextTest.php b/pkg/snsqs/Tests/Spec/SnsQsContextTest.php
index 8554fcde6..c4fc61960 100644
--- a/pkg/snsqs/Tests/Spec/SnsQsContextTest.php
+++ b/pkg/snsqs/Tests/Spec/SnsQsContextTest.php
@@ -3,13 +3,47 @@
namespace Enqueue\SnsQs\Tests\Spec;
use Enqueue\Sns\SnsContext;
+use Enqueue\Sns\SnsSubscribe;
use Enqueue\SnsQs\SnsQsContext;
+use Enqueue\SnsQs\SnsQsQueue;
+use Enqueue\SnsQs\SnsQsTopic;
use Enqueue\Sqs\SqsConsumer;
use Enqueue\Sqs\SqsContext;
use Interop\Queue\Spec\ContextSpec;
class SnsQsContextTest extends ContextSpec
{
+ public function testSetsSubscriptionAttributes(): void
+ {
+ $topic = new SnsQsTopic('topic1');
+
+ $snsContext = $this->createMock(SnsContext::class);
+ $snsContext->expects($this->once())
+ ->method('setSubscriptionAttributes')
+ ->with($this->equalTo(new SnsSubscribe(
+ $topic,
+ 'queueArn1',
+ 'sqs',
+ false,
+ ['attr1' => 'value1'],
+ )));
+
+ $sqsContext = $this->createMock(SqsContext::class);
+ $sqsContext->expects($this->any())
+ ->method('createConsumer')
+ ->willReturn($this->createMock(SqsConsumer::class));
+ $sqsContext->expects($this->any())
+ ->method('getQueueArn')
+ ->willReturn('queueArn1');
+
+ $context = new SnsQsContext($snsContext, $sqsContext);
+ $context->setSubscriptionAttributes(
+ $topic,
+ new SnsQsQueue('queue1'),
+ ['attr1' => 'value1'],
+ );
+ }
+
protected function createContext()
{
$sqsContext = $this->createMock(SqsContext::class);
diff --git a/pkg/snsqs/Tests/Spec/SnsQsFactoryTrait.php b/pkg/snsqs/Tests/Spec/SnsQsFactoryTrait.php
index efc4a7046..e314c2667 100644
--- a/pkg/snsqs/Tests/Spec/SnsQsFactoryTrait.php
+++ b/pkg/snsqs/Tests/Spec/SnsQsFactoryTrait.php
@@ -33,7 +33,7 @@ protected function createSnsQsContext(): SnsQsContext
protected function createSnsQsQueue(string $queueName): SnsQsQueue
{
- $queueName = $queueName.time();
+ $queueName .= time();
$this->snsQsQueue = $this->snsQsContext->createQueue($queueName);
$this->snsQsContext->declareQueue($this->snsQsQueue);
@@ -47,7 +47,7 @@ protected function createSnsQsQueue(string $queueName): SnsQsQueue
protected function createSnsQsTopic(string $topicName): SnsQsTopic
{
- $topicName = $topicName.time();
+ $topicName .= time();
$this->snsQsTopic = $this->snsQsContext->createTopic($topicName);
$this->snsQsContext->declareTopic($this->snsQsTopic);
diff --git a/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php b/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php
index ed199180d..707cab529 100644
--- a/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php
+++ b/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php
@@ -8,6 +8,7 @@
/**
* @group functional
+ *
* @retry 5
*/
class SnsQsSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
diff --git a/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php b/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php
index 53ae719b2..652766de4 100644
--- a/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php
@@ -8,6 +8,7 @@
/**
* @group functional
+ *
* @retry 5
*/
class SnsQsSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
diff --git a/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php b/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php
index 24206c9d8..4a5869d63 100644
--- a/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php
+++ b/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php
@@ -8,6 +8,7 @@
/**
* @group functional
+ *
* @retry 5
*/
class SnsQsSendToTopicAndReceiveFromQueueSpec extends SendToTopicAndReceiveFromQueueSpec
diff --git a/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveNoWaitFromQueueTest.php
index e370c1f32..433fcf3a7 100644
--- a/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveNoWaitFromQueueTest.php
@@ -8,6 +8,7 @@
/**
* @group functional
+ *
* @retry 5
*/
class SnsQsSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec
diff --git a/pkg/snsqs/composer.json b/pkg/snsqs/composer.json
index 19398df34..e0596b25b 100644
--- a/pkg/snsqs/composer.json
+++ b/pkg/snsqs/composer.json
@@ -6,16 +6,16 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8",
"enqueue/dsn": "^0.10",
"enqueue/sns": "^0.10",
"enqueue/sqs": "^0.10"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/snsqs/examples/consumer.php b/pkg/snsqs/examples/consumer.php
index a5303b9ea..37f193925 100644
--- a/pkg/snsqs/examples/consumer.php
+++ b/pkg/snsqs/examples/consumer.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\SnsQs\SnsQsConnectionFactory;
@@ -34,7 +34,7 @@
while (true) {
if ($m = $consumer->receive(20000)) {
$consumer->acknowledge($m);
- echo 'Received message: '.$m->getBody().' '.json_encode($m->getHeaders()).' '.json_encode($m->getProperties()).PHP_EOL;
+ echo 'Received message: '.$m->getBody().' '.json_encode($m->getHeaders()).' '.json_encode($m->getProperties()).\PHP_EOL;
}
}
echo 'Done'."\n";
diff --git a/pkg/snsqs/examples/produce.php b/pkg/snsqs/examples/produce.php
index 0396d9cd0..53018d769 100644
--- a/pkg/snsqs/examples/produce.php
+++ b/pkg/snsqs/examples/produce.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\SnsQs\SnsQsConnectionFactory;
@@ -33,7 +33,7 @@
while (true) {
$context->createProducer()->send($topic, $message);
- echo 'Sent message: '.$message->getBody().PHP_EOL;
+ echo 'Sent message: '.$message->getBody().\PHP_EOL;
sleep(1);
}
diff --git a/pkg/sqs/.github/workflows/ci.yml b/pkg/sqs/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/sqs/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/sqs/.travis.yml b/pkg/sqs/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/sqs/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/sqs/README.md b/pkg/sqs/README.md
index bcc1e83ac..7f4170bf2 100644
--- a/pkg/sqs/README.md
+++ b/pkg/sqs/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Amazon SQS Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/sqs)
+[](https://github.com/php-enqueue/sqs/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/sqs)
[](https://packagist.org/packages/enqueue/sqs)
diff --git a/pkg/sqs/SqsClient.php b/pkg/sqs/SqsClient.php
index 0d61584bf..bba2a5760 100644
--- a/pkg/sqs/SqsClient.php
+++ b/pkg/sqs/SqsClient.php
@@ -148,11 +148,6 @@ private function resolveClient(): void
}
}
- throw new \LogicException(sprintf(
- 'The input client must be an instance of "%s" or "%s" or a callable that returns one of those. Got "%s"',
- AwsSqsClient::class,
- MultiRegionClient::class,
- is_object($client) ? get_class($client) : gettype($client)
- ));
+ throw new \LogicException(sprintf('The input client must be an instance of "%s" or "%s" or a callable that returns one of those. Got "%s"', AwsSqsClient::class, MultiRegionClient::class, is_object($client) ? $client::class : gettype($client)));
}
}
diff --git a/pkg/sqs/SqsConnectionFactory.php b/pkg/sqs/SqsConnectionFactory.php
index a39cf806a..71e73b705 100644
--- a/pkg/sqs/SqsConnectionFactory.php
+++ b/pkg/sqs/SqsConnectionFactory.php
@@ -108,6 +108,10 @@ private function establishConnection(): SqsClient
}
}
+ if (isset($this->config['http'])) {
+ $config['http'] = $this->config['http'];
+ }
+
$establishConnection = function () use ($config) {
return (new Sdk(['Sqs' => $config]))->createMultiRegionSqs();
};
@@ -139,6 +143,7 @@ private function parseDsn(string $dsn): array
'endpoint' => $dsn->getString('endpoint'),
'profile' => $dsn->getString('profile'),
'queue_owner_aws_account_id' => $dsn->getString('queue_owner_aws_account_id'),
+ 'http' => $dsn->getArray('http', [])->toArray(),
]), function ($value) { return null !== $value; });
}
@@ -155,6 +160,7 @@ private function defaultConfig(): array
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
];
}
}
diff --git a/pkg/sqs/SqsConsumer.php b/pkg/sqs/SqsConsumer.php
index 04d5bbd81..860bc648b 100644
--- a/pkg/sqs/SqsConsumer.php
+++ b/pkg/sqs/SqsConsumer.php
@@ -53,7 +53,7 @@ public function getVisibilityTimeout(): ?int
* The duration (in seconds) that the received messages are hidden from subsequent retrieve
* requests after being retrieved by a ReceiveMessage request.
*/
- public function setVisibilityTimeout(int $visibilityTimeout = null): void
+ public function setVisibilityTimeout(?int $visibilityTimeout = null): void
{
$this->visibilityTimeout = $visibilityTimeout;
}
diff --git a/pkg/sqs/SqsContext.php b/pkg/sqs/SqsContext.php
index 60906f72f..65f12ae89 100644
--- a/pkg/sqs/SqsContext.php
+++ b/pkg/sqs/SqsContext.php
@@ -134,7 +134,7 @@ public function getSqsClient(): SqsClient
*/
public function getClient(): AwsSqsClient
{
- @trigger_error('The method is deprecated since 0.9.2. SqsContext::getAwsSqsClient() method should be used.', E_USER_DEPRECATED);
+ @trigger_error('The method is deprecated since 0.9.2. SqsContext::getAwsSqsClient() method should be used.', \E_USER_DEPRECATED);
return $this->getAwsSqsClient();
}
diff --git a/pkg/sqs/SqsDestination.php b/pkg/sqs/SqsDestination.php
index 5649d30a3..d77966f15 100644
--- a/pkg/sqs/SqsDestination.php
+++ b/pkg/sqs/SqsDestination.php
@@ -62,7 +62,7 @@ public function getAttributes(): array
* The number of seconds for which the delivery of all messages in the queue is delayed.
* Valid values: An integer from 0 to 900 seconds (15 minutes). The default is 0 (zero).
*/
- public function setDelaySeconds(int $seconds = null): void
+ public function setDelaySeconds(?int $seconds = null): void
{
if (null == $seconds) {
unset($this->attributes['DelaySeconds']);
@@ -76,7 +76,7 @@ public function setDelaySeconds(int $seconds = null): void
* Valid values: An integer from 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB).
* The default is 262,144 (256 KiB).
*/
- public function setMaximumMessageSize(int $bytes = null): void
+ public function setMaximumMessageSize(?int $bytes = null): void
{
if (null == $bytes) {
unset($this->attributes['MaximumMessageSize']);
@@ -90,7 +90,7 @@ public function setMaximumMessageSize(int $bytes = null): void
* Valid values: An integer from 60 seconds (1 minute) to 1,209,600 seconds (14 days).
* The default is 345,600 (4 days).
*/
- public function setMessageRetentionPeriod(int $seconds = null): void
+ public function setMessageRetentionPeriod(?int $seconds = null): void
{
if (null == $seconds) {
unset($this->attributes['MessageRetentionPeriod']);
@@ -103,7 +103,7 @@ public function setMessageRetentionPeriod(int $seconds = null): void
* The queue's policy. A valid AWS policy. For more information about policy structure,
* see http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html.
*/
- public function setPolicy(string $policy = null): void
+ public function setPolicy(?string $policy = null): void
{
if (null == $policy) {
unset($this->attributes['Policy']);
@@ -116,7 +116,7 @@ public function setPolicy(string $policy = null): void
* The number of seconds for which a ReceiveMessage action waits for a message to arrive.
* Valid values: An integer from 0 to 20 (seconds). The default is 0 (zero).
*/
- public function setReceiveMessageWaitTimeSeconds(int $seconds = null): void
+ public function setReceiveMessageWaitTimeSeconds(?int $seconds = null): void
{
if (null == $seconds) {
unset($this->attributes['ReceiveMessageWaitTimeSeconds']);
@@ -145,7 +145,7 @@ public function setRedrivePolicy(int $maxReceiveCount, string $deadLetterTargetA
* The default is 30. For more information about the visibility timeout,
* see http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html.
*/
- public function setVisibilityTimeout(int $seconds = null): void
+ public function setVisibilityTimeout(?int $seconds = null): void
{
if (null == $seconds) {
unset($this->attributes['VisibilityTimeout']);
@@ -208,7 +208,7 @@ public function setQueueOwnerAWSAccountId(?string $queueOwnerAWSAccountId): void
$this->queueOwnerAWSAccountId = $queueOwnerAWSAccountId;
}
- public function setRegion(string $region = null): void
+ public function setRegion(?string $region = null): void
{
$this->region = $region;
}
diff --git a/pkg/sqs/SqsMessage.php b/pkg/sqs/SqsMessage.php
index cd2b1bdfe..772c3e217 100644
--- a/pkg/sqs/SqsMessage.php
+++ b/pkg/sqs/SqsMessage.php
@@ -144,7 +144,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
@@ -154,7 +154,7 @@ public function getReplyTo(): ?string
return $this->getHeader('reply_to');
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', $correlationId);
}
@@ -164,7 +164,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', $messageId);
}
@@ -181,7 +181,7 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
@@ -211,7 +211,7 @@ public function getDelaySeconds(): int
* any messages sent with the same MessageDeduplicationId are accepted successfully but aren't delivered during the 5-minute
* deduplication interval. For more information, see http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing.
*/
- public function setMessageDeduplicationId(string $id = null): void
+ public function setMessageDeduplicationId(?string $id = null): void
{
$this->messageDeduplicationId = $id;
}
@@ -230,7 +230,7 @@ public function getMessageDeduplicationId(): ?string
* for multiple users). In this scenario, multiple readers can process the queue, but the session data
* of each user is processed in a FIFO fashion.
*/
- public function setMessageGroupId(string $id = null): void
+ public function setMessageGroupId(?string $id = null): void
{
$this->messageGroupId = $id;
}
@@ -247,7 +247,7 @@ public function getMessageGroupId(): ?string
* If you receive a message more than once, each time you receive it, you get a different receipt handle.
* You must provide the most recently received receipt handle when you request to delete the message (otherwise, the message might not be deleted).
*/
- public function setReceiptHandle(string $receipt = null): void
+ public function setReceiptHandle(?string $receipt = null): void
{
$this->receiptHandle = $receipt;
}
diff --git a/pkg/sqs/SqsProducer.php b/pkg/sqs/SqsProducer.php
index b33d57fb8..2e43d8370 100644
--- a/pkg/sqs/SqsProducer.php
+++ b/pkg/sqs/SqsProducer.php
@@ -56,7 +56,7 @@ public function send(Destination $destination, Message $message): void
];
if (null !== $this->deliveryDelay) {
- $arguments['DelaySeconds'] = (int) $this->deliveryDelay / 1000;
+ $arguments['DelaySeconds'] = (int) ceil($this->deliveryDelay / 1000);
}
if ($message->getDelaySeconds()) {
@@ -81,7 +81,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return SqsProducer
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
$this->deliveryDelay = $deliveryDelay;
@@ -96,7 +96,7 @@ public function getDeliveryDelay(): ?int
/**
* @return SqsProducer
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
@@ -113,7 +113,7 @@ public function getPriority(): ?int
/**
* @return SqsProducer
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
if (null === $timeToLive) {
return $this;
diff --git a/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php b/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php
index ef8263fa6..7d06df229 100644
--- a/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php
+++ b/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php
@@ -27,7 +27,7 @@ class SqsCommonUseCasesTest extends TestCase
*/
private $queueName;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php
index b9c1a2987..9c57dcbdc 100644
--- a/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php
+++ b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php
@@ -18,15 +18,15 @@
class SqsConsumptionUseCasesTest extends TestCase
{
- use SqsExtension;
use RetryTrait;
+ use SqsExtension;
/**
* @var SqsContext
*/
private $context;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/pkg/sqs/Tests/Spec/CreateSqsQueueTrait.php b/pkg/sqs/Tests/Spec/CreateSqsQueueTrait.php
index 79af8208e..3af2a5129 100644
--- a/pkg/sqs/Tests/Spec/CreateSqsQueueTrait.php
+++ b/pkg/sqs/Tests/Spec/CreateSqsQueueTrait.php
@@ -11,7 +11,7 @@ trait CreateSqsQueueTrait
protected function createSqsQueue(SqsContext $context, string $queueName): SqsDestination
{
- $queueName = $queueName.time();
+ $queueName .= time();
$this->queue = $context->createQueue($queueName);
$context->declareQueue($this->queue);
diff --git a/pkg/sqs/Tests/Spec/SqsMessageTest.php b/pkg/sqs/Tests/Spec/SqsMessageTest.php
index 9007df099..994fe5be5 100644
--- a/pkg/sqs/Tests/Spec/SqsMessageTest.php
+++ b/pkg/sqs/Tests/Spec/SqsMessageTest.php
@@ -7,9 +7,6 @@
class SqsMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new SqsMessage();
diff --git a/pkg/sqs/Tests/Spec/SqsProducerTest.php b/pkg/sqs/Tests/Spec/SqsProducerTest.php
index c241a2165..f0e5c8b06 100644
--- a/pkg/sqs/Tests/Spec/SqsProducerTest.php
+++ b/pkg/sqs/Tests/Spec/SqsProducerTest.php
@@ -12,9 +12,6 @@ class SqsProducerTest extends ProducerSpec
{
use SqsExtension;
- /**
- * {@inheritdoc}
- */
protected function createProducer()
{
return $this->buildSqsContext()->createProducer();
diff --git a/pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php
index 357ed93eb..40f20d68f 100644
--- a/pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php
+++ b/pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php
@@ -11,13 +11,14 @@
/**
* @group functional
+ *
* @retry 5
*/
class SqsSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDelayedMessageFromQueueSpec
{
+ use CreateSqsQueueTrait;
use RetryTrait;
use SqsExtension;
- use CreateSqsQueueTrait;
/**
* @var SqsContext
diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php
index 802d887ac..db698017d 100644
--- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php
+++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php
@@ -11,13 +11,14 @@
/**
* @group functional
+ *
* @retry 5
*/
class SqsSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
{
+ use CreateSqsQueueTrait;
use RetryTrait;
use SqsExtension;
- use CreateSqsQueueTrait;
/**
* @var SqsContext
diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php
index ac57818aa..5cd14468a 100644
--- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php
+++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php
@@ -11,13 +11,14 @@
/**
* @group functional
+ *
* @retry 5
*/
class SqsSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
{
- use SqsExtension;
- use RetryTrait;
use CreateSqsQueueTrait;
+ use RetryTrait;
+ use SqsExtension;
/**
* @var SqsContext
diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromQueueTest.php
index 3f03006d9..7e31a25a4 100644
--- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromQueueTest.php
@@ -11,13 +11,14 @@
/**
* @group functional
+ *
* @retry 5
*/
class SqsSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec
{
+ use CreateSqsQueueTrait;
use RetryTrait;
use SqsExtension;
- use CreateSqsQueueTrait;
/**
* @var SqsContext
diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromTopicTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromTopicTest.php
index 12a3c0c6e..34f2e75dd 100644
--- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromTopicTest.php
+++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromTopicTest.php
@@ -11,13 +11,14 @@
/**
* @group functional
+ *
* @retry 5
*/
class SqsSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec
{
+ use CreateSqsQueueTrait;
use RetryTrait;
use SqsExtension;
- use CreateSqsQueueTrait;
/**
* @var SqsContext
diff --git a/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveFromQueueTest.php
index 519db1be5..b8e60aee9 100644
--- a/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveFromQueueTest.php
+++ b/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveFromQueueTest.php
@@ -11,13 +11,14 @@
/**
* @group functional
+ *
* @retry 5
*/
class SqsSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec
{
+ use CreateSqsQueueTrait;
use RetryTrait;
use SqsExtension;
- use CreateSqsQueueTrait;
/**
* @var SqsContext
diff --git a/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveNoWaitFromQueueTest.php
index 317d7297c..e5520e01f 100644
--- a/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveNoWaitFromQueueTest.php
+++ b/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveNoWaitFromQueueTest.php
@@ -11,13 +11,14 @@
/**
* @group functional
+ *
* @retry 5
*/
class SqsSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec
{
+ use CreateSqsQueueTrait;
use RetryTrait;
use SqsExtension;
- use CreateSqsQueueTrait;
/**
* @var SqsContext
diff --git a/pkg/sqs/Tests/SqsClientTest.php b/pkg/sqs/Tests/SqsClientTest.php
index 08c44a307..ff6a966d4 100644
--- a/pkg/sqs/Tests/SqsClientTest.php
+++ b/pkg/sqs/Tests/SqsClientTest.php
@@ -16,8 +16,7 @@ public function testShouldAllowGetAwsClientIfSingleClientProvided()
$awsClient = (new Sdk(['Sqs' => [
'key' => '',
'secret' => '',
- 'token' => '',
- 'region' => '',
+ 'region' => 'us-west-2',
'version' => '2012-11-05',
'endpoint' => 'http://localhost',
]]))->createSqs();
@@ -32,8 +31,7 @@ public function testShouldAllowGetAwsClientIfMultipleClientProvided()
$awsClient = (new Sdk(['Sqs' => [
'key' => '',
'secret' => '',
- 'token' => '',
- 'region' => '',
+ 'region' => 'us-west-2',
'version' => '2012-11-05',
'endpoint' => 'http://localhost',
]]))->createMultiRegionSqs();
diff --git a/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php b/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php
index 8225a4d34..c7a954b0f 100644
--- a/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php
+++ b/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php
@@ -4,6 +4,7 @@
use Enqueue\Sqs\SqsConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@
class SqsConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
@@ -39,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
@@ -65,6 +64,7 @@ public static function provideConfigs()
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
],
];
@@ -81,6 +81,7 @@ public static function provideConfigs()
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
],
];
@@ -97,6 +98,7 @@ public static function provideConfigs()
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
],
];
@@ -113,6 +115,7 @@ public static function provideConfigs()
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
],
];
@@ -129,6 +132,7 @@ public static function provideConfigs()
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
],
];
@@ -145,6 +149,7 @@ public static function provideConfigs()
'endpoint' => null,
'profile' => 'staging',
'queue_owner_aws_account_id' => null,
+ 'http' => [],
],
];
@@ -161,6 +166,7 @@ public static function provideConfigs()
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
],
];
@@ -183,6 +189,7 @@ public static function provideConfigs()
'endpoint' => 'http://localstack:1111',
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
],
];
@@ -201,6 +208,27 @@ public static function provideConfigs()
'endpoint' => null,
'profile' => 'staging',
'queue_owner_aws_account_id' => null,
+ 'http' => [],
+ ],
+ ];
+
+ yield [
+ ['dsn' => 'sqs:?http[timeout]=5&http[connect_timeout]=2'],
+ [
+ 'key' => null,
+ 'secret' => null,
+ 'token' => null,
+ 'region' => null,
+ 'retries' => 3,
+ 'version' => '2012-11-05',
+ 'lazy' => true,
+ 'endpoint' => null,
+ 'profile' => null,
+ 'queue_owner_aws_account_id' => null,
+ 'http' => [
+ 'timeout' => '5',
+ 'connect_timeout' => '2',
+ ],
],
];
}
diff --git a/pkg/sqs/Tests/SqsConnectionFactoryTest.php b/pkg/sqs/Tests/SqsConnectionFactoryTest.php
index 189cfe7f8..c327522c5 100644
--- a/pkg/sqs/Tests/SqsConnectionFactoryTest.php
+++ b/pkg/sqs/Tests/SqsConnectionFactoryTest.php
@@ -7,12 +7,14 @@
use Enqueue\Sqs\SqsConnectionFactory;
use Enqueue\Sqs\SqsContext;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
class SqsConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
@@ -34,6 +36,7 @@ public function testCouldBeConstructedWithEmptyConfiguration()
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
], 'config', $factory);
}
@@ -52,6 +55,7 @@ public function testCouldBeConstructedWithCustomConfiguration()
'endpoint' => null,
'profile' => null,
'queue_owner_aws_account_id' => null,
+ 'http' => [],
], 'config', $factory);
}
diff --git a/pkg/sqs/Tests/SqsConsumerTest.php b/pkg/sqs/Tests/SqsConsumerTest.php
index 05fbb9b69..ef06c6157 100644
--- a/pkg/sqs/Tests/SqsConsumerTest.php
+++ b/pkg/sqs/Tests/SqsConsumerTest.php
@@ -24,11 +24,6 @@ public function testShouldImplementConsumerInterface()
$this->assertClassImplements(Consumer::class, SqsConsumer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new SqsConsumer($this->createContextMock(), new SqsDestination('queue'));
- }
-
public function testShouldReturnInstanceOfDestination()
{
$destination = new SqsDestination('queue');
diff --git a/pkg/sqs/Tests/SqsContextTest.php b/pkg/sqs/Tests/SqsContextTest.php
index 75970bbad..5081add41 100644
--- a/pkg/sqs/Tests/SqsContextTest.php
+++ b/pkg/sqs/Tests/SqsContextTest.php
@@ -25,11 +25,6 @@ public function testShouldImplementContextInterface()
$this->assertClassImplements(Context::class, SqsContext::class);
}
- public function testCouldBeConstructedWithSqsClientAsFirstArgument()
- {
- new SqsContext($this->createSqsClientMock(), []);
- }
-
public function testShouldAllowCreateEmptyMessage()
{
$context = new SqsContext($this->createSqsClientMock(), []);
diff --git a/pkg/sqs/Tests/SqsProducerTest.php b/pkg/sqs/Tests/SqsProducerTest.php
index 1bda62c48..35cb9850b 100644
--- a/pkg/sqs/Tests/SqsProducerTest.php
+++ b/pkg/sqs/Tests/SqsProducerTest.php
@@ -24,11 +24,6 @@ public function testShouldImplementProducerInterface()
$this->assertClassImplements(Producer::class, SqsProducer::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new SqsProducer($this->createSqsContextMock());
- }
-
public function testShouldThrowIfBodyOfInvalidType()
{
$this->expectException(InvalidMessageException::class);
diff --git a/pkg/sqs/composer.json b/pkg/sqs/composer.json
index cb21e9905..2ddc1b267 100644
--- a/pkg/sqs/composer.json
+++ b/pkg/sqs/composer.json
@@ -6,15 +6,15 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"queue-interop/queue-interop": "^0.8",
"enqueue/dsn": "^0.10",
- "aws/aws-sdk-php": "~3.26"
+ "aws/aws-sdk-php": "^3.290"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/sqs/examples/consume.php b/pkg/sqs/examples/consume.php
index 9c5eaa12f..d82274d80 100644
--- a/pkg/sqs/examples/consume.php
+++ b/pkg/sqs/examples/consume.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\Sqs\SqsConnectionFactory;
@@ -26,7 +26,7 @@
while (true) {
if ($m = $consumer->receive(20000)) {
$consumer->acknowledge($m);
- echo 'Received message: '.$m->getBody().PHP_EOL;
+ echo 'Received message: '.$m->getBody().\PHP_EOL;
}
}
diff --git a/pkg/sqs/examples/produce.php b/pkg/sqs/examples/produce.php
index ba35c84c1..a9ba3e3b7 100644
--- a/pkg/sqs/examples/produce.php
+++ b/pkg/sqs/examples/produce.php
@@ -12,7 +12,7 @@
if ($autoload) {
require_once $autoload;
} else {
- throw new \LogicException('Composer autoload was not found');
+ throw new LogicException('Composer autoload was not found');
}
use Enqueue\Sqs\SqsConnectionFactory;
@@ -27,7 +27,7 @@
while (true) {
$context->createProducer()->send($queue, $message);
- echo 'Sent message: '.$message->getBody().PHP_EOL;
+ echo 'Sent message: '.$message->getBody().\PHP_EOL;
sleep(1);
}
diff --git a/pkg/stomp/.github/workflows/ci.yml b/pkg/stomp/.github/workflows/ci.yml
new file mode 100644
index 000000000..0492424e8
--- /dev/null
+++ b/pkg/stomp/.github/workflows/ci.yml
@@ -0,0 +1,29 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+ with:
+ composer-options: "--prefer-source"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/stomp/.travis.yml b/pkg/stomp/.travis.yml
deleted file mode 100644
index ae8b10d3d..000000000
--- a/pkg/stomp/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/stomp/BufferedStompClient.php b/pkg/stomp/BufferedStompClient.php
index 5feb88fae..e2c54d731 100644
--- a/pkg/stomp/BufferedStompClient.php
+++ b/pkg/stomp/BufferedStompClient.php
@@ -103,9 +103,6 @@ public function readMessageFrame(string $subscriptionId, int $timeout): ?Frame
}
}
- /**
- * {@inheritdoc}
- */
public function disconnect($sync = false)
{
parent::disconnect($sync);
diff --git a/pkg/stomp/ExtensionType.php b/pkg/stomp/ExtensionType.php
index 37c248feb..c1c265f68 100644
--- a/pkg/stomp/ExtensionType.php
+++ b/pkg/stomp/ExtensionType.php
@@ -6,7 +6,7 @@
class ExtensionType
{
- const ACTIVEMQ = 'activemq';
- const RABBITMQ = 'rabbitmq';
- const ARTEMIS = 'artemis';
+ public const ACTIVEMQ = 'activemq';
+ public const RABBITMQ = 'rabbitmq';
+ public const ARTEMIS = 'artemis';
}
diff --git a/pkg/stomp/README.md b/pkg/stomp/README.md
index 5fbe0d19d..e8a98e433 100644
--- a/pkg/stomp/README.md
+++ b/pkg/stomp/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# STOMP Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/stomp)
+[](https://github.com/php-enqueue/stomp/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/stomp)
[](https://packagist.org/packages/enqueue/stomp)
diff --git a/pkg/stomp/StompConnectionFactory.php b/pkg/stomp/StompConnectionFactory.php
index 9110911bc..da9c6f9bd 100644
--- a/pkg/stomp/StompConnectionFactory.php
+++ b/pkg/stomp/StompConnectionFactory.php
@@ -13,7 +13,7 @@
class StompConnectionFactory implements ConnectionFactory
{
- const SUPPORTED_SCHEMES = [
+ public const SUPPORTED_SCHEMES = [
ExtensionType::ACTIVEMQ,
ExtensionType::RABBITMQ,
ExtensionType::ARTEMIS,
@@ -120,7 +120,7 @@ private function parseDsn(string $dsn): array
$dsn = Dsn::parseFirst($dsn);
if ('stomp' !== $dsn->getSchemeProtocol()) {
- throw new \LogicException(sprintf('The given DSN is not supported. Must start with "stomp:".'));
+ throw new \LogicException('The given DSN is not supported. Must start with "stomp:".');
}
$schemeExtension = current($dsn->getSchemeExtensions());
diff --git a/pkg/stomp/StompConsumer.php b/pkg/stomp/StompConsumer.php
index 681f45624..5a80be890 100644
--- a/pkg/stomp/StompConsumer.php
+++ b/pkg/stomp/StompConsumer.php
@@ -15,9 +15,9 @@
class StompConsumer implements Consumer
{
- const ACK_AUTO = 'auto';
- const ACK_CLIENT = 'client';
- const ACK_CLIENT_INDIVIDUAL = 'client-individual';
+ public const ACK_AUTO = 'auto';
+ public const ACK_CLIENT = 'client';
+ public const ACK_CLIENT_INDIVIDUAL = 'client-individual';
/**
* @var StompDestination
@@ -111,7 +111,7 @@ public function receive(int $timeout = 0): ?Message
}
}
} catch (ErrorFrameException $e) {
- throw new Exception($e->getMessage()."\n".$e->getFrame()->getBody(), null, $e);
+ throw new Exception($e->getMessage()."\n".$e->getFrame()->getBody(), 0, $e);
}
return null;
diff --git a/pkg/stomp/StompContext.php b/pkg/stomp/StompContext.php
index c71277e65..1e77f88ee 100644
--- a/pkg/stomp/StompContext.php
+++ b/pkg/stomp/StompContext.php
@@ -74,7 +74,7 @@ public function createMessage(string $body = '', array $properties = [], array $
*/
public function createQueue(string $name): Queue
{
- if (0 !== strpos($name, '/')) {
+ if (!str_starts_with($name, '/')) {
$destination = new StompDestination($this->extensionType);
$destination->setType(StompDestination::TYPE_QUEUE);
$destination->setStompName($name);
@@ -101,7 +101,7 @@ public function createTemporaryQueue(): Queue
*/
public function createTopic(string $name): Topic
{
- if (0 !== strpos($name, '/')) {
+ if (!str_starts_with($name, '/')) {
$destination = new StompDestination($this->extensionType);
$destination->setType($this->useExchangePrefix ? StompDestination::TYPE_EXCHANGE : StompDestination::TYPE_TOPIC);
$destination->setStompName($name);
@@ -130,7 +130,7 @@ public function createDestination(string $destination): StompDestination
foreach ($types as $_type) {
$typePrefix = '/'.$_type.'/';
- if (0 === strpos($dest, $typePrefix)) {
+ if (str_starts_with($dest, $typePrefix)) {
$type = $_type;
$dest = substr($dest, strlen($typePrefix));
@@ -225,7 +225,7 @@ private function createStomp(): BufferedStompClient
$stomp = call_user_func($this->stompFactory);
if (false == $stomp instanceof BufferedStompClient) {
- throw new \LogicException(sprintf('The factory must return instance of BufferedStompClient. It returns %s', is_object($stomp) ? get_class($stomp) : gettype($stomp)));
+ throw new \LogicException(sprintf('The factory must return instance of BufferedStompClient. It returns %s', is_object($stomp) ? $stomp::class : gettype($stomp)));
}
return $stomp;
diff --git a/pkg/stomp/StompDestination.php b/pkg/stomp/StompDestination.php
index 30e858e1d..3364968c4 100644
--- a/pkg/stomp/StompDestination.php
+++ b/pkg/stomp/StompDestination.php
@@ -9,16 +9,16 @@
class StompDestination implements Topic, Queue
{
- const TYPE_TOPIC = 'topic';
- const TYPE_EXCHANGE = 'exchange';
- const TYPE_QUEUE = 'queue';
- const TYPE_AMQ_QUEUE = 'amq/queue';
- const TYPE_TEMP_QUEUE = 'temp-queue';
- const TYPE_REPLY_QUEUE = 'reply-queue';
+ public const TYPE_TOPIC = 'topic';
+ public const TYPE_EXCHANGE = 'exchange';
+ public const TYPE_QUEUE = 'queue';
+ public const TYPE_AMQ_QUEUE = 'amq/queue';
+ public const TYPE_TEMP_QUEUE = 'temp-queue';
+ public const TYPE_REPLY_QUEUE = 'reply-queue';
- const HEADER_DURABLE = 'durable';
- const HEADER_AUTO_DELETE = 'auto-delete';
- const HEADER_EXCLUSIVE = 'exclusive';
+ public const HEADER_DURABLE = 'durable';
+ public const HEADER_AUTO_DELETE = 'auto-delete';
+ public const HEADER_EXCLUSIVE = 'exclusive';
/**
* @var string
@@ -122,7 +122,7 @@ public function getRoutingKey(): ?string
return $this->routingKey;
}
- public function setRoutingKey(string $routingKey = null): void
+ public function setRoutingKey(?string $routingKey = null): void
{
$this->routingKey = $routingKey;
}
diff --git a/pkg/stomp/StompHeadersEncoder.php b/pkg/stomp/StompHeadersEncoder.php
index 27e637cc3..e3484abf6 100644
--- a/pkg/stomp/StompHeadersEncoder.php
+++ b/pkg/stomp/StompHeadersEncoder.php
@@ -6,13 +6,13 @@
class StompHeadersEncoder
{
- const PROPERTY_PREFIX = '_property_';
- const TYPE_PREFIX = '_type_';
- const TYPE_STRING = 's';
- const TYPE_INT = 'i';
- const TYPE_FLOAT = 'f';
- const TYPE_BOOL = 'b';
- const TYPE_NULL = 'n';
+ public const PROPERTY_PREFIX = '_property_';
+ public const TYPE_PREFIX = '_type_';
+ public const TYPE_STRING = 's';
+ public const TYPE_INT = 'i';
+ public const TYPE_FLOAT = 'f';
+ public const TYPE_BOOL = 'b';
+ public const TYPE_NULL = 'n';
public static function encode(array $headers = [], array $properties = []): array
{
@@ -36,7 +36,7 @@ public static function decode(array $headers = []): array
// separate headers/properties
foreach ($headers as $key => $value) {
- if (0 === strpos($key, self::PROPERTY_PREFIX)) {
+ if (str_starts_with($key, self::PROPERTY_PREFIX)) {
$encodedProperties[substr($key, $prefixLength)] = $value;
} else {
$encodedHeaders[$key] = $value;
@@ -94,7 +94,7 @@ private static function doDecode(array $headers = []): array
foreach ($headers as $key => $value) {
// skip type header
- if (0 === strpos($key, self::TYPE_PREFIX)) {
+ if (str_starts_with($key, self::TYPE_PREFIX)) {
continue;
}
diff --git a/pkg/stomp/StompMessage.php b/pkg/stomp/StompMessage.php
index bb563c8cd..7098679b7 100644
--- a/pkg/stomp/StompMessage.php
+++ b/pkg/stomp/StompMessage.php
@@ -120,7 +120,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}
- public function setCorrelationId(string $correlationId = null): void
+ public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', (string) $correlationId);
}
@@ -130,7 +130,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}
- public function setMessageId(string $messageId = null): void
+ public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', (string) $messageId);
}
@@ -147,7 +147,7 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}
- public function setTimestamp(int $timestamp = null): void
+ public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}
@@ -157,12 +157,12 @@ public function getFrame(): ?Frame
return $this->frame;
}
- public function setFrame(Frame $frame = null): void
+ public function setFrame(?Frame $frame = null): void
{
$this->frame = $frame;
}
- public function setReplyTo(string $replyTo = null): void
+ public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply-to', $replyTo);
}
diff --git a/pkg/stomp/StompProducer.php b/pkg/stomp/StompProducer.php
index 8c1933ee4..909720973 100644
--- a/pkg/stomp/StompProducer.php
+++ b/pkg/stomp/StompProducer.php
@@ -45,7 +45,7 @@ public function send(Destination $destination, Message $message): void
/**
* @return $this|Producer
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (empty($deliveryDelay)) {
return $this;
@@ -64,7 +64,7 @@ public function getDeliveryDelay(): ?int
*
* @return $this|Producer
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (empty($priority)) {
return $this;
@@ -81,7 +81,7 @@ public function getPriority(): ?int
/**
* @return $this|Producer
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
if (empty($timeToLive)) {
return $this;
diff --git a/pkg/stomp/Tests/BufferedStompClientTest.php b/pkg/stomp/Tests/BufferedStompClientTest.php
index 8732170e9..e4b6226e1 100644
--- a/pkg/stomp/Tests/BufferedStompClientTest.php
+++ b/pkg/stomp/Tests/BufferedStompClientTest.php
@@ -4,6 +4,7 @@
use Enqueue\Stomp\BufferedStompClient;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Enqueue\Test\WriteAttributeTrait;
use Stomp\Client;
use Stomp\Network\Connection;
@@ -12,6 +13,7 @@
class BufferedStompClientTest extends \PHPUnit\Framework\TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
use WriteAttributeTrait;
public function testShouldExtendLibStompClient()
@@ -19,11 +21,6 @@ public function testShouldExtendLibStompClient()
$this->assertClassExtends(Client::class, BufferedStompClient::class);
}
- public function testCouldBeConstructedWithRequiredArguments()
- {
- new BufferedStompClient('tcp://localhost:12345');
- }
-
public function testCouldGetBufferSizeValue()
{
$client = new BufferedStompClient('tcp://localhost:12345', 12345);
diff --git a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php
index e2175b8af..e3f09737a 100644
--- a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php
+++ b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php
@@ -12,22 +12,22 @@
*/
class StompCommonUseCasesTest extends \PHPUnit\Framework\TestCase
{
- use RabbitmqStompExtension;
use RabbitManagementExtensionTrait;
+ use RabbitmqStompExtension;
/**
* @var StompContext
*/
private $stompContext;
- public function setUp()
+ protected function setUp(): void
{
$this->stompContext = $this->buildStompContext();
$this->removeQueue('stomp.test');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->stompContext->close();
}
diff --git a/pkg/stomp/Tests/Functional/StompConnectionFactoryTest.php b/pkg/stomp/Tests/Functional/StompConnectionFactoryTest.php
index 9029c17c1..6d4223616 100644
--- a/pkg/stomp/Tests/Functional/StompConnectionFactoryTest.php
+++ b/pkg/stomp/Tests/Functional/StompConnectionFactoryTest.php
@@ -4,6 +4,7 @@
use Enqueue\Stomp\StompConnectionFactory;
use Enqueue\Test\RabbitmqStompExtension;
+use Enqueue\Test\ReadAttributeTrait;
use Stomp\Network\Observer\Exception\HeartbeatException;
use Stomp\Network\Observer\HeartbeatEmitter;
use Stomp\Network\Observer\ServerAliveObserver;
@@ -14,6 +15,7 @@
class StompConnectionFactoryTest extends \PHPUnit\Framework\TestCase
{
use RabbitmqStompExtension;
+ use ReadAttributeTrait;
public function testShouldNotCreateConnectionWithSendHeartbeat()
{
diff --git a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php
index 36357ca21..2025380fd 100644
--- a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php
+++ b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php
@@ -20,22 +20,22 @@
*/
class StompConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase
{
- use RabbitmqStompExtension;
use RabbitManagementExtensionTrait;
+ use RabbitmqStompExtension;
/**
* @var StompContext
*/
private $stompContext;
- public function setUp()
+ protected function setUp(): void
{
$this->stompContext = $this->buildStompContext();
$this->removeQueue('stomp.test');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->stompContext->close();
}
diff --git a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php
index 4c06d59b1..4cbb3af47 100644
--- a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php
+++ b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php
@@ -14,15 +14,15 @@
*/
class StompRpcUseCasesTest extends \PHPUnit\Framework\TestCase
{
- use RabbitmqStompExtension;
use RabbitManagementExtensionTrait;
+ use RabbitmqStompExtension;
/**
* @var StompContext
*/
private $stompContext;
- public function setUp()
+ protected function setUp(): void
{
$this->stompContext = $this->buildStompContext();
@@ -30,7 +30,7 @@ public function setUp()
$this->removeQueue('stomp.rpc.reply_test');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->stompContext->close();
}
diff --git a/pkg/stomp/Tests/Spec/StompMessageTest.php b/pkg/stomp/Tests/Spec/StompMessageTest.php
index dd9e733ea..8f6748b63 100644
--- a/pkg/stomp/Tests/Spec/StompMessageTest.php
+++ b/pkg/stomp/Tests/Spec/StompMessageTest.php
@@ -7,9 +7,6 @@
class StompMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new StompMessage();
diff --git a/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php b/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php
index 50031e1e7..d784d4104 100644
--- a/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php
+++ b/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php
@@ -4,6 +4,7 @@
use Enqueue\Stomp\StompConnectionFactory;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@
class StompConnectionFactoryConfigTest extends TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testThrowNeitherArrayStringNorNullGivenAsConfig()
{
@@ -39,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed()
/**
* @dataProvider provideConfigs
- *
- * @param mixed $config
- * @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
diff --git a/pkg/stomp/Tests/StompConnectionFactoryTest.php b/pkg/stomp/Tests/StompConnectionFactoryTest.php
index 91986e6d0..1f39e3b20 100644
--- a/pkg/stomp/Tests/StompConnectionFactoryTest.php
+++ b/pkg/stomp/Tests/StompConnectionFactoryTest.php
@@ -5,11 +5,13 @@
use Enqueue\Stomp\StompConnectionFactory;
use Enqueue\Stomp\StompContext;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
class StompConnectionFactoryTest extends \PHPUnit\Framework\TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
@@ -26,7 +28,7 @@ public function testShouldCreateLazyContext()
$this->assertAttributeEquals(null, 'stomp', $context);
$this->assertAttributeEquals(true, 'useExchangePrefix', $context);
- $this->assertInternalType('callable', $this->readAttribute($context, 'stompFactory'));
+ self::assertIsCallable($this->readAttribute($context, 'stompFactory'));
}
public function testShouldCreateRabbitMQContext()
diff --git a/pkg/stomp/Tests/StompConsumerTest.php b/pkg/stomp/Tests/StompConsumerTest.php
index ff07ebde1..d461284c9 100644
--- a/pkg/stomp/Tests/StompConsumerTest.php
+++ b/pkg/stomp/Tests/StompConsumerTest.php
@@ -8,6 +8,7 @@
use Enqueue\Stomp\StompDestination;
use Enqueue\Stomp\StompMessage;
use Enqueue\Test\ClassExtensionTrait;
+use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\Consumer;
use Interop\Queue\Exception\InvalidMessageException;
use Interop\Queue\Message;
@@ -17,17 +18,13 @@
class StompConsumerTest extends \PHPUnit\Framework\TestCase
{
use ClassExtensionTrait;
+ use ReadAttributeTrait;
public function testShouldImplementMessageConsumerInterface()
{
$this->assertClassImplements(Consumer::class, StompConsumer::class);
}
- public function testCouldBeConstructedWithRequiredAttributes()
- {
- new StompConsumer($this->createStompClientMock(), $this->createDummyDestination());
- }
-
public function testCouldGetQueue()
{
$consumer = new StompConsumer($this->createStompClientMock(), $dest = $this->createDummyDestination());
@@ -521,8 +518,8 @@ public function testShouldGenerateUniqueSubscriptionIdPerConsumer()
$fooConsumer = new StompConsumer($this->createStompClientMock(), $destination);
$barConsumer = new StompConsumer($this->createStompClientMock(), $destination);
- $this->assertAttributeNotEmpty('subscriptionId', $fooConsumer);
- $this->assertAttributeNotEmpty('subscriptionId', $barConsumer);
+ $this->assertNotEmpty($this->readAttribute($fooConsumer, 'subscriptionId'));
+ $this->assertNotEmpty($this->readAttribute($barConsumer, 'subscriptionId'));
$fooSubscriptionId = $this->readAttribute($fooConsumer, 'subscriptionId');
$barSubscriptionId = $this->readAttribute($barConsumer, 'subscriptionId');
diff --git a/pkg/stomp/Tests/StompContextTest.php b/pkg/stomp/Tests/StompContextTest.php
index b0a41b64d..cfb9245dc 100644
--- a/pkg/stomp/Tests/StompContextTest.php
+++ b/pkg/stomp/Tests/StompContextTest.php
@@ -23,18 +23,6 @@ public function testShouldImplementSessionInterface()
$this->assertClassImplements(Context::class, StompContext::class);
}
- public function testCouldBeCreatedWithRequiredArguments()
- {
- new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
- }
-
- public function testCouldBeConstructedWithExtChannelCallbackFactoryAsFirstArgument()
- {
- new StompContext(function () {
- return $this->createStompClientMock();
- }, ExtensionType::RABBITMQ);
- }
-
public function testThrowIfNeitherCallbackNorExtChannelAsFirstArgument()
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/pkg/stomp/Tests/StompHeadersEncoderTest.php b/pkg/stomp/Tests/StompHeadersEncoderTest.php
index 7997e05a4..cd3d112dd 100644
--- a/pkg/stomp/Tests/StompHeadersEncoderTest.php
+++ b/pkg/stomp/Tests/StompHeadersEncoderTest.php
@@ -32,9 +32,6 @@ public function propertyValuesDataProvider()
/**
* @dataProvider headerValuesDataProvider
- *
- * @param mixed $originalValue
- * @param mixed $encodedValue
*/
public function testShouldEncodeHeaders($originalValue, $encodedValue)
{
@@ -43,9 +40,6 @@ public function testShouldEncodeHeaders($originalValue, $encodedValue)
/**
* @dataProvider propertyValuesDataProvider
- *
- * @param mixed $originalValue
- * @param mixed $encodedValue
*/
public function testShouldEncodeProperties($originalValue, $encodedValue)
{
@@ -54,9 +48,6 @@ public function testShouldEncodeProperties($originalValue, $encodedValue)
/**
* @dataProvider headerValuesDataProvider
- *
- * @param mixed $originalValue
- * @param mixed $encodedValue
*/
public function testShouldDecodeHeaders($originalValue, $encodedValue)
{
@@ -65,9 +56,6 @@ public function testShouldDecodeHeaders($originalValue, $encodedValue)
/**
* @dataProvider propertyValuesDataProvider
- *
- * @param mixed $originalValue
- * @param mixed $encodedValue
*/
public function testShouldDecodeProperties($originalValue, $encodedValue)
{
diff --git a/pkg/stomp/Tests/StompMessageTest.php b/pkg/stomp/Tests/StompMessageTest.php
index 736df79a2..49be1a8c5 100644
--- a/pkg/stomp/Tests/StompMessageTest.php
+++ b/pkg/stomp/Tests/StompMessageTest.php
@@ -93,7 +93,7 @@ public function testShouldUnsetHeaderIfNullPassed()
$message->setHeader('aHeader', 'aVal');
- //guard
+ // guard
$this->assertSame('aVal', $message->getHeader('aHeader'));
$message->setHeader('aHeader', null);
@@ -108,7 +108,7 @@ public function testShouldUnsetPropertyIfNullPassed()
$message->setProperty('aProperty', 'aVal');
- //guard
+ // guard
$this->assertSame('aVal', $message->getProperty('aProperty'));
$message->setProperty('aProperty', null);
diff --git a/pkg/stomp/composer.json b/pkg/stomp/composer.json
index 30fe9a2fa..2cceb9fea 100644
--- a/pkg/stomp/composer.json
+++ b/pkg/stomp/composer.json
@@ -6,19 +6,21 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
+ "php": "^8.1",
"enqueue/dsn": "^0.10",
- "stomp-php/stomp-php": "^4",
+ "stomp-php/stomp-php": "^4.5|^5.0",
"queue-interop/queue-interop": "^0.8",
- "php-http/guzzle6-adapter": "^1.1",
- "php-http/client-common": "^1.7@dev",
- "richardfullmer/rabbitmq-management-api": "^2.0"
+ "php-http/guzzle7-adapter": "^0.1.1",
+ "php-http/client-common": "^2.2.1",
+ "andrewmy/rabbitmq-management-api": "^2.1.2",
+ "guzzlehttp/guzzle": "^7.0.1",
+ "php-http/discovery": "^1.13"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
diff --git a/pkg/test/RabbitManagementExtensionTrait.php b/pkg/test/RabbitManagementExtensionTrait.php
index 82bdd072c..184b1758e 100644
--- a/pkg/test/RabbitManagementExtensionTrait.php
+++ b/pkg/test/RabbitManagementExtensionTrait.php
@@ -21,17 +21,17 @@ private function removeQueue($queueName)
);
$ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword());
- curl_setopt($ch, CURLOPT_HTTPHEADER, [
+ curl_setopt($ch, \CURLOPT_URL, $url);
+ curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
+ curl_setopt($ch, \CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC);
+ curl_setopt($ch, \CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword());
+ curl_setopt($ch, \CURLOPT_HTTPHEADER, [
'Content-Type' => 'application/json',
]);
curl_exec($ch);
- $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ $httpCode = curl_getinfo($ch, \CURLINFO_HTTP_CODE);
curl_close($ch);
@@ -55,17 +55,17 @@ private function removeExchange($exchangeName)
);
$ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword());
- curl_setopt($ch, CURLOPT_HTTPHEADER, [
+ curl_setopt($ch, \CURLOPT_URL, $url);
+ curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
+ curl_setopt($ch, \CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC);
+ curl_setopt($ch, \CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword());
+ curl_setopt($ch, \CURLOPT_HTTPHEADER, [
'Content-Type' => 'application/json',
]);
curl_exec($ch);
- $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ $httpCode = curl_getinfo($ch, \CURLINFO_HTTP_CODE);
curl_close($ch);
diff --git a/pkg/test/ReadAttributeTrait.php b/pkg/test/ReadAttributeTrait.php
new file mode 100644
index 000000000..5b9758a64
--- /dev/null
+++ b/pkg/test/ReadAttributeTrait.php
@@ -0,0 +1,57 @@
+getClassAttribute($object, $attribute);
+ $refProperty->setAccessible(true);
+ $value = $refProperty->getValue($object);
+ $refProperty->setAccessible(false);
+
+ return $value;
+ }
+
+ private function getClassAttribute(
+ object $object,
+ string $attribute,
+ ?string $class = null,
+ ): \ReflectionProperty {
+ if (null === $class) {
+ $class = $object::class;
+ }
+
+ try {
+ return new \ReflectionProperty($class, $attribute);
+ } catch (\ReflectionException $exception) {
+ $parentClass = get_parent_class($object);
+ if (false === $parentClass) {
+ throw $exception;
+ }
+
+ return $this->getClassAttribute($object, $attribute, $parentClass);
+ }
+ }
+
+ private function assertAttributeSame($expected, string $attribute, object $object): void
+ {
+ static::assertSame($expected, $this->readAttribute($object, $attribute));
+ }
+
+ private function assertAttributeEquals($expected, string $attribute, object $object): void
+ {
+ static::assertEquals($expected, $this->readAttribute($object, $attribute));
+ }
+
+ private function assertAttributeInstanceOf(string $expected, string $attribute, object $object): void
+ {
+ static::assertInstanceOf($expected, $this->readAttribute($object, $attribute));
+ }
+
+ private function assertAttributeCount(int $count, string $attribute, object $object): void
+ {
+ static::assertCount($count, $this->readAttribute($object, $attribute));
+ }
+}
diff --git a/pkg/test/RedisExtension.php b/pkg/test/RedisExtension.php
index 86586d16b..3227785c2 100644
--- a/pkg/test/RedisExtension.php
+++ b/pkg/test/RedisExtension.php
@@ -20,7 +20,7 @@ private function buildPhpRedisContext(): RedisContext
$context = (new RedisConnectionFactory($config))->createContext();
- //guard
+ // guard
$this->assertInstanceOf(PhpRedis::class, $context->getRedis());
return $context;
@@ -36,7 +36,7 @@ private function buildPRedisContext(): RedisContext
$context = (new RedisConnectionFactory($config))->createContext();
- //guard
+ // guard
$this->assertInstanceOf(PRedis::class, $context->getRedis());
return $context;
diff --git a/pkg/test/RetryTrait.php b/pkg/test/RetryTrait.php
index 17c96ae89..1f1042c81 100644
--- a/pkg/test/RetryTrait.php
+++ b/pkg/test/RetryTrait.php
@@ -4,6 +4,7 @@
use PHPUnit\Framework\IncompleteTestError;
use PHPUnit\Framework\SkippedTestError;
+use PHPUnit\Util\Test;
trait RetryTrait
{
@@ -46,7 +47,7 @@ public function runBare(): void
*/
private function getNumberOfRetries()
{
- $annotations = $this->getAnnotations();
+ $annotations = Test::parseTestMethodAnnotations(static::class, $this->getName(false));
if (isset($annotations['method']['retry'][0])) {
return $annotations['method']['retry'][0];
diff --git a/pkg/test/TestLogger.php b/pkg/test/TestLogger.php
new file mode 100644
index 000000000..9db2c2a5e
--- /dev/null
+++ b/pkg/test/TestLogger.php
@@ -0,0 +1,144 @@
+ 0) {
+ $genericMethod = $matches[1].('Records' !== $matches[3] ? 'Record' : '').$matches[3];
+ $level = strtolower($matches[2]);
+ if (method_exists($this, $genericMethod)) {
+ $args[] = $level;
+
+ return call_user_func_array([$this, $genericMethod], $args);
+ }
+ }
+ throw new \BadMethodCallException('Call to undefined method TestLogger::'.$method.'()');
+ }
+
+ public function log($level, $message, array $context = []): void
+ {
+ $record = [
+ 'level' => $level,
+ 'message' => $message,
+ 'context' => $context,
+ ];
+
+ $this->recordsByLevel[$record['level']][] = $record;
+ $this->records[] = $record;
+ }
+
+ public function hasRecords($level)
+ {
+ return isset($this->recordsByLevel[$level]);
+ }
+
+ public function hasRecord($record, $level)
+ {
+ if (is_string($record)) {
+ $record = ['message' => $record];
+ }
+
+ return $this->hasRecordThatPasses(function ($rec) use ($record) {
+ if ($rec['message'] !== $record['message']) {
+ return false;
+ }
+ if (isset($record['context']) && $rec['context'] !== $record['context']) {
+ return false;
+ }
+
+ return true;
+ }, $level);
+ }
+
+ public function hasRecordThatContains($message, $level)
+ {
+ return $this->hasRecordThatPasses(function ($rec) use ($message) {
+ return str_contains($rec['message'], $message);
+ }, $level);
+ }
+
+ public function hasRecordThatMatches($regex, $level)
+ {
+ return $this->hasRecordThatPasses(function ($rec) use ($regex) {
+ return preg_match($regex, $rec['message']) > 0;
+ }, $level);
+ }
+
+ public function hasRecordThatPasses(callable $predicate, $level)
+ {
+ if (!isset($this->recordsByLevel[$level])) {
+ return false;
+ }
+ foreach ($this->recordsByLevel[$level] as $i => $rec) {
+ if (call_user_func($predicate, $rec, $i)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public function reset()
+ {
+ $this->records = [];
+ $this->recordsByLevel = [];
+ }
+}
diff --git a/pkg/test/WriteAttributeTrait.php b/pkg/test/WriteAttributeTrait.php
index e2e84bd2a..6f8c1aab5 100644
--- a/pkg/test/WriteAttributeTrait.php
+++ b/pkg/test/WriteAttributeTrait.php
@@ -7,11 +7,10 @@ trait WriteAttributeTrait
/**
* @param object $object
* @param string $attribute
- * @param mixed $value
*/
public function writeAttribute($object, $attribute, $value)
{
- $refProperty = new \ReflectionProperty(get_class($object), $attribute);
+ $refProperty = new \ReflectionProperty($object::class, $attribute);
$refProperty->setAccessible(true);
$refProperty->setValue($object, $value);
$refProperty->setAccessible(false);
diff --git a/pkg/wamp/.github/workflows/ci.yml b/pkg/wamp/.github/workflows/ci.yml
new file mode 100644
index 000000000..5448d7b1a
--- /dev/null
+++ b/pkg/wamp/.github/workflows/ci.yml
@@ -0,0 +1,27 @@
+name: CI
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['7.4', '8.0', '8.1', '8.2']
+
+ name: PHP ${{ matrix.php }} tests
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - uses: "ramsey/composer-install@v1"
+
+ - run: vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/wamp/.travis.yml b/pkg/wamp/.travis.yml
deleted file mode 100644
index 02ba7238b..000000000
--- a/pkg/wamp/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-sudo: false
-
-git:
- depth: 10
-
-language: php
-
-php:
- - '7.1'
- - '7.2'
- - '7.3'
- - '7.4'
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-install:
- - composer self-update
- - composer install
-
-script:
- - vendor/bin/phpunit --exclude-group=functional
diff --git a/pkg/wamp/JsonSerializer.php b/pkg/wamp/JsonSerializer.php
index b6027ba81..9a224fbb8 100644
--- a/pkg/wamp/JsonSerializer.php
+++ b/pkg/wamp/JsonSerializer.php
@@ -14,12 +14,8 @@ public function toString(WampMessage $message): string
'headers' => $message->getHeaders(),
]);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return $json;
@@ -28,12 +24,8 @@ public function toString(WampMessage $message): string
public function toMessage(string $string): WampMessage
{
$data = json_decode($string, true);
- if (JSON_ERROR_NONE !== json_last_error()) {
- throw new \InvalidArgumentException(sprintf(
- 'The malformed json given. Error %s and message %s',
- json_last_error(),
- json_last_error_msg()
- ));
+ if (\JSON_ERROR_NONE !== json_last_error()) {
+ throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}
return new WampMessage($data['body'], $data['properties'], $data['headers']);
diff --git a/pkg/wamp/README.md b/pkg/wamp/README.md
index 67f5c9cef..ee0bcaa17 100644
--- a/pkg/wamp/README.md
+++ b/pkg/wamp/README.md
@@ -10,7 +10,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made
# Web Application Messaging Protocol (WAMP) Transport
[](https://gitter.im/php-enqueue/Lobby)
-[](https://travis-ci.org/php-enqueue/wamp)
+[](https://github.com/php-enqueue/wamp/actions?query=workflow%3ACI)
[](https://packagist.org/packages/enqueue/wamp)
[](https://packagist.org/packages/enqueue/wamp)
diff --git a/pkg/wamp/SerializerAwareTrait.php b/pkg/wamp/SerializerAwareTrait.php
index c2ce9b603..adfe66e7e 100644
--- a/pkg/wamp/SerializerAwareTrait.php
+++ b/pkg/wamp/SerializerAwareTrait.php
@@ -11,9 +11,6 @@ trait SerializerAwareTrait
*/
private $serializer;
- /**
- * @param Serializer $serializer
- */
public function setSerializer(Serializer $serializer)
{
$this->serializer = $serializer;
diff --git a/pkg/wamp/Tests/Functional/WampConsumerTest.php b/pkg/wamp/Tests/Functional/WampConsumerTest.php
index f76cce71b..bb2dd89a4 100644
--- a/pkg/wamp/Tests/Functional/WampConsumerTest.php
+++ b/pkg/wamp/Tests/Functional/WampConsumerTest.php
@@ -12,14 +12,15 @@
/**
* @group functional
* @group Wamp
+ *
* @retry 5
*/
class WampConsumerTest extends TestCase
{
- use WampExtension;
use RetryTrait;
+ use WampExtension;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
Logger::set(new NullLogger());
}
diff --git a/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php b/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php
index c28b3e0a5..e272f42ed 100644
--- a/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php
+++ b/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php
@@ -16,7 +16,7 @@ class WampSubscriptionConsumerTest extends TestCase
{
use WampExtension;
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
Logger::set(new NullLogger());
}
diff --git a/pkg/wamp/Tests/Spec/JsonSerializerTest.php b/pkg/wamp/Tests/Spec/JsonSerializerTest.php
index 1e7e29413..f062a7058 100644
--- a/pkg/wamp/Tests/Spec/JsonSerializerTest.php
+++ b/pkg/wamp/Tests/Spec/JsonSerializerTest.php
@@ -20,11 +20,6 @@ public function testShouldImplementSerializerInterface()
$this->assertClassImplements(Serializer::class, JsonSerializer::class);
}
- public function testCouldBeConstructedWithoutAnyArguments()
- {
- new JsonSerializer();
- }
-
public function testShouldConvertMessageToJsonString()
{
$serializer = new JsonSerializer();
@@ -42,8 +37,8 @@ public function testThrowIfFailedToEncodeMessageToJson()
$resource = fopen(__FILE__, 'r');
- //guard
- $this->assertInternalType('resource', $resource);
+ // guard
+ $this->assertIsResource($resource);
$message = new WampMessage('theBody', ['aProp' => $resource]);
diff --git a/pkg/wamp/Tests/Spec/WampConnectionFactoryTest.php b/pkg/wamp/Tests/Spec/WampConnectionFactoryTest.php
index 3c3ccf841..5b6e418c9 100644
--- a/pkg/wamp/Tests/Spec/WampConnectionFactoryTest.php
+++ b/pkg/wamp/Tests/Spec/WampConnectionFactoryTest.php
@@ -10,9 +10,6 @@
*/
class WampConnectionFactoryTest extends ConnectionFactorySpec
{
- /**
- * {@inheritdoc}
- */
protected function createConnectionFactory()
{
return new WampConnectionFactory();
diff --git a/pkg/wamp/Tests/Spec/WampContextTest.php b/pkg/wamp/Tests/Spec/WampContextTest.php
index 0bd70c772..4b2fb6c59 100644
--- a/pkg/wamp/Tests/Spec/WampContextTest.php
+++ b/pkg/wamp/Tests/Spec/WampContextTest.php
@@ -13,9 +13,6 @@ class WampContextTest extends ContextSpec
{
use WampExtension;
- /**
- * {@inheritdoc}
- */
protected function createContext()
{
return $this->buildWampContext();
diff --git a/pkg/wamp/Tests/Spec/WampMessageTest.php b/pkg/wamp/Tests/Spec/WampMessageTest.php
index 5482fadde..3e030d8c1 100644
--- a/pkg/wamp/Tests/Spec/WampMessageTest.php
+++ b/pkg/wamp/Tests/Spec/WampMessageTest.php
@@ -10,9 +10,6 @@
*/
class WampMessageTest extends MessageSpec
{
- /**
- * {@inheritdoc}
- */
protected function createMessage()
{
return new WampMessage();
diff --git a/pkg/wamp/Tests/Spec/WampProducerTest.php b/pkg/wamp/Tests/Spec/WampProducerTest.php
index d28194688..55aa68403 100644
--- a/pkg/wamp/Tests/Spec/WampProducerTest.php
+++ b/pkg/wamp/Tests/Spec/WampProducerTest.php
@@ -13,9 +13,6 @@ class WampProducerTest extends ProducerSpec
{
use WampExtension;
- /**
- * {@inheritdoc}
- */
protected function createProducer()
{
return $this->buildWampContext()->createProducer();
diff --git a/pkg/wamp/Tests/Spec/WampQueueTest.php b/pkg/wamp/Tests/Spec/WampQueueTest.php
index e8cb87267..015536fd1 100644
--- a/pkg/wamp/Tests/Spec/WampQueueTest.php
+++ b/pkg/wamp/Tests/Spec/WampQueueTest.php
@@ -10,9 +10,6 @@
*/
class WampQueueTest extends QueueSpec
{
- /**
- * {@inheritdoc}
- */
protected function createQueue()
{
return new WampDestination(self::EXPECTED_QUEUE_NAME);
diff --git a/pkg/wamp/Tests/Spec/WampTopicTest.php b/pkg/wamp/Tests/Spec/WampTopicTest.php
index 4c48e7911..854da2c87 100644
--- a/pkg/wamp/Tests/Spec/WampTopicTest.php
+++ b/pkg/wamp/Tests/Spec/WampTopicTest.php
@@ -10,9 +10,6 @@
*/
class WampTopicTest extends TopicSpec
{
- /**
- * {@inheritdoc}
- */
protected function createTopic()
{
return new WampDestination(self::EXPECTED_TOPIC_NAME);
diff --git a/pkg/wamp/WampConnectionFactory.php b/pkg/wamp/WampConnectionFactory.php
index 3ba29f60a..d4ea9d73b 100644
--- a/pkg/wamp/WampConnectionFactory.php
+++ b/pkg/wamp/WampConnectionFactory.php
@@ -88,10 +88,7 @@ private function parseDsn(string $dsn): array
$dsn = Dsn::parseFirst($dsn);
if (false === in_array($dsn->getSchemeProtocol(), ['wamp', 'ws'], true)) {
- throw new \LogicException(sprintf(
- 'The given scheme protocol "%s" is not supported. It must be "wamp"',
- $dsn->getSchemeProtocol()
- ));
+ throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "wamp"', $dsn->getSchemeProtocol()));
}
return array_filter(array_replace($dsn->getQuery(), [
diff --git a/pkg/wamp/WampConsumer.php b/pkg/wamp/WampConsumer.php
index 8dc859739..8a6733e36 100644
--- a/pkg/wamp/WampConsumer.php
+++ b/pkg/wamp/WampConsumer.php
@@ -84,7 +84,7 @@ public function receive(int $timeout = 0): ?Message
}
if ($timeout > 0) {
- $timeout = $timeout / 1000;
+ $timeout /= 1000;
$timeout = $timeout >= 0.1 ? $timeout : 0.1;
$this->timer = $this->client->getLoop()->addTimer($timeout, function () {
@@ -112,8 +112,6 @@ public function receiveNoWait(): ?Message
}
/**
- * {@inheritdoc}
- *
* @param WampMessage $message
*/
public function acknowledge(Message $message): void
@@ -122,8 +120,6 @@ public function acknowledge(Message $message): void
}
/**
- * {@inheritdoc}
- *
* @param WampMessage $message
*/
public function reject(Message $message, bool $requeue = false): void
diff --git a/pkg/wamp/WampContext.php b/pkg/wamp/WampContext.php
index 9bbed5087..623aa33f9 100644
--- a/pkg/wamp/WampContext.php
+++ b/pkg/wamp/WampContext.php
@@ -97,11 +97,7 @@ public function getNewClient(): Client
$client = call_user_func($this->clientFactory);
if (false == $client instanceof Client) {
- throw new \LogicException(sprintf(
- 'The factory must return instance of "%s". But it returns %s',
- Client::class,
- is_object($client) ? get_class($client) : gettype($client)
- ));
+ throw new \LogicException(sprintf('The factory must return instance of "%s". But it returns %s', Client::class, is_object($client) ? $client::class : gettype($client)));
}
$this->clients[] = $client;
diff --git a/pkg/wamp/WampProducer.php b/pkg/wamp/WampProducer.php
index 3bffe21f0..71ea625ae 100644
--- a/pkg/wamp/WampProducer.php
+++ b/pkg/wamp/WampProducer.php
@@ -48,8 +48,6 @@ public function __construct(WampContext $context)
}
/**
- * {@inheritdoc}
- *
* @param WampDestination $destination
* @param WampMessage $message
*/
@@ -113,11 +111,9 @@ public function send(Destination $destination, Message $message): void
}
/**
- * {@inheritdoc}
- *
* @return WampProducer
*/
- public function setDeliveryDelay(int $deliveryDelay = null): Producer
+ public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $deliveryDelay) {
return $this;
@@ -132,11 +128,9 @@ public function getDeliveryDelay(): ?int
}
/**
- * {@inheritdoc}
- *
* @return WampProducer
*/
- public function setPriority(int $priority = null): Producer
+ public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
@@ -151,11 +145,9 @@ public function getPriority(): ?int
}
/**
- * {@inheritdoc}
- *
* @return WampProducer
*/
- public function setTimeToLive(int $timeToLive = null): Producer
+ public function setTimeToLive(?int $timeToLive = null): Producer
{
if (null === $timeToLive) {
return $this;
diff --git a/pkg/wamp/WampSubscriptionConsumer.php b/pkg/wamp/WampSubscriptionConsumer.php
index 6b96926e1..2d25a673b 100644
--- a/pkg/wamp/WampSubscriptionConsumer.php
+++ b/pkg/wamp/WampSubscriptionConsumer.php
@@ -84,7 +84,7 @@ public function consume(int $timeout = 0): void
}
if ($timeout > 0) {
- $timeout = $timeout / 1000;
+ $timeout /= 1000;
$timeout = $timeout >= 0.1 ? $timeout : 0.1;
$this->timer = $this->client->getLoop()->addTimer($timeout, function () {
@@ -100,14 +100,12 @@ public function consume(int $timeout = 0): void
}
/**
- * {@inheritdoc}
- *
* @param WampConsumer $consumer
*/
public function subscribe(Consumer $consumer, callable $callback): void
{
if (false == $consumer instanceof WampConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', WampConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', WampConsumer::class, $consumer::class));
}
if ($this->client) {
@@ -127,14 +125,12 @@ public function subscribe(Consumer $consumer, callable $callback): void
}
/**
- * {@inheritdoc}
- *
* @param WampConsumer $consumer
*/
public function unsubscribe(Consumer $consumer): void
{
if (false == $consumer instanceof WampConsumer) {
- throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', WampConsumer::class, get_class($consumer)));
+ throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', WampConsumer::class, $consumer::class));
}
if ($this->client) {
diff --git a/pkg/wamp/composer.json b/pkg/wamp/composer.json
index c128997e5..b510627bd 100644
--- a/pkg/wamp/composer.json
+++ b/pkg/wamp/composer.json
@@ -6,17 +6,21 @@
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
- "php": "^7.1.3",
- "queue-interop/queue-interop": "^0.8",
- "enqueue/dsn": "^0.10",
- "thruway/client": "^0.5.0",
- "thruway/pawl-transport": "^0.5.0"
+ "php": "^8.1",
+ "queue-interop/queue-interop": "^0.8.1",
+ "enqueue/dsn": "^0.10.8",
+ "thruway/client": "^0.5.5",
+ "thruway/pawl-transport": "^0.5.1",
+ "voryx/thruway-common": "^1.0.1",
+ "react/dns": "^1.4",
+ "react/event-loop": "^1.2",
+ "react/promise": "^2.8"
},
"require-dev": {
- "phpunit/phpunit": "~7.5",
+ "phpunit/phpunit": "^9.5",
"enqueue/test": "0.10.x-dev",
"enqueue/null": "0.10.x-dev",
- "queue-interop/queue-spec": "^0.6"
+ "queue-interop/queue-spec": "^0.6.2"
},
"support": {
"email": "opensource@forma-pro.com",
@@ -31,10 +35,13 @@
"/Tests/"
]
},
- "minimum-stability": "dev",
+ "minimum-stability": "beta",
"extra": {
"branch-alias": {
"dev-master": "0.10.x-dev"
}
+ },
+ "config": {
+ "prefer-stable": true
}
}