From 553353a1c6b8510448d74670ceec62f8b6fca1d7 Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 5 Feb 2026 12:42:59 +0000 Subject: [PATCH 1/4] drop version requirement back to 7.4 --- .circleci/config.yml | 73 ----------------------------------- .github/workflows/phpunit.yml | 45 +++++++++++++++++++++ composer.json | 4 +- phpunit.xml | 15 +++---- 4 files changed, 55 insertions(+), 82 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/phpunit.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 659b277..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,73 +0,0 @@ -defaults: &defaults - steps: - # common php steps - - run: echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories - - run: if [ -n "$ADD_PACKAGES" ]; then apk -U add $ADD_PACKAGES; fi; - - run: if [ -n "$ADD_MODULES" ]; then docker-php-ext-install $ADD_MODULES; fi; - - run: | - if [ -n "$ADD_PECL" ]; then - docker-php-source extract \ - && apk add --no-cache --virtual .phpize-deps-configure $PHPIZE_DEPS $ADD_PHPIZE_DEPS \ - && printf "\n" | pecl install $ADD_PECL \ - && docker-php-ext-enable $(echo $ADD_PECL | sed -E 's/-[0-9]+(\.[0-9]+)*//g') \ - && apk del .phpize-deps-configure \ - && docker-php-source delete - fi; - - run: echo "date.timezone = UTC" >> $(php --ini |grep Scan |awk '{print $NF}')/timezone.ini - - run: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer - - # pre-checkout steps - - # checkout - - checkout - - # post-checkout steps - - # run tests - - run: composer install -n --prefer-dist - - run: php -d apc.enable_cli=on vendor/phpunit/phpunit/phpunit -c phpunit.xml --log-junit /tmp/test-results/phpunit/junit.xml - - store_test_results: - path: /tmp/test-results - -version: 2 -jobs: - build-php80: - <<: *defaults - docker: - - image: php:8.0-alpine - environment: - ADD_PECL: "apcu" - build-php81: - <<: *defaults - docker: - - image: php:8.1-alpine - environment: - ADD_PECL: "apcu" - build-php82: - <<: *defaults - docker: - - image: php:8.2-alpine - environment: - ADD_PECL: "apcu" - build-php83: - <<: *defaults - docker: - - image: php:8.3-alpine - environment: - ADD_PECL: "apcu" - build-php84: - <<: *defaults - docker: - - image: php:8.4-alpine - environment: - ADD_PECL: "apcu" - -workflows: - version: 2 - build: - jobs: - - build-php80 - - build-php81 - - build-php82 - - build-php83 - - build-php84 diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..cd21113 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,45 @@ +name: PHPUnit + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] + + name: PHP ${{ matrix.php }} + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: bcmath + coverage: xdebug + + - name: Install dependencies + run: composer install --no-interaction --prefer-dist --no-progress + + - name: Run PHPUnit + run: vendor/bin/phpunit --coverage-text=coverage.txt + + - name: Check coverage + run: | + cat coverage.txt + COVERAGE=$(grep -A3 'Summary:' coverage.txt | grep 'Lines:' | grep -oP '\d+\.\d+(?=%)') + THRESHOLD=98 + if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then + echo "Coverage is $COVERAGE%, below ${THRESHOLD}% threshold" + exit 1 + fi + echo "Coverage is $COVERAGE% (threshold: ${THRESHOLD}%)" diff --git a/composer.json b/composer.json index a2aad03..015b6b7 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,13 @@ } ], "require": { - "php": ">=8.0" + "php": ">=7.4" }, "suggest": { "ext-apcu": "*" }, "require-dev": { - "phpunit/phpunit": "^8" + "phpunit/phpunit": "~9" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index f1016a2..564f4ce 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,6 @@ - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + src + + tests - - - src - - From e5783cff8abb677e1a1432b19fa951f3118d0cb3 Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 5 Feb 2026 12:47:00 +0000 Subject: [PATCH 2/4] replace mixed return with ReturnTypeWillChange annotation --- src/Provider/ConfigSection.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Provider/ConfigSection.php b/src/Provider/ConfigSection.php index fa4eeb7..7529f65 100644 --- a/src/Provider/ConfigSection.php +++ b/src/Provider/ConfigSection.php @@ -169,7 +169,8 @@ public function offsetExists($offset): bool * * @return mixed Can return all value types. */ - public function offsetGet($offset): mixed + #[\ReturnTypeWillChange] + public function offsetGet($offset) { return $this->getItem($offset); } From 8c6844ecae07c8b275c43920c0dfc4cb6094aaec Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 5 Feb 2026 12:52:26 +0000 Subject: [PATCH 3/4] enable apc in cli --- .github/workflows/phpunit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index cd21113..a5ffd5e 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -26,6 +26,7 @@ jobs: php-version: ${{ matrix.php }} extensions: bcmath coverage: xdebug + ini-values: apc.enable_cli=1 - name: Install dependencies run: composer install --no-interaction --prefer-dist --no-progress From 571e83f3db812178017313ffd8307dff0494f27d Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 5 Feb 2026 12:57:02 +0000 Subject: [PATCH 4/4] increase coverage --- .github/workflows/phpunit.yml | 2 +- tests/ConfigProviderBaseTest.php | 11 +++++++++++ tests/IniConfigProviderTest.php | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index a5ffd5e..3891bba 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -38,7 +38,7 @@ jobs: run: | cat coverage.txt COVERAGE=$(grep -A3 'Summary:' coverage.txt | grep 'Lines:' | grep -oP '\d+\.\d+(?=%)') - THRESHOLD=98 + THRESHOLD=100 if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then echo "Coverage is $COVERAGE%, below ${THRESHOLD}% threshold" exit 1 diff --git a/tests/ConfigProviderBaseTest.php b/tests/ConfigProviderBaseTest.php index 9466a99..2c7f5fd 100644 --- a/tests/ConfigProviderBaseTest.php +++ b/tests/ConfigProviderBaseTest.php @@ -165,6 +165,17 @@ public function testMissingSectionThrows() $provider->getSection("database"); } + /** + * @depends testValidProvider + */ + public function testMissingSectionNoThrow() + { + $provider = $this->getConfigProvider(); + $section = $provider->getSection("missing", false); + $this->assertInstanceOf(ConfigSection::class, $section); + $this->assertEquals("missing", $section->getName()); + } + /** * @depends testValidProvider */ diff --git a/tests/IniConfigProviderTest.php b/tests/IniConfigProviderTest.php index 63ea035..9a2c2a2 100644 --- a/tests/IniConfigProviderTest.php +++ b/tests/IniConfigProviderTest.php @@ -50,6 +50,25 @@ public function testLoadFiles() $this->assertEquals("value2", $provider->getItem("default", "item2")); } + public function testLoadFilesMissingFileSilent() + { + $file = __DIR__ . '/testData/test.ini'; + $missing = __DIR__ . '/testData/missing.file'; + $provider = $this->getConfigProvider(); + $provider->loadFiles([$missing, $file]); + $this->assertEquals("packaged", $provider->getItem("database", "database")); + } + + public function testLoadFilesMissingFileThrows() + { + $file = __DIR__ . '/testData/test.ini'; + $missing = __DIR__ . '/testData/missing.file'; + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage("Config file '$missing' could not be found"); + $provider = $this->getConfigProvider(); + $provider->loadFiles([$missing, $file], false, true); + } + public function testLoadFileConstruct() { $file = __DIR__ . '/testData/test.ini';