Skip to content

Commit dea83b2

Browse files
committed
"Fixed potential self-loop issue in Then object and updated related tests"
1 parent 0844fe3 commit dea83b2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/ValueObjects/Then.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class Then
1515
*/
1616
public function __construct(public string $action, public string|UnitEnum $then)
1717
{
18-
if ($action === FractionName::format($then)) {
18+
if (FractionName::format($action) === FractionName::format($then)) {
1919
throw new PreventLoop();
2020
}
2121
}

tests/Feature/ValueObjects/ThenTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
use Fraction\ValueObjects\Then;
77

88
test('can instantiate', function () {
9-
$then = new Then('foo', 'foo');
9+
$then = new Then('foo', 'bar');
1010

11-
expect($then->then)->toBe('foo');
11+
expect($then->then)->toBe('bar');
1212
});
1313

1414
test('cannot instantiate due same name', function () {
15-
$then = new Then('__fraction.foo', 'foo');
15+
$then = new Then('action', 'action');
1616

1717
expect($then->then)->toBe('foo');
1818
})->throws(PreventLoop::class, 'The hook "then" cannot be used to invoke itself.');

0 commit comments

Comments
 (0)