Skip to content

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Sep 25, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? no
Deprecations? no
Issues
License MIT

Instead of performing some fuzzy matching on the automatically generated mock name (the pattern varies between different PHPUnit versions) we can simply use the actual exact class name.

@xabbuh xabbuh requested a review from chalasr as a code owner September 25, 2024 20:35
@carsonbot carsonbot added this to the 7.2 milestone Sep 25, 2024
@xabbuh xabbuh force-pushed the phpunit-mock-class-name-matching branch 2 times, most recently from 3b2aed5 to 1c7c9ad Compare September 25, 2024 20:47
Instead of performing some fuzzy matching on the automatically generated mock
name (the pattern varies between different PHPUnit versions) we can simply
use the actual exact class name.
@xabbuh xabbuh force-pushed the phpunit-mock-class-name-matching branch from 1c7c9ad to 2c99e00 Compare September 25, 2024 20:50
@nicolas-grekas
Copy link
Member

Thank you @xabbuh.

@nicolas-grekas nicolas-grekas merged commit 996d98e into symfony:7.2 Sep 26, 2024
9 of 10 checks passed
@@ -44,7 +44,7 @@ public function testItSendsTheMessageToAssignedSender()
/* @var SentStamp $stamp */
$this->assertInstanceOf(SentStamp::class, $stamp = $envelope->last(SentStamp::class), 'it adds a sent stamp');
$this->assertSame('my_sender', $stamp->getSenderAlias());
$this->assertStringMatchesFormat('Mock_SenderInterface_%s', $stamp->getSenderClass());
$this->assertStringMatchesFormat($sender::class, $stamp->getSenderClass());
Copy link
Member

Choose a reason for hiding this comment

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

use assertEquals instead of matching a format then.

Copy link
Member Author

Choose a reason for hiding this comment

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

@xabbuh xabbuh deleted the phpunit-mock-class-name-matching branch September 26, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants