Skip to content

Commit 8268ec8

Browse files
committed
Initial commit
0 parents  commit 8268ec8

26 files changed

Lines changed: 1227 additions & 0 deletions

‎.editorconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true

‎.gitattributes‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.github export-ignore
2+
/tests export-ignore
3+
/.editorconfig export-ignore
4+
/.gitattributes export-ignore
5+
/.gitignore export-ignore
6+
/.php-cs-fixer.dist.php export-ignore
7+
/phpstan.dist.neon export-ignore
8+
/phpstan-baseline.neon export-ignore
9+
/phpunit.dist.xml export-ignore

‎.github/dependabot.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'github-actions'
4+
directory: '/'
5+
target-branch: '1.x'
6+
schedule:
7+
interval: 'weekly'
8+
pull-request-branch-name:
9+
separator: '-'
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: '0 8 * * *'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
PHP_VERSION: '8.4'
16+
17+
jobs:
18+
composer:
19+
runs-on: ubuntu-latest
20+
name: Composer Validation
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v7
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ env.PHP_VERSION }}
29+
coverage: none
30+
31+
- name: Validate composer.json
32+
run: composer validate --strict
33+
34+
- name: Check for PSR Violations
35+
run: composer dump --optimize --strict-psr
36+
37+
php-cs-fixer:
38+
runs-on: ubuntu-latest
39+
name: Coding Standards
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v7
43+
44+
- name: Setup PHP
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: ${{ env.PHP_VERSION }}
48+
coverage: none
49+
tools: php-cs-fixer, cs2pr
50+
51+
- name: PHP Coding Standards Fixer
52+
run: php-cs-fixer fix --dry-run --format checkstyle | cs2pr
53+
54+
phpstan:
55+
runs-on: ubuntu-latest
56+
name: Static Analysis
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v7
60+
61+
- name: Setup PHP
62+
uses: shivammathur/setup-php@v2
63+
with:
64+
php-version: ${{ env.PHP_VERSION }}
65+
coverage: none
66+
tools: phpstan
67+
68+
- name: Install Dependencies
69+
uses: ramsey/composer-install@v4
70+
with:
71+
composer-options: '--prefer-dist'
72+
73+
- name: Run PHPStan
74+
run: phpstan analyse --no-progress

‎.github/workflows/tests.yaml‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: '0 8 * * *'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
phpunit:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
21+
phpunit: [ '10.5.27', '11.5', '12.5', '13.0', '13.1', '13.2' ]
22+
dependencies: [ 'highest', 'lowest' ]
23+
exclude:
24+
- php: '8.1'
25+
phpunit: '11.5'
26+
- php: '8.1'
27+
phpunit: '12.5'
28+
- php: '8.2'
29+
phpunit: '12.5'
30+
- php: '8.1'
31+
phpunit: '13.0'
32+
- php: '8.1'
33+
phpunit: '13.1'
34+
- php: '8.1'
35+
phpunit: '13.2'
36+
- php: '8.2'
37+
phpunit: '13.0'
38+
- php: '8.2'
39+
phpunit: '13.1'
40+
- php: '8.2'
41+
phpunit: '13.2'
42+
- php: '8.3'
43+
phpunit: '13.0'
44+
- php: '8.3'
45+
phpunit: '13.1'
46+
- php: '8.3'
47+
phpunit: '13.2'
48+
name: PHP ${{ matrix.php }} & PHPUnit ${{ matrix.phpunit }}${{ matrix.dependencies == 'lowest' && ' (lowest)' || '' }} Test
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v7
52+
53+
- name: Setup PHP
54+
uses: shivammathur/setup-php@v2
55+
with:
56+
php-version: ${{ matrix.php }}
57+
ini-values: zend.exception_ignore_args=false
58+
59+
- name: Require PHPUnit Version
60+
run: composer require --dev phpunit/phpunit:^${{ matrix.phpunit }} --no-update
61+
62+
- name: Adjust PHPUnit 10 Configuration
63+
if: matrix.phpunit == '10.5.27'
64+
run: |
65+
sed -i 's/failOnPhpunitDeprecation="true"//g' phpunit.dist.xml
66+
sed -i 's/failOnPhpunitNotice="true"//g' phpunit.dist.xml
67+
68+
- name: Adjust PHPUnit 11 Configuration
69+
if: matrix.phpunit == '11.5'
70+
run: sed -i 's/failOnPhpunitNotice="true"//g' phpunit.dist.xml
71+
72+
- name: Install Dependencies
73+
uses: ramsey/composer-install@v4
74+
with:
75+
composer-options: '--prefer-dist'
76+
dependency-versions: ${{ matrix.dependencies }}
77+
78+
- name: Run Tests
79+
run: vendor/bin/phpunit --log-junit=junit.xml --coverage-text --coverage-clover=coverage.xml
80+
81+
- name: Publish Test Report
82+
uses: mikepenz/action-junit-report@v6
83+
if: always()
84+
with:
85+
annotate_only: true
86+
fail_on_failure: true
87+
require_tests: true
88+
report_paths: ./junit.xml
89+
90+
- name: Upload Test Coverage
91+
if: ${{ success() }}
92+
uses: codecov/codecov-action@v7
93+
with:
94+
files: coverage.xml
95+
flags: ${{ matrix.php }}
96+
token: ${{ secrets.CODECOV_TOKEN }}

‎.gitignore‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Composer
2+
composer.lock
3+
vendor/
4+
5+
# PHP Coding Standards Fixer
6+
.php-cs-fixer.cache
7+
.php-cs-fixer.php
8+
9+
# PHPUnit
10+
.phpunit.cache
11+
phpunit.xml
12+
13+
# PHPStan
14+
phpstan.neon

‎.php-cs-fixer.dist.php‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Config\RuleCustomisationPolicyInterface;
6+
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
7+
8+
$finder = PhpCsFixer\Finder::create()
9+
->in(__DIR__)
10+
->append([__FILE__])
11+
;
12+
13+
return (new PhpCsFixer\Config())
14+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
15+
->setUsingCache(true)
16+
->setRules([
17+
'@PHP8x1Migration' => true,
18+
'@PHPUnit10x0Migration:risky' => true,
19+
'@Symfony' => true,
20+
'@Symfony:risky' => true,
21+
'attribute_empty_parentheses' => true,
22+
'declare_strict_types' => true,
23+
'heredoc_to_nowdoc' => true,
24+
'no_superfluous_phpdoc_tags' => true,
25+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
26+
'self_static_accessor' => true,
27+
'single_line_throw' => false,
28+
'trailing_comma_in_multiline' => [
29+
'after_heredoc' => true,
30+
'elements' => ['arguments', 'array_destructuring', 'arrays', 'match', 'parameters'],
31+
],
32+
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
33+
])
34+
->setRiskyAllowed(true)
35+
->setRuleCustomisationPolicy(new class implements RuleCustomisationPolicyInterface {
36+
public function getPolicyVersionForCache(): string
37+
{
38+
return hash_file('xxh128', __FILE__);
39+
}
40+
41+
public function getRuleCustomisers(): array
42+
{
43+
return [
44+
'native_function_invocation' => static function (SplFileInfo $file) {
45+
if (str_starts_with($file->getPathname(), __DIR__.'/src/')) {
46+
$fixer = new NativeFunctionInvocationFixer();
47+
$fixer->configure(['include' => ['@all']]);
48+
49+
return $fixer;
50+
}
51+
52+
return true;
53+
},
54+
];
55+
}
56+
})
57+
->setFinder($finder)
58+
;

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 HypeMC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Bizkit PHPUnit function mock
2+
3+
[![Latest Stable Version](https://poser.pugx.org/bizkit/phpunit-function-mock/v/stable)](https://packagist.org/packages/bizkit/phpunit-function-mock)
4+
[![Build Status](https://github.com/HypeMC/phpunit-function-mock/workflows/Tests/badge.svg)](https://github.com/HypeMC/phpunit-function-mock/actions)
5+
[![Code Coverage](https://codecov.io/gh/HypeMC/phpunit-function-mock/branch/1.x/graph/badge.svg)](https://codecov.io/gh/HypeMC/phpunit-function-mock)
6+
[![License](https://poser.pugx.org/bizkit/phpunit-function-mock/license)](https://packagist.org/packages/bizkit/phpunit-function-mock)
7+
8+
Provides a simple way to mock built-in PHP functions in PHPUnit tests.
9+
10+
## Versioning
11+
12+
This project adheres to [Semantic Versioning 2.0.0](http://semver.org/).
13+
14+
## Reporting issues
15+
16+
Use the [issue tracker](https://github.com/HypeMC/phpunit-function-mock/issues) to report any issues you might have.
17+
18+
## License
19+
20+
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).

‎composer.json‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "bizkit/phpunit-function-mock",
3+
"description": "Provides a simple way to mock built-in PHP functions in PHPUnit tests.",
4+
"type": "library",
5+
"keywords": [
6+
"phpunit",
7+
"phpunit extension",
8+
"testing",
9+
"mock",
10+
"mock functions",
11+
"monkey patching"
12+
],
13+
"homepage": "https://github.com/HypeMC/phpunit-function-mock",
14+
"license": "MIT",
15+
"authors": [
16+
{
17+
"name": "HypeMC",
18+
"email": "hypemc@gmail.com"
19+
}
20+
],
21+
"autoload": {
22+
"psr-4": {
23+
"Bizkit\\FunctionMock\\": "src/"
24+
}
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Bizkit\\FunctionMock\\Tests\\": "tests/"
29+
}
30+
},
31+
"require": {
32+
"php": ">=8.1"
33+
},
34+
"require-dev": {
35+
"phpunit/phpunit": "^10.5.27 || ^11.5 || ^12.5 || ^13"
36+
},
37+
"scripts": {
38+
"run-checks": [
39+
"php-cs-fixer fix -vvv",
40+
"phpunit",
41+
"phpstan analyse"
42+
]
43+
},
44+
"config": {
45+
"audit": {
46+
"block-insecure": false
47+
},
48+
"sort-packages": true
49+
}
50+
}

0 commit comments

Comments
 (0)