Skip to content

Commit

Permalink
Add red test for annotated matcher in AspectTest
Browse files Browse the repository at this point in the history
See #218

This commit introduces a new test method `testAnnotateMatcher` to ensure that classes marked with the `FakeClassMarker` annotation are correctly intercepted by the aspect. The method verifies the instance creation and binding of interceptors to annotated classes.
  • Loading branch information
koriym committed Sep 3, 2024
1 parent 3af54e5 commit 5e88adb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/Aspect/AspectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Ray\Aop;

use PHPUnit\Framework\TestCase;
use Ray\Aop\Annotation\FakeClassMarker;
use Ray\Aop\Aspect\Fake\src\FakeMyClass;
use Ray\Aop\Matcher\AnyMatcher;
use Ray\Aop\Matcher\StartsWithMatcher;
Expand Down Expand Up @@ -63,4 +64,17 @@ public function testWeave(): void
// the original method is intercepted
$this->assertEquals('intercepted original', $result);
}

public function testAnnotateMatcher(): void
{
$aspect = new Aspect();
$aspect->bind(
(new Matcher())->annotatedWith(FakeClassMarker::class),
(new Matcher())->any(),
[new FakeMyInterceptor()]
);

$billing = $aspect->newInstance(FakeMyClass::class);
$this->assertInstanceOf(FakeMyClass::class, $billing);
}
}

0 comments on commit 5e88adb

Please sign in to comment.