-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathInjectPlugin.php
More file actions
33 lines (29 loc) · 1.03 KB
/
Copy pathInjectPlugin.php
File metadata and controls
33 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
namespace Testo\Testing;
use Internal\Container\Container;
use Testo\Common\PluginConfigurator;
use Testo\Pipeline\InterceptorCollector;
use Testo\Testing\Attribute\Inject;
use Testo\Testing\Internal\ExpectInterceptor;
use Testo\Testing\Internal\InjectInterceptor;
/**
* Enables property autowiring for test case classes.
*
* Registers {@see InjectInterceptor}, which populates properties marked with
* {@see Inject} from the DI container right after a test case object is created.
*
* @internal
* @psalm-internal Testo
*/
final readonly class InjectPlugin implements PluginConfigurator
{
#[\Override]
public function configure(Container $container): void
{
# Registered as a class-string so the collector resolves it through the
# container and autowires the {@see Container} dependency.
$container->get(InterceptorCollector::class)->addInterceptor(InjectInterceptor::class);
$container->get(InterceptorCollector::class)->addInterceptor(new ExpectInterceptor());
}
}