From ababe092bdef1fc87bef042ee8e7de8c5b185900 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Sat, 30 Nov 2024 19:01:20 +0900 Subject: [PATCH] Replace TestClass with FakeTestClass in tests This commit introduces a new FakeTestClass and replaces instances of TestClass in unit tests with FakeTestClass. Redundant classes and attributes related to TestClass are removed to streamline the test files and prevent namespace conflicts. These changes will improve maintainability and clarity in the test suite. --- tests/AirInjectorTest.php | 13 +++---------- tests/Fake/FakeTestClass.php | 12 ++++++++++++ tests/InjectionPointTest.php | 21 +++------------------ 3 files changed, 18 insertions(+), 28 deletions(-) create mode 100644 tests/Fake/FakeTestClass.php diff --git a/tests/AirInjectorTest.php b/tests/AirInjectorTest.php index b9dd0b8..63bbe44 100644 --- a/tests/AirInjectorTest.php +++ b/tests/AirInjectorTest.php @@ -45,7 +45,7 @@ protected function tearDown(): void public function testGetInstance(): void { - $className = TestClass::class; + $className = FakeTestClass::class; file_put_contents( $this->scriptDir . '/' . str_replace('\\', '_', $className) . '-' . Name::ANY . '.php', 'scriptDir . '/' . str_replace('\\', '_', $className) . '-' . Name::ANY . '.php', @@ -71,7 +71,7 @@ public function testGetInstanceSingleton(): void public function testGetInstanceWithName(): void { - $className = TestClass::class; + $className = FakeTestClass::class; $name = 'named'; file_put_contents( $this->scriptDir . '/' . str_replace('\\', '_', $className) . '-' . $name . '.php', @@ -145,10 +145,3 @@ public function testWithCompiler(): void $this->assertInstanceOf(FakeCar::class, $instance); } } - -class TestClass -{ - public function testMethod(string $param): void - { - } -} diff --git a/tests/Fake/FakeTestClass.php b/tests/Fake/FakeTestClass.php new file mode 100644 index 0000000..c222d28 --- /dev/null +++ b/tests/Fake/FakeTestClass.php @@ -0,0 +1,12 @@ +getMethod('testMethod'); $this->parameter = $reflectionMethod->getParameters()[0]; - $this->injectionPoint = InjectionPoint::getInstance([FooClass::class, 'testMethod', 'param']); + $this->injectionPoint = InjectionPoint::getInstance([FakeTestClass::class, 'testMethod', 'param']); } public function testGetParameter(): void @@ -45,7 +43,7 @@ public function testGetClass(): void { $class = $this->injectionPoint->getClass(); $this->assertInstanceOf(ReflectionClass::class, $class); - $this->assertSame(FooClass::class, $class->getName()); + $this->assertSame(FakeTestClass::class, $class->getName()); } public function testGetQualifiers(): void @@ -61,16 +59,3 @@ public function testGetQualifierReturnsNullWhenNoQualifier(): void $this->assertNull($qualifier); } } - -class FooClass -{ - public function testMethod(string $param): void - { - } -} - -#[Attribute] -#[Qualifier] -class TestQualifier -{ -}