diff --git a/google_vision.install b/google_vision.install new file mode 100755 index 0000000..a7140c6 --- /dev/null +++ b/google_vision.install @@ -0,0 +1,28 @@ +get('api_key'); + if(!$key) { + $requirements['google_vision'] = array( + 'title' => t('Google Vision API'), + 'severity' => REQUIREMENT_ERROR, + 'description' => t('Google Vision API key is not set and it is required for some functionalities to work. Please set it up at the Google Vision module settings page.', array( + ':settings' => Url::fromRoute('google_vision.settings')->toString(), + )), + ); + } + } + return $requirements; +} diff --git a/src/Tests/ApiKeyConfigurationTest.php b/src/Tests/ApiKeyConfigurationTest.php new file mode 100755 index 0000000..48c2888 --- /dev/null +++ b/src/Tests/ApiKeyConfigurationTest.php @@ -0,0 +1,56 @@ +adminUser = $this->drupalCreateUser(array('administer google vision','administer site configuration') + ); + $this->drupalLogin($this->adminUser); + } + + /** + * Tests that the Google Vision API Key is set in the admin config page. + */ + function testKeyConfiguration() { + $this->drupalGet(Url::fromRoute('google_vision.settings')); + $this->assertResponse(200); + + $config = $this->container->get('config.factory')->get('google_vision.settings'); + $this->assertFieldByName('api_key', '', 'The API key is not set'); + $this->drupalGet(Url::fromRoute('system.status')); + $this->assertResponse(200); + $this->assertText('Google Vision API key is not set and it is required for some functionalities to work.', 'The content exists on the report page'); + + } +}