diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e5bc08c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +ARG PHP_VERSION + +FROM php:${PHP_VERSION}-cli-alpine AS php + +WORKDIR /app + +RUN set -eux; \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + linux-headers \ + ; \ + \ + pecl install xdebug; \ + docker-php-ext-enable xdebug; \ + pecl clear-cache; \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --no-cache --virtual .app-phpexts-rundeps $runDeps; \ + \ + apk del .build-deps + + +# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser +ENV COMPOSER_ALLOW_SUPERUSER=1 +ENV PATH="${PATH}:/root/.composer/vendor/bin" + +COPY --from=composer/composer:2-bin --link /composer /usr/bin/composer diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..88d557f --- /dev/null +++ b/compose.yml @@ -0,0 +1,36 @@ +x-params: + - &common + environment: + XDEBUG_MODE: coverage + volumes: + - ./:/app + command: + - sh + - -c + - 'rm -f composer.lock && rm -rf tests/Bundle/App/var/cache && composer install && vendor/bin/simple-phpunit --coverage-text' + +# To run test just exec e.g. 'docker compose run --rm php8.1' +services: + php8.1: + build: + context: . + target: php + args: + PHP_VERSION: 8.1 + <<: *common + + php8.2: + build: + context: . + target: php + args: + PHP_VERSION: 8.2 + <<: *common + + php8.3: + build: + context: . + target: php + args: + PHP_VERSION: 8.3 + <<: *common diff --git a/composer.json b/composer.json index eb992f2..44d1330 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,13 @@ ], "require": { "php": ">=7.4", - "symfony/dependency-injection": "^4.4|^5.0|^6.0" + "symfony/dependency-injection": "^4.4|^5.0|^6.0|^7.0" }, "require-dev": { - "symfony/framework-bundle": "^4.4|^5.0|^6.0", - "symfony/phpunit-bridge": "^4.4|^5.0|^6.0", - "symfony/browser-kit": "^4.4|^5.0|^6.0", - "symfony/yaml": "^4.4|^5.0|^6.0" + "symfony/framework-bundle": "^4.4|^5.0|^6.0|^7.0", + "symfony/phpunit-bridge": "^4.4|^5.0|^6.0|^7.0", + "symfony/browser-kit": "^4.4|^5.0|^6.0|^7.0", + "symfony/yaml": "^4.4|^5.0|^6.0|^7.0" }, "autoload": { "psr-4": { "PrismaMedia\\Metrics\\": "src/" } diff --git a/tests/MetricAggregatorTest.php b/tests/MetricAggregatorTest.php index ecde6a4..2b49995 100644 --- a/tests/MetricAggregatorTest.php +++ b/tests/MetricAggregatorTest.php @@ -40,6 +40,6 @@ public function getMetrics(): iterable $metrics = $aggregator->getMetrics(); $this->assertInstanceOf(\Generator::class, $metrics); - $this->assertCount(3, $metrics); + $this->assertEquals(3, iterator_count($metrics)); } } diff --git a/tests/MetricLabellerTest.php b/tests/MetricLabellerTest.php index e4197bf..2cbc657 100644 --- a/tests/MetricLabellerTest.php +++ b/tests/MetricLabellerTest.php @@ -25,7 +25,7 @@ public function getMetrics(): \Traversable $labeller = new MetricLabeller($metrics, ['env' => 'staging']); $this->assertInstanceOf(\Generator::class, $labeller->getMetrics()); - $this->assertCount(3, $labeller->getMetrics()); + $this->assertEquals(3, iterator_count($labeller->getMetrics())); $metrics = iterator_to_array($labeller->getMetrics()); $this->assertSame('article_total', $metrics[0]->getName()); diff --git a/tests/allowed.json b/tests/allowed.json index cb78ad2..ebd6d09 100644 --- a/tests/allowed.json +++ b/tests/allowed.json @@ -3,5 +3,20 @@ "location": "PrismaMedia\\Metrics\\Tests\\Bundle\\FunctionalTest::testEndpointMetrics", "message": "Since symfony/framework-bundle 5.1: Not setting the \"framework.router.utf8\" configuration option is deprecated, it will default to \"true\" in version 6.0.", "count": 1 + }, + { + "location": "PrismaMedia\\Metrics\\Tests\\Bundle\\FunctionalTest::testEndpointMetrics", + "message": "Since symfony/framework-bundle 6.1: Not setting the \"framework.http_method_override\" config option is deprecated. It will default to \"false\" in 7.0.", + "count": 2 + }, + { + "location": "PrismaMedia\\Metrics\\Tests\\Bundle\\FunctionalTest::testEndpointMetrics", + "message": "Since symfony/framework-bundle 6.4: Not setting the \"framework.handle_all_throwables\" config option is deprecated. It will default to \"true\" in 7.0.", + "count": 2 + }, + { + "location": "PrismaMedia\\Metrics\\Tests\\Bundle\\FunctionalTest::testEndpointMetrics", + "message": "Since symfony/framework-bundle 6.4: Not setting the \"framework.php_errors.log\" config option is deprecated. It will default to \"true\" in 7.0.", + "count": 2 } -] \ No newline at end of file +]