33namespace PSFS \tests \controller ;
44
55use PHPUnit \Framework \TestCase ;
6+ use PSFS \base \Router ;
67use PSFS \base \Security ;
78use PSFS \base \exception \ApiException ;
89use PSFS \controller \AdminFrontendRoutesController ;
910
1011class AdminFrontendRoutesControllerTest extends TestCase
1112{
13+ protected function setUp (): void
14+ {
15+ Router::dropInstance ();
16+ Router::getInstance ()->hydrateRouting ();
17+ }
18+
1219 protected function tearDown (): void
1320 {
1421 Security::setTest (false );
1522 Security::dropInstance ();
23+ Router::dropInstance ();
1624 }
1725
1826 public function testRoutesEndpointReturnsTheRouterCatalogWithoutHtml (): void
@@ -26,21 +34,13 @@ public function testRoutesEndpointReturnsTheRouterCatalogWithoutHtml(): void
2634
2735 public function testDocumentationIndexReturnsTheKnownDomainsAsAnEnvelope (): void
2836 {
29- $ response = (new AdminFrontendRoutesControllerProbe ())->documentation ();
30-
31- self ::assertStringContainsString ('"ok":true ' , $ response );
32- self ::assertStringContainsString ('"domains" ' , $ response );
33- self ::assertStringContainsString ('"documentPaths" ' , $ response );
34- self ::assertStringContainsString ('/CLIENT/api/doc ' , $ response );
35- self ::assertStringNotContainsString ('<html ' , strtolower ($ response ));
36- }
37-
38- public function testDocumentationDomainAcceptsTheDomainPublishedByTheIndex (): void
39- {
40- $ response = (new AdminFrontendRoutesControllerProbe ())->documentationDomain ('client ' );
37+ $ response = json_decode ((new AdminFrontendRoutesControllerProbe ())->documentation (), true , 512 , JSON_THROW_ON_ERROR );
4138
42- self ::assertStringContainsString ('"ok":true ' , $ response );
43- self ::assertStringContainsString ('"openapi" ' , $ response );
39+ self ::assertTrue ($ response ['ok ' ]);
40+ self ::assertNotEmpty ($ response ['data ' ]['domains ' ]);
41+ foreach ($ response ['data ' ]['domains ' ] as $ domain ) {
42+ self ::assertSame ('/ ' . strtoupper ($ domain ) . '/api/doc ' , $ response ['data ' ]['documentPaths ' ][$ domain ]);
43+ }
4444 }
4545
4646 public function testDocumentationDomainReturnsTheV2EnvelopeForAnUnknownDomain (): void
0 commit comments