Skip to content

Commit 662ddbb

Browse files
committed
test: refactor PolicyTest to use beforeEach for configuration setup
1 parent 20f28f0 commit 662ddbb

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

contexts/Authorization/Tests/Feature/PolicyTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
use Contexts\Authorization\Infrastructure\Repositories\UserRepository;
1313
use Illuminate\Support\Facades\Config;
1414

15-
function setTestConfig()
16-
{
15+
beforeEach(function () {
1716
Config::set('policies.article_publishing', [
1817
'context_default' => [
1918
'handler' => RolePolicy::class,
@@ -31,11 +30,9 @@ function setTestConfig()
3130
],
3231
],
3332
]);
34-
}
33+
});
3534

3635
it('can get default policy handler', function () {
37-
setTestConfig();
38-
3936
$policy = app(PolicyFactory::class)
4037
->forContext('article_publishing')
4138
->action('publish');
@@ -44,8 +41,6 @@ function setTestConfig()
4441
});
4542

4643
it('can evaluate user against policy', function () {
47-
setTestConfig();
48-
4944
$userRepository = new UserRepository;
5045

5146
$userRecord = UserRecord::factory()->create();

0 commit comments

Comments
 (0)