-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWikiReadOnlyControllerTest.php
More file actions
48 lines (37 loc) · 1.29 KB
/
WikiReadOnlyControllerTest.php
File metadata and controls
48 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Tests\Routes\Backend;
use App\Wiki;
use App\WikiSetting;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class WikiReadOnlyControllerTest extends TestCase {
use RefreshDatabase;
protected string $route = '/backend/setWikiReadOnly';
public function testItReturns404WhenWikiNotFound() {
$response = $this->postJson($this->route, [
'domain' => 'nonexistent.wikibase.cloud',
]);
$response->assertStatus(404)
->assertJson([
'error' => 'Wiki not found for domain: nonexistent.wikibase.cloud',
]);
}
public function testSetWikiToReadOnly() {
$wiki = Wiki::factory()->create([
'domain' => 'somewiki.wikibase.cloud',
]);
$response = $this->postJson($this->route, [
'domain' => 'somewiki.wikibase.cloud',
]);
$response->assertStatus(200)
->assertJson([
'success' => true,
'domain' => 'somewiki.wikibase.cloud',
'message' => 'Wiki set to read-only successfully.',
]);
$this->assertSame(
'This wiki is currently read-only.',
WikiSetting::whereWikiId($wiki->id)->whereName('wgReadOnly')->first()->value
);
}
}