/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Console/Tests/ArgumentResolver/TraceableArgumentResolverTest.php
69 строк
2 KB
Robin Chalas
[Console][WebProfilerBundle] Trace value resolvers in profiler
23 фев 2026, 19:59
Не верифицирован
23 фев 2026, 19:59
85f8372
Код
Авторство
О чём код?
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Tests\ArgumentResolver; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\ArgumentResolver\ArgumentResolverInterface; use Symfony\Component\Console\ArgumentResolver\TraceableArgumentResolver; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Stopwatch\Stopwatch; class TraceableArgumentResolverTest extends TestCase { public function testTimingsInGetArguments() { $stopwatch = new Stopwatch(); $innerResolver = new class implements ArgumentResolverInterface { public function getArguments(InputInterface $input, callable $command, ?\ReflectionFunctionAbstract $reflector = null): array { return ['arg1', 'arg2']; } }; $resolver = new TraceableArgumentResolver($innerResolver, $stopwatch); $input = new ArrayInput([]); $command = static fn () => 0; $arguments = $resolver->getArguments($input, $command); $this->assertSame(['arg1', 'arg2'], $arguments); $event = $stopwatch->getEvent('command.get_arguments'); $this->assertCount(1, $event->getPeriods()); } public function testTimingsAreRecordedOnException() { $stopwatch = new Stopwatch(); $innerResolver = new class implements ArgumentResolverInterface { public function getArguments(InputInterface $input, callable $command, ?\ReflectionFunctionAbstract $reflector = null): array { throw new \RuntimeException('Test exception'); } }; $resolver = new TraceableArgumentResolver($innerResolver, $stopwatch); $input = new ArrayInput([]); $command = static fn () => 0; try { $resolver->getArguments($input, $command); $this->fail('Expected exception was not thrown'); } catch (\RuntimeException $e) { $this->assertSame('Test exception', $e->getMessage()); } $event = $stopwatch->getEvent('command.get_arguments'); $this->assertCount(1, $event->getPeriods()); } }