Skip to content

Commit 8ac9b3d

Browse files
committed
add test for reuse_prototype
1 parent 148925e commit 8ac9b3d

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

tests/Routes/Wiki/PublicWikiTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\Routes\Wiki;
44

55
use App\Wiki;
6+
use App\WikiProfile;
67
use App\WikiSetting;
78
use App\WikiSiteStats;
89
use Illuminate\Foundation\Testing\DatabaseTransactions;
@@ -18,12 +19,14 @@ class PublicWikiTest extends TestCase {
1819
protected function setUp(): void {
1920
parent::setUp();
2021
Wiki::query()->delete();
22+
WikiProfile::query()->delete();
2123
WikiSiteStats::query()->delete();
2224
WikiSetting::query()->delete();
2325
}
2426

2527
protected function tearDown(): void {
2628
Wiki::query()->delete();
29+
WikiProfile::query()->delete();
2730
WikiSiteStats::query()->delete();
2831
WikiSetting::query()->delete();
2932
parent::tearDown();
@@ -279,4 +282,48 @@ public function testLogoUrl() {
279282
)
280283
->assertJsonPath('data.1.logo_url', null);
281284
}
285+
286+
public function testReusePrototype() {
287+
$reusableWiki = Wiki::factory()->create([
288+
'domain' => 'reusable.wikibase.cloud', 'sitename' => 'asite',
289+
]);
290+
WikiSiteStats::factory()->create([
291+
'wiki_id' => $reusableWiki->id,
292+
]);
293+
WikiProfile::create([
294+
'wiki_id' => $reusableWiki->id,
295+
'purpose' => 'data_hub',
296+
'temporality' => 'permanent',
297+
'audience' => 'wide',
298+
]);
299+
300+
$nonReusableWiki = Wiki::factory()->create([
301+
'domain' => 'non-reusable.wikibase.cloud', 'sitename' => 'bsite',
302+
]);
303+
WikiSiteStats::factory()->create([
304+
'wiki_id' => $nonReusableWiki->id,
305+
]);
306+
WikiProfile::create([
307+
'wiki_id' => $nonReusableWiki->id,
308+
'purpose' => 'other',
309+
'temporality' => 'other',
310+
'audience' => 'other',
311+
]);
312+
313+
$noProfileWiki = Wiki::factory()->create([
314+
'domain' => 'no-profile.wikibase.cloud', 'sitename' => 'csite',
315+
]);
316+
WikiSiteStats::factory()->create([
317+
'wiki_id' => $noProfileWiki->id,
318+
]);
319+
320+
$this->json('GET', $this->route)
321+
->assertStatus(200)
322+
->assertJsonPath('data.0.domain', 'reusable.wikibase.cloud')
323+
->assertJsonPath('data.0.reuse_prototype', true)
324+
->assertJsonPath('data.1.domain', 'non-reusable.wikibase.cloud')
325+
->assertJsonPath('data.1.reuse_prototype', false)
326+
->assertJsonPath('data.2.domain', 'no-profile.wikibase.cloud')
327+
->assertJsonPath('data.2.reuse_prototype', null);
328+
}
282329
}

0 commit comments

Comments
 (0)