Skip to content

Enable PHPUnit mocks in tests#24

Merged
DanielBadura merged 1 commit into1.7.xfrom
enable-mocks
Apr 2, 2026
Merged

Enable PHPUnit mocks in tests#24
DanielBadura merged 1 commit into1.7.xfrom
enable-mocks

Conversation

@DanielBadura
Copy link
Copy Markdown
Member

Move execution into when instead of the #[After] hook. This enables unit testing with phpunit mocks, as they are currently cleanuped before asserting.

…es unit testing with phpunit mocks, as they are currently cleanuped before asserting.
@DanielBadura DanielBadura requested a review from DavidBadura April 2, 2026 11:46
@DanielBadura DanielBadura self-assigned this Apr 2, 2026
@DanielBadura DanielBadura added the enhancement New feature or request label Apr 2, 2026
@DanielBadura DanielBadura added this to the 1.7.0 milestone Apr 2, 2026
self::assertSame(1, $test::getCount());
}

public function testVisitedDoubleAssert(): void
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a weird test which aimed for infeciton 100%, not needed anymore.

$test
->when(
static fn () => 'no aggregate as return',
static fn () => null,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes more sense

$test = $this->getTester();

$notifier = $this->createMock(Notifier::class);
$notifier->expects($this->once())->method('notify');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without these changes, phpunit would always say that the function was never called.

@DanielBadura
Copy link
Copy Markdown
Member Author

BC-Check unrelated due to PHPunit changes internally.

@DanielBadura DanielBadura merged commit 7fbdfaa into 1.7.x Apr 2, 2026
21 of 22 checks passed
@DanielBadura DanielBadura deleted the enable-mocks branch April 2, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants