Skip to content

Commit 1652a67

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Tests] Remove occurrences of `withConsecutive()` Fix support binary values in parameters. [Dotenv] Improve Dotenv::usePutenv phpdoc
2 parents 27eaa1b + 355db9a commit 1652a67

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Tests/Extension/StopwatchExtensionTest.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\Twig\Extension\StopwatchExtension;
1616
use Symfony\Component\Stopwatch\Stopwatch;
17+
use Symfony\Component\Stopwatch\StopwatchEvent;
1718
use Twig\Environment;
1819
use Twig\Error\RuntimeError;
1920
use Twig\Loader\ArrayLoader;
@@ -67,12 +68,29 @@ protected function getStopwatch($events = [])
6768
$expectedStopCalls[] = [$this->equalTo($eventName)];
6869
}
6970

70-
$startInvocationMocker = $stopwatch->expects($this->exactly($expectedCalls))
71-
->method('start');
72-
\call_user_func_array([$startInvocationMocker, 'withConsecutive'], $expectedStartCalls);
73-
$stopInvocationMocker = $stopwatch->expects($this->exactly($expectedCalls))
74-
->method('stop');
75-
\call_user_func_array([$stopInvocationMocker, 'withConsecutive'], $expectedStopCalls);
71+
$stopwatch
72+
->expects($this->exactly($expectedCalls))
73+
->method('start')
74+
->willReturnCallback(function (string $name, string $category) use (&$expectedStartCalls) {
75+
[$expectedName, $expectedCategory] = array_shift($expectedStartCalls);
76+
77+
$expectedName->evaluate($name);
78+
$this->assertSame($expectedCategory, $category);
79+
80+
return $this->createMock(StopwatchEvent::class);
81+
})
82+
;
83+
84+
$stopwatch
85+
->expects($this->exactly($expectedCalls))
86+
->method('stop')
87+
->willReturnCallback(function (string $name) use (&$expectedStopCalls) {
88+
[$expectedName] = array_shift($expectedStopCalls);
89+
$expectedName->evaluate($name);
90+
91+
return $this->createMock(StopwatchEvent::class);
92+
})
93+
;
7694

7795
return $stopwatch;
7896
}

0 commit comments

Comments
 (0)