Commit Graph

62 Commits

Author SHA1 Message Date
bdf60cea91 Merge pull request #1565 from louisbels/fix-dataset-method-chaining
fix: dataset inheritance with method chaining (beforeEach()->with(), describe()->with())
2026-04-10 17:05:25 +01:00
654cb726c9 Merge branch '4.x' into patch-1 2026-04-10 16:58:26 +01:00
5948bcd71e chore: type improvements 2026-04-10 16:50:10 +01:00
8dddb47ad5 Merge branch '4.x' into fix-dataset-method-chaining 2026-04-10 11:41:13 +01:00
2a80101f42 chore: update styling 2026-03-10 21:06:28 +00:00
ec3e0b2d33 fix: Parameter closure this type annotations in Functions.php 2026-02-09 20:48:56 +01:00
26345fd9f4 fix: dataset inheritance with method chaining (beforeEach()->with(), describe()->with())
Fixes issue where datasets were not applied when using method chaining patterns
like beforeEach()->with([...]) or describe()->with([...]) inside nested describe blocks.

Root cause: Multiple functions were using Backtrace::file() which returns the
immediate caller's filename. This breaks when called through method chaining
because the backtrace returns internal Pest files instead of the test file.

Solution: Use Backtrace::testFile() which walks the entire backtrace to find
the actual test file being executed. This matches the pattern already used by
test() and describe() functions.

Changes in src/Functions.php:
- beforeEach(): Use testFile() to fix beforeEach()->with() pattern
- afterEach(): Use testFile() for consistency with beforeEach()
- beforeAll(): Use testFile() for better error messages
- afterAll(): Use testFile() for better error messages
- pest(): Use testFile() to fix pest()->beforeEach() pattern
- uses(): Use testFile() for consistency with pest()
- covers(): Use testFile() for correct test file context
- mutates(): Use testFile() for correct test file context

Changes in src/PendingCalls/DescribeCall.php:
- __destruct(): Force BeforeEachCall destructor before test creation
- __call(): Use $this->filename instead of Backtrace, more efficient
- __call(): Properly merge describing context for nested describe blocks

Fixes patterns:
- beforeEach()->with([...])
- describe()->with([...])
- pest()->beforeEach()->with([...]

Tests passing:
- tests/Features/Describe.php (all dataset tests)
- tests/Hooks/BeforeEachTest.php (global hook execution)
- tests/Features/Expect/toMatchSnapshot.php (28 tests)
2025-11-05 17:46:52 +01:00
d6c6489e93 Merge branch '4.x' into fix/sibling-describe-blocks 2025-07-26 04:26:10 +01:00
0bc3219a2b feat: moves visit to the core 2025-06-28 18:18:26 +01:00
ef76c04dbe feat: adds fixture 2025-06-27 02:15:28 +01:00
50ff347b59 Pass description into describe call 2025-01-20 17:40:18 -05:00
a6cd83665c Execute all parent beforeEach and afterEach functions for each test 2024-10-11 23:51:18 -04:00
b98ce0ced3 feat: adds mutates 2024-09-19 23:32:28 +01:00
c6b81e6e12 More fixes 2024-09-06 20:59:54 +01:00
c78d33b69e wip 2024-09-05 23:37:40 +01:00
bfd351783e wip 2024-09-05 22:41:26 +01:00
1cae035887 fix 2024-09-05 18:26:13 +01:00
2d80ff19ec feat(mutate): only 2024-09-05 02:49:52 +01:00
98e947e0cc more fixes 2024-09-05 01:19:17 +01:00
65f74f620c feat: adds covers 2024-09-05 00:10:29 +01:00
e2d360b1b5 chore: adjusts tests 2024-09-03 14:09:03 +01:00
ccdf43726d fix: pest() 2024-07-06 18:25:43 +01:00
04c39bae2e Adjust style 2024-06-25 21:02:52 +01:00
c65755725d feat: improves type hinting with @param-closure-this 2024-06-15 15:37:35 +01:00
c919bb5bc4 feat: adds pest function 2024-05-14 01:58:44 +01:00
ab64912c70 chore: adjusts coding style 2024-01-11 11:30:11 +00:00
5aa13b8e97 chore: adjusts coding style 2024-01-11 11:26:48 +00:00
453133d382 chore: code style changes 2023-12-15 11:42:09 +00:00
fd4f161edd release: v2.24.1 2023-10-26 11:02:35 -04:00
2cdd5e3ba0 fix: infer generic type from expectation 2023-10-21 11:06:26 +01:00
4f3796ed2e feat: improves VS Code auto-complete 2023-07-01 10:31:26 +01:00
3e8616ec64 feat(describe): continues work around hooks 2023-07-01 10:31:26 +01:00
465c65243d feat(describe): improves logic around hooks 2023-07-01 10:31:26 +01:00
97898a0a8e feat: allows to use test calls on before each calls 2023-05-01 22:18:47 +01:00
81cdb7a300 chore: refacto 2023-04-08 12:23:10 +01:00
49619ff2b5 feat: improves DX on auto-complete 2023-02-18 14:39:47 +00:00
7fdc7d6997 feat: improves auto-completion 2023-02-14 08:56:46 +00:00
6982b02d48 feat: --todo flag 2023-01-15 20:51:27 +00:00
e228d565af feat: allows to chain todo 2023-01-10 20:21:36 +00:00
70f447a8bc chore: improves type coverage 2022-12-07 09:17:35 +00:00
850955d7dd fix: reverts autoloading functions 2022-12-04 23:07:39 +00:00
3324455e0a feat: only registers globals if necessary 2022-12-04 16:32:45 +00:00
80854d5f87 Add DatasetInfo support class 2022-09-22 10:33:15 +02:00
cbee6e76b0 [feat] scoped datasets 2022-09-20 00:11:37 +02:00
45011ebd14 Code quality improvements 2022-09-16 11:27:17 +01:00
e9564febaf Migrates to Pint 2022-09-16 10:45:53 +01:00
af82c1005a Adds todo 2022-09-15 23:08:32 +01:00
b1f9ce2283 refacto: structure 2021-12-05 14:40:08 +00:00
e64b6fe924 refacto: pipes 2021-12-05 14:21:11 +00:00
98db677646 refacto: pipes 2021-12-05 14:03:09 +00:00