Skip to content

Commit

Permalink
Merge pull request #32 from acelaya-forks/feature/phpunit-11
Browse files Browse the repository at this point in the history
Remove infection and update to PHPUnit 11
  • Loading branch information
acelaya committed Feb 19, 2024
2 parents a43b380 + d999601 commit 0e7a1b9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 73 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ docker-compose.override.yml.dist export-ignore
docker-compose.yml export-ignore
Dockerfile export-ignore
indocker export-ignore
infection.json export-ignore
phpcs.xml export-ignore
phpunit.xml.dist export-ignore
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ on:
jobs:
ci:
uses: shlinkio/github-actions/.github/workflows/php-lib-ci.yml@main
secrets:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
with:
mutation-tests: false
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this

### Changed
* Update dependencies
* Update to PHPUnit 11

### Deprecated
* *Nothing*

### Removed
* *Nothing*
* Remove infection and mutation tests

### Fixed
* Remove support for swoole and openswoole
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![Build Status](https://img.shields.io/github/actions/workflow/status/shlinkio/shlink-config/ci.yml?branch=main&logo=github&style=flat-square)](https://github.com/shlinkio/shlink-config/actions/workflows/ci.yml?query=workflow%3A%22Continuous+integration%22)
[![Code Coverage](https://img.shields.io/codecov/c/gh/shlinkio/shlink-config/main?style=flat-square)](https://app.codecov.io/gh/shlinkio/shlink-config)
[![Infection MSI](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fshlinkio%2Fshlink-config%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/shlinkio/shlink-config/main)
[![Latest Stable Version](https://img.shields.io/github/release/shlinkio/shlink-config.svg?style=flat-square)](https://packagist.org/packages/shlinkio/shlink-config)
[![License](https://img.shields.io/github/license/shlinkio/shlink-config.svg?style=flat-square)](https://github.com/shlinkio/shlink-config/blob/main/LICENSE)
[![Paypal donate](https://img.shields.io/badge/Donate-paypal-blue.svg?style=flat-square&logo=paypal&colorA=aaaaaa)](https://slnk.to/donate)
Expand Down
28 changes: 6 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
},
"require-dev": {
"devster/ubench": "^2.1",
"infection/infection": "^0.27.9",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.5",
"phpunit/phpunit": "^11.0",
"psr/simple-cache": "^2.0",
"roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~2.3.0",
Expand All @@ -44,43 +43,28 @@
"ci": [
"@cs",
"@stan",
"@test:ci",
"@infect:ci"
"@test:ci"
],
"cs": "phpcs",
"cs:fix": "phpcbf",
"stan": "phpstan analyse src functions --level=8",
"test": "phpunit --order-by=random --testdox --colors=always",
"test:ci": "@test --coverage-clover=build/clover.xml --coverage-xml=build/coverage-xml --log-junit=build/junit.xml",
"test:pretty": "@test --coverage-html build/coverage-html",
"infect": "infection --threads=max --min-msi=85 --log-verbosity=default --only-covered",
"infect:ci": "@infect --coverage=build --skip-initial-tests",
"infect:show": "@infect --show-mutations",
"infect:show:ci": "@infect --show-mutations --coverage=build",
"test:infect": [
"@test:ci",
"@infect:show:ci"
]
"test:pretty": "@test --coverage-html build/coverage-html"
},
"scripts-descriptions": {
"ci": "<fg=blue;options=bold>Alias for \"cs\", \"stan\", \"test:ci\" and \"infect:ci\"</>",
"ci": "<fg=blue;options=bold>Alias for \"cs\", \"stan\" and \"test:ci\"</>",
"cs": "<fg=blue;options=bold>Checks coding styles</>",
"cs:fix": "<fg=blue;options=bold>Fixes coding styles, when possible</>",
"stan": "<fg=blue;options=bold>Inspects code with phpstan</>",
"test": "<fg=blue;options=bold>Runs unit tests with no coverage reports</>",
"test:ci": "<fg=blue;options=bold>Runs unit tests generating coverage reports and logs</>",
"test:pretty": "<fg=blue;options=bold>Runs unit tests generating coverage reports in html</>",
"test:infect": "<fg=blue;options=bold>Alias for \"test:ci\" and \"infect:show:ci\"</>",
"infect": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing</>",
"infect:ci": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing with existing reports and logs</>",
"infect:show": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing and shows applied mutators</>",
"infect:show:ci": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing with existing reports and logs and shows applied mutators</>"
"test:pretty": "<fg=blue;options=bold>Runs unit tests generating coverage reports in html</>"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"infection/extension-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
26 changes: 0 additions & 26 deletions infection.json5

This file was deleted.

32 changes: 12 additions & 20 deletions test/Factory/DottedAccessConfigAbstractFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\ServiceManager;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Config\Exception\InvalidArgumentException;
use Shlinkio\Shlink\Config\Factory\DottedAccessConfigAbstractFactory;
Expand All @@ -22,20 +22,16 @@ public function setUp(): void
$this->factory = new DottedAccessConfigAbstractFactory();
}

#[Test, DataProvider('provideDotNames')]
#[Test]
#[TestWith(data: ['foo.bar', true], name: 'valid service')]
#[TestWith(data: ['config.something', true], name: 'another valid service')]
#[TestWith(data: ['config_something', false], name: 'invalid service')]
#[TestWith(data: ['foo', false], name: 'another invalid service')]
public function canCreateOnlyServicesWithDot(string $serviceName, bool $canCreate): void
{
self::assertEquals($canCreate, $this->factory->canCreate(new ServiceManager(), $serviceName));
}

public static function provideDotNames(): iterable
{
yield 'with a valid service' => ['foo.bar', true];
yield 'with another valid service' => ['config.something', true];
yield 'with an invalid service' => ['config_something', false];
yield 'with another invalid service' => ['foo', false];
}

#[Test]
public function throwsExceptionWhenFirstPartOfTheServiceIsNotRegistered(): void
{
Expand All @@ -47,7 +43,12 @@ public function throwsExceptionWhenFirstPartOfTheServiceIsNotRegistered(): void
$this->factory->__invoke(new ServiceManager(), 'foo.bar');
}

#[Test, DataProvider('provideNonArrayValues')]
#[Test]
#[TestWith(data: ['string'], name: 'string')]
#[TestWith(data: [new stdClass()], name: 'object')]
#[TestWith(data: [true], name: 'true')]
#[TestWith(data: [false], name: 'false')]
#[TestWith(data: [100], name: 'number')]
public function throwsExceptionWhenFirstPartOfTheServiceDoesNotResultInAnArray(mixed $value): void
{
$this->expectException(ServiceNotCreatedException::class);
Expand All @@ -60,15 +61,6 @@ public function throwsExceptionWhenFirstPartOfTheServiceDoesNotResultInAnArray(m
]]), 'a.bar');
}

public static function provideNonArrayValues(): iterable
{
yield 'string' => ['string'];
yield 'object' => [new stdClass()];
yield 'true' => [true];
yield 'false' => [false];
yield 'number' => [100];
}

#[Test]
public function dottedNotationIsRecursivelyResolvedUntilLastValueIsFoundAndReturned(): void
{
Expand Down

0 comments on commit 0e7a1b9

Please sign in to comment.