-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWikiControllerTest.php
More file actions
53 lines (43 loc) · 1.42 KB
/
WikiControllerTest.php
File metadata and controls
53 lines (43 loc) · 1.42 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
49
50
51
52
53
<?php
namespace Tests\Routes\Backend;
use App\Wiki;
use App\WikiDb;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class WikiControllerTest extends TestCase {
use RefreshDatabase;
protected $route = '/backend/wiki/getWikiForDomain';
private function createWiki(string $domain) {
$wiki = Wiki::factory()->create(['domain' => $domain]);
WikiDb::create([
'name' => $domain,
'user' => 'someUser',
'password' => 'somePassword',
'prefix' => 'somePrefix',
'version' => 'someVersion',
'wiki_id' => $wiki->id,
]);
}
public function testGetWikiDomainSuccess() {
$wikiDomain = 'coffeebase.wikibase.cloud';
$this->createWiki($wikiDomain);
$this->get("{$this->route}?domain={$wikiDomain}")
->assertStatus(200)
->assertJsonPath('data.domain', $wikiDomain)
->assertJsonStructure([
'data' => [
'domain',
'sitename',
'wiki_queryservice_namespace',
],
]);
}
public function testGetWikiDomainMissingWikiDomain() {
$this->getJson("{$this->route}")
->assertStatus(422);
}
public function testGetWikiDomainWikiNotFound() {
$this->getJson("{$this->route}?domain=somewiki")
->assertStatus(404);
}
}