diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 282ff32..c07380f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,36 +6,36 @@ on: - cron: '0 0 * * *' jobs: - php80: - name: PHP 8.0 - runs-on: ubuntu-20.04 + php81: + name: PHP 8.1 + runs-on: ubuntu-22.04 steps: - name: checkout uses: actions/checkout@v3 - name: composer test - uses: docker://chubbyphp/ci-php80:latest + uses: docker://chubbyphp/ci-php81:latest env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - php81: - name: PHP 8.1 - runs-on: ubuntu-20.04 + php82: + name: PHP 8.2 + runs-on: ubuntu-22.04 steps: - name: checkout uses: actions/checkout@v3 - name: composer test - uses: docker://chubbyphp/ci-php81:latest + uses: docker://chubbyphp/ci-php82:latest env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - php82: - name: PHP 8.2 - runs-on: ubuntu-20.04 + php83: + name: PHP 8.3 + runs-on: ubuntu-22.04 steps: - name: checkout uses: actions/checkout@v3 - name: composer test - uses: docker://chubbyphp/ci-php82:latest + uses: docker://chubbyphp/ci-php83:latest env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} diff --git a/.gitignore b/.gitignore index 3de0a96..91ca7d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .DS_Store .idea/ -.phpunit.result.cache +.phpunit.cache .vscode/ build/ composer.lock -vendor/ \ No newline at end of file +vendor/ diff --git a/README.md b/README.md index 2543fa1..5329b2e 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ [![CI](https://github.com/chubbyphp/chubbyphp-mock/workflows/CI/badge.svg?branch=master)](https://github.com/chubbyphp/chubbyphp-mock/actions?query=workflow%3ACI) [![Coverage Status](https://coveralls.io/repos/github/chubbyphp/chubbyphp-mock/badge.svg?branch=master)](https://coveralls.io/github/chubbyphp/chubbyphp-mock?branch=master) -[![Infection MSI](https://badge.stryker-mutator.io/github.com/chubbyphp/chubbyphp-mock/master)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/chubbyphp-mock/master) -[![Latest Stable Version](https://poser.pugx.org/chubbyphp/chubbyphp-mock/v/stable.png)](https://packagist.org/packages/chubbyphp/chubbyphp-mock) +[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fchubbyphp%2Fchubbyphp-mock%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/chubbyphp-mock/master)[![Latest Stable Version](https://poser.pugx.org/chubbyphp/chubbyphp-mock/v/stable.png)](https://packagist.org/packages/chubbyphp/chubbyphp-mock) [![Total Downloads](https://poser.pugx.org/chubbyphp/chubbyphp-mock/downloads.png)](https://packagist.org/packages/chubbyphp/chubbyphp-mock) [![Monthly Downloads](https://poser.pugx.org/chubbyphp/chubbyphp-mock/d/monthly)](https://packagist.org/packages/chubbyphp/chubbyphp-mock) @@ -25,15 +24,15 @@ A helper trait simplify mocking within phpunit. ## Requirements - * php: ^8.0 - * phpunit/phpunit: ^9.5 + * php: ^8.1 + * phpunit/phpunit: ^10.4.2 ## Installation Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-mock][1]. ```sh -composer require chubbyphp/chubbyphp-mock "^1.6" --dev +composer require chubbyphp/chubbyphp-mock "^1.7" --dev ``` ## Usage diff --git a/composer.json b/composer.json index 9ad3956..a37f036 100644 --- a/composer.json +++ b/composer.json @@ -10,17 +10,16 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "ext-json": "*", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^10.4.2" }, "require-dev": { "chubbyphp/chubbyphp-dev-helper": "dev-master", - "infection/infection": "^0.26.5", - "php-coveralls/php-coveralls": "^2.5.2", - "phploc/phploc": "^7.0.2", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.4.8" + "infection/infection": "^0.27.8", + "php-coveralls/php-coveralls": "^2.7.0", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^1.10.45" }, "autoload": { "psr-4": { "Chubbyphp\\Mock\\": "src/" } @@ -30,7 +29,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.7-dev" } }, "scripts": { @@ -41,14 +40,12 @@ "@test:integration", "@test:infection", "@test:static-analysis", - "@test:loc", "@test:cs" ], "test:cs": "mkdir -p build && PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --cache-file=build/phpcs.cache", - "test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=86 --verbose --coverage=build/phpunit", + "test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=87 --verbose --coverage=build/phpunit", "test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-result-file=build/phpunit/result.cache", "test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log", - "test:loc": "mkdir -p build && vendor/bin/phploc src | tee build/phploc.log", "test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=8 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'", "test:unit": "vendor/bin/phpunit --testsuite=Unit --coverage-text --coverage-clover=build/phpunit/clover.xml --coverage-html=build/phpunit/coverage-html --coverage-xml=build/phpunit/coverage-xml --log-junit=build/phpunit/junit.xml --cache-result-file=build/phpunit/result.cache" }, diff --git a/phpunit.xml b/phpunit.xml index 4ea36f1..3e4616e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,26 +1,17 @@ - - - - ./src - - - - - ./tests/Integration - - - ./tests/Unit - - + + + + + ./tests/Integration + + + ./tests/Unit + + + + + ./src + + diff --git a/src/Argument/ArgumentCallback.php b/src/Argument/ArgumentCallback.php index 28a65b2..050917f 100644 --- a/src/Argument/ArgumentCallback.php +++ b/src/Argument/ArgumentCallback.php @@ -17,10 +17,9 @@ public function __construct(callable $callback) } /** - * @param mixed $argument * @param array $context */ - public function assert($argument, array $context): void + public function assert(mixed $argument, array $context): void { ($this->callback)($argument, $context); } diff --git a/src/Argument/ArgumentInstanceOf.php b/src/Argument/ArgumentInstanceOf.php index 90af768..a4c1455 100644 --- a/src/Argument/ArgumentInstanceOf.php +++ b/src/Argument/ArgumentInstanceOf.php @@ -16,10 +16,9 @@ public function __construct(string $class) } /** - * @param mixed $argument * @param array $context */ - public function assert($argument, array $context): void + public function assert(mixed $argument, array $context): void { Assert::assertInstanceOf( $this->class, diff --git a/src/Argument/ArgumentInterface.php b/src/Argument/ArgumentInterface.php index ba3c330..4828ff6 100644 --- a/src/Argument/ArgumentInterface.php +++ b/src/Argument/ArgumentInterface.php @@ -7,8 +7,7 @@ interface ArgumentInterface { /** - * @param mixed $argument * @param array $context */ - public function assert($argument, array $context): void; + public function assert(mixed $argument, array $context): void; } diff --git a/src/Call.php b/src/Call.php index ca5de3a..b94beae 100644 --- a/src/Call.php +++ b/src/Call.php @@ -28,10 +28,7 @@ class Call private bool $hasReturnCallback = false; - /** - * @var mixed - */ - private $return; + private mixed $return = null; /** * @var null|callable @@ -97,10 +94,7 @@ public function willReturnSelf(): self return $this; } - /** - * @param mixed $return - */ - public function willReturn($return): self + public function willReturn(mixed $return): self { if (null !== $this->exception) { throw new \InvalidArgumentException(sprintf(self::ALREADY_A_EXCEPTION, __METHOD__)); diff --git a/tests/Helper/AssertTrait.php b/tests/Helper/AssertTrait.php index 758260e..b306a50 100644 --- a/tests/Helper/AssertTrait.php +++ b/tests/Helper/AssertTrait.php @@ -4,6 +4,4 @@ namespace Chubbyphp\Tests\Mock\Helper; -trait AssertTrait -{ -} +trait AssertTrait {} diff --git a/tests/Unit/Argument/ArgumentInstanceOfTest.php b/tests/Unit/Argument/ArgumentInstanceOfTest.php index c421c2d..b16b1ba 100644 --- a/tests/Unit/Argument/ArgumentInstanceOfTest.php +++ b/tests/Unit/Argument/ArgumentInstanceOfTest.php @@ -36,7 +36,7 @@ public function testAssertFail(): void } catch (ExpectationFailedException $e) { self::assertSame( 'Method "method" on class "class" at call 0, argument 0'.PHP_EOL. - 'Failed asserting that DateTimeImmutable Object (...) is an instance of class "stdClass".', + 'Failed asserting that an object is an instance of class stdClass.', $e->getMessage() ); diff --git a/tests/Unit/MockByCallsTraitTest.php b/tests/Unit/MockByCallsTraitTest.php index 8e86588..79fbcfe 100644 --- a/tests/Unit/MockByCallsTraitTest.php +++ b/tests/Unit/MockByCallsTraitTest.php @@ -58,7 +58,7 @@ public function testInterfaceWithInvalidCallUsingArgumentInterface(): void } catch (ExpectationFailedException $e) { self::assertSame( 'Method "sample" on class "Chubbyphp\Tests\Mock\Unit\SampleInterface" at call 0, argument 0'.PHP_EOL. - 'Failed asserting that DateTimeImmutable Object (...) is an instance of class "stdClass".', + 'Failed asserting that an object is an instance of class stdClass.', $e->getMessage() ); @@ -143,8 +143,8 @@ public function testInterfaceWithToManyCalls(): void $invocation->verify(); } catch (ExpectationFailedException $e) { self::assertSame( - 'Expectation failed for method name is anything when invoked 0 time(s).'.PHP_EOL. - 'Method was expected to be called 0 times, actually called 1 times.'.PHP_EOL, + 'Expectation failed for method name is anything when invoked 0 times.'.PHP_EOL. + 'Method was expected to be called 0 times, actually called 1 time.'.PHP_EOL, $e->getMessage() ); @@ -155,7 +155,7 @@ public function testInterfaceWithToManyCalls(): void return; } - self::fail('Expectation failed for method name is anything when invoked 0 time(s).'); + self::fail('Expectation failed for method name is anything when invoked 0 times.'); } self::fail('Chubbyphp\Tests\Mock\Unit\SampleInterface::sample(\'argument1\', true) was not expected to be called.'); @@ -177,8 +177,8 @@ public function testInterfaceWithToLessCalls(): void $invocation->verify(); } catch (ExpectationFailedException $e) { self::assertSame( - 'Expectation failed for method name is anything when invoked 2 time(s).'.PHP_EOL. - 'Method was expected to be called 2 times, actually called 1 times.'.PHP_EOL, + 'Expectation failed for method name is anything when invoked 2 times.'.PHP_EOL. + 'Method was expected to be called 2 times, actually called 1 time.'.PHP_EOL, $e->getMessage() ); @@ -189,7 +189,7 @@ public function testInterfaceWithToLessCalls(): void return; } - self::fail('Expectation failed for method name is anything when invoked 2 time(s).'); + self::fail('Expectation failed for method name is anything when invoked 2 times.'); } public function testInterfaceWithWrongCall(): void @@ -234,16 +234,9 @@ public function __clone() TestCase::fail('Clone should be mocked'); } - /** - * @param mixed $argument1 - */ - public function sample($argument1, bool $argument2 = true): void - { - } + public function sample(mixed $argument1, bool $argument2 = true): void {} - public function dotNotProxy(): void - { - } + public function dotNotProxy(): void {} } abstract class AbstractSampleClass implements SampleInterface @@ -258,26 +251,15 @@ public function __clone() TestCase::fail('Clone should be mocked'); } - /** - * @param mixed $argument1 - */ - public function sample($argument1, bool $argument2 = true): void - { - } + public function sample(mixed $argument1, bool $argument2 = true): void {} } interface SampleInterface { - /** - * @param mixed $argument1 - */ - public function sample($argument1, bool $argument2 = true); + public function sample(mixed $argument1, bool $argument2 = true); } interface AdditionalSampleInterface { - /** - * @param mixed $argument1 - */ - public function additionalSample($argument1, bool $argument2 = true); + public function additionalSample(mixed $argument1, bool $argument2 = true); }