|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bridge\PhpUnit; |
| 13 | + |
| 14 | +use PHPUnit\Runner\Extension\Extension; |
| 15 | +use PHPUnit\Runner\Extension\Facade; |
| 16 | +use PHPUnit\Runner\Extension\ParameterCollection; |
| 17 | +use PHPUnit\TextUI\Configuration\Configuration; |
| 18 | +use Symfony\Bridge\PhpUnit\Extension\DisableClockMockSubscriber; |
| 19 | +use Symfony\Bridge\PhpUnit\Extension\DisableDnsMockSubscriber; |
| 20 | +use Symfony\Bridge\PhpUnit\Extension\EnableClockMockSubscriber; |
| 21 | +use Symfony\Bridge\PhpUnit\Extension\RegisterClockMockSubscriber; |
| 22 | +use Symfony\Bridge\PhpUnit\Extension\RegisterDnsMockSubscriber; |
| 23 | +use Symfony\Component\ErrorHandler\DebugClassLoader; |
| 24 | + |
| 25 | +class SymfonyExtension implements Extension |
| 26 | +{ |
| 27 | + public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void |
| 28 | + { |
| 29 | + if (class_exists(DebugClassLoader::class)) { |
| 30 | + DebugClassLoader::enable(); |
| 31 | + } |
| 32 | + |
| 33 | + if ($parameters->has('clock-mock-namespaces')) { |
| 34 | + foreach (explode(',', $parameters->get('clock-mock-namespaces')) as $namespace) { |
| 35 | + ClockMock::register($namespace.'\DummyClass'); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + $facade->registerSubscriber(new RegisterClockMockSubscriber()); |
| 40 | + $facade->registerSubscriber(new EnableClockMockSubscriber()); |
| 41 | + $facade->registerSubscriber(new DisableClockMockSubscriber()); |
| 42 | + |
| 43 | + if ($parameters->has('dns-mock-namespaces')) { |
| 44 | + foreach (explode(',', $parameters->get('dns-mock-namespaces')) as $namespace) { |
| 45 | + DnsMock::register($namespace.'\DummyClass'); |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + $facade->registerSubscriber(new RegisterDnsMockSubscriber()); |
| 50 | + $facade->registerSubscriber(new DisableDnsMockSubscriber()); |
| 51 | + } |
| 52 | +} |
0 commit comments