Skip to content

Commit c0633e3

Browse files
committed
Add authorization to tests
1 parent 45d8a7d commit c0633e3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tests/Http/Controllers/PreviewControllerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
actingAs(User::find()->one());
1818

1919
$this->entry = Entry::factory()->create();
20+
21+
Craft::$app->getSession()->authorize("previewElement:{$this->entry->id}");
2022
});
2123

2224
it('can create a token', function () {

tests/Http/Controllers/StructuresControllerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
$user->update(['admin' => true]);
6060
actingAs($user->asElement());
6161

62+
Craft::$app->getSession()->authorize("editStructure:{$structure->id}");
63+
6264
$status = postJson($route, [
6365
'structureId' => $structure->id,
6466
'elementId' => $structure->structureElements()->first()->elementId,
@@ -71,6 +73,8 @@
7173
it('needs a valid element', function (string $route) {
7274
$structure = Structure::factory()->create();
7375

76+
Craft::$app->getSession()->authorize("editStructure:{$structure->id}");
77+
7478
postJson($route, [
7579
'structureId' => $structure->id,
7680
'elementId' => 999,
@@ -82,6 +86,7 @@
8286
$structure = Structure::factory()->create();
8387
$root = $structure->structureElements()->firstOrFail();
8488
Entry::factory()->create(['id' => $root->elementId]);
89+
Craft::$app->getSession()->authorize("editStructure:{$structure->id}");
8590

8691
$child = new StructureElement([
8792
'structureId' => $structure->id,
@@ -116,6 +121,7 @@
116121
$structure = Structure::factory()->create();
117122
$root = $structure->structureElements()->firstOrFail();
118123
Entry::factory()->create(['id' => $root->elementId]);
124+
Craft::$app->getSession()->authorize("editStructure:{$structure->id}");
119125

120126
$child1 = new StructureElement([
121127
'structureId' => $structure->id,

0 commit comments

Comments
 (0)