@@ -43,23 +43,6 @@ protected function tearDown(): void
4343 parent ::tearDown ();
4444 }
4545
46- public function testGetOpenApiSpecReturnsDecodedJsonForMatomo ()
47- {
48- $ expectedSpec = [
49- 'openapi ' => '3.1.0 ' ,
50- 'info ' => [
51- 'title ' => 'Matomo Reporting API ' ,
52- 'version ' => '1.0.0 ' ,
53- ],
54- ];
55-
56- $ api = $ this ->buildApiMock ('/tmp/matomo_openapi_spec_v1.0.0.json ' , true , json_encode ($ expectedSpec ));
57-
58- $ result = $ api ->getOpenApiSpec ();
59-
60- $ this ->assertSame ($ expectedSpec , $ result );
61- }
62-
6346 public function testGetOpenApiSpecReturnsDecodedJsonForPlugin ()
6447 {
6548 $ expectedSpec = [
@@ -79,22 +62,22 @@ public function testGetOpenApiSpecReturnsDecodedJsonForPlugin()
7962
8063 public function testGetOpenApiSpecThrowsExceptionWhenFileMissing ()
8164 {
82- $ api = $ this ->buildApiMock ('/tmp/matomo_openapi_spec_v1 .0.0.json ' , false );
65+ $ api = $ this ->buildApiMock ('/tmp/CustomAlerts_openapi_spec_v1 .0.0.json ' , false );
8366
8467 $ this ->expectException (\Exception::class);
8568 $ this ->expectExceptionMessage ('OpenAPI spec file was not found ' );
8669
87- $ api ->getOpenApiSpec ();
70+ $ api ->getOpenApiSpec (' CustomAlerts ' );
8871 }
8972
9073 public function testGetOpenApiSpecThrowsExceptionWhenJsonIsInvalid ()
9174 {
92- $ api = $ this ->buildApiMock ('/tmp/matomo_openapi_spec_v1 .0.0.json ' , true , '{invalid json} ' );
75+ $ api = $ this ->buildApiMock ('/tmp/CustomAlerts_openapi_spec_v1 .0.0.json ' , true , '{invalid json} ' );
9376
9477 $ this ->expectException (\Exception::class);
9578 $ this ->expectExceptionMessage ('OpenAPI spec file contains invalid JSON ' );
9679
97- $ api ->getOpenApiSpec ();
80+ $ api ->getOpenApiSpec (' CustomAlerts ' );
9881 }
9982
10083 public function testGetOpenApiSpecThrowsExceptionWhenFormatIsInvalid ()
@@ -107,14 +90,13 @@ public function testGetOpenApiSpecThrowsExceptionWhenFormatIsInvalid()
10790 $ api ->getOpenApiSpec ('CustomAlerts ' , 'yaml ' );
10891 }
10992
110- public function testGetSpecFilePathUsesMatomoFileNameByDefault ()
93+ public function testGetOpenApiSpecThrowsExceptionWhenSpecIsNotAValidPlugin ()
11194 {
11295 $ api = new API ();
11396
114- $ this ->assertSame (
115- PIWIK_INCLUDE_PATH . '/plugins/OpenApiDocs/tmp/specs/matomo_openapi_spec_v1.0.0.json ' ,
116- $ this ->callProtectedMethod ($ api , 'getSpecFilePath ' , ['matomo ' ])
117- );
97+ $ this ->expectException (\Piwik \Exception \PluginNotFoundException::class);
98+
99+ $ api ->getOpenApiSpec ('DefinitelyNotARealPlugin ' );
118100 }
119101
120102 public function testGetSpecFilePathUsesPluginSpecificFileName ()
0 commit comments