Skip to content

Commit

Permalink
php 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Nov 27, 2023
1 parent 9e8b818 commit 9c24f3b
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 102 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
.idea/
.phpunit.result.cache
.phpunit.cache
.vscode/
build/
composer.lock
vendor/
vendor/
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
19 changes: 8 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand All @@ -30,7 +29,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.6-dev"
"dev-master": "1.7-dev"
}
},
"scripts": {
Expand All @@ -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"
},
Expand Down
39 changes: 15 additions & 24 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
executionOrder="random"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Integration">
<directory>./tests/Integration</directory>
</testsuite>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" executionOrder="random" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<testsuites>
<testsuite name="Integration">
<directory>./tests/Integration</directory>
</testsuite>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
3 changes: 1 addition & 2 deletions src/Argument/ArgumentCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ public function __construct(callable $callback)
}

/**
* @param mixed $argument
* @param array<mixed> $context
*/
public function assert($argument, array $context): void
public function assert(mixed $argument, array $context): void
{
($this->callback)($argument, $context);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Argument/ArgumentInstanceOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ public function __construct(string $class)
}

/**
* @param mixed $argument
* @param array<mixed> $context
*/
public function assert($argument, array $context): void
public function assert(mixed $argument, array $context): void
{
Assert::assertInstanceOf(
$this->class,
Expand Down
3 changes: 1 addition & 2 deletions src/Argument/ArgumentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
interface ArgumentInterface
{
/**
* @param mixed $argument
* @param array<mixed> $context
*/
public function assert($argument, array $context): void;
public function assert(mixed $argument, array $context): void;
}
10 changes: 2 additions & 8 deletions src/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ class Call

private bool $hasReturnCallback = false;

/**
* @var mixed
*/
private $return;
private mixed $return = null;

/**
* @var null|callable
Expand Down Expand Up @@ -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__));
Expand Down
4 changes: 1 addition & 3 deletions tests/Helper/AssertTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Chubbyphp\Tests\Mock\Helper;

trait AssertTrait
{
}
trait AssertTrait {}
2 changes: 1 addition & 1 deletion tests/Unit/Argument/ArgumentInstanceOfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);

Expand Down
42 changes: 12 additions & 30 deletions tests/Unit/MockByCallsTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);

Expand Down Expand Up @@ -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()
);

Expand All @@ -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.');
Expand All @@ -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()
);

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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);
}

0 comments on commit 9c24f3b

Please sign in to comment.