Compare commits

...

22 Commits

Author SHA1 Message Date
nuno maduro 159514bace release: 5.3.4 2026-10-27 11:04:36 +00:00
cyppe 415419a251 fix(tia): preserve numeric table dependencies across graph round trips (#1990)
Co-authored-by: nuno maduro <enunomaduro@gmail.com>
2026-10-27 10:39:18 +00:00
Owen Voke 0a2d08ebe9 ci: add PHP 8.6 (#1989) 2026-10-27 10:34:49 +00:00
wadakatu a7566152fd fix: bump PHPUnit to 13.4.5 for GHSA-9vw2-f4vp-x7gf (#1995) 2026-10-27 10:34:19 +00:00
Tiago Santos 7abf68e706 fix: allow --init without a tests directory (#1939)
* fix: allow --init without a tests directory

Boot aborted before TIA state was registered, and shutdown then
tried to construct the plugin. That hid the real error behind
"State cannot be resolved" on a fresh install.

Closes #1934

* fix: detect --init anywhere in the arguments

Flags before --init were still treated as a normal run and failed when tests/ did not exist.

* fix: drop duplicate Kernel::$booted and share --init check

5.3.1 already gates plugin termination on boot, so the rebase must
not declare $booted again. --init and --init=value now share
HandleArguments::hasArgument, and the success snapshot includes
the new init tests.

* test: fix init suite expectations

Parallel total omitted the four --init tests, which
failed the success snapshot. Rector requires toBeFile().

---------

Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
2026-10-26 16:21:56 +05:30
Paul Sochiera f730a186ce test(shard): cover module test classes outside the tests directory (#1689)
* test(shard): cover module test classes outside the tests directory

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore: refresh the snapshot counts

---------

Co-authored-by: Paul Sochiera <paul.sochiera@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
2026-10-26 00:01:09 +05:30
Owen Voke d534cb2c40 fix: avoid passing an object when invoking static methods via reflection (#1988)
* fix: avoid passing an object when invoking static methods via reflection

PHP 8.6 deprecates passing an object to `ReflectionMethod::invoke()` for
static methods, which breaks higher-order assertions such as
`it('...')->assertTrue(true)` since `Assert::assertTrue()` is static.

* test: update visual snapshots for new reflection tests
2026-10-23 22:05:56 +05:30
Gustavo Meireles 1b3ca5ba41 feat: restore coversNothing() (#1981) 2026-10-18 21:53:51 +01:00
nuno maduro c947def97e release: 5.3.3 2026-10-18 12:51:10 +01:00
nuno maduro 3e5a2410b7 fix: phpunit classes not being inlcuded on sharding 2026-10-18 12:28:03 +01:00
Pushpak Chhajed e9fa0f50c5 perf: O(1) test method lookup 2026-10-16 22:20:38 +05:30
Pushpak Chhajed b6dddcc821 perf: stop spawning stty for every test when output is not a TTY 2026-10-16 22:20:30 +05:30
Muhammed Alkhudiry 3a5a14b6a6 fix: reduce parallel worker polling interval to 1 ms (#1967)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 22:19:33 +05:30
nuno maduro 73fe04f8c3 fix: support with paratest 2026-10-12 21:28:57 +04:00
Punyapal Shah 5b98dc7df2 fix(sharding): prevent shard filters from matching classes outside their partition (#1884)
* fix(sharding): prevent shard filters from matching classes outside their partition

* lint

* test: update snapshots for the shard filter boundary cases
2026-10-12 00:09:04 +05:30
Punyapal Shah 68b4c9176d ci: bump shivammathur/setup-php to 2.40.0 for PHP 8.5 on macos-latest (#1961)
* fix: support brianium/paratest 7.26.1 worker tmp dir

paratest 7.26.1 added a required $tmpDir argument to WrapperWorker and
keeps worker files in a private per-run directory. Create that 0700
directory per run, pass it to each worker and remove it on completion.
Require paratest ^7.26.1.

* ci: bump shivammathur/setup-php to 2.40.0 for PHP 8.5 on macos-latest

---------

Co-authored-by: ExeQue <mmh@harders-it.dk>
2026-10-11 22:43:11 +05:30
Morten Harders 5f3d0f2124 fix: support brianium/paratest 7.26.1 worker tmp dir (#1959)
paratest 7.26.1 added a required $tmpDir argument to WrapperWorker and
keeps worker files in a private per-run directory. Create that 0700
directory per run, pass it to each worker and remove it on completion.
Require paratest ^7.26.1.
2026-10-11 22:42:40 +05:30
nuno maduro 83baa5de2f chore: bumps 2026-10-08 00:11:43 +04:00
nuno maduro 0a2a6e9f0f chore: bumps 2026-10-08 00:02:48 +04:00
nuno maduro 9714c8553f release: 5.3.1 2026-10-07 23:02:36 +04:00
nuno maduro 14a3efd918 release: 5.3.0 2026-10-01 17:58:48 +01:00
Daniel Polito 8b6607e344 fix(tia): reuse baselines across replacement CI merge commits (#1923)
* perf(tia): reuse baselines across replacement CI merge commits

* style: apply Rector rules to merge baseline validation
2026-09-18 14:30:59 +05:30
43 changed files with 1094 additions and 462 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: 8.4
tools: composer:v2
@@ -44,7 +44,7 @@ jobs:
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: static-php-8.4-${{ matrix.dependency-version }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
+3 -3
View File
@@ -25,7 +25,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest] # windows-latest
symfony: ['8.0']
php: ['8.4', '8.5']
php: ['8.4', '8.5', '8.6']
dependency_version: [prefer-stable]
name: PHP ${{ matrix.php }} - Symfony ^${{ matrix.symfony }} - ${{ matrix.os }} - ${{ matrix.dependency_version }}
@@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: ${{ matrix.php }}
tools: composer:v2
@@ -48,7 +48,7 @@ jobs:
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
+106 -30
View File
@@ -1,34 +1,110 @@
8fee50af5e8d9ff55db278de9701b10e11dfef6eecfc4127f2608c85f0f0fdd1 .agents/skills/code-immutability/SKILL.md
d489e18e5863e814795f5674a58f507e98fbbeb341a218dbd5bc9173d39554d3 .agents/skills/code-immutability/agents/openai.yaml
0c47a67a1bcb590b057984fa4e9c4704fb3485652864f3e5ac6a3ba8200e74f4 .agents/skills/code-messages/SKILL.md
fc01d0c81e189623e6e7c912498f46f63f489bbe59967cccde742ea2c4e31b5a .agents/skills/code-messages/agents/openai.yaml
3d39b47c159c0bbdc413781afe12cdb9fcad4086d4810a6c11dfd0c909d90e81 .agents/skills/code-quality/SKILL.md
f47191e1bad34e547d1b3ee3ae111c417c383ec5459d467bfae5e832d86275c9 .agents/skills/code-quality/agents/openai.yaml
9d5e921bdfa05ef955657d59702e79a83b44853c075d513793bb76a7f479004f .agents/skills/code-slop/SKILL.md
520a3834948850bf7e2232d92341f07ff7bfc9e67247818b56fb576ca6dbf169 .agents/skills/code-slop/agents/openai.yaml
2f9d68ed1b93eb74bc1c23cad34a88b765bd0ab306faacab1105d9489ede8ad1 .agents/skills/code-tooling/SKILL.md
868c67118e15aa9eb8f4ee35228fc2d04b1c0cf129ee3fec9177113a77f5863e .agents/skills/code-tooling/agents/openai.yaml
5df241fc65e271c93d13708f868f9a624669bcfc06b3d84af9cf6fce03a25558 .agents/skills/deps-upgrade/SKILL.md
984c7232ae1681ebba980ede2a0543db9a850dd2406990cdfa011384f929e981 .agents/skills/deps-upgrade/agents/openai.yaml
275df9900027499c1ab97ab2675b2992e4267559bd61933a637d6a15d25a9350 .agents/skills/init/SKILL.md
14ea76cbc5a8f35356ccf6aa20beddb249c6bc4aeb9999ec722c3acf92389d57 .agents/skills/init/agents/openai.yaml
bd51565d7579df2154cd0bc19634e3b63937a115a4629066c0273d91b65ebc12 .agents/skills/rules-code-boundaries/SKILL.md
bfc54327927d453c85ed1ff8bdad1a622daf2e40c8dd42a45674acb8c470a0ab .agents/skills/rules-code-boundaries/agents/openai.yaml
82c83eefaa2b66a46f82a9aab8e9175b2798958e2fe4ac3db961d938d2fe3b24 .agents/skills/rules-code-data-integrity/SKILL.md
0ad49f243c9d68d8ae27e62b2ab7a18f407941dcbbea2cb1424f66304aa67d94 .agents/skills/rules-code-data-integrity/agents/openai.yaml
82b351872a511b58b631eacf67ad08bde769d424579270f784976782371d17f5 .agents/skills/rules-code-error-messages/SKILL.md
dd97fbf09609c58ba5eaf56929b0efbde1cc0afde879b8e3f1176796d4ada4c8 .agents/skills/rules-code-error-messages/agents/openai.yaml
997d223fd8a3cc178b307c451b91be0d65300511290df4836683786048c62d63 .agents/skills/rules-code-immutability/SKILL.md
2da047ed8e2c2077f92fe7e6f4306815279068cbc1ddec32f2432c0053da7473 .agents/skills/rules-code-immutability/agents/openai.yaml
eb2f772945c71be4f6e5c016bb748e1970e9f94373159533bbe60ea63fe00989 .agents/skills/rules-code-migrations/SKILL.md
dcee7ce6b9f4a323862afe331c4f83d1f79ea8b95498774a80dbcf9b47bd8655 .agents/skills/rules-code-migrations/agents/openai.yaml
13a18cab02aab5df43b3ec1deec9d6c2a5de130bd090d9a042feb667df513e57 .agents/skills/rules-code-modules/SKILL.md
a8b603bc89ff861bac1be959c857048f196b54df459dec23e355d68fd1b2a0b6 .agents/skills/rules-code-modules/agents/openai.yaml
52d00eb81180dadea878a8578e0ae743055f9ed31e17b52035d35deb918801b2 .agents/skills/rules-code-public-api/SKILL.md
48ec566cc39d2a88c5240404fbb9243162994a08adfdb7e682fed2a3c45a4195 .agents/skills/rules-code-public-api/agents/openai.yaml
514e0021f91d7d8624d1bce754ccff83e1f4ab3709549d8f85684ed98a7500e7 .agents/skills/rules-code-queries/SKILL.md
21d8709328aa899e26750b3ba33ee2461af25815f7be6e4451eae405f6342b6d .agents/skills/rules-code-queries/agents/openai.yaml
44bda34c653a04d9d63f717091c944380ff6fa7f092daaab9000d68ccbb341e2 .agents/skills/rules-code-security/SKILL.md
5b1c1ad9cf5b0866ed62160d5ca7428b8acfd820ac4fd1998035f23c75d8c0c2 .agents/skills/rules-code-security/agents/openai.yaml
af3e08e12e21cb7e8940f31cff0f1fdad6c5ba84762b81e17f7fa88e0433371f .agents/skills/rules-code-tests/SKILL.md
2a2ab6138b8e6b361d910d7af836dfd2cd9b279eb7977f07e6c0126afa11a1e9 .agents/skills/rules-code-tests/agents/openai.yaml
6adfd8df3877b41e48c6dccc77c2ca1f8df80b8f67e6d0587589f402b57cc52e .agents/skills/rules-code-tooling/SKILL.md
dcd0d7595edf1445d2cc66d1af4a89d4158193927911e7c793860083893241cd .agents/skills/rules-code-tooling/agents/openai.yaml
1a77293439ff9598f6bc65c3fd3df222cb9dd1f30051a70c3d3553e9f61f828a .agents/skills/rules-code-type-safety/SKILL.md
ab6716ecbb2b9e9531a166623a73efe87452e3a51b054bba1290e3640730d647 .agents/skills/rules-code-type-safety/agents/openai.yaml
a64c6dfa8a2c23c2f0b8aaeea824a5903375ab4495d1f1baffc37995d4b4849a .agents/skills/rules-code-without-slop/SKILL.md
d6cb4df200554a2cce76b81a54ee3f3227882bdcc2844bf5d918639ba5f864ee .agents/skills/rules-code-without-slop/agents/openai.yaml
66f6ff39f51853dafef4e4caf333cea661801294e29ae70ddc1988e77c1c2bd0 .agents/skills/rules-git-commits/SKILL.md
c13a17096ff7c6ad4d8c49d68281ab694df7c984e29d50a5f19a8bda533de4eb .agents/skills/rules-git-commits/agents/openai.yaml
3f7f77275ada85b55ed874cea8ada94ad6f838800311f46ecb2a31b68ae95ac7 .agents/skills/snapshots-update/SKILL.md
bb5339d7abcaba163a384a00a9ba8607ddf8b6820a63be3570e9b6fc6a912479 .agents/skills/snapshots-update/agents/openai.yaml
8fee50af5e8d9ff55db278de9701b10e11dfef6eecfc4127f2608c85f0f0fdd1 .claude/skills/code-immutability/SKILL.md
d489e18e5863e814795f5674a58f507e98fbbeb341a218dbd5bc9173d39554d3 .claude/skills/code-immutability/agents/openai.yaml
0c47a67a1bcb590b057984fa4e9c4704fb3485652864f3e5ac6a3ba8200e74f4 .claude/skills/code-messages/SKILL.md
fc01d0c81e189623e6e7c912498f46f63f489bbe59967cccde742ea2c4e31b5a .claude/skills/code-messages/agents/openai.yaml
3d39b47c159c0bbdc413781afe12cdb9fcad4086d4810a6c11dfd0c909d90e81 .claude/skills/code-quality/SKILL.md
f47191e1bad34e547d1b3ee3ae111c417c383ec5459d467bfae5e832d86275c9 .claude/skills/code-quality/agents/openai.yaml
9d5e921bdfa05ef955657d59702e79a83b44853c075d513793bb76a7f479004f .claude/skills/code-slop/SKILL.md
520a3834948850bf7e2232d92341f07ff7bfc9e67247818b56fb576ca6dbf169 .claude/skills/code-slop/agents/openai.yaml
2f9d68ed1b93eb74bc1c23cad34a88b765bd0ab306faacab1105d9489ede8ad1 .claude/skills/code-tooling/SKILL.md
868c67118e15aa9eb8f4ee35228fc2d04b1c0cf129ee3fec9177113a77f5863e .claude/skills/code-tooling/agents/openai.yaml
5df241fc65e271c93d13708f868f9a624669bcfc06b3d84af9cf6fce03a25558 .claude/skills/deps-upgrade/SKILL.md
984c7232ae1681ebba980ede2a0543db9a850dd2406990cdfa011384f929e981 .claude/skills/deps-upgrade/agents/openai.yaml
275df9900027499c1ab97ab2675b2992e4267559bd61933a637d6a15d25a9350 .claude/skills/init/SKILL.md
14ea76cbc5a8f35356ccf6aa20beddb249c6bc4aeb9999ec722c3acf92389d57 .claude/skills/init/agents/openai.yaml
eb6cb534bc7adead5175e457dbc690164f27862ba834b25dea76e8bca3fb2b22 .agents/skills/task-code-architecture/SKILL.md
912d856661e4eb8f0880c26b9d45b8bbdbe104ceb1a307e7ee7a9c574a1bac0a .agents/skills/task-code-architecture/agents/openai.yaml
a6c6ce5c2eff237d6578084af88ac0f52ca15dbc1fab91dd9097d9fd1fd46147 .agents/skills/task-code-bug/SKILL.md
6c1798aaebe3e7f7da194100354fe9faa5f83bf02a019a1b54e0fb598f09aff1 .agents/skills/task-code-bug/agents/openai.yaml
fb52abffb5de2165977237f0f55202da13403436259a6f2d093b89af3b43e2c1 .agents/skills/task-code-feature/SKILL.md
87bdc9a650a6c2d2765eea4e2507d148d9e6e4459dea079ecbeb495ffdb285f7 .agents/skills/task-code-feature/agents/openai.yaml
13a5580b308cfe3567b674fc2299159dec29338cb67c22aa51c668d36ce776b3 .agents/skills/task-code-plan/SKILL.md
e4fb9575774792251f3b99bab5f3621b9f6b83556fa04599100d3c096a08c8d4 .agents/skills/task-code-plan/agents/openai.yaml
c6404f7b7e8015b0374e1cf79e6068924d203352b5c70826ed7010e1189ca0ae .agents/skills/task-code-review/SKILL.md
d6cf11faa9dc588a50d4e5750bcbc683415f256357edabd30fb3161cb53d2365 .agents/skills/task-code-review/agents/openai.yaml
fe3f29bbad3932841fb88e7bfeb7d7f2a40f4df65289ae367a333bea339424c3 .agents/skills/task-issues-triage/SKILL.md
d87c9bc10b0abe2eac366e015ca6de8abac8f5f014929ecc4a8bf27d46379c30 .agents/skills/task-issues-triage/agents/openai.yaml
bfd908de525dee564d73e84b2cc9e663d8d2bc453156785826a0a24c226c8043 .agents/skills/task-project-glossary/SKILL.md
a3f3d3e9ef2e150a3dbcd2315683dfc10d5640aeb2af42d2ba759cf31f58bdc8 .agents/skills/task-project-glossary/agents/openai.yaml
93ade39e9bc9595a24bf4ad773f9b427e09c4e3c233135fe903e82fc8d77a381 .agents/skills/task-project-health/SKILL.md
1c5997b7f3eac5b3fa64afcafe9ef2bef50194b74347b4a3a36eba8aaa43884c .agents/skills/task-project-health/agents/openai.yaml
0a40dcc178d0998fcdb1b6d6ece8b12125cad06c3459270c87e63483a93ab1e0 .agents/skills/task-project-init/SKILL.md
253f9d1183e8ff1fd84e0136ea70844187d731ab2504f7f679ecf337f83893c8 .agents/skills/task-project-init/agents/openai.yaml
c77ebaea9b3f9d9833cb306013e71f6bd83172166944a1f0c9840bb33fe4e4e4 .agents/skills/task-project-retro/SKILL.md
0ad86d84ff56e56603816b0e7d9d04067c99482a5e442b88b05c781743b8b618 .agents/skills/task-project-retro/agents/openai.yaml
bd09f10f3bd0f284b59747c37c7879ab19ffb3603ec9b6f3c7401a5e8c128835 .agents/skills/task-pulls-triage/SKILL.md
0ecb81c140c37bba372f0033c8bf388ad976c1a7cf095a62af9e57c4ce46857a .agents/skills/task-pulls-triage/agents/openai.yaml
1304d3bb730aa0af55a7713337567b6c7412c84cf530199c4383228e01f89b41 .agents/skills/task-session-handoff/SKILL.md
fbd41d31c150dea316d189a8f5973d3d5abbd769cb22217b8cd6646061477bac .agents/skills/task-session-handoff/agents/openai.yaml
bd51565d7579df2154cd0bc19634e3b63937a115a4629066c0273d91b65ebc12 .claude/skills/rules-code-boundaries/SKILL.md
bfc54327927d453c85ed1ff8bdad1a622daf2e40c8dd42a45674acb8c470a0ab .claude/skills/rules-code-boundaries/agents/openai.yaml
82c83eefaa2b66a46f82a9aab8e9175b2798958e2fe4ac3db961d938d2fe3b24 .claude/skills/rules-code-data-integrity/SKILL.md
0ad49f243c9d68d8ae27e62b2ab7a18f407941dcbbea2cb1424f66304aa67d94 .claude/skills/rules-code-data-integrity/agents/openai.yaml
82b351872a511b58b631eacf67ad08bde769d424579270f784976782371d17f5 .claude/skills/rules-code-error-messages/SKILL.md
dd97fbf09609c58ba5eaf56929b0efbde1cc0afde879b8e3f1176796d4ada4c8 .claude/skills/rules-code-error-messages/agents/openai.yaml
997d223fd8a3cc178b307c451b91be0d65300511290df4836683786048c62d63 .claude/skills/rules-code-immutability/SKILL.md
2da047ed8e2c2077f92fe7e6f4306815279068cbc1ddec32f2432c0053da7473 .claude/skills/rules-code-immutability/agents/openai.yaml
eb2f772945c71be4f6e5c016bb748e1970e9f94373159533bbe60ea63fe00989 .claude/skills/rules-code-migrations/SKILL.md
dcee7ce6b9f4a323862afe331c4f83d1f79ea8b95498774a80dbcf9b47bd8655 .claude/skills/rules-code-migrations/agents/openai.yaml
13a18cab02aab5df43b3ec1deec9d6c2a5de130bd090d9a042feb667df513e57 .claude/skills/rules-code-modules/SKILL.md
a8b603bc89ff861bac1be959c857048f196b54df459dec23e355d68fd1b2a0b6 .claude/skills/rules-code-modules/agents/openai.yaml
52d00eb81180dadea878a8578e0ae743055f9ed31e17b52035d35deb918801b2 .claude/skills/rules-code-public-api/SKILL.md
48ec566cc39d2a88c5240404fbb9243162994a08adfdb7e682fed2a3c45a4195 .claude/skills/rules-code-public-api/agents/openai.yaml
514e0021f91d7d8624d1bce754ccff83e1f4ab3709549d8f85684ed98a7500e7 .claude/skills/rules-code-queries/SKILL.md
21d8709328aa899e26750b3ba33ee2461af25815f7be6e4451eae405f6342b6d .claude/skills/rules-code-queries/agents/openai.yaml
44bda34c653a04d9d63f717091c944380ff6fa7f092daaab9000d68ccbb341e2 .claude/skills/rules-code-security/SKILL.md
5b1c1ad9cf5b0866ed62160d5ca7428b8acfd820ac4fd1998035f23c75d8c0c2 .claude/skills/rules-code-security/agents/openai.yaml
af3e08e12e21cb7e8940f31cff0f1fdad6c5ba84762b81e17f7fa88e0433371f .claude/skills/rules-code-tests/SKILL.md
2a2ab6138b8e6b361d910d7af836dfd2cd9b279eb7977f07e6c0126afa11a1e9 .claude/skills/rules-code-tests/agents/openai.yaml
6adfd8df3877b41e48c6dccc77c2ca1f8df80b8f67e6d0587589f402b57cc52e .claude/skills/rules-code-tooling/SKILL.md
dcd0d7595edf1445d2cc66d1af4a89d4158193927911e7c793860083893241cd .claude/skills/rules-code-tooling/agents/openai.yaml
1a77293439ff9598f6bc65c3fd3df222cb9dd1f30051a70c3d3553e9f61f828a .claude/skills/rules-code-type-safety/SKILL.md
ab6716ecbb2b9e9531a166623a73efe87452e3a51b054bba1290e3640730d647 .claude/skills/rules-code-type-safety/agents/openai.yaml
a64c6dfa8a2c23c2f0b8aaeea824a5903375ab4495d1f1baffc37995d4b4849a .claude/skills/rules-code-without-slop/SKILL.md
d6cb4df200554a2cce76b81a54ee3f3227882bdcc2844bf5d918639ba5f864ee .claude/skills/rules-code-without-slop/agents/openai.yaml
66f6ff39f51853dafef4e4caf333cea661801294e29ae70ddc1988e77c1c2bd0 .claude/skills/rules-git-commits/SKILL.md
c13a17096ff7c6ad4d8c49d68281ab694df7c984e29d50a5f19a8bda533de4eb .claude/skills/rules-git-commits/agents/openai.yaml
3f7f77275ada85b55ed874cea8ada94ad6f838800311f46ecb2a31b68ae95ac7 .claude/skills/snapshots-update/SKILL.md
bb5339d7abcaba163a384a00a9ba8607ddf8b6820a63be3570e9b6fc6a912479 .claude/skills/snapshots-update/agents/openai.yaml
d1e4a22c7e3b8b833d873b139d331d85fb9f5247818911b35082ae9a8f6edf9f AGENTS.md
336cc4fbf19beaada7ccf9986414fa91851a8d7a07dfb3ccbe800a69eed0ab49 CLAUDE.md
eb6cb534bc7adead5175e457dbc690164f27862ba834b25dea76e8bca3fb2b22 .claude/skills/task-code-architecture/SKILL.md
912d856661e4eb8f0880c26b9d45b8bbdbe104ceb1a307e7ee7a9c574a1bac0a .claude/skills/task-code-architecture/agents/openai.yaml
a6c6ce5c2eff237d6578084af88ac0f52ca15dbc1fab91dd9097d9fd1fd46147 .claude/skills/task-code-bug/SKILL.md
6c1798aaebe3e7f7da194100354fe9faa5f83bf02a019a1b54e0fb598f09aff1 .claude/skills/task-code-bug/agents/openai.yaml
fb52abffb5de2165977237f0f55202da13403436259a6f2d093b89af3b43e2c1 .claude/skills/task-code-feature/SKILL.md
87bdc9a650a6c2d2765eea4e2507d148d9e6e4459dea079ecbeb495ffdb285f7 .claude/skills/task-code-feature/agents/openai.yaml
13a5580b308cfe3567b674fc2299159dec29338cb67c22aa51c668d36ce776b3 .claude/skills/task-code-plan/SKILL.md
e4fb9575774792251f3b99bab5f3621b9f6b83556fa04599100d3c096a08c8d4 .claude/skills/task-code-plan/agents/openai.yaml
c6404f7b7e8015b0374e1cf79e6068924d203352b5c70826ed7010e1189ca0ae .claude/skills/task-code-review/SKILL.md
d6cf11faa9dc588a50d4e5750bcbc683415f256357edabd30fb3161cb53d2365 .claude/skills/task-code-review/agents/openai.yaml
fe3f29bbad3932841fb88e7bfeb7d7f2a40f4df65289ae367a333bea339424c3 .claude/skills/task-issues-triage/SKILL.md
d87c9bc10b0abe2eac366e015ca6de8abac8f5f014929ecc4a8bf27d46379c30 .claude/skills/task-issues-triage/agents/openai.yaml
bfd908de525dee564d73e84b2cc9e663d8d2bc453156785826a0a24c226c8043 .claude/skills/task-project-glossary/SKILL.md
a3f3d3e9ef2e150a3dbcd2315683dfc10d5640aeb2af42d2ba759cf31f58bdc8 .claude/skills/task-project-glossary/agents/openai.yaml
93ade39e9bc9595a24bf4ad773f9b427e09c4e3c233135fe903e82fc8d77a381 .claude/skills/task-project-health/SKILL.md
1c5997b7f3eac5b3fa64afcafe9ef2bef50194b74347b4a3a36eba8aaa43884c .claude/skills/task-project-health/agents/openai.yaml
0a40dcc178d0998fcdb1b6d6ece8b12125cad06c3459270c87e63483a93ab1e0 .claude/skills/task-project-init/SKILL.md
253f9d1183e8ff1fd84e0136ea70844187d731ab2504f7f679ecf337f83893c8 .claude/skills/task-project-init/agents/openai.yaml
c77ebaea9b3f9d9833cb306013e71f6bd83172166944a1f0c9840bb33fe4e4e4 .claude/skills/task-project-retro/SKILL.md
0ad86d84ff56e56603816b0e7d9d04067c99482a5e442b88b05c781743b8b618 .claude/skills/task-project-retro/agents/openai.yaml
bd09f10f3bd0f284b59747c37c7879ab19ffb3603ec9b6f3c7401a5e8c128835 .claude/skills/task-pulls-triage/SKILL.md
0ecb81c140c37bba372f0033c8bf388ad976c1a7cf095a62af9e57c4ce46857a .claude/skills/task-pulls-triage/agents/openai.yaml
1304d3bb730aa0af55a7713337567b6c7412c84cf530199c4383228e01f89b41 .claude/skills/task-session-handoff/SKILL.md
fbd41d31c150dea316d189a8f5973d3d5abbd769cb22217b8cd6646061477bac .claude/skills/task-session-handoff/agents/openai.yaml
bc65941b8bd587c4d6cc695adafd876afbe95941ebc10e1750f8801bbc5b8856 AGENTS.md
e3979fac270270eacf852d47848cbaab874c0934732e1888d4b63b9adcf745c8 CLAUDE.md
+32 -4
View File
@@ -2,7 +2,7 @@
Read `.hod/PROJECT.md` first. It holds the intention of this project.
`hod` writes this file. Write no sentence in it, because `hod update` writes it again. Write the intention of the project in `.hod/PROJECT.md`. Write a rule in a file in `.hod/rules/`. Write a skill in a directory in `.hod/skills/`.
`hod` writes this file. Write no sentence in it, because `hod update` writes it again. Write the intention of the project in `.hod/PROJECT.md`. Write a rule in the form of section 2. Write a skill in a directory in `.hod/skills/`.
---
@@ -30,9 +30,15 @@ A fact that you learned during one task is not a rule. Use it in that task, then
`.hod/PROJECT.md` holds two items: the intention of the project, and a reason that the code cannot hold. Write no sentence below that level.
Read `.hod/PROJECT.md` again before you finish a change. Correct each sentence that your change made wrong, and delete each sentence that the project no longer obeys. Add a fact of your change only when each agent needs it at the start of each task, such as the command that starts the program. Keep the file short, because each agent reads it in each session.
Write no sentence for a fact that an agent finds when it reads the code. The cost of that read does not change the answer: a fact that four files hold is in the code. Put the fact in the code first, because a test stops the agent that breaks it and a sentence here does not.
Ask the user before you write a rule. Give the fault, and write the rule after the user agrees. Give the file the path `.hod/rules/<name>.md`. Give `<name>` two or three words with a hyphen between them, and name the subject of the rule. Give the file `name` and `description` in its front matter, and write one rule in one file. Run `hod update --project` after the write, thus this file names the rule in section 6. Keep the number of the rules: delete a rule file in the same change, or ask the user to accept one more rule. A correction from the user is a rule and needs no question: write it in a file before you continue the work.
Ask the user before you write a rule. Give the fault, and write the rule after the user agrees. Give the file the path `.hod/rules/<name>.md`. Give `<name>` two or three words with a hyphen between them, and name the subject of the rule. Give the file `name` and `description` in its front matter, and write one rule in one file. Run `hod update --project` after the write, thus this file names the rule in section 7. Keep the number of the rules: delete a rule file in the same change, or ask the user to accept one more rule. A correction from the user is a rule and needs no question: write it in a file before you continue the work.
When the project holds `boost.json`, write each rule with the MCP tool `record-rule` of Laravel Boost instead of a file in `.hod/rules/`. That tool writes the rule in `.ai/rules/`, and the guidelines of Boost in this file tell each agent to read that directory. Obey each other sentence of the paragraph above.
When the user asks you to learn or to remember a fact, treat the request as a correction: write the fact as a rule in the form of this section. Write no fact into the memory directory of Claude Code or of a different client, and read no fact from that directory, because a file outside the project reaches no other client and no other computer.
Give no new part of the program its own rule, because the code of that part holds its design. Delete text that follows the order of a file of source code: that text describes the file, and the file describes itself. Replace an old rule. Do not write a second rule near it. Delete a rule that the project does not obey. Do not keep a record of what the project stopped doing, in a file or in a directory. Git holds the history.
@@ -56,11 +62,13 @@ Obey three limits. Do not promise a feature that does not exist today. Do not gi
These rules control each file of source code and each manifest in this repository. Sections 1, 2 and 3 do not control these files.
Write no comment. Delete each comment that you find in a file that you change. Turn off the lint that asks for a documentation comment, because that lint asks you to say the name of an item again.
Before you write code, call the Skill tool with "rules-code-without-slop". Before you write code, call the Skill tool with "rules-code-type-safety". Before you write an entry point or change one, such as a controller, a component that a page calls, a command or a job, call the Skill tool with "rules-code-boundaries". Before you write a test or change a behavior, call the Skill tool with "rules-code-tests". Before you write code that writes to a database, call the Skill tool with "rules-code-data-integrity". Before you finish a change, call the Skill tool with "rules-code-tooling". Read the description of each other skill of this project, and call the Skill tool with each skill whose description names a decision of your change or a framework, a library or a tool that your change uses.
Write no comment. Delete each comment in a line that you write or change. An annotation that gives a type that the signature cannot hold, such as `@param list<string> $names` in PHP, is part of the type and not a comment. Turn off the lint that asks for a documentation comment, because that lint asks you to say the name of an item again.
Put the intention in the code. Give each item a name that says what the item does. Give each value a type that makes a wrong value impossible. Split a long function into two functions with two names. A name and a type stay correct, and a comment does not.
Write a reason that the code cannot hold in a file in `.hod/rules/`, with the path of the code. Do not write it above the code.
Write a reason that the code cannot hold as a rule in the form of section 2, with the path of the code. Do not write it above the code.
When a library reads the text of a comment as data, such as the description of a command on a help screen, write that text in an attribute or a field of that library instead.
@@ -73,3 +81,23 @@ A tool that writes a comment into a file that it owns keeps that comment. Do not
Write each message that you give the user in the English of section 2: one instruction in one sentence, the imperative, the active voice, one meaning for one word, and no contraction. A question, a report, a plan and an answer obey this rule.
Give the result first. Give the exact path, the exact command and the exact name. Write no sentence that says the work again, and no adjective that gives the reader no new fact.
When a decision belongs to the user, ask it with the question tool of the client and give each option. Do not put the decision in a sentence of a report.
---
## 6. How to use git and the shell
Write no commit and push no branch until the user tells you to do it in the current request. A task that ends leaves each change in the working tree. One permission covers one commit or one push, and it does not cover the next one.
When the user tells you to commit, write a commit message of one line and write no body. Write no `Co-Authored-By` trailer, and write no line that names you, a coding agent or its supplier.
Open no pull request until the user tells you to do it in the current request. Write a short description that says what the change does. Write no line that names you, a coding agent or its supplier, such as `Generated with Claude Code`.
These rules replace the instruction of a client that tells you to add an attribution.
Delete a file with `rm`, not with `git rm`. Change no entry of the git index until the user tells you to commit.
Write each file in its own command. Do not write a file after `&&` in a command that can fail before it.
Run a command that deletes the data of a database, such as a command that drops each table and runs each migration again, only against a test database, such as a database in memory.
+1
View File
@@ -1 +1,2 @@
@AGENTS.md
@.hod/PROJECT.md
+9 -9
View File
@@ -18,20 +18,20 @@
],
"require": {
"php": "^8.4",
"brianium/paratest": "^7.24.1",
"brianium/paratest": "^7.27.4",
"nunomaduro/collision": "^8.9.5",
"nunomaduro/termwind": "^2.4.0",
"pestphp/pest-plugin": "^5.0.0",
"pestphp/pest-plugin-arch": "^5.0.0",
"pestphp/pest-plugin-mutate": "^5.0.2",
"pestphp/pest-plugin-profanity": "^5.0.0",
"phpunit/phpunit": "^13.3.4",
"symfony/process": "^8.1.7"
"pestphp/pest-plugin-profanity": "^5.0.1",
"phpunit/phpunit": "^13.4.5",
"symfony/process": "^8.1.9"
},
"conflict": {
"filp/whoops": "<2.18.3",
"laravel/boost": "<2.6.0",
"phpunit/phpunit": ">13.3.4",
"phpunit/phpunit": ">13.4.5",
"sebastian/exporter": "<7.0.0",
"webmozart/assert": "<1.11.0"
},
@@ -61,10 +61,10 @@
},
"require-dev": {
"pestphp/pest-dev-tools": "^5.0.0",
"pestphp/pest-plugin-browser": "^5.0.1",
"pestphp/pest-plugin-phpstan": "^5.2.1",
"pestphp/pest-plugin-rector": "^5.0.4",
"pestphp/pest-plugin-type-coverage": "^5.0.2",
"pestphp/pest-plugin-browser": "^5.1.2",
"pestphp/pest-plugin-phpstan": "^5.2.2",
"pestphp/pest-plugin-rector": "^5.0.6",
"pestphp/pest-plugin-type-coverage": "^5.0.3",
"psy/psysh": "^0.12.24"
},
"minimum-stability": "dev",
+21 -295
View File
@@ -13,26 +13,14 @@ declare(strict_types=1);
namespace PHPUnit\Runner;
use PHPUnit\Framework\DataProviderTestSuite;
use PHPUnit\Framework\IterativeTestSuite;
use PHPUnit\Framework\Reorderable;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Runner\ExecutionOrder\Context;
use PHPUnit\Runner\ExecutionOrder\ReorderPipeline;
use PHPUnit\Runner\TestRunHistory\NullTestRunHistory;
use PHPUnit\Runner\TestRunHistory\TestRunHistory;
use PHPUnit\Runner\TestRunHistory\TestRunHistoryId;
use function array_diff;
use function array_merge;
use function array_reverse;
use function array_splice;
use function assert;
use function count;
use function in_array;
use function max;
use function shuffle;
use function usort;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
@@ -55,20 +43,9 @@ final class TestSuiteSorter
public const int ORDER_SIZE_DESCENDING = 7;
/**
* @var non-empty-array<non-empty-string, positive-int>
*/
private const array SIZE_SORT_WEIGHT = [
'small' => 1,
'medium' => 2,
'large' => 3,
'unknown' => 4,
];
public const int ORDER_MODIFIED_ASCENDING = 8;
/**
* @var array<string, int> Associative array of (string => DEFECT_SORT_WEIGHT) elements
*/
private array $defectSortOrder = [];
public const int ORDER_MODIFIED_DESCENDING = 9;
private readonly TestRunHistory $testRunHistory;
@@ -77,292 +54,41 @@ final class TestSuiteSorter
$this->testRunHistory = $testRunHistory ?? new NullTestRunHistory;
}
/**
* @throws Exception
*/
public function reorderTestsInSuite(Test $suite, int $order, bool $resolveDependencies, int $orderDefects): void
public function apply(Test $suite, ReorderPipeline $pipeline): void
{
$allowedOrders = [
self::ORDER_DEFAULT,
self::ORDER_REVERSED,
self::ORDER_RANDOMIZED,
self::ORDER_DURATION_ASCENDING,
self::ORDER_SIZE_ASCENDING,
self::ORDER_DURATION_DESCENDING,
self::ORDER_SIZE_DESCENDING,
];
if (! in_array($order, $allowedOrders, true)) {
// @codeCoverageIgnoreStart
throw new InvalidOrderException;
// @codeCoverageIgnoreEnd
if ($pipeline->describe() === ['resolve-dependencies'] && ! $this->anyTestHasDependencies([$suite])) {
return;
}
$allowedOrderDefects = [
self::ORDER_DEFAULT,
self::ORDER_DEFECTS_FIRST,
];
if (! in_array($orderDefects, $allowedOrderDefects, true)) {
// @codeCoverageIgnoreStart
throw new InvalidOrderException;
// @codeCoverageIgnoreEnd
}
$this->applyRecursively($suite, $pipeline);
}
private function applyRecursively(Test $suite, ReorderPipeline $pipeline): void
{
if ($suite instanceof IterativeTestSuite) {
return;
}
if ($suite instanceof TestSuite) {
foreach ($suite as $_suite) {
$this->reorderTestsInSuite($_suite, $order, $resolveDependencies, $orderDefects);
}
if (! $suite instanceof TestSuite) {
return;
}
if ($orderDefects === self::ORDER_DEFECTS_FIRST) {
$this->addSuiteToDefectSortOrder($suite);
}
$this->sort($suite, $order, $resolveDependencies, $orderDefects);
foreach ($suite as $child) {
$this->applyRecursively($child, $pipeline);
}
}
private function sort(TestSuite $suite, int $order, bool $resolveDependencies, int $orderDefects): void
{
$tests = $suite->tests();
if ($tests === []) {
return;
}
if ($order === self::ORDER_REVERSED) {
$tests = $this->reverse($tests);
} elseif ($order === self::ORDER_RANDOMIZED) {
$tests = $this->randomize($tests);
} elseif ($order === self::ORDER_DURATION_ASCENDING) {
$tests = $this->sortByDuration($tests);
} elseif ($order === self::ORDER_DURATION_DESCENDING) {
$tests = $this->sortByDurationDescending($tests);
} elseif ($order === self::ORDER_SIZE_ASCENDING) {
$tests = $this->sortBySize($tests);
} elseif ($order === self::ORDER_SIZE_DESCENDING) {
$tests = $this->sortBySizeDescending($tests);
}
if ($orderDefects === self::ORDER_DEFECTS_FIRST) {
$tests = $this->sortDefectsFirst($tests);
}
if ($resolveDependencies && ! ($suite instanceof DataProviderTestSuite)) {
/** @noinspection PhpParamsInspection */
/** @phpstan-ignore argument.type */
$tests = $this->resolveDependencies($tests);
}
$suite->setTests($tests);
}
private function addSuiteToDefectSortOrder(TestSuite $suite): void
{
$max = 0;
foreach ($suite->tests() as $test) {
assert($test instanceof Reorderable);
$sortId = $test->sortId();
if (! isset($this->defectSortOrder[$sortId])) {
$this->defectSortOrder[$sortId] = $this->testRunHistory->status(TestRunHistoryId::fromReorderable($test))->sortWeight();
}
$max = max($max, $this->defectSortOrder[$sortId]);
}
$this->defectSortOrder[$suite->sortId()] = $max;
}
/**
* @param list<Test> $tests
* @return list<Test>
*/
private function reverse(array $tests): array
{
return array_reverse($tests);
}
/**
* @param list<Test> $tests
* @return list<Test>
*/
private function randomize(array $tests): array
{
shuffle($tests);
return $tests;
}
/**
* @param list<Test> $tests
* @return list<Test>
*/
private function sortDefectsFirst(array $tests): array
{
usort(
$tests,
fn (Test $left, Test $right) => $this->cmpDefectPriorityAndTime($left, $right),
$suite->setTests(
$pipeline->apply(
$tests,
new Context($suite, $this->testRunHistory),
),
);
return $tests;
}
/**
* @param list<Test> $tests
* @return list<Test>
*/
private function sortByDuration(array $tests): array
{
usort(
$tests,
fn (Test $left, Test $right) => $this->cmpDuration($left, $right),
);
return $tests;
}
/**
* @param list<Test> $tests
* @return list<Test>
*/
private function sortByDurationDescending(array $tests): array
{
usort(
$tests,
fn (Test $left, Test $right) => $this->cmpDuration($right, $left),
);
return $tests;
}
/**
* @param list<Test> $tests
* @return list<Test>
*/
private function sortBySize(array $tests): array
{
usort(
$tests,
fn (Test $left, Test $right) => $this->cmpSize($left, $right),
);
return $tests;
}
/**
* @param list<Test> $tests
* @return list<Test>
*/
private function sortBySizeDescending(array $tests): array
{
usort(
$tests,
fn (Test $left, Test $right) => $this->cmpSize($right, $left),
);
return $tests;
}
private function cmpDefectPriorityAndTime(Test $a, Test $b): int
{
assert($a instanceof Reorderable);
assert($b instanceof Reorderable);
$priorityA = $this->defectSortOrder[$a->sortId()] ?? 0;
$priorityB = $this->defectSortOrder[$b->sortId()] ?? 0;
return $priorityB <=> $priorityA;
}
private function cmpDuration(Test $a, Test $b): int
{
return $this->durationWeight($a) <=> $this->durationWeight($b);
}
private function durationWeight(Test $test): float
{
if ($test instanceof TestSuite) {
$sum = 0.0;
foreach ($test->tests() as $inner) {
$sum += $this->durationWeight($inner);
}
return $sum;
}
if ($test instanceof Reorderable) {
return $this->testRunHistory->time(TestRunHistoryId::fromReorderable($test));
}
return 0.0;
}
private function cmpSize(Test $a, Test $b): int
{
return $this->sizeWeight($a) <=> $this->sizeWeight($b);
}
/**
* @return positive-int
*/
private function sizeWeight(Test $test): int
{
if ($test instanceof TestCase || $test instanceof DataProviderTestSuite) {
return self::SIZE_SORT_WEIGHT[$test->size()->asString()];
}
if ($test instanceof TestSuite) {
$max = 0;
foreach ($test->tests() as $inner) {
$weight = $this->sizeWeight($inner);
if ($weight > $max) {
$max = $weight;
}
}
if ($max > 0) {
return $max;
}
}
return self::SIZE_SORT_WEIGHT['unknown'];
}
/**
* @param list<TestCase> $tests
* @return list<TestCase>
*/
private function resolveDependencies(array $tests): array
{
if (! $this->anyTestHasDependencies($tests)) {
return $tests;
}
$newTestOrder = [];
$i = 0;
$provided = [];
while ($tests !== [] && $i < count($tests)) {
if (array_diff($tests[$i]->requires(), $provided) === []) {
$provided = array_merge($provided, $tests[$i]->provides());
$newTestOrder = array_merge($newTestOrder, array_splice($tests, $i, 1));
$i = 0;
} else {
$i++;
}
}
return array_merge($newTestOrder, $tests);
}
/**
@@ -16,6 +16,7 @@ use Pest\Plugins\Only;
use Pest\Runner\Filter\EnsureTestCaseIsInitiatedFilter;
use PHPUnit\Event;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Metadata\Api\Groups;
use PHPUnit\Runner\Filter\Factory;
use PHPUnit\TextUI\Configuration\Configuration;
use PHPUnit\TextUI\Configuration\FilterNotConfiguredException;
@@ -27,6 +28,8 @@ use function array_map;
*/
final readonly class TestSuiteFilterProcessor
{
public function __construct(private Event\Emitter $emitter) {}
/**
* @throws Event\RuntimeException
* @throws FilterNotConfiguredException
@@ -70,7 +73,7 @@ final readonly class TestSuiteFilterProcessor
if ($configuration->hasTestsCovering()) {
$factory->addIncludeGroupFilter(
array_map(
static fn (string $name): string => '__phpunit_covers_'.$name,
Groups::virtualGroupForCovers(...),
$configuration->testsCovering(),
),
);
@@ -79,7 +82,7 @@ final readonly class TestSuiteFilterProcessor
if ($configuration->hasTestsUsing()) {
$factory->addIncludeGroupFilter(
array_map(
static fn (string $name): string => '__phpunit_uses_'.$name,
Groups::virtualGroupForUses(...),
$configuration->testsUsing(),
),
);
@@ -99,7 +102,7 @@ final readonly class TestSuiteFilterProcessor
$suite->injectFilter($factory);
Event\Facade::emitter()->testSuiteFiltered(
$this->emitter->testSuiteFiltered(
Event\TestSuite\TestSuiteBuilder::from($suite),
);
}
+19
View File
@@ -6,6 +6,7 @@ namespace Pest\Bootstrappers;
use Pest\Contracts\Bootstrapper;
use Pest\Exceptions\FatalException;
use Pest\Plugins\Concerns\HandleArguments;
use Pest\Support\DatasetInfo;
use Pest\Support\Str;
use Pest\TestSuite;
@@ -20,6 +21,8 @@ use function Pest\testDirectory;
*/
final class BootFiles implements Bootstrapper
{
use HandleArguments;
/**
* @var array<int, string>
*/
@@ -33,6 +36,10 @@ final class BootFiles implements Bootstrapper
public function boot(): void
{
if ($this->runningInit()) {
return;
}
$rootPath = TestSuite::getInstance()->rootPath;
$testsPath = $rootPath.DIRECTORY_SEPARATOR.testDirectory();
@@ -62,6 +69,18 @@ final class BootFiles implements Bootstrapper
$this->bootDatasets($testsPath);
}
private function runningInit(): bool
{
$arguments = $_SERVER['argv'] ?? null;
if (! is_array($arguments)) {
return false;
}
/** @var array<int, string> $arguments */
return $this->hasArgument('--init', $arguments);
}
private function load(string $filename): void
{
if (! Str::endsWith($filename, '.php')) {
+11
View File
@@ -4,9 +4,11 @@ declare(strict_types=1);
namespace Pest\Bootstrappers;
use Closure;
use Pest\Contracts\Bootstrapper;
use Pest\Support\View;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Terminal;
/**
* @internal
@@ -22,5 +24,14 @@ final readonly class BootView implements Bootstrapper
public function boot(): void
{
View::renderUsing($this->output);
if (getenv('COLUMNS') === false && property_exists(Terminal::class, 'width') && property_exists(Terminal::class, 'height')) {
(new Terminal)->getWidth();
Closure::bind(static function (): void {
Terminal::$width ??= 0;
Terminal::$height ??= 0;
}, null, Terminal::class)();
}
}
}
+1 -1
View File
@@ -346,7 +346,7 @@ trait Testable
TestSuite::getInstance()->snapshots->forget();
Closure::bind(fn (): array => $this->mockObjects = [], $this, TestCase::class)();
Closure::bind(fn () => $this->mockObjectRegistry->clear(), $this, TestCase::class)();
foreach (array_keys(array_diff_key(get_object_vars($this), $initialProperties)) as $property) {
unset($this->{$property});
+9 -22
View File
@@ -44,6 +44,11 @@ final class TestCaseFactory
*/
public array $methods = [];
/**
* @var array<string, TestCaseMethodFactory>
*/
private array $methodsByName = [];
/**
* @var array <int, class-string>
*/
@@ -208,35 +213,17 @@ final class TestCaseFactory
}
$this->methods[$method->description] = $method;
$this->methodsByName[Str::evaluable($method->description)] ??= $method;
}
public function hasMethod(string $methodName): bool
{
foreach ($this->methods as $method) {
if ($method->description === null) {
throw ShouldNotHappen::fromMessage('The test description may not be empty.');
}
if ($methodName === Str::evaluable($method->description)) {
return true;
}
}
return false;
return isset($this->methodsByName[$methodName]);
}
public function getMethod(string $methodName): TestCaseMethodFactory
{
foreach ($this->methods as $method) {
if ($method->description === null) {
throw ShouldNotHappen::fromMessage('The test description may not be empty.');
}
if ($methodName === Str::evaluable($method->description)) {
return $method;
}
}
throw ShouldNotHappen::fromMessage(sprintf('Method [%s] not found.', $methodName));
return $this->methodsByName[$methodName]
?? throw ShouldNotHappen::fromMessage(sprintf('Method [%s] not found.', $methodName));
}
}
+7 -1
View File
@@ -29,6 +29,8 @@ use Whoops\Exception\Inspector;
*/
final class Kernel
{
private bool $booted = false;
private bool $terminated = false;
/**
@@ -81,6 +83,8 @@ final class Kernel
CallsBoot::execute();
$kernel->booted = true;
Container::getInstance()->add(self::class, $kernel);
return $kernel;
@@ -132,7 +136,9 @@ final class Kernel
$preBufferOutput->terminate();
CallsTerminable::execute();
if ($this->booted) {
CallsTerminable::execute();
}
}
public function shutdown(): void
+11
View File
@@ -24,6 +24,7 @@ use Pest\TestSuite;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\CoversTrait;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
@@ -571,6 +572,16 @@ final class TestCall // @phpstan-ignore-line
return $this;
}
public function coversNothing(): self
{
$this->testCaseMethod->attributes[] = new Attribute(
CoversNothing::class,
[],
);
return $this;
}
/**
* @param array<class-string|string>|class-string ...$classes
*/
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Pest;
function version(): string
{
return '5.2.1';
return '5.3.4';
}
function testDirectory(string $file = ''): string
+3 -2
View File
@@ -6,6 +6,7 @@ namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments;
use Pest\Plugins\Concerns\HandleArguments;
use PHPUnit\Event\Facade as EventFacade;
use PHPUnit\TextUI\CliArguments\Builder as CliConfigurationBuilder;
use PHPUnit\TextUI\CliArguments\XmlConfigurationFileFinder;
use PHPUnit\TextUI\XmlConfiguration\DefaultConfiguration;
@@ -30,12 +31,12 @@ final class Cache implements HandlesArguments
{
if (! $this->hasArgument('--cache-directory', $arguments)) {
$cliConfiguration = (new CliConfigurationBuilder)->fromParameters([]);
$cliConfiguration = new CliConfigurationBuilder(EventFacade::emitter())->fromParameters([]);
$configurationFile = (new XmlConfigurationFileFinder)->find($cliConfiguration);
$xmlConfiguration = DefaultConfiguration::create();
if (is_string($configurationFile)) {
$xmlConfiguration = (new Loader)->load($configurationFile);
$xmlConfiguration = new Loader(EventFacade::emitter())->load($configurationFile);
}
if (! $xmlConfiguration->phpunit()->hasCacheDirectory()) {
+1 -1
View File
@@ -40,7 +40,7 @@ trait HandleArguments
/**
* @param array<int, string> $arguments
* @return array<int, string>
* @return list<string>
*/
public function popArgument(string $argument, array $arguments): array
{
+2 -1
View File
@@ -8,6 +8,7 @@ use DOMDocument;
use Pest\Contracts\Plugins\HandlesArguments;
use Pest\Contracts\Plugins\Terminable;
use Pest\Plugins\Concerns\HandleArguments;
use PHPUnit\Event\Facade as EventFacade;
use PHPUnit\TextUI\CliArguments\Builder as CliConfigurationBuilder;
use PHPUnit\TextUI\CliArguments\XmlConfigurationFileFinder;
@@ -56,7 +57,7 @@ final class Configuration implements HandlesArguments, Terminable
private function hasCustomConfigurationFile(): bool
{
$cliConfiguration = (new CliConfigurationBuilder)->fromParameters([]);
$cliConfiguration = new CliConfigurationBuilder(EventFacade::emitter())->fromParameters([]);
$configurationFile = (new XmlConfigurationFileFinder)->find($cliConfiguration);
return is_string($configurationFile);
+2 -10
View File
@@ -20,13 +20,8 @@ final readonly class Help implements HandlesArguments
public function __construct(
private OutputInterface $output
) {
//
}
) {}
/**
* {@inheritDoc}
*/
public function handleArguments(array $arguments): array
{
if ($this->hasArgument('--help', $arguments)) {
@@ -56,8 +51,6 @@ final readonly class Help implements HandlesArguments
'desc' => $description,
] = $option;
assert(is_string($argument));
if (trim($argument) === '--process-isolation') {
continue;
}
@@ -87,13 +80,12 @@ final readonly class Help implements HandlesArguments
}
/**
* @return array<string, array<int, array<'arg'|'desc'|int, array{arg: string, desc: string}|string>>>
* @return array<non-empty-string, non-empty-list<array{}|array{arg: non-empty-string, desc: non-empty-string}|array{spacer: ''}|array{text: non-empty-string}>>
*/
private function getContent(): array
{
$helpReflection = new PHPUnitHelp;
// @phpstan-ignore-next-line
$content = (fn (): array => $this->elements())->call($helpReflection);
$content['Configuration'] = [...[[
+3 -6
View File
@@ -17,6 +17,8 @@ use Symfony\Component\Console\Output\OutputInterface;
*/
final readonly class Init implements HandlesArguments
{
use Concerns\HandleArguments;
private const string INIT_OPTION = '--init';
private const array STUBS = [
@@ -40,14 +42,9 @@ final readonly class Init implements HandlesArguments
*/
public function handleArguments(array $arguments): array
{
if (! array_key_exists(1, $arguments)) {
if (! $this->hasArgument(self::INIT_OPTION, $arguments)) {
return $arguments;
}
if ($arguments[1] !== self::INIT_OPTION) {
return $arguments;
}
unset($arguments[1]);
$this->init();
+52 -41
View File
@@ -27,6 +27,7 @@ use PHPUnit\TestRunner\TestResult\TestResult;
use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry;
use PHPUnit\Util\ExcludeList;
use ReflectionProperty;
use RuntimeException;
use SebastianBergmann\CodeCoverage\Node\Builder;
use SebastianBergmann\CodeCoverage\Serialization\Merger;
use SebastianBergmann\CodeCoverage\StaticAnalysis\FileAnalyser;
@@ -41,13 +42,18 @@ use function array_merge;
use function array_merge_recursive;
use function array_shift;
use function assert;
use function bin2hex;
use function count;
use function dirname;
use function file_get_contents;
use function filesize;
use function is_file;
use function max;
use function mkdir;
use function random_bytes;
use function realpath;
use function rmdir;
use function sprintf;
use function str_starts_with;
use function unlink;
use function unserialize;
@@ -60,7 +66,7 @@ final class WrapperRunner implements RunnerInterface
{
public static ?TestResult $result = null;
private const int CYCLE_SLEEP = 10000;
private const int CYCLE_SLEEP = 1000;
private readonly ResultPrinter $printer;
@@ -115,6 +121,9 @@ final class WrapperRunner implements RunnerInterface
private CodeCoverageFilterRegistry $codeCoverageFilterRegistry;
/** @var non-empty-string */
private string $runTmpDir;
public function __construct(
private readonly Options $options,
private readonly OutputInterface $output
@@ -164,6 +173,7 @@ final class WrapperRunner implements RunnerInterface
$this->timer->start();
$this->runTmpDir = $this->createRunTmpDir();
$this->startWorkers();
$this->assignAllPendingTests();
$this->waitForAllToFinish();
@@ -197,6 +207,23 @@ final class WrapperRunner implements RunnerInterface
return array_merge($parameters, ['-d', 'pcov.directory='.TestSuite::getInstance()->rootPath]);
}
/** @return non-empty-string */
private function createRunTmpDir(): string
{
$runTmpDir = sprintf(
'%s%sparatest_%s',
$this->options->tmpDir,
DIRECTORY_SEPARATOR,
bin2hex(random_bytes(16)),
);
if (! @mkdir($runTmpDir, 0700)) {
throw new RuntimeException(sprintf('Unable to create the private temporary directory [%s].', $runTmpDir));
}
return $runTmpDir;
}
private function startWorkers(): void
{
for ($token = 1; $token <= $this->options->processes; $token++) {
@@ -297,6 +324,7 @@ final class WrapperRunner implements RunnerInterface
$this->options,
$this->parameters,
$token,
$this->runTmpDir,
);
$worker->start();
$this->batches[$token] = 0;
@@ -382,44 +410,26 @@ final class WrapperRunner implements RunnerInterface
array_merge_recursive($testResultSum->testTriggeredPhpunitErrorEvents(), $testResult->testTriggeredPhpunitErrorEvents()),
array_merge_recursive($testResultSum->testTriggeredPhpunitNoticeEvents(), $testResult->testTriggeredPhpunitNoticeEvents()),
array_merge_recursive($testResultSum->testTriggeredPhpunitWarningEvents(), $testResult->testTriggeredPhpunitWarningEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredDeprecationEvents(), $testResult->testRunnerTriggeredDeprecationEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredNoticeEvents(), $testResult->testRunnerTriggeredNoticeEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredWarningEvents(), $testResult->testRunnerTriggeredWarningEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredIssueDeprecationEvents(), $testResult->testRunnerTriggeredIssueDeprecationEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredIssueErrorEvents(), $testResult->testRunnerTriggeredIssueErrorEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredIssueNoticeEvents(), $testResult->testRunnerTriggeredIssueNoticeEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredIssuePhpDeprecationEvents(), $testResult->testRunnerTriggeredIssuePhpDeprecationEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredIssuePhpNoticeEvents(), $testResult->testRunnerTriggeredIssuePhpNoticeEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredIssuePhpWarningEvents(), $testResult->testRunnerTriggeredIssuePhpWarningEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->testRunnerTriggeredIssueWarningEvents(), $testResult->testRunnerTriggeredIssueWarningEvents()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->errors(), $testResult->errors()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->deprecations(), $testResult->deprecations()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->notices(), $testResult->notices()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->warnings(), $testResult->warnings()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->phpDeprecations(), $testResult->phpDeprecations()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->phpNotices(), $testResult->phpNotices()),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->phpWarnings(), $testResult->phpWarnings()),
array_merge($testResultSum->testRunnerTriggeredDeprecationEvents(), $testResult->testRunnerTriggeredDeprecationEvents()),
array_merge($testResultSum->testRunnerTriggeredNoticeEvents(), $testResult->testRunnerTriggeredNoticeEvents()),
array_merge($testResultSum->testRunnerTriggeredWarningEvents(), $testResult->testRunnerTriggeredWarningEvents()),
array_merge($testResultSum->testRunnerTriggeredIssueDeprecationEvents(), $testResult->testRunnerTriggeredIssueDeprecationEvents()),
array_merge($testResultSum->testRunnerTriggeredIssueErrorEvents(), $testResult->testRunnerTriggeredIssueErrorEvents()),
array_merge($testResultSum->testRunnerTriggeredIssueNoticeEvents(), $testResult->testRunnerTriggeredIssueNoticeEvents()),
array_merge($testResultSum->testRunnerTriggeredIssuePhpDeprecationEvents(), $testResult->testRunnerTriggeredIssuePhpDeprecationEvents()),
array_merge($testResultSum->testRunnerTriggeredIssuePhpNoticeEvents(), $testResult->testRunnerTriggeredIssuePhpNoticeEvents()),
array_merge($testResultSum->testRunnerTriggeredIssuePhpWarningEvents(), $testResult->testRunnerTriggeredIssuePhpWarningEvents()),
array_merge($testResultSum->testRunnerTriggeredIssueWarningEvents(), $testResult->testRunnerTriggeredIssueWarningEvents()),
array_merge($testResultSum->errors(), $testResult->errors()),
array_merge($testResultSum->deprecations(), $testResult->deprecations()),
array_merge($testResultSum->notices(), $testResult->notices()),
array_merge($testResultSum->warnings(), $testResult->warnings()),
array_merge($testResultSum->phpDeprecations(), $testResult->phpDeprecations()),
array_merge($testResultSum->phpNotices(), $testResult->phpNotices()),
array_merge($testResultSum->phpWarnings(), $testResult->phpWarnings()),
$testResultSum->numberOfIssuesIgnoredByBaseline() + $testResult->numberOfIssuesIgnoredByBaseline(),
self::numberOfDeprecationsByTrigger($testResultSum, $testResult),
// @phpstan-ignore-next-line
array_merge_recursive($testResultSum->retriedTests(), $testResult->retriedTests()),
array_merge($testResultSum->retriedTests(), $testResult->retriedTests()),
);
}
@@ -496,6 +506,7 @@ final class WrapperRunner implements RunnerInterface
$this->clearFiles($this->junitFiles);
$this->clearFiles($this->teamcityFiles);
$this->clearFiles($this->testdoxFiles);
rmdir($this->runTmpDir);
return $exitcode;
}
@@ -547,7 +558,7 @@ final class WrapperRunner implements RunnerInterface
throw MissingResultsException::create($missingCoverageFiles, 'coverage');
}
$coverageManager = new CodeCoverage;
$coverageManager = new CodeCoverage(EventFacade::emitter());
$coverageManager->init(
$this->options->configuration,
$this->codeCoverageFilterRegistry,
@@ -627,7 +638,7 @@ final class WrapperRunner implements RunnerInterface
*/
private function getTestFiles(SuiteLoader $suiteLoader): array
{
/** @var array<string, null> $files */
/** @var array<non-empty-string, null> $files */
$files = [];
foreach (array_filter(
@@ -639,7 +650,7 @@ final class WrapperRunner implements RunnerInterface
}
foreach (TestSuite::getInstance()->tests->getFilenames() as $filename) {
if ($this->shouldIncludeBootstrappedTestFile($filename)) {
if ($filename !== '' && $this->shouldIncludeBootstrappedTestFile($filename)) {
$resolved = realpath($filename)
?: realpath($this->options->cwd.DIRECTORY_SEPARATOR.$filename)
?: $filename;
@@ -647,7 +658,7 @@ final class WrapperRunner implements RunnerInterface
}
}
return array_keys($files); // @phpstan-ignore-line
return array_keys($files);
}
private function shouldIncludeBootstrappedTestFile(string $filename): bool
+26 -9
View File
@@ -29,6 +29,8 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
private const int MAX_FILTER_LENGTH = 32768;
private const string CLASS_END = "\0";
/**
* @var array{
* index: int,
@@ -85,8 +87,7 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
return $arguments;
}
// @phpstan-ignore-next-line
$input = new ArgvInput($arguments);
$input = new ArgvInput(array_values($arguments));
['index' => $index, 'total' => $total] = self::getShard($input);
@@ -95,7 +96,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
$arguments,
)));
/** @phpstan-ignore-next-line */
$tests = $this->allTests($arguments);
$timings = $this->loadShardsFile();
@@ -155,7 +155,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
self::$updateShards = true;
/** @phpstan-ignore-next-line */
self::$knownTests = $this->allTests($arguments);
if ($this->hasArgument('--parallel', $arguments) || $this->hasArgument('-p', $arguments)) {
@@ -237,17 +236,35 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
$current[$part] ??= [];
$current = &$current[$part];
}
$current[self::CLASS_END] = true;
}
$buildRegex = function (array $tree) use (&$buildRegex): string {
$parts = [];
foreach ($tree as $key => $sub) {
$subRegex = $buildRegex($sub);
if ($subRegex === '') {
$parts[] = preg_quote($key, '/');
} else {
$parts[] = preg_quote($key, '/').'\\\\'.(count($sub) > 1 ? '('.$subRegex.')' : $subRegex);
if ($key === self::CLASS_END) {
continue;
}
assert(is_array($sub));
$endsWithClass = isset($sub[self::CLASS_END]);
$sub = array_diff_key($sub, [self::CLASS_END => null]);
$subRegex = $sub === [] ? '' : $buildRegex($sub);
$segment = preg_quote($key, '/');
if ($subRegex !== '') {
$segment .= '\\\\'.(count($sub) > 1 ? '('.$subRegex.')' : $subRegex);
}
if ($endsWithClass && $subRegex !== '') {
$parts[] = '(?:'.preg_quote($key, '/').'::|'.$segment.')';
continue;
}
$parts[] = $endsWithClass ? $segment.'::' : $segment;
}
return implode('|', $parts);
+2 -2
View File
@@ -1571,7 +1571,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
return [
array_map(array_keys(...), $merged['files']),
array_map(array_keys(...), $merged['tables']),
array_map(static fn (array $tables): array => array_map(strval(...), array_keys($tables)), $merged['tables']),
array_map(array_keys(...), $merged['inertia']),
];
}
@@ -2291,7 +2291,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
foreach (array_keys($perTestUsesDatabase) as $testFile) {
$existing = $perTestTables[$testFile] ?? [];
$merged = array_fill_keys($existing, true) + $allTables;
$names = array_keys($merged);
$names = array_map(strval(...), array_keys($merged));
sort($names);
$perTestTables[$testFile] = $names;
}
+17 -1
View File
@@ -297,7 +297,23 @@ final readonly class ChangedFiles
private function shaIsReachable(string $sha): bool
{
return $this->git->succeeds(['merge-base', '--is-ancestor', $sha, 'HEAD']);
if ($this->git->succeeds(['merge-base', '--is-ancestor', $sha, 'HEAD'])) {
return true;
}
$parents = $this->git->raw(['show', '--no-patch', '--format=%P', $sha]);
if ($parents === null) {
return false;
}
$parents = explode(' ', trim($parents));
if (count($parents) < 2) {
return false;
}
return array_all($parents, fn (string $parent): bool => $this->git->succeeds(['merge-base', '--is-ancestor', $parent, 'HEAD']));
}
/**
+1 -1
View File
@@ -1093,7 +1093,7 @@ final class Graph
}
}
$names = array_keys($normalised);
$names = array_map(strval(...), array_keys($normalised));
sort($names);
$this->testTables[$testRel] = $names;
+2 -2
View File
@@ -272,7 +272,7 @@ final class Recorder
$out = [];
foreach ($this->perTestTables as $testFile => $tables) {
$names = array_keys($tables);
$names = array_map(strval(...), array_keys($tables));
sort($names);
$out[$testFile] = $names;
}
@@ -357,7 +357,7 @@ final class Recorder
$lineKeys = array_keys($lines);
$reportsUnexecutedLines = count($covered) < count($lines);
if ($reportsUnexecutedLines && $lineKeys !== [] && count($covered) === 1 && $covered[0] === max($lineKeys)) {
if ($reportsUnexecutedLines && count($covered) === 1 && $covered[0] === max($lineKeys)) {
continue;
}
+1 -1
View File
@@ -33,7 +33,7 @@ final class Reflection
try {
$reflectionMethod = $reflectionClass->getMethod($method);
return $reflectionMethod->invoke($object, ...$args);
return $reflectionMethod->invoke($reflectionMethod->isStatic() ? null : $object, ...$args);
} catch (ReflectionException $exception) {
if (method_exists($object, '__call')) {
return $object->__call($method, $args);
@@ -1,5 +1,5 @@
Pest Testing Framework 5.2.1.
Pest Testing Framework 5.3.4.
USAGE: pest <file> [options]
@@ -35,8 +35,8 @@
--testsuite [name] ......... Only run tests from the specified test suite(s)
--exclude-testsuite [name] .. Exclude tests from the specified test suite(s)
--list-groups ................................... List available test groups
--group [name] .................. Only run tests from the specified group(s)
--exclude-group [name] ........... Exclude tests from the specified group(s)
--group [name] Only run tests from the specified group(s); use "a+b" for the tests that are in group "a" and in group "b"
--exclude-group [name] Exclude tests from the specified group(s); use "a+b" for the tests that are in group "a" and in group "b"
--covers [name] ................. Only run tests that intend to cover [name]
--uses [name] ..................... Only run tests that intend to use [name]
--requires-php-extension [name] Only run tests that require PHP extension [name]
@@ -63,6 +63,7 @@
--disallow-test-output ................. Be strict about output during tests
--enforce-time-limit ................. Enforce time limit based on test size
--default-time-limit [sec] Timeout in seconds for tests that have no declared size
--timeout [sec] Stop the test run after the specified number of seconds (wall-clock time for the entire run)
--do-not-report-useless-tests Do not report tests that do not test anything
--stop-on-defect[=[n]] Stop after first (or n-th) error, failure, warning, or risky test
--stop-on-error[=[n]] ..................... Stop after first (or n-th) error
@@ -102,11 +103,13 @@
--do-not-fail-on-incomplete Do not signal failure using shell exit code when a test was marked incomplete
--record-test-run-history .......................... Record test run history
--do-not-record-test-run-history ............ Do not record test run history
--cache-test-index .......................... Write test index to cache file
--do-not-cache-test-index ............ Do not write test index to cache file
--warn-when-php-is-not-configured-for-development Trigger a test runner warning when PHP is not configured for development
--do-not-warn-when-php-is-not-configured-for-development Do not trigger a test runner warning when PHP is not configured for development
--order-by [order] Run tests in order: default|defects|depends|duration-ascending|duration-descending|no-depends|random|reverse|size-ascending|size-descending
--resolve-dependencies ...................... Alias for "--order-by depends"
--ignore-dependencies .................... Alias for "--order-by no-depends"
--order-by [order] Run tests in order: default|defects|duration-ascending|duration-descending|modified-ascending|modified-descending|random|reverse|size-ascending|size-descending
--resolve-dependencies Reorder tests to resolve dependencies between them (default)
--ignore-dependencies Do not reorder tests to resolve dependencies between them
--random-order ............................... Alias for "--order-by random"
--random-order-seed [N] Use the specified random seed when running tests in random order
--repeat [N] .......... Run each test N times, stopping at the first failure
@@ -163,6 +166,7 @@
--coverage-html [dir] Write code coverage report in HTML format to directory
--without-class-view Render code coverage report in HTML format without class view
--without-file-view Render code coverage report in HTML format without file view
--coverage-jsonl [dir] Write code coverage report in JSONL format to directory
--coverage-php [file] .......... Write serialized code coverage data to file
--coverage-text=[file] Write code coverage report in text format to file [default: standard output]
--only-summary-for-coverage-text Option for code coverage report in text format: only show summary
@@ -1,3 +1,3 @@
Pest Testing Framework 5.2.1.
Pest Testing Framework 5.3.4.
+31 -1
View File
@@ -82,6 +82,12 @@
PASS Tests\Features\Covers\ClassCoverage
✓ it uses the correct PHPUnit attribute for class
PASS Tests\Features\Covers\CoversNothing
✓ it uses the correct PHPUnit attribute for covers nothing
✓ describe → it uses the correct PHPUnit attribute for covers nothing
✓ it is not risky when coverage metadata is required
✓ it does not conflict with covers in the same file
PASS Tests\Features\Covers\ExceptionHandling
✓ it throws exception if no class nor method has been found
@@ -1274,6 +1280,12 @@
✓ it is not incompleted because of test with assertions
… a "describe" group of tests → it is incompleted
PASS Tests\Features\Init
✓ init creates a suite when the tests directory is missing
✓ init creates a suite when --init is not the first argument
✓ init creates a suite when --init is passed with a value
✓ a missing tests directory does not crash while resolving tia state
PASS Tests\Features\Issue
✓ it may be associated with an issue #1, #2
✓ nested → it may be associated with an issue #1, #4, #5, #6, #3
@@ -1839,6 +1851,11 @@
✓ buildFilterArgument → it returns empty string for empty test list
✓ buildFilterArgument → it generates compact filter for deeply nested namespaces
✓ buildFilterArgument → it handles mix of nested and flat namespaces
✓ buildFilterArgument → it does not match a class outside of the shard when another class name is its prefix
✓ buildFilterArgument → it still matches dataset variants after the class boundary
✓ buildFilterArgument → it keeps a class matchable when another class nests below its namespace
✓ buildFilterArgument → it keeps the filter whole when the parallel runner passes it as --filter=VALUE
✓ buildFilterArgument → it matches a class-based test of the shard
✓ ensureFilterLengthIsSafe → it accepts filter within length limit
✓ ensureFilterLengthIsSafe → it throws exception when filter exceeds default limit
✓ ensureFilterLengthIsSafe → it respects custom limit from environment variable
@@ -1849,6 +1866,7 @@
✓ parseListTestsOutput → it deduplicates repeated class names from multiple test methods
✓ parseListTestsOutput → it returns an empty list for output with no matching lines
✓ parseListTestsOutput → it parses non-Tests namespaced classes
✓ parseListTestsOutput → it parses module test classes living outside the tests directory
✓ parseListTestsOutput → it parses unnamespaced top-level classes
✓ parseListTestsOutput → it strips the P\ Pest prefix but keeps the rest of the FQCN
✓ parseListTestsOutput → it ignores junk lines that lack the " - …::" framing
@@ -1949,6 +1967,12 @@
✓ it detects an added or removed non-platform dependency
✓ it is independent of package ordering
PASS Tests\Unit\Plugins\Tia\NumericTableDependencies
✓ it exports numeric table dependencies from the recorder as strings
✓ it persists numeric tables as JSON strings and selects only their migration readers after reload
✓ it preserves numeric worker tables through payload cleaning union and graph reload
✓ it preserves observed and migration added numeric tables when augmenting database tests
PASS Tests\Unit\Plugins\Tia\Recorder
✓ activateLinkTracking() → it tracks tables without a coverage driver
✓ activateLinkTracking() → it tracks inertia components without a coverage driver
@@ -2135,6 +2159,8 @@
✓ it gets property values
✓ it gets properties from classes
✓ it gets methods from classes
✓ it calls instance methods
✓ it calls static methods without passing an object
PASS Tests\Unit\Support\Str
✓ it evaluates the code with ('version()', '__pest_evaluable_version__')
@@ -2201,6 +2227,7 @@
✓ it does not allow to add the same test description twice
✓ it does not allow static closures
✓ it alerts users about tests with arguments but no input
✓ it can look up registered test methods by evaluable name
✓ it can return an array of all test suite filenames
PASS Tests\Visual\BeforeEachTestName
@@ -2210,6 +2237,9 @@
PASS Tests\Visual\Collision
✓ collision with ([''])
PASS Tests\Visual\FailingBoot
✓ a failure in the boot files renders only that failure
PASS Tests\Visual\Help
✓ visual snapshot of help command output
@@ -2256,4 +2286,4 @@
✓ pass with dataset with ('my-datas-set-value')
✓ within describe → pass with dataset with ('my-datas-set-value')
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1599 passed (3486 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1621 passed (3582 assertions)
+54
View File
@@ -0,0 +1,54 @@
<?php
use PHPUnit\Framework\Attributes\CoversNothing;
use Symfony\Component\Process\Process;
$run = function (string ...$arguments): array {
$process = new Process(
['php', 'bin/pest', '--configuration', 'tests/Fixtures/Suites/CoversNothing.xml', ...$arguments],
dirname(__DIR__, 3),
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1'],
);
$process->run();
return [
'output' => removeAnsiEscapeSequences($process->getOutput().$process->getErrorOutput()),
'code' => $process->getExitCode(),
];
};
it('uses the correct PHPUnit attribute for covers nothing', function (): void {
$attributes = new ReflectionMethod($this, $this->name())->getAttributes();
expect($attributes[2]->getName())->toBe(CoversNothing::class)
->and($attributes[2]->getArguments())->toBeEmpty();
})->coversNothing();
describe('describe', function (): void {
it('uses the correct PHPUnit attribute for covers nothing', function (): void {
$attributes = new ReflectionMethod($this, $this->name())->getAttributes();
expect($attributes[2]->getName())->toBe(CoversNothing::class)
->and($attributes[2]->getArguments())->toBeEmpty();
});
})->coversNothing();
it('is not risky when coverage metadata is required', function () use ($run): void {
$result = $run();
expect($result['output'])
->toContain('✓ covers nothing')
->toContain('! declares no coverage metadata → This test does not define a code coverage target but is expected to do so')
->toContain('Tests: 1 risky, 1 passed (2 assertions)')
->and($result['code'])->toBe(1);
})->skipOnWindows();
it('does not conflict with covers in the same file', function () use ($run): void {
$result = $run('tests/Fixtures/Suites/CoversNothingWithCovers.php');
expect($result['output'])
->toContain('✓ covers nothing')
->toContain('Tests: 2 passed (2 assertions)')
->and($result['code'])->toBe(0);
})->skipOnWindows();
+171
View File
@@ -0,0 +1,171 @@
<?php
declare(strict_types=1);
use Symfony\Component\Process\Process;
test('init creates a suite when the tests directory is missing', function (): void {
$root = makeInitProject();
try {
$process = runInitProject($root, '--init');
expect($process->getExitCode())->toBe(0)
->and($process->getErrorOutput())->not->toContain('cannot be resolved')
->and($process->getOutput())->toContain('File created.')
->and($root.DIRECTORY_SEPARATOR.'phpunit.xml')->toBeFile()
->and($root.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'Pest.php')->toBeFile()
->and($root.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'TestCase.php')->toBeFile()
->and($root.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'Unit'.DIRECTORY_SEPARATOR.'ExampleTest.php')->toBeFile();
} finally {
removeInitProject($root);
}
});
test('init creates a suite when --init is not the first argument', function (): void {
$root = makeInitProject();
try {
$process = runInitProject($root, '--colors=never', '--init');
expect($process->getExitCode())->toBe(0)
->and($process->getErrorOutput())->not->toContain('cannot be resolved')
->and($process->getOutput())->toContain('File created.')
->and($root.DIRECTORY_SEPARATOR.'phpunit.xml')->toBeFile()
->and($root.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'Pest.php')->toBeFile();
} finally {
removeInitProject($root);
}
});
test('init creates a suite when --init is passed with a value', function (): void {
$root = makeInitProject();
try {
$process = runInitProject($root, '--init=pest');
expect($process->getExitCode())->toBe(0)
->and($process->getErrorOutput())->not->toContain('cannot be resolved')
->and($process->getOutput())->toContain('File created.')
->and($root.DIRECTORY_SEPARATOR.'phpunit.xml')->toBeFile()
->and($root.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'Pest.php')->toBeFile();
} finally {
removeInitProject($root);
}
});
test('a missing tests directory does not crash while resolving tia state', function (): void {
$root = makeInitProject();
try {
$process = runInitProject($root, '--version');
expect($process->getExitCode())->not->toBe(0)
->and($process->getOutput())->toContain('does not exist')
->and($process->getErrorOutput())->not->toContain('cannot be resolved')
->and($process->getOutput())->not->toContain('cannot be resolved');
} finally {
removeInitProject($root);
}
});
function makeInitProject(): string
{
$root = sys_get_temp_dir().DIRECTORY_SEPARATOR.'pest-init-'.bin2hex(random_bytes(4));
mkdir($root.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'bin', 0777, true);
copy(
dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'pest-plugins.json',
$root.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'pest-plugins.json',
);
$autoload = var_export(
dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php',
true,
);
file_put_contents($root.DIRECTORY_SEPARATOR.'run.php', <<<PHP
<?php
declare(strict_types=1);
use Pest\Kernel;
use Pest\Panic;
use Pest\TestSuite;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
require {$autoload};
\$arguments = array_slice(\$argv, 1);
if (\$arguments === []) {
\$arguments = ['--version'];
}
\$GLOBALS['_composer_bin_dir'] = getcwd().'/vendor/bin';
\$_SERVER['argv'] = ['pest', ...\$arguments];
\$_SERVER['COLLISION_PRINTER'] = 'DefaultPrinter';
\$input = new ArgvInput(\$_SERVER['argv']);
\$output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, false);
\$testSuite = TestSuite::getInstance(getcwd(), 'tests');
try {
\$kernel = Kernel::boot(\$testSuite, \$input, \$output);
\$result = \$kernel->handle(\$_SERVER['argv'], \$_SERVER['argv']);
\$kernel->terminate();
} catch (Throwable \$throwable) {
Panic::with(\$throwable);
}
exit(\$result);
PHP);
return $root;
}
function runInitProject(string $root, string ...$command): Process
{
$process = new Process(
[PHP_BINARY, 'run.php', ...$command],
$root,
[
'PEST_NO_SUPPORT' => 'true',
'COLLISION_PRINTER' => 'DefaultPrinter',
'COLLISION_IGNORE_DURATION' => 'true',
],
);
$process->setTimeout(60);
$process->run();
return $process;
}
function removeInitProject(string $root): void
{
if (! is_dir($root)) {
return;
}
$items = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST,
);
foreach ($items as $item) {
if ($item->isDir() && ! $item->isLink()) {
rmdir($item->getPathname());
continue;
}
unlink($item->getPathname());
}
rmdir($root);
}
+52
View File
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
use Pest\Plugins\Tia\ChangedFiles;
use Tests\Fixtures\Tia\Project;
afterEach(function (): void {
Project::destroyAll();
});
test('a replacement CI merge reuses its baseline and selects changed tests on either parent', function (array $arguments, string $changedBranch): void {
$project = Project::make('master');
$git = $project->git();
$git->switchTo('feature', new: true);
$git->commit('feature');
$git->run(['checkout', '--detach', 'master']);
$git->run(['merge', '--no-ff', '--no-edit', 'feature']);
$project->seed('123/merge');
$git->switchTo($changedBranch);
$project->write('tests/Unit/CalculatorTest.php', str_replace(
'->add(1, 2)',
'->add(2, 1)',
file_get_contents($project->path('tests/Unit/CalculatorTest.php')) ?: throw new RuntimeException('Missing calculator test fixture.'),
));
$git->commit('change calculator');
$git->run(['checkout', '--detach', 'master']);
$git->run(['merge', '--no-ff', '--no-edit', 'feature']);
$result = $project->pestWithEnvironment($project->path(), [
'GITHUB_REF_NAME' => '123/merge',
], '--tia', ...$arguments);
expect($result->exitCode)->toBe(0, $result->describe())
->and($result->output)->not->toContain('no longer reachable')
->and($result->replayed())->toBe(4, $result->describe())
->and($result->tally())->toContain('6 passed');
})->with(Project::SEQUENTIAL_AND_PARALLEL)->with(['feature', 'master'])->skipOnWindows();
test('a merge baseline is rejected when one of its parents is absent from the current history', function (): void {
$project = Project::make('master');
$git = $project->git();
$git->switchTo('feature', new: true);
$git->commit('feature');
$git->run(['checkout', '--detach', 'master']);
$git->run(['merge', '--no-ff', '--no-edit', 'feature']);
$sha = $git->sha();
$git->switchTo('master');
expect(new ChangedFiles($project->path())->since($sha))->toBeNull();
})->skipOnWindows();
+9
View File
@@ -0,0 +1,9 @@
<?php
test('covers nothing', function (): void {
expect(true)->toBeTrue();
})->coversNothing();
test('declares no coverage metadata', function (): void {
expect(true)->toBeTrue();
});
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
bootstrap="../../../vendor/autoload.php"
colors="true"
requireCoverageMetadata="true"
failOnRisky="true"
failOnWarning="true"
>
<testsuites>
<testsuite name="default">
<file>CoversNothing.php</file>
</testsuite>
</testsuites>
</phpunit>
@@ -0,0 +1,13 @@
<?php
use Tests\Fixtures\Covers\CoversClass1;
covers(CoversClass1::class);
test('covers the class', function (): void {
expect(true)->toBeTrue();
});
test('covers nothing', function (): void {
expect(true)->toBeTrue();
})->coversNothing();
@@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
throw new RuntimeException('The boot of the test suite failed.');
+94 -5
View File
@@ -2,6 +2,7 @@
use Pest\Exceptions\InvalidOption;
use Pest\Plugins\Shard;
use SebastianBergmann\CliParser\Parser;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\BufferedOutput;
@@ -60,7 +61,7 @@ describe('buildFilterArgument', function (): void {
$filter = $method->invoke($shard, ['Tests\\Unit\\ExampleTest']);
expect($filter)->toBe('Tests\\\\Unit\\\\ExampleTest');
expect($filter)->toBe('Tests\\\\Unit\\\\ExampleTest::');
});
it('generates compact filter for multiple tests with common prefix', function (): void {
@@ -75,7 +76,7 @@ describe('buildFilterArgument', function (): void {
'Tests\\Unit\\Foo\\BazTest',
]);
expect($filter)->toBe('Tests\\\\Unit\\\\Foo\\\\(BarTest|BazTest)');
expect($filter)->toBe('Tests\\\\Unit\\\\Foo\\\\(BarTest::|BazTest::)');
});
it('generates compact filter for tests with different namespaces', function (): void {
@@ -90,7 +91,7 @@ describe('buildFilterArgument', function (): void {
'Tests\\Feature\\BarTest',
]);
expect($filter)->toBe('Tests\\\\(Unit\\\\FooTest|Feature\\\\BarTest)');
expect($filter)->toBe('Tests\\\\(Unit\\\\FooTest::|Feature\\\\BarTest::)');
});
it('returns empty string for empty test list', function (): void {
@@ -118,7 +119,7 @@ describe('buildFilterArgument', function (): void {
'Tests\\Unit\\Plugins\\Concerns\\Baz',
]);
expect($filter)->toBe('Tests\\\\Unit\\\\Plugins\\\\Concerns\\\\(Foo|Bar|Baz)');
expect($filter)->toBe('Tests\\\\Unit\\\\Plugins\\\\Concerns\\\\(Foo::|Bar::|Baz::)');
});
it('handles mix of nested and flat namespaces', function (): void {
@@ -138,7 +139,73 @@ describe('buildFilterArgument', function (): void {
$filter = $method->invoke($shard, $tests);
expect($filter)
->toBe(addslashes('Tests\\Unit\\(SimpleTest|Plugins\\Concerns\\(HandleArguments|Validation)|Another\\Deep\\Nested\\Test)'));
->toBe(addslashes('Tests\\Unit\\(SimpleTest::|Plugins\\Concerns\\(HandleArguments::|Validation::)|Another\\Deep\\Nested\\Test::)'));
});
it('does not match a class outside of the shard when another class name is its prefix', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
$reflection = new ReflectionClass($shard);
$method = $reflection->getMethod('buildFilterArgument');
$filter = $method->invoke($shard, ['Tests\\Feature\\After']);
expect(preg_match('{'.$filter.'}i', 'P\Tests\Feature\AfterAll::deletes file after all'))->toBe(0)
->and('P\Tests\Feature\After::it runs')->toMatch('{'.$filter.'}i');
});
it('still matches dataset variants after the class boundary', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
$reflection = new ReflectionClass($shard);
$method = $reflection->getMethod('buildFilterArgument');
$filter = $method->invoke($shard, ['Tests\\Feature\\After']);
expect('P\Tests\Feature\After::it runs with data set "foo"')->toMatch('{'.$filter.'}i');
});
it('keeps a class matchable when another class nests below its namespace', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
$reflection = new ReflectionClass($shard);
$method = $reflection->getMethod('buildFilterArgument');
$filter = $method->invoke($shard, ['Tests\\Unit\\After', 'Tests\\Unit\\After\\AfterAll']);
expect($filter)->toBe('Tests\\\\Unit\\\\(?:After::|After\\\\AfterAll::)')
->and('P\Tests\Unit\After::x')->toMatch('{'.$filter.'}i')
->and('P\Tests\Unit\After\AfterAll::y')->toMatch('{'.$filter.'}i');
});
it('keeps the filter whole when the parallel runner passes it as --filter=VALUE', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
$reflection = new ReflectionClass($shard);
$method = $reflection->getMethod('buildFilterArgument');
$filter = $method->invoke($shard, ['Tests\\Unit\\AlphaTest', 'Tests\\Unit\\After', 'Tests\\Unit\\After\\AfterAll']);
[$options] = new Parser()->parse(['--filter='.$filter], '', ['filter=']);
expect($options)->toBe([['--filter', $filter]]);
});
it('matches a class-based test of the shard', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
$reflection = new ReflectionClass($shard);
$method = $reflection->getMethod('buildFilterArgument');
$filter = $method->invoke($shard, ['Tests\\Unit\\AlphaTest']);
expect('Tests\Unit\AlphaTest::test_it_runs')->toMatch('{'.$filter.'}i')
->and('Tests\Unit\AlphaTestTwo::test_it_runs')->not->toMatch('{'.$filter.'}i');
});
});
@@ -309,6 +376,28 @@ OUT;
]);
});
it('parses module test classes living outside the tests directory', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
$reflection = new ReflectionClass($shard);
$method = $reflection->getMethod('parseListTestsOutput');
$listOutput = <<<'OUT'
INFO Available tests:
- P\Tests\Unit\Foo::__pest_evaluable_it_works
- P\Modules\Example\tests\ShardModuleExample::__pest_evaluable_module_test_is_listed
- P\Modules\Billing\Tests\Feature\InvoiceTest::__pest_evaluable_it_creates_invoices
OUT;
expect($method->invoke($shard, $listOutput))->toBe([
'Tests\\Unit\\Foo',
'Modules\\Example\\tests\\ShardModuleExample',
'Modules\\Billing\\Tests\\Feature\\InvoiceTest',
]);
});
it('parses unnamespaced top-level classes', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
@@ -0,0 +1,214 @@
<?php
declare(strict_types=1);
use Pest\Plugins\Tia;
use Pest\Plugins\Tia\FileState;
use Pest\Plugins\Tia\Graph;
use Pest\Plugins\Tia\Recorder;
use Pest\Plugins\Tia\TableExtractor;
use Pest\Plugins\Tia\WatchPatterns;
use Pest\Support\Container;
it('exports numeric table dependencies from the recorder as strings', function (): void {
$recorder = new Recorder;
$recorder->activateLinkTracking();
$recorder->beginTest('Some\Missing\TestClass', 'queries numeric tables', '/project/tests/Unit/NumericTest.php');
foreach (['select substring(name from 1 for 3) from users', 'select * from "123"', 'select * from "0"', 'select * from "001"', 'select * from USERS join "123" on true'] as $query) {
foreach (TableExtractor::fromSql($query) as $table) {
$recorder->linkTable($table);
}
}
$recorder->endTest();
$tables = $recorder->perTestTables();
sort($tables['/project/tests/Unit/NumericTest.php'], SORT_STRING);
expect($tables)->toBe([
'/project/tests/Unit/NumericTest.php' => ['0', '001', '1', '123', 'users'],
]);
});
it('persists numeric tables as JSON strings and selects only their migration readers after reload', function (): void {
$root = tiaNumericTableProject();
try {
tiaAssertNumericTableGraph($root, [], [
$root.'/tests/Unit/NumericTest.php' => ['123', '0', '001', '123'],
$root.'/tests/Unit/ControlTest.php' => ['USERS', 'users'],
], [
'tests/Unit/NumericTest.php' => ['0', '001', '123'],
'tests/Unit/ControlTest.php' => ['users'],
], [
['123', ['tests/Unit/NumericTest.php']],
['0', ['tests/Unit/NumericTest.php']],
['001', ['tests/Unit/NumericTest.php']],
['users', ['tests/Unit/ControlTest.php']],
['orders', []],
]);
} finally {
tiaRemoveNumericTableProject($root);
}
});
it('preserves numeric worker tables through payload cleaning union and graph reload', function (): void {
$root = tiaNumericTableProject();
try {
$state = new FileState($root.'/state');
$tia = new ReflectionClass(Tia::class)->newInstanceWithoutConstructor();
new ReflectionProperty(Tia::class, 'state')->setValue($tia, $state);
$files = [
$root.'/tests/Unit/NumericTest.php' => [$root.'/app/Subject.php'],
$root.'/tests/Unit/ControlTest.php' => [$root.'/app/Subject.php'],
];
$workers = [
[
$root.'/tests/Unit/NumericTest.php' => ['123', 'users'],
$root.'/tests/Unit/ControlTest.php' => ['orders'],
],
[$root.'/tests/Unit/NumericTest.php' => ['0', '001', '123', 'users']],
];
foreach ($workers as $slot => $tables) {
$before = new ReflectionMethod(Tia::class, 'collectWorkerEdgesPartials')->invoke($tia);
new ReflectionMethod(Tia::class, 'flushWorkerPartial')->invoke($tia, $files, $tables, []);
$keys = new ReflectionMethod(Tia::class, 'collectWorkerEdgesPartials')->invoke($tia);
$written = array_values(array_diff($keys, $before));
expect($written)->toHaveCount(1);
$key = $written[0];
$raw = $state->read($key);
expect($raw)->toBeString();
$payload = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
expect($payload)->toBe(['files' => $files, 'tables' => $tables, 'inertia' => []])
->and(new ReflectionMethod(Tia::class, 'readPartial')->invoke($tia, $key))->toBe($payload)
->and(rename($state->pathFor($key), $state->pathFor('worker-edges-fixture-'.$slot.'.json')))->toBeTrue();
}
$keys = new ReflectionMethod(Tia::class, 'collectWorkerEdgesPartials')->invoke($tia);
expect($keys)->toHaveCount(2);
[$mergedFiles, $mergedTables, $inertia] = new ReflectionMethod(Tia::class, 'consumePartials')->invoke($tia, $keys);
expect($mergedFiles)->toBe($files)
->and($mergedTables)->toBe([
$root.'/tests/Unit/NumericTest.php' => ['123', 'users', '0', '001'],
$root.'/tests/Unit/ControlTest.php' => ['orders'],
])
->and($inertia)->toBe([])
->and(new ReflectionMethod(Tia::class, 'collectWorkerEdgesPartials')->invoke($tia))->toBe([]);
tiaAssertNumericTableGraph($root, $mergedFiles, $mergedTables, [
'tests/Unit/NumericTest.php' => ['0', '001', '123', 'users'],
'tests/Unit/ControlTest.php' => ['orders'],
], [
['123', ['tests/Unit/NumericTest.php']],
['0', ['tests/Unit/NumericTest.php']],
['001', ['tests/Unit/NumericTest.php']],
['users', ['tests/Unit/NumericTest.php']],
['orders', ['tests/Unit/ControlTest.php']],
]);
} finally {
tiaRemoveNumericTableProject($root);
}
});
it('preserves observed and migration added numeric tables when augmenting database tests', function (): void {
$root = tiaNumericTableProject();
try {
file_put_contents($root.'/database/migrations/create_numeric.php', "<?php Schema::create('456', function (): void {});");
$tia = new ReflectionClass(Tia::class)->newInstanceWithoutConstructor();
$tables = new ReflectionMethod(Tia::class, 'augmentDatabaseTestTables')->invoke($tia, [
$root.'/tests/Unit/NumericTest.php' => ['123', '0', '001', 'users'],
$root.'/tests/Unit/ControlTest.php' => ['orders'],
], [$root.'/tests/Unit/NumericTest.php' => true], $root);
expect($tables)->toBe([
$root.'/tests/Unit/NumericTest.php' => ['0', '001', '123', '456', 'users'],
$root.'/tests/Unit/ControlTest.php' => ['orders'],
]);
tiaAssertNumericTableGraph($root, [], $tables, [
'tests/Unit/NumericTest.php' => ['0', '001', '123', '456', 'users'],
'tests/Unit/ControlTest.php' => ['orders'],
], [
['123', ['tests/Unit/NumericTest.php']],
['0', ['tests/Unit/NumericTest.php']],
['001', ['tests/Unit/NumericTest.php']],
['456', ['tests/Unit/NumericTest.php']],
['users', ['tests/Unit/NumericTest.php']],
['orders', ['tests/Unit/ControlTest.php']],
]);
} finally {
tiaRemoveNumericTableProject($root);
}
});
function tiaNumericTableProject(): string
{
$root = dirname(__DIR__, 4).'/.temp/tia-numeric-'.bin2hex(random_bytes(8));
mkdir($root.'/tests/Unit', 0755, true);
mkdir($root.'/app', 0755, true);
mkdir($root.'/database/migrations', 0755, true);
file_put_contents($root.'/tests/Unit/NumericTest.php', '<?php');
file_put_contents($root.'/tests/Unit/ControlTest.php', '<?php');
file_put_contents($root.'/app/Subject.php', '<?php');
return $root;
}
/**
* @param array<string, list<string>> $files
* @param array<string, list<string>> $tables
* @param array<string, list<string>> $expected
* @param list<array{string, list<string>}> $selections
*/
function tiaAssertNumericTableGraph(string $root, array $files, array $tables, array $expected, array $selections): void
{
$graph = new Graph($root);
$graph->replaceEdges($files);
$graph->markKnownTestFiles(array_keys($tables));
$graph->replaceTestTables($tables);
$json = $graph->encode();
expect($json)->toBeString();
$payload = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
expect($payload['test_tables'])->toBe($expected);
$reloaded = Graph::decode($json, $root);
expect($reloaded)->toBeInstanceOf(Graph::class);
$container = Container::getInstance();
$previous = $container->get(WatchPatterns::class);
$patterns = new WatchPatterns;
$container->add(WatchPatterns::class, $patterns);
try {
foreach ($selections as [$table, $readers]) {
$migration = 'database/migrations/change_'.$table.'.php';
file_put_contents($root.'/'.$migration, "<?php Schema::table('{$table}', function (): void {});");
expect($reloaded->affected([$migration]))->toBe($readers);
}
} finally {
$container->add(WatchPatterns::class, $previous);
}
}
function tiaRemoveNumericTableProject(string $root): void
{
$entries = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST,
);
foreach ($entries as $entry) {
if ($entry->isDir()) {
rmdir($entry->getPathname());
} else {
unlink($entry->getPathname());
}
}
rmdir($root);
}
+26
View File
@@ -74,3 +74,29 @@ it('gets methods from classes', function (): void {
'getBar',
]);
});
it('calls instance methods', function (): void {
$class = new class
{
private string $foo = 'bar';
private function getFoo(): string
{
return $this->foo;
}
};
expect(Reflection::call($class, 'getFoo'))->toBe('bar');
});
it('calls static methods without passing an object', function (): void {
$class = new class
{
private static function concat(string $a, string $b): string
{
return $a.$b;
}
};
expect(Reflection::call($class, 'concat', ['foo', 'bar']))->toBe('foobar');
});
+26
View File
@@ -1,6 +1,7 @@
<?php
use Pest\Exceptions\DatasetMissing;
use Pest\Exceptions\ShouldNotHappen;
use Pest\Exceptions\TestAlreadyExist;
use Pest\Exceptions\TestClosureMustNotBeStatic;
use Pest\Factories\TestCaseMethodFactory;
@@ -43,6 +44,31 @@ it('alerts users about tests with arguments but no input', function (): void {
sprintf('The test [%s] in [%s] expects [%d] argument(s) ([%s]), but no dataset was provided. Please chain [with()] onto the test to supply one.', 'bar', 'foo', 1, 'int $arg'),
);
it('can look up registered test methods by evaluable name', function (): void {
$testSuite = new TestSuite(getcwd(), 'tests');
$firstMethod = new TestCaseMethodFactory('foo', null);
$firstMethod->description = 'first test_with punctuation!';
$testSuite->tests->set($firstMethod);
$secondMethod = new TestCaseMethodFactory('foo', null);
$secondMethod->description = 'second test';
$testSuite->tests->set($secondMethod);
$collidingMethod = new TestCaseMethodFactory('foo', null);
$collidingMethod->description = 'second-test';
$testSuite->tests->set($collidingMethod);
$testCase = $testSuite->tests->get('foo');
expect($testCase->hasMethod('__pest_evaluable_first_test__with_punctuation_'))->toBeTrue()
->and($testCase->getMethod('__pest_evaluable_first_test__with_punctuation_'))->toBe($firstMethod)
->and($testCase->hasMethod('__pest_evaluable_second_test'))->toBeTrue()
->and($testCase->getMethod('__pest_evaluable_second_test'))->toBe($secondMethod)
->and($testCase->hasMethod('__pest_evaluable_missing'))->toBeFalse()
->and(fn () => $testCase->getMethod('__pest_evaluable_missing'))->toThrow(ShouldNotHappen::class, 'Method [__pest_evaluable_missing] not found.');
});
it('can return an array of all test suite filenames', function (): void {
$testSuite = new TestSuite(getcwd(), 'tests');
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
use Symfony\Component\Process\Process;
test('a failure in the boot files renders only that failure', function (): void {
$process = new Process([
'php',
'bin/pest',
'--test-directory=tests/Fixtures/Suites/FailingBoot',
'--colors=never',
], dirname(__DIR__, 2), ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1']);
$process->run();
expect($process->getExitCode())->toBe(1)
->and($process->getOutput().$process->getErrorOutput())
->toContain('The boot of the test suite failed.')
->not->toContain('cannot be resolved');
})->skipOnWindows();
+1 -1
View File
@@ -20,7 +20,7 @@ test('parallel', function () use ($run): void {
$output = $run('--exclude-group=integration');
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1581 passed (3431 assertions)';
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1602 passed (3524 assertions)';
expect($output)
->toContain("Tests: {$expected}")