File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \Routes \Backend ;
4+
5+ use App \Wiki ;
6+ use App \WikiSetting ;
7+ use Illuminate \Foundation \Testing \RefreshDatabase ;
8+ use Tests \TestCase ;
9+
10+ class WikiReadOnlyControllerTest extends TestCase {
11+ use RefreshDatabase;
12+
13+ protected string $ route = '/backend/setWikiReadOnly ' ;
14+
15+ public function testItReturns404WhenWikiNotFound (){
16+ $ response = $ this ->postJson ($ this ->route , [
17+ 'domain ' => 'nonexistent.wikibase.cloud '
18+ ]);
19+
20+ $ response ->assertStatus (404 )
21+ ->assertJson ([
22+ 'error ' => 'Wiki not found for domain: nonexistent.wikibase.cloud ' ,
23+ ]);
24+ }
25+
26+ public function testSetWikiToReadOnly (){
27+ $ wiki = Wiki::factory ()->create ([
28+ 'domain ' => 'somewiki.wikibase.cloud ' ,
29+ ]);
30+
31+ $ response = $ this ->postJson ($ this ->route , [
32+ 'domain ' => 'somewiki.wikibase.cloud ' ,
33+ ]);
34+
35+ $ response ->assertStatus (200 )
36+ ->assertJson ([
37+ 'success ' => true ,
38+ 'domain ' => 'somewiki.wikibase.cloud ' ,
39+ 'message ' => 'Wiki set to read-only successfully. ' ,
40+ ]);
41+
42+ $ this ->assertSame (
43+ 'This wiki is currently read-only. ' ,
44+ WikiSetting::whereWikiId ($ wiki ->id )->whereName ('wgReadOnly ' )->first ()->value
45+ );
46+
47+ }
48+
49+ }
You can’t perform that action at this time.
0 commit comments