Merge branch 'MDL-65335_master' of https://github.com/marxjohnson/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 1 Oct 2019 21:21:51 +0000 (23:21 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 1 Oct 2019 21:21:51 +0000 (23:21 +0200)
auth/oauth2/classes/api.php
auth/oauth2/tests/api_test.php

index 1b152b5..e5b0789 100644 (file)
@@ -402,7 +402,6 @@ class api {
      * @return bool
      */
     public static function is_enabled() {
-        $plugininfo = \core_plugin_manager::instance()->get_plugin_info('auth_oauth2');
-        return $plugininfo->is_enabled();
+        return is_enabled_auth('oauth2');
     }
 }
index 83bf1a6..d2fc8e1 100644 (file)
@@ -140,4 +140,23 @@ class auth_oauth2_external_testcase extends advanced_testcase {
         $this->assertEquals($newuser->id, $match->get('userid'));
     }
 
+    /**
+     * Test that is_enabled correctly identifies when the plugin is enabled.
+     */
+    public function test_is_enabled() {
+        $this->resetAfterTest();
+
+        set_config('auth', 'manual,oauth2');
+        $this->assertTrue(\auth_oauth2\api::is_enabled());
+    }
+
+    /**
+     * Test that is_enabled correctly identifies when the plugin is disabled.
+     */
+    public function test_is_enabled_disabled() {
+        $this->resetAfterTest();
+
+        set_config('auth', 'manual');
+        $this->assertFalse(\auth_oauth2\api::is_enabled());
+    }
 }