|
10 | 10 | use App\WikiSetting; |
11 | 11 | use App\User; |
12 | 12 | use App\WikiManager; |
| 13 | +use App\WikiProfile; |
13 | 14 |
|
14 | 15 | class DetailsTest extends TestCase |
15 | 16 | { |
@@ -59,4 +60,41 @@ public function testSkipsNonPublicSettings() |
59 | 60 | $this->assertEquals('wwUseQuestyCaptcha', $publicSettings[0]['name']); |
60 | 61 | $this->assertEquals(1, $publicSettings[0]['value']); |
61 | 62 | } |
| 63 | + |
| 64 | + public function testWikiProfile() |
| 65 | + { |
| 66 | + $wiki = Wiki::factory()->create(); |
| 67 | + $user = User::factory()->create(['verified' => true]); |
| 68 | + WikiManager::factory()->create(['wiki_id' => $wiki->id, 'user_id' => $user->id]); |
| 69 | + |
| 70 | + $versionA = WikiProfile::create([ |
| 71 | + 'wiki_id' => $wiki->id, |
| 72 | + 'audience' => 'wide', |
| 73 | + 'temporality' => 'temporary', |
| 74 | + 'purpose' => 'data_hub' |
| 75 | + ])->refresh()->toArray(); |
| 76 | + |
| 77 | + $response = $this->actingAs($user, 'api') |
| 78 | + ->postJson($this->route, ['wiki' => $wiki->id]) |
| 79 | + ->assertStatus(200); |
| 80 | + |
| 81 | + $profile = data_get($response->json(), 'data.wiki_latest_profile', []); |
| 82 | + $this->assertNotEmpty($profile); |
| 83 | + $this->assertEquals($versionA, $profile); |
| 84 | + |
| 85 | + $versionB = WikiProfile::create([ |
| 86 | + 'wiki_id' => $wiki->id, |
| 87 | + 'audience' => 'wide', |
| 88 | + 'temporality' => 'permanent', |
| 89 | + 'purpose' => 'data_hub' |
| 90 | + ])->refresh()->toArray(); |
| 91 | + |
| 92 | + $response = $this->actingAs($user, 'api') |
| 93 | + ->postJson($this->route, ['wiki' => $wiki->id]) |
| 94 | + ->assertStatus(200); |
| 95 | + |
| 96 | + $profile = data_get($response->json(), 'data.wiki_latest_profile', []); |
| 97 | + $this->assertNotEmpty($profile); |
| 98 | + $this->assertEquals($versionB, $profile); |
| 99 | + } |
62 | 100 | } |
0 commit comments