Skip to content

Commit 869ab67

Browse files
test: add test for shared state builder timing
1 parent a12628a commit 869ab67

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/Feature/SharedStateTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,20 @@
182182
],
183183
]);
184184
});
185+
186+
it('sets the shared state at the correct time when the builder is used', function () {
187+
$cat = Cat::factory()->new()->createOne();
188+
$dog = Dog::factory()->new()->createOne();
189+
190+
expect(ActiveState::getShared())->toBe(app(StateRegistry::class)->getDefaultState());
191+
192+
$builder = CatResource::state('table');
193+
194+
DogResource::make($dog);
195+
196+
expect(ActiveState::getShared())->toBe(app(StateRegistry::class)->getDefaultState());
197+
198+
$builder->make($cat);
199+
200+
expect(ActiveState::getShared())->toBe('table');
201+
});

0 commit comments

Comments
 (0)