@@ -63,4 +63,42 @@ public function testIndexEagerLoadsWikiLatestProfileOnceForCollection(): void {
6363 $ this ->assertSame (1 , $ wikiProfileQueryCount );
6464 $ this ->assertTrue ($ resourceCollection ->first ()->relationLoaded ('wikiLatestProfile ' ));
6565 }
66+
67+ public function testIndexReturnsFalseWhenWikiHasNoLatestProfile (): void {
68+ $ wikiWithoutProfile = Wiki::factory ()->create ([
69+ 'domain ' => 'no-profile.wikibase.cloud ' ,
70+ 'sitename ' => 'No Profile Test Site ' ,
71+ ]);
72+
73+ $ controller = new PublicWikiController ;
74+ $ request = new Request ;
75+ $ resourceCollection = $ controller ->index ($ request );
76+
77+ $ resource = $ resourceCollection ->firstWhere ('id ' , $ wikiWithoutProfile ->id );
78+
79+ $ this ->assertNotNull ($ resource );
80+ $ this ->assertFalse ($ resource ->toArray ($ request )['reuse_prototype ' ]);
81+ }
82+
83+ public function testIndexReturnsFalseWhenWikiLatestProfileDoesNotMatchReusePrototype (): void {
84+ $ incompleteProfileWiki = Wiki::factory ()->create ([
85+ 'domain ' => 'incomplete-profile.wikibase.cloud ' ,
86+ 'sitename ' => 'Incomplete Profile Test Site ' ,
87+ ]);
88+ WikiProfile::create ([
89+ 'wiki_id ' => $ incompleteProfileWiki ->id ,
90+ 'purpose ' => 'other ' ,
91+ 'temporality ' => 'temporary ' ,
92+ 'audience ' => 'other ' ,
93+ ]);
94+
95+ $ controller = new PublicWikiController ;
96+ $ request = new Request ;
97+ $ resourceCollection = $ controller ->index ($ request );
98+
99+ $ resource = $ resourceCollection ->firstWhere ('id ' , $ incompleteProfileWiki ->id );
100+
101+ $ this ->assertNotNull ($ resource );
102+ $ this ->assertFalse ($ resource ->toArray ($ request )['reuse_prototype ' ]);
103+ }
66104}
0 commit comments