Skip to content

Fix: Tests throwing warnings #1374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
name: Static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
pkg/**/*.php
Expand All @@ -25,7 +25,7 @@ jobs:

- run: php ./bin/fix-symfony-version.php "5.4.*"

- uses: "ramsey/composer-install@v1"
- uses: "ramsey/composer-install@v3"

- run: sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php

Expand All @@ -37,9 +37,9 @@ jobs:
name: Code style check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
pkg/**/*.php
Expand All @@ -49,7 +49,7 @@ jobs:
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-cs-check-${{ hashFiles('**/composer.json') }}
Expand Down Expand Up @@ -87,14 +87,14 @@ jobs:
name: PHP ${{ matrix.php }} unit tests on Sf ${{ matrix.symfony_version }}, deps=${{ matrix.dependencies }}

steps:
- uses: actions/checkout@v2
- 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@v2
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ matrix.symfony_version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
Expand Down Expand Up @@ -131,14 +131,14 @@ jobs:
name: PHP ${{ matrix.php }} functional tests on Sf ${{ matrix.symfony_version }}, deps=${{ matrix.dependencies }}

steps:
- uses: actions/checkout@v2
- 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@v2
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ matrix.symfony_version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
Expand All @@ -162,10 +162,4 @@ jobs:
env:
PHP_VERSION: ${{ matrix.php }}

# TODO: convert these two steps into one w/o excludes when Gearman extension gets a release for PHP 8.1
# See https://github.com/php/pecl-networking-gearman/issues/16
- run: bin/test.sh
if: ${{ matrix.php != '8.1' && matrix.php != '8.2' }}

- run: bin/test.sh --exclude-group=gearman
if: ${{ matrix.php == '8.1' && matrix.php != '8.2' }}
- run: bin/test.sh --group=functional
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"google/cloud-pubsub": "^1.4.3",
"doctrine/orm": "^2.12",
"doctrine/persistence": "^2.0|^3.0",
"mongodb/mongodb": "^1.2",
"mongodb/mongodb": "^1.17",
"pda/pheanstalk": "^3.1",
"aws/aws-sdk-php": "^3.290",
"stomp-php/stomp-php": "^4.5|^5",
Expand All @@ -50,8 +50,8 @@
},
"require-dev": {
"ext-pcntl": "*",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.0",
"phpunit/phpunit": "^9.6.22",
"phpstan/phpstan": "^2.1",
"queue-interop/queue-spec": "^0.6.2",
"symfony/browser-kit": "^6.2|^7.0",
"symfony/config": "^6.2|^7.0",
Expand Down Expand Up @@ -127,7 +127,7 @@
"ext-rdkafka": "4.0",
"ext-bcmath": "1",
"ext-mbstring": "1",
"ext-mongo": "1.6.14",
"ext-mongodb": "1.17",
"ext-sockets": "1"
},
"prefer-stable": true,
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
version: '2'

services:
dev:
# when image publishing gets sorted:
# image: enqueue/dev:${PHP_VERSION:-7.4}
# image: enqueue/dev:${PHP_VERSION:-8.2}
build:
context: docker
args:
PHP_VERSION: "${PHP_VERSION:-8.1}"
PHP_VERSION: "${PHP_VERSION:-8.2}"
depends_on:
- rabbitmq
- mysql
Expand Down
91 changes: 27 additions & 64 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,76 +1,39 @@
ARG PHP_VERSION=8.2
FROM makasim/nginx-php-fpm:${PHP_VERSION}-all-exts
FROM php:${PHP_VERSION}-alpine

ARG PHP_VERSION

## libs
RUN set -x && \
apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests \
wget \
curl \
openssl \
ca-certificates \
nano \
netcat \
php${PHP_VERSION}-dev \
php${PHP_VERSION}-redis \
php${PHP_VERSION}-pgsql \
git \
python \
php${PHP_VERSION}-amqp \
php${PHP_VERSION}-xml \
php${PHP_VERSION}-mysql \
php${PHP_VERSION}-curl \
php${PHP_VERSION}-mongodb \
php${PHP_VERSION}-mbstring \
make \
g++ \
unzip \
&& \
update-alternatives --install /usr/bin/php php /usr/bin/php${PHP_VERSION} 100

## gearman
RUN set -x && \
apt-get install -y --no-install-recommends --no-install-suggests \
libgearman-dev \
&& \
mkdir -p $HOME/gearman && \
cd $HOME/gearman && \
git clone https://github.com/php/pecl-networking-gearman.git . && \
git checkout gearman-2.1.0 && \
phpize && ./configure && make && make install && \
if [ ! -f /etc/php/${PHP_VERSION}/cli/conf.d/20-gearman.ini ]; then \
echo "extension=gearman.so" > /etc/php/${PHP_VERSION}/cli/conf.d/20-gearman.ini && \
echo "extension=gearman.so" > /etc/php/${PHP_VERSION}/fpm/conf.d/20-gearman.ini \
; \
fi;

## librdkafka
RUN set -x && \
mkdir -p $HOME/librdkafka && \
cd $HOME/librdkafka && \
git clone https://github.com/edenhill/librdkafka.git . && \
git checkout v1.0.0 && \
./configure && make && make install

## php-rdkafka
RUN set -x && \
mkdir -p $HOME/php-rdkafka && \
cd $HOME/php-rdkafka && \
git clone https://github.com/arnaud-lb/php-rdkafka.git . && \
git checkout 5.0.1 && \
phpize && ./configure && make all && make install && \
echo "extension=rdkafka.so" > /etc/php/${PHP_VERSION}/cli/conf.d/10-rdkafka.ini && \
echo "extension=rdkafka.so" > /etc/php/${PHP_VERSION}/fpm/conf.d/10-rdkafka.ini

COPY ./php/cli.ini /etc/php/${PHP_VERSION}/cli/conf.d/1-dev_cli.ini
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/1-dev_cli
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

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

CMD /usr/local/bin/entrypoint.sh
CMD ["/usr/local/bin/entrypoint.sh"]
2 changes: 1 addition & 1 deletion docker/bin/dev_entrypoiny.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

while true; do sleep 1; done
2 changes: 1 addition & 1 deletion docker/bin/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

# wait for service
# $1 host
Expand Down
18 changes: 9 additions & 9 deletions pkg/amqp-lib/Tests/AmqpContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,19 @@ public function testShouldPurgeQueue()
$context->purgeQueue($queue);
}

public function testShouldSetQos()
public function testShouldSetQos(): void
{
$invoked = $this->exactly(2);
$channel = $this->createChannelMock();
$channel
->expects($this->at(0))
->expects($invoked)
->method('basic_qos')
->with($this->identicalTo(0), $this->identicalTo(1), $this->isFalse())
;
$channel
->expects($this->at(1))
->method('basic_qos')
->with($this->identicalTo(123), $this->identicalTo(456), $this->isTrue())
;
->willReturnCallback(function ($prefetch_size, $prefetch_count, $a_global) use ($invoked) {
match ($invoked->getInvocationCount()) {
1 => $this->assertSame([0, 1, false], [$prefetch_size, $prefetch_count, $a_global]),
2 => $this->assertSame([123, 456, true], [$prefetch_size, $prefetch_count, $a_global]),
};
});

$connection = $this->createConnectionMock();
$connection
Expand Down
2 changes: 1 addition & 1 deletion pkg/enqueue/Client/DriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,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),
Expand Down
2 changes: 1 addition & 1 deletion pkg/enqueue/Symfony/Client/ConsumeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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), 0, $e);
}

$driver = $this->getDriver($client);
Expand Down
2 changes: 1 addition & 1 deletion pkg/enqueue/Symfony/Client/ProduceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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), 0, $e);
}

if ($topic) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/enqueue/Symfony/Client/RoutesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')), 0, $e);
}

$routes = $this->driver->getRouteCollection()->all();
Expand Down
2 changes: 1 addition & 1 deletion pkg/enqueue/Symfony/Client/SetupBrokerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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), 0, $e);
}

$output->writeln('Broker set up');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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), 0, $e);
}

$this->setQueueConsumerOptions($consumer, $input);
Expand Down
2 changes: 1 addition & 1 deletion pkg/enqueue/Symfony/Consumption/ConsumeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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), 0, $e);
}

$this->setQueueConsumerOptions($consumer, $input);
Expand Down
Loading
Loading