InteractsWithAop
trait InteractsWithAop
Provides a test helper for invoking a method through the AOP pipeline without relying on generated proxies.
In full application or Testbench integration tests, AOP proxies may already be generated and those tests should call the target method normally. This trait is for tests where the target is not already proxied, or where the goal is to exercise aspect pipeline behavior directly.
callWithAspects() invokes the same dispatcher used by generated proxies before calling the original method via reflection.
Methods
Determine if the given instance is already running through an AOP proxy.
Call a method through the registered AOP aspect pipeline.
Details
at line 38
protected bool
isAopProxied(object $instance)
Determine if the given instance is already running through an AOP proxy.
This is useful in tests that need to handle both execution paths explicitly. In isolated runs, the target class may be proxied during bootstrap and should be called normally. In larger test runs, load order may mean the original class was loaded before proxy generation, so the test must use callWithAspects() instead.
Keeping this check separate makes it clear whether the test is using the real proxy path or the manual pipeline path.
at line 55
protected mixed
callWithAspects(object $instance, string $method, array $arguments = [])
Call a method through the registered AOP aspect pipeline.
Builds a ProceedingJoinPoint for the given instance and method, resolves matching aspects from AspectCollector, and executes them in priority order. The original method is called via reflection at the end of the pipeline. The instance must not already be proxied.