From 28538c1a346df6273e882d235e417086ed9e19c7 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 3 Sep 2024 15:20:25 +0300 Subject: [PATCH] Add getter for ActivityPrototype::$factory (#492) --- src/Internal/Declaration/Prototype/ActivityPrototype.php | 5 +++++ tests/Unit/Activity/ActivityPrototypeTestCase.php | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Internal/Declaration/Prototype/ActivityPrototype.php b/src/Internal/Declaration/Prototype/ActivityPrototype.php index 021abc074..81d9dc1ed 100644 --- a/src/Internal/Declaration/Prototype/ActivityPrototype.php +++ b/src/Internal/Declaration/Prototype/ActivityPrototype.php @@ -112,4 +112,9 @@ public function isLocalActivity(): bool { return $this->isLocalActivity; } + + public function getFactory(): ?Closure + { + return $this->factory; + } } diff --git a/tests/Unit/Activity/ActivityPrototypeTestCase.php b/tests/Unit/Activity/ActivityPrototypeTestCase.php index b0bcc733a..67ea648a7 100644 --- a/tests/Unit/Activity/ActivityPrototypeTestCase.php +++ b/tests/Unit/Activity/ActivityPrototypeTestCase.php @@ -111,4 +111,13 @@ public function testFactoryAcceptsReflectionClassOfActivity(): void $this->assertEquals($protoWithFactory->getInstance()->getContext(), $protoWithFactory->getInstance()->getContext()); $this->assertNotSame($protoWithFactory->getInstance()->getContext(), $protoWithFactory->getInstance()->getContext()); } + + public function testGetFactory(): void + { + $proto = $this->activityReader->fromClass(DummyActivity::class)[0]; + $protoWithFactory = $proto->withFactory(fn (\ReflectionClass $reflectionClass) => $reflectionClass->newInstance()); + + $this->assertNull($proto->getFactory()); + $this->assertNotNull($protoWithFactory->getFactory()); + } }