Skip to content
Merged
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
73 changes: 0 additions & 73 deletions .circleci/config.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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
ini-values: apc.enable_cli=1

- 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=100
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
echo "Coverage is $COVERAGE%, below ${THRESHOLD}% threshold"
exit 1
fi
echo "Coverage is $COVERAGE% (threshold: ${THRESHOLD}%)"
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
15 changes: 8 additions & 7 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
Expand All @@ -8,15 +9,15 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="test">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
3 changes: 2 additions & 1 deletion src/Provider/ConfigSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 11 additions & 0 deletions tests/ConfigProviderBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
19 changes: 19 additions & 0 deletions tests/IniConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down