Skip to content

Commit

Permalink
more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Jan 19, 2025
1 parent 87c00ca commit 3acb183
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/Feature_v2/Settings/UpdateSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,64 @@ public function testUpdateSettingsAdmin(): void
]);
$this->assertCreated($response);
}

public function testUpdateCssForbidden(): void
{
$response = $this->postJson('Settings::setCSS', []);
$this->assertUnprocessable($response);

$response = $this->postJson('Settings::setCSS', [
'css' => 'body { background-color: red; }',
]);
$this->assertUnauthorized($response);

$response = $this->actingAs($this->userMayUpload1)->postJson('Settings::setCSS', []);
$this->assertUnprocessable($response);

$response = $this->actingAs($this->userMayUpload1)->postJson('Settings::setCSS', [
'css' => 'body { background-color: red; }',
]);
$this->assertForbidden($response);
}

public function testUpdateCssAdmin(): void
{
$response = $this->actingAs($this->admin)->postJson('Settings::setCSS', []);
$this->assertUnprocessable($response);

$response = $this->actingAs($this->admin)->postJson('Settings::setCSS', [
'css' => 'body { background-color: red; }',
]);
$this->assertNoContent($response);
}

public function testupdateJsForbiddne(): void
{
$response = $this->postJson('Settings::setJS', []);
$this->assertUnprocessable($response);

$response = $this->postJson('Settings::setJS', [
'js' => 'console.log("Hello World!");',
]);
$this->assertUnauthorized($response);

$response = $this->actingAs($this->userMayUpload1)->postJson('Settings::setJS', []);
$this->assertUnprocessable($response);

$response = $this->actingAs($this->userMayUpload1)->postJson('Settings::setJS', [
'js' => 'console.log("Hello World!");',
]);
$this->assertForbidden($response);
}

public function testUpdateJsAdmin(): void
{
$response = $this->actingAs($this->admin)->postJson('Settings::setJS', []);
$this->assertUnprocessable($response);

$response = $this->actingAs($this->admin)->postJson('Settings::setJS', [
'js' => 'console.log("Hello World!");',
]);
$this->assertNoContent($response);
}
}

0 comments on commit 3acb183

Please sign in to comment.