Skip to content

Commit 7447ace

Browse files
developerstudservisn.gnato
andauthored
Disable useless phpunit doc block additions (#1)
* Disable useless phpunit doc block additions * Configure github actions, add phpunit test, configure gitattributes * Add phpunit version with php 7.4 support --------- Co-authored-by: n.gnato <[email protected]>
1 parent a2b0468 commit 7447ace

File tree

7 files changed

+103
-0
lines changed

7 files changed

+103
-0
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.gitignore export-ignore
2+
/.github export-ignore
3+
/tests export-ignore
4+
/phpunit.xml export-ignore

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on: push
4+
5+
jobs:
6+
php-tests:
7+
8+
strategy:
9+
matrix:
10+
php:
11+
- 7.4
12+
- 8.0
13+
- 8.1
14+
- 8.2
15+
- 8.3
16+
prefer:
17+
- lowest
18+
- stable
19+
20+
name: Test on PHP ${{ matrix.php }} with ${{ matrix.prefer }} composer prefer option
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout Code
25+
uses: actions/checkout@v4
26+
27+
- name: Install PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: ${{ matrix.php }}
31+
32+
- name: Check PHP Version
33+
run: php -v
34+
35+
- name: Cache Composer packages
36+
id: composer-cache
37+
uses: actions/cache@v4
38+
with:
39+
path: vendor
40+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.prefer }}-
41+
restore-keys: |
42+
${{ runner.os }}-php-${{ matrix.php }}-composer-${{ matrix.prefer }}-
43+
44+
- name: Install dependencies
45+
if: steps.composer-cache.outputs.cache-hit != 'true'
46+
run: composer update --prefer-${{ matrix.prefer }} --prefer-dist --no-progress
47+
48+
- name: Run tests
49+
run: vendor/bin/phpunit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/.idea/
22
/vendor/
3+
4+
/.phpunit.cache
35
/composer.lock

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
"files": [
1616
"./src/config_builder.php"
1717
]
18+
},
19+
"require-dev": {
20+
"phpunit/phpunit": "^9.6 | ^10.5"
1821
}
1922
}

phpunit.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
executionOrder="depends,defects"
7+
requireCoverageMetadata="false"
8+
beStrictAboutCoverageMetadata="true"
9+
beStrictAboutOutputDuringTests="true"
10+
failOnRisky="true"
11+
failOnWarning="true">
12+
<testsuites>
13+
<testsuite name="default">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
18+
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
19+
<include>
20+
<directory>src</directory>
21+
</include>
22+
</source>
23+
</phpunit>

src/rules.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
'no_break_comment' => false,
4040
'no_superfluous_phpdoc_tags' => true,
4141
'nullable_type_declaration_for_default_null_value' => true,
42+
43+
'php_unit_test_class_requires_covers' => false,
44+
'php_unit_internal_class' => false,
45+
4246
'ordered_class_elements' => ['order' => [
4347
'use_trait',
4448
'case',

tests/config_builderTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace StudService\PhpCsFixerTests;
4+
5+
use PhpCsFixer\Finder;
6+
use PHPUnit\Framework\TestCase;
7+
use function StudService\PhpCsFixer\build_config;
8+
9+
class config_builderTest extends TestCase
10+
{
11+
public function test_build_config()
12+
{
13+
$config = build_config(new Finder());
14+
15+
$this->assertFalse($config->getRiskyAllowed());
16+
$this->assertSame("\n", $config->getLineEnding());
17+
}
18+
}

0 commit comments

Comments
 (0)