Skip to content

Commit afc8bff

Browse files
AC-15498: PHPUnit 12 Upgrade | Added createInvocationMatcher() to MockCreationTrait
1 parent 2e38df7 commit afc8bff

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

lib/internal/Magento/Framework/TestFramework/Unit/Helper/MockCreationTrait.php

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,42 +45,14 @@ protected function createPartialMockWithReflection(string $className, array $met
4545
}
4646

4747
/**
48-
* Convert a string matcher specification to a PHPUnit invocation matcher.
49-
*
5048
* This is useful in data providers where you cannot call PHPUnit matcher methods
5149
* directly (since they are non-static). Instead, pass a string representation
52-
* and convert it to the actual matcher in your test method.
53-
*
54-
* Supported string formats:
55-
* - 'never' → $this->never()
56-
* - 'once' → $this->once()
57-
* - 'any' → $this->any()
58-
* - 'atLeastOnce' → $this->atLeastOnce()
59-
* - 'exactly_N' → $this->exactly(N) e.g., 'exactly_3'
60-
* - 'atLeast_N' → $this->atLeast(N) e.g., 'atLeast_2'
61-
* - 'atMost_N' → $this->atMost(N) e.g., 'atMost_5'
50+
* and convert it to the actual matcher in your test method. Supported string formats:
51+
* 'never', 'once', 'any', 'atLeastOnce', 'exactly_N', 'atLeast_N', 'atMost_N`
6252
*
6353
* @param string $matcherSpec The string specification of the matcher
6454
* @return InvocationOrder The PHPUnit invocation matcher
6555
* @throws \InvalidArgumentException If the matcher specification is not recognized
66-
*
67-
* @example
68-
* // In data provider:
69-
* public static function dataProvider(): array
70-
* {
71-
* return [
72-
* ['methodName', 'returnValue', 'once'],
73-
* ['methodName', 'returnValue', 'exactly_3'],
74-
* ['methodName', 'returnValue', 'never'],
75-
* ];
76-
* }
77-
*
78-
* // In test method:
79-
* public function testMethod(string $method, string $returnValue, string $matcherSpec): void
80-
* {
81-
* $matcher = $this->createInvocationMatcher($matcherSpec);
82-
* $mock->expects($matcher)->method($method)->willReturn($returnValue);
83-
* }
8456
*/
8557
protected function createInvocationMatcher(string $matcherSpec): InvocationOrder
8658
{

0 commit comments

Comments
 (0)