Skip to content

Commit e9e9743

Browse files
authored
Merge pull request #1393 from paulbalandan/cleanup-phpunit
chore: cleanup phpunit
2 parents c990c3a + 053b49c commit e9e9743

8 files changed

Lines changed: 42 additions & 56 deletions

File tree

‎.gitattributes‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/mkdocs.yml export-ignore
1313
/phpstan-baseline.php export-ignore
1414
/phpstan.neon.dist export-ignore
15-
/phpunit.xml.dist export-ignore
15+
/phpunit.dist.xml export-ignore
1616
/pyrameter.php export-ignore
1717
/psalm_autoload.php export-ignore
1818
/psalm-baseline.xml export-ignore

‎.github/workflows/phpunit-lang.yml‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
paths:
88
- 'src/Language/**.php'
99
- '!src/Language/en/**.php'
10-
- 'phpunit*'
10+
- 'phpunit.dist.xml'
1111
- '.github/workflows/phpunit-lang.yml'
1212
- 'tests/Language/AbstractTranslationTestCase.php'
1313
push:
@@ -16,7 +16,7 @@ on:
1616
paths:
1717
- 'src/Language/**.php'
1818
- '!src/Language/en/**.php'
19-
- 'phpunit*'
19+
- 'phpunit.dist.xml'
2020
- '.github/workflows/phpunit-lang.yml'
2121
- 'tests/Language/AbstractTranslationTestCase.php'
2222

@@ -29,37 +29,35 @@ jobs:
2929
steps:
3030
- name: Checkout
3131
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32+
with:
33+
persist-credentials: false
3234

3335
- name: Set up PHP
3436
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
3537
with:
3638
php-version: '8.2'
37-
tools: composer, phive, phpunit
38-
extensions: intl, json, mbstring, gd, xdebug, xml, sqlite3
39-
coverage: xdebug
39+
coverage: none
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4242

4343
- name: Get composer cache directory
44-
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV
44+
id: composer-cache
45+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
4546

4647
- name: Cache composer dependencies
4748
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
4849
with:
49-
path: ${{ env.COMPOSER_CACHE_FILES_DIR }}
50-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
51-
restore-keys: ${{ runner.os }}-composer-
50+
path: ${{ steps.composer-cache.outputs.dir }}
51+
key: composer-8.2-${{ hashFiles('**/composer.json') }}
52+
restore-keys: |
53+
composer-8.2-
54+
composer-
5255
5356
- name: Install dependencies
54-
run: |
55-
if [ -f composer.lock ]; then
56-
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
57-
else
58-
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
59-
fi
57+
run: composer update --ansi
6058

6159
- name: Test with PHPUnit
62-
run: vendor/bin/phpunit --no-coverage --testsuite lang
60+
run: vendor/bin/phpunit --no-coverage tests/Language
6361
env:
6462
TERM: xterm-256color
6563
TACHYCARDIA_MONITOR_GA: enabled

‎.github/workflows/phpunit-lowest.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ on:
66
- develop
77
paths:
88
- '**.php'
9-
- 'composer.*'
10-
- 'phpunit*'
9+
- 'composer.json'
10+
- 'phpunit.dist.xml'
1111
- '.github/workflows/phpunit-lowest.yml'
1212
push:
1313
branches:
1414
- develop
1515
paths:
1616
- '**.php'
17-
- 'composer.*'
18-
- 'phpunit*'
17+
- 'composer.json'
18+
- 'phpunit.dist.xml'
1919
- '.github/workflows/phpunit-lowest.yml'
2020

2121
jobs:

‎.github/workflows/phpunit.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ on:
66
- develop
77
paths:
88
- '**.php'
9-
- 'composer.*'
10-
- 'phpunit*'
9+
- 'composer.json'
10+
- 'phpunit.dist.xml'
1111
- '.github/workflows/phpunit.yml'
1212
push:
1313
branches:
1414
- develop
1515
paths:
1616
- '**.php'
17-
- 'composer.*'
18-
- 'phpunit*'
17+
- 'composer.json'
18+
- 'phpunit.dist.xml'
1919
- '.github/workflows/phpunit.yml'
2020

2121
jobs:

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ nb-configuration.xml
106106
.vscode/
107107

108108
/results/
109-
/phpunit*.xml
109+
/phpunit.xml
110110
/.phpunit.*.cache
111111

112112
/.php-cs-fixer.php

‎composer.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
"infection/extension-installer": true,
6969
"phpstan/extension-installer": true
7070
},
71+
"preferred-install": "dist",
72+
"optimize-autoloader": true,
7173
"sort-packages": true
7274
},
7375
"scripts": {

‎docs/references/testing.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class ActionsTest extends TestCase
3838

3939
By default, Shield has set the `Config\Auth::$hashCost = 12` due to the greater security of passwords. However, to increase the test execution time, we have set the `$hashCost = 4` for the test environment.
4040

41-
If you use Shield in your project and your tests execution time is high, just set the `$hashCost = 4` in file **phpunit.xml.dist** of your project as follows:
41+
If you use Shield in your project and your tests execution time is high, just set the `$hashCost = 4` in file **phpunit.dist.xml** of your project as follows:
4242

4343
```
4444
<php>
4545
<!-- Set hashCost for improving the speed of running tests -->
4646
<env name="auth.hashCost" value="4"/>
4747
</php>
48-
```
48+
```
Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php"
5-
backupGlobals="false"
65
beStrictAboutOutputDuringTests="true"
76
colors="true"
7+
columns="max"
88
executionOrder="random"
99
failOnRisky="true"
1010
failOnWarning="true"
11-
stopOnError="false"
12-
stopOnFailure="false"
13-
stopOnIncomplete="false"
14-
stopOnSkipped="false"
1511
cacheDirectory="build/.phpunit.cache"
16-
beStrictAboutCoverageMetadata="true">
12+
beStrictAboutCoverageMetadata="true"
13+
>
14+
<source>
15+
<include>
16+
<directory suffix=".php">./src/</directory>
17+
</include>
18+
<exclude>
19+
<directory suffix=".php">./src/Config</directory>
20+
<directory suffix=".php">./src/Views</directory>
21+
<directory suffix=".php">./src/Language</directory>
22+
</exclude>
23+
</source>
1724
<coverage includeUncoveredFiles="true">
1825
<report>
1926
<clover outputFile="build/phpunit/clover.xml"/>
20-
<html outputDirectory="build/phpunit/html"/>
21-
<php outputFile="build/phpunit/coverage.serialized"/>
22-
<text outputFile="php://stdout" showUncoveredFiles="false"/>
23-
<xml outputDirectory="build/phpunit/xml-coverage"/>
2427
</report>
2528
</coverage>
2629
<testsuites>
@@ -36,11 +39,6 @@
3639
</bootstrap>
3740
<bootstrap class="Boundwize\Pyrameter\Extension"/>
3841
</extensions>
39-
<logging>
40-
<testdoxHtml outputFile="build/phpunit/testdox.html"/>
41-
<testdoxText outputFile="build/phpunit/testdox.txt"/>
42-
<junit outputFile="build/phpunit/junit.xml"/>
43-
</logging>
4442
<php>
4543
<env name="XDEBUG_MODE" value="coverage"/>
4644
<!-- Set hashCost for improving the speed of running tests -->
@@ -52,8 +50,6 @@
5250
<const name="CONFIGPATH" value="vendor/codeigniter4/framework/app/Config/"/>
5351
<!-- Directory containing the front controller (index.php) -->
5452
<const name="PUBLICPATH" value="./public/"/>
55-
<!-- https://getcomposer.org/xdebug -->
56-
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
5753
<!-- Default HMAC encryption key -->
5854
<env name="authtoken.hmacEncryptionKeys" value="{&quot;k1&quot;:{&quot;key&quot;:&quot;hex2bin:178ed94fd0b6d57dd31dd6b22fc601fab8ad191efac165a5f3f30a8ac09d813d&quot;},&quot;k2&quot;:{&quot;key&quot;:&quot;hex2bin:b0ab85bd0320824c496db2f40eb47c8712a6dfcfdf99b805988e22bdea6b9203&quot;}}"/>
5955
<!-- Database configuration -->
@@ -67,14 +63,4 @@
6763
<env name="database.tests.DBPrefix" value="db_"/>
6864
-->
6965
</php>
70-
<source>
71-
<include>
72-
<directory suffix=".php">./src/</directory>
73-
</include>
74-
<exclude>
75-
<directory suffix=".php">./src/Config</directory>
76-
<directory suffix=".php">./src/Views</directory>
77-
<directory suffix=".php">./src/Language</directory>
78-
</exclude>
79-
</source>
8066
</phpunit>

0 commit comments

Comments
 (0)