Skip to content

Commit

Permalink
Add getter for ActivityPrototype::$factory (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm authored Sep 3, 2024
1 parent 7a11616 commit 28538c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Internal/Declaration/Prototype/ActivityPrototype.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,9 @@ public function isLocalActivity(): bool
{
return $this->isLocalActivity;
}

public function getFactory(): ?Closure
{
return $this->factory;
}
}
9 changes: 9 additions & 0 deletions tests/Unit/Activity/ActivityPrototypeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 28538c1

Please sign in to comment.