diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b75d4f..826438a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,14 +8,18 @@ jobs: fail-fast: false matrix: include: + - php: '7.3' + moodle-branch: 'MOODLE_39_STABLE' + database: 'pgsql' + node: '16.18.1' - php: '7.4' moodle-branch: 'MOODLE_311_STABLE' database: 'mariadb' - node: '14.15.0' - - php: '7.3' - moodle-branch: 'MOODLE_310_STABLE' - database: 'pgsql' - node: '14.15.0' + node: '16.18.1' + - php: '8.0' + moodle-branch: 'MOODLE_400_STABLE' + database: 'mariadb' + node: '16.18.1' services: postgres: @@ -42,12 +46,12 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: plugin - name: Install node - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} @@ -56,6 +60,7 @@ jobs: with: php-version: ${{ matrix.php }} extensions: zip, gd, mbstring, pgsql, mysqli + ini-values: max_input_vars=5000 - name: Deploy moodle-plugin-ci run: | @@ -114,4 +119,4 @@ jobs: - name: behat if: ${{ always() }} - run: moodle-plugin-ci behat --profile chrome \ No newline at end of file + run: moodle-plugin-ci behat --profile chrome diff --git a/.gitignore b/.gitignore index c3e6cd3..243c069 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,8 @@ Icon # Grunt stuff .sass-cache node_modules + +# phpDocumentor +phpdoc +tools +.phive diff --git a/CHANGES.md b/CHANGES.md index a91e7b4..2ab53b1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,28 @@ -Release Notes +# Release Notes -Release 3.8.0 (Build 2019112600) +## 4.0.0 (Build - 2022112400) +Compatibility with Moodle 4.0 +Remove errors and warnings from codechecker and phpdoc + +## 3.8.0 (Build 2019112600) +Compatibility with Moodle 3.8 & 3.9 Updated subplugin declaration file to new subplugins.json structure. -(see CHANGES.TXT in release 3.3 for earlier changes.) \ No newline at end of file +## 3.3.0 +An xpath change was required in the Behat tests in order to get Behat to pass due to changes in Moodle's output. + +## 3.2 +the plugin was rewritten to utilize the oembed provider definitions from [http://oembed.com/providers.json](http://oembed.com/providers.json). +The previous provider definitions that were hardcoded, but not present in the oembed provider list, were added as "local" definitions to avoid regression errors. + +## 3.2.0.0 (Alpha) +Change highlights: + +- Oembed providers defintions are downloaded from http://oembed.com/providers.json and stored in the Moodle database, rather than code. +- Oembed defintions are refreshed nightly with new additions and deletions. +- Management screen allows for administrators to save provider defintions as local overrides not refreshed by oembed.com. +- Two types of tags can be used for filtering. The one desired can be configured. +- Lazy loading can be turned on or off; default is on. This can improve site performance. +- Provider management screen allows enable/disable, and edit as local as well as providing all of the provider information. +- A subplugin system is in place to allow providers not stored at oembed.com to define oembed information. + Some of the existing Microsoft providers have been rewritten as these. diff --git a/README.md b/README.md new file mode 100644 index 0000000..53fdc40 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Moodle oEmbed Filter # +![Licence](https://img.shields.io/github/license/PoetOS/moodle-filter_oembed) + + +## Description +This is a text filter for Moodle that converts urls from many different media sites into embeded content. +Embed code is retrieved from the original site so should work even if the site changes embed format. + +## Installation +1. Download the source files. (zip file is available under download section) +2. Unzip the package +3. Copy the "oembed" folder to moodle/filter on the Moodle server. +4. Login as an admin on the Moodle site and install the filter. + +### Upgrading from earlier versions +Upgrade per normal procedures. Your settings from earlier plugins will be preserved. + +**NOTE** Embed providers may change the text that identifies them. +It is possible that media embedded previously on your site no +longer meets the provider text definitions, and as such, may not show up as embedded media. +Check the provider definition to see if the media link needs to change. + +## To use +Under Plugins > Filters > Oembed Filter / Settings, you can choose: + + - The type of tag to identify the embedded media. + - To delay the media loading or load it immediately. + +By default the oembed filter disables all providers. +You can change this under *Plugins > Filters > Oembed Filter / Manage providers*. + +When inserting a media link url into a discussion, create a hyperlink and insert the url as the target. +When the discussion is posted the url will be changed into the embed content. + +**N.B.** if you enable the *Convert URLs into links and images* filter ahead of this then it is easier for users to embed media. + +The embedded media providers are in three groups: + + - Downloaded from [//oembed.com/providers.json](https://oembed.com/providers.json). This is the main repository that manages Oembed provider definitions. + These are updated regularly in the cron job, and can change. + - Plugins provided to extend media providers provided in earlier versions of the plugin, but not contained in the provider repo. + - Local providers which allow a site administrator to save a downloaded one locally, so that it does not change with download updates. + This also allows new providers to be created that are not part of the omebed repo. diff --git a/README.txt b/README.txt deleted file mode 100644 index 11f8fcc..0000000 --- a/README.txt +++ /dev/null @@ -1,33 +0,0 @@ -Description: -This is a text filter for Moodle that converts urls from many different media sites into embeded content. -Embed code is retrieved from the original site so should work even if the site changes embed format. - -Installation: -Download the source files. (zip file is available under download section) -Unzip the package -Copy the "oembed" folder to moodle/filter on the Moodle server. -Login as an admin on the Moodle site and install the filter. - -Upgrading from earlier versions: -Upgrade per normal procedures. Your settings from earlier plugins will be preserved. -NOTE - Embed providers may change the text that identifies them. It is possible that media embedded previously on your site no -longer meets the provider text definitions, and as such, may not show up as embedded media. Check the provider definition to see -if the media link needs to change. - -To use: -Under Plugins > Filters > Oembed Filter / Settings, you can choose: - - The type of tag to identify the embedded media. - - To delay the media loading or load it immediately. -By default the oembed filter disables all providers. -You can change this under Plugins > Filters > Oembed Filter / Manage providers. - -When inserting a media link url into a discussion, create a hyperlink and insert the url as the target. -When the discussion is posted the url will be changed into the embed content. -N.B. if you enable the "Convert URLs into links and images" filter ahead of this then it is easier for users to embed media. - -The embedded media providers are in three groups: - - Downloaded from http://oembed.com/providers.json. This is the main repository that manages Oembed provider definitions. - These are updated regularly in the cron job, and can change. - - Plugins provided to extend media providers provided in earlier versions of the plugin, but not contained in the provider repo. - - Local providers which allow a site administrator to save a downloaded one locally, so that it does not change with download - updates. This also allows new providers to be created that are not part of the omebed repo. diff --git a/classes/db/abstract_dbrow.php b/classes/db/abstract_dbrow.php index ab91cd9..3d776db 100644 --- a/classes/db/abstract_dbrow.php +++ b/classes/db/abstract_dbrow.php @@ -16,6 +16,7 @@ /** * Base class for classes which map to db tables. + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -24,8 +25,9 @@ namespace filter_oembed\db; use stdClass; -defined('MOODLE_INTERNAL') || die(); - +/** + * Base class for classes which map to db tables. + */ class abstract_dbrow { /** diff --git a/classes/db/providerrow.php b/classes/db/providerrow.php index 06bb265..a1d981b 100644 --- a/classes/db/providerrow.php +++ b/classes/db/providerrow.php @@ -16,16 +16,17 @@ /** * Provider Row. + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace filter_oembed\db; - -defined('MOODLE_INTERNAL') || die(); - -class providerrow extends abstract_dbrow{ +/** + * Provider Row class. + */ +class providerrow extends abstract_dbrow { /** * @var int id */ diff --git a/classes/forms/provider.php b/classes/forms/provider.php index 9887874..83b9a4a 100644 --- a/classes/forms/provider.php +++ b/classes/forms/provider.php @@ -16,6 +16,7 @@ /** * Provider mform. + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -27,7 +28,9 @@ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/lib/formslib.php'); - +/** + * Provider mform. + */ class provider extends moodleform { /** * Define this form - is called from parent constructor. diff --git a/classes/output/managementpage.php b/classes/output/managementpage.php index e41a9ea..e703427 100644 --- a/classes/output/managementpage.php +++ b/classes/output/managementpage.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Management page output + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -26,8 +28,9 @@ use filter_oembed\db\providerrow; use filter_oembed\provider\provider; -defined('MOODLE_INTERNAL') || die(); - +/** + * Management page class. + */ class managementpage implements \renderable, \templatable { /** diff --git a/classes/output/providermodel.php b/classes/output/providermodel.php index 95dbdbb..e29b72e 100644 --- a/classes/output/providermodel.php +++ b/classes/output/providermodel.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * providermodel output + * * @package filter_oembed * @author Guy Thomas * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -27,11 +29,10 @@ use filter_oembed\provider\provider; use filter_oembed\db\providerrow; -defined('MOODLE_INTERNAL') || die(); - /** * Class providermodel - * @package filter_oembed\output + * + * @package filter_oembed * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 1604256..0971862 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -16,15 +16,16 @@ /** * Renderer for oembed filter. + * @package filter_oembed * @author gthomas2 * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace filter_oembed\output; - -defined('MOODLE_INTERNAL') || die(); - +/** + * Renderer for oembed filter. + */ class renderer extends \plugin_renderer_base { /** diff --git a/classes/plugininfo/oembedprovider.php b/classes/plugininfo/oembedprovider.php index e1cc541..8ab74c1 100644 --- a/classes/plugininfo/oembedprovider.php +++ b/classes/plugininfo/oembedprovider.php @@ -15,6 +15,7 @@ // along with Moodle. If not, see . /** + * filter_oembed capabilities list * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -22,11 +23,15 @@ */ namespace filter_oembed\plugininfo; - -defined('MOODLE_INTERNAL') || die(); - +/** + * filter_oembed capabilities list + */ class oembedprovider extends \core\plugininfo\base { + /** + * filter_oembed has the uninstall capability + * @return boolean always true + */ public function is_uninstall_allowed() { return true; } -} \ No newline at end of file +} diff --git a/classes/provider/endpoint.php b/classes/provider/endpoint.php index e0d4574..9740c13 100644 --- a/classes/provider/endpoint.php +++ b/classes/provider/endpoint.php @@ -15,6 +15,7 @@ // along with Moodle. If not, see . /** + * Base class for oembed endpoints. * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,8 +24,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * Base class for oembed endpoints. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -53,7 +52,7 @@ class endpoint { /** * Constructor. - * @param $data JSON decoded array or data object containing all endpoint data. + * @param any $data JSON decoded array or data object containing all endpoint data. */ public function __construct($data = null) { if (is_object($data)) { @@ -87,4 +86,4 @@ public function __get($name) { throw new \coding_exception($name.' is not a publicly accessible property of '.get_class($this)); } } -} \ No newline at end of file +} diff --git a/classes/provider/provider.php b/classes/provider/provider.php index f9d089b..a4b17d0 100644 --- a/classes/provider/provider.php +++ b/classes/provider/provider.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Base class for oembed providers and plugins + * * @package filter_oembed * @author Mike Churchward * @author Erich M. Wappis @@ -25,10 +27,11 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); /** - * Base class for oembed providers and plugins. Plugins should extend this class. + * Base class for oembed providers and plugins. + * + * Plugins should extend this class. * If "filter" is provided, there is nothing else a plugin needs to implement. * Plugins can instead / additionally override "get_oembed_request", "oembed_response" and "endpoints_regex". * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -67,10 +70,16 @@ class provider { protected $source = ''; /** - * @var Class constant descriptions. + * @var PROVIDER SOURCE LOCAL. */ const PROVIDER_SOURCE_LOCAL = 'local::'; + /** + * @var PROVIDER SOURCE DOWNLOAD. + */ const PROVIDER_SOURCE_DOWNLOAD = 'download::'; + /** + * @var PROVIDER SOURCE PLUGIN. + */ const PROVIDER_SOURCE_PLUGIN = 'plugin::'; /** @@ -80,7 +89,7 @@ class provider { * include "_" in variable names, which violates the Moodle coding standard. Currently, * this is managed by the update processes to ensure compatibility. * - * @param $data JSON decoded array or a data object containing all provider data. + * @param any $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if (is_object($data)) { @@ -183,7 +192,12 @@ public function get_oembed_request($text) { */ public function oembed_response($url) { $ret = download_file_content($url, null, null, true, 300, 20, false, null, false); - return json_decode($ret->results, true); + if ($ret->results) { + return json_decode($ret->results, true); + } else { + debugging("Error getting oembed URL $url [".$ret->error."]"); + return false; + } } /** diff --git a/classes/service/oembed.php b/classes/service/oembed.php index 8771db4..692484a 100755 --- a/classes/service/oembed.php +++ b/classes/service/oembed.php @@ -35,7 +35,7 @@ /** * Class oembed - * @package filter_oembed\service + * @package filter_oembed * @copyright Erich M. Wappis / Guy Thomas 2016 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * Singleton class providing function for filtering embedded content links in text. @@ -147,8 +147,12 @@ public function html_output($text) { // If we have a consumer request, we're done searching. Try for a response. $jsonret = $provider->oembed_response($requesturl); - if (!$jsonret) { + + if (!$jsonret or !array_key_exists('html', $jsonret)) { $output = ''; + if (array_key_exists('status', $jsonret)) { + debugging("Error getting oembed URL $requesturl [".implode(" -- ", $jsonret)."]"); + } } else if ($lazyload) { $output = $this->oembed_getpreloadhtml($jsonret, $params); } else { @@ -251,7 +255,7 @@ protected function oembed_getpreloadhtml(array $jsonarr, $params = []) { return $renderer->preload($this->oembed_gethtml($jsonarr, $params), $jsonarr); } - // ---- PROVIDER DATA MANAGEMENT SECTION ---- + // PROVIDER DATA MANAGEMENT SECTION. /** * Function to update provider data in database with current provider sources. @@ -557,7 +561,7 @@ final protected static function match_provider_names($providerarray, $provider) return $foundrecord; } - // ---- OTHER HELPER FUNCTIONS ---- + // OTHER HELPER FUNCTIONS. /** * Magic method for getting properties. @@ -577,7 +581,7 @@ public function __get($name) { /** * Set the provider to "enabled". * - * @param int | provider The provider to enable. + * @param int|provider The provider to enable. */ public function enable_provider($provider) { $this->set_provider_enable_value($provider, 1); @@ -586,7 +590,7 @@ public function enable_provider($provider) { /** * Set the provider to "disabled". * - * @param int | provider The provider to disable. + * @param int|provider The provider to disable. */ public function disable_provider($provider) { $this->set_provider_enable_value($provider, 0); @@ -595,7 +599,7 @@ public function disable_provider($provider) { /** * Delete the local provider. * - * @param int | provider The provider to delete. + * @param int|provider The provider to delete. */ public function delete_provider($provider) { global $DB; @@ -662,7 +666,7 @@ public function copy_provider_to_local($providerdata) { /** * Set the provider enabled field to the specified value. * - * @param int | object $provider The provider to modify. + * @param int|object $provider The provider to modify. * @param int $value Value to set. */ private function set_provider_enable_value($provider, $value) { diff --git a/classes/service/util.php b/classes/service/util.php index 3e07cd5..17f31bd 100644 --- a/classes/service/util.php +++ b/classes/service/util.php @@ -31,6 +31,7 @@ /** * General utility class. + * @package filter_oembed * @author gthomas2 * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -41,9 +42,9 @@ class util { * * NOTE: Current limitations - does not recurse to properties that are object instances or arrays. * - * @param $classorobject + * @param any $classorobject * @throws coding_exception - * @return external_value[] + * @return array external_value[] */ public static function define_class_for_webservice($classorobject) { $reflect = new \ReflectionClass($classorobject); diff --git a/classes/task/update_providers.php b/classes/task/update_providers.php index a7f53ca..e19cff2 100644 --- a/classes/task/update_providers.php +++ b/classes/task/update_providers.php @@ -15,6 +15,7 @@ // along with Moodle. If not, see . /** + * Task to update providers list * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,10 +24,10 @@ namespace filter_oembed\task; -defined('MOODLE_INTERNAL') || die(); - use filter_oembed\service\oembed; - +/** + * Task to update providers list + */ class update_providers extends \core\task\scheduled_task { /** @@ -39,7 +40,7 @@ public function get_name() { } /** - * Run forum cron. + * Run cron. */ public function execute() { oembed::update_provider_data(); diff --git a/classes/webservice/ws_provider_manage.php b/classes/webservice/ws_provider_manage.php index c0ac060..0ecd1a4 100644 --- a/classes/webservice/ws_provider_manage.php +++ b/classes/webservice/ws_provider_manage.php @@ -26,11 +26,13 @@ /** * Web service for managing provider visibility. * @author Guy Thomas + * @package filter_oembed * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class ws_provider_manage extends \external_api { /** + * service_parameters description] * @return \external_function_parameters */ public static function service_parameters() { @@ -42,6 +44,7 @@ public static function service_parameters() { } /** + * [service_returns description] * @return \external_single_structure */ public static function service_returns() { @@ -58,6 +61,7 @@ public static function service_returns() { } /** + * [service description] * @param int $pid * @param string $action * @return array diff --git a/classes/webservice/ws_providers.php b/classes/webservice/ws_providers.php index b32ada6..475be78 100644 --- a/classes/webservice/ws_providers.php +++ b/classes/webservice/ws_providers.php @@ -27,11 +27,13 @@ /** * Web service for getting array of provider models. * @author Guy Thomas + * @package filter_oembed * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class ws_providers extends \external_api { /** + * [service_parameters description] * @return \external_function_parameters */ public static function service_parameters() { @@ -42,6 +44,7 @@ public static function service_parameters() { } /** + * [service_returns description] * @return \external_single_structure */ public static function service_returns() { @@ -74,9 +77,9 @@ public static function service_returns() { } /** - * @param int $pid - * @param string $action - * @return array + * [service description] + * @param [type] $scope [description] + * @return [type] [description] */ public static function service($scope) { global $PAGE; diff --git a/db/install.php b/db/install.php index 26e3cbd..c8c6da3 100644 --- a/db/install.php +++ b/db/install.php @@ -25,8 +25,6 @@ * Soundcloud (Troy Williams) */ -defined('MOODLE_INTERNAL') || die(); - use filter_oembed\service\oembed; /** * Installs the OEmbed filter. @@ -36,4 +34,4 @@ function xmldb_filter_oembed_install() { // Insert the initial data elements from the instance's providers. oembed::update_provider_data(); -} \ No newline at end of file +} diff --git a/db/tasks.php b/db/tasks.php index a0c4efc..cf97470 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -15,6 +15,7 @@ // along with Moodle. If not, see . /** + * oEmbed filter tasks * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/db/upgrade.php b/db/upgrade.php index 7409bdf..8d42565 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -25,15 +25,13 @@ * Soundcloud (Troy Williams) */ -defined('MOODLE_INTERNAL') || die(); - use filter_oembed\service\oembed; use filter_oembed\provider\provider; /** * Upgrades the OEmbed filter. * - * @param $oldversion Version to be upgraded from. + * @param int $oldversion Version to be upgraded from. * @return bool Success. */ function xmldb_filter_oembed_upgrade($oldversion) { @@ -139,4 +137,4 @@ function xmldb_filter_oembed_upgrade($oldversion) { } return true; -} \ No newline at end of file +} diff --git a/filter.php b/filter.php index c6e67e8..79908bc 100644 --- a/filter.php +++ b/filter.php @@ -36,7 +36,7 @@ /** * Main filter class for embedded remote content. * - * @package filter_oembed + * @package filter_oembed * @copyright Erich M. Wappis / Guy Thomas 2016 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -46,8 +46,8 @@ class filter_oembed extends moodle_text_filter { * content gets filtered, links either wrapped in an tag or in a
tag with class="oembed" * will be replaced by embeded content * - * @param $text HTML to be processed. - * @param $options + * @param string $text HTML to be processed. + * @param array $options * @return string String containing processed HTML. */ public function filter($text, array $options = array()) { @@ -87,7 +87,7 @@ public function filter($text, array $options = array()) { /** * Callback function to be used by the main filter * - * @param $match array An array of matched groups, where [1] is the URL matched. + * @param array $match An array of matched groups, where [1] is the URL matched. * */ private static function find_oembeds_callback($match) { diff --git a/lang/fr/filter_oembed.php b/lang/fr/filter_oembed.php index 5a186ce..964da7c 100644 --- a/lang/fr/filter_oembed.php +++ b/lang/fr/filter_oembed.php @@ -31,9 +31,9 @@ $string['ted'] = 'Chats Ted'; $string['slideshare'] = 'SlideShare'; $string['officemix'] = 'Combinaison Office'; -$string['issuu'] = 'Problème'; +$string['issuu'] = 'Issuu'; $string['screenr'] = 'Écran'; $string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Sonder partout'; +$string['pollev'] = 'Poll Everywhere'; $string['lazyload'] = 'Retarder l\'intégration du chargement (Lazyload)'; $string['connection_error'] = 'Erreur lors de l\'accès au média intégré. Veuillez actualiser la page.'; diff --git a/lib.php b/lib.php index ad95266..bee5c51 100644 --- a/lib.php +++ b/lib.php @@ -16,12 +16,12 @@ /** * General lib file + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); use filter_oembed\forms\provider; diff --git a/manageproviders.php b/manageproviders.php index 2e60159..b53b98a 100644 --- a/manageproviders.php +++ b/manageproviders.php @@ -15,6 +15,7 @@ // along with Moodle. If not, see . /** + * Providers management page for oEmbed filter * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/package.json b/package.json index 491b689..2873a92 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,14 @@ "description": "Grunt tasks for sass.", "private": true, "devDependencies": { - "grunt": "~0.4.1", - "grunt-autoprefixer": "^3.0.3", - "grunt-contrib-csslint": "^0.5.0", - "grunt-contrib-jshint": "^0.12.0", - "grunt-sass": "^1.2.1", + "grunt": "~1.5.3", + "grunt-autoprefixer": "^3.0.4", + "grunt-contrib-csslint": "^2.0.0", + "grunt-contrib-jshint": "^3.2.0", + "grunt-sass": "^3.1.0", "grunt-cssbeautifier": "^0.1.2", - "grunt-contrib-watch": "^0.6.1", - "grunt-exec": "~0.4.2", + "grunt-contrib-watch": "^1.1.0", + "grunt-exec": "~3.0.0", "grunt-load-gruntfile" : "^0.0.2" } } diff --git a/provider/docsdotcom/docsdotcom.php b/provider/docsdotcom/docsdotcom.php index 9305f24..688aee6 100644 --- a/provider/docsdotcom/docsdotcom.php +++ b/provider/docsdotcom/docsdotcom.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Microsoft docs.com + * * @package filter_oembed * @author James McQuillan * @author Mike Churchward @@ -24,8 +26,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for Docs.com */ @@ -33,7 +33,7 @@ class docsdotcom extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param any $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { diff --git a/provider/docsdotcom/lang/en/oembedprovider_docsdotcom.php b/provider/docsdotcom/lang/en/oembedprovider_docsdotcom.php index 89a74b6..9ffe86e 100644 --- a/provider/docsdotcom/lang/en/oembedprovider_docsdotcom.php +++ b/provider/docsdotcom/lang/en/oembedprovider_docsdotcom.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * oembedprovider Microsoft docs.com + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Docsdotcom'; \ No newline at end of file +$string['pluginname'] = 'Docsdotcom'; diff --git a/provider/docsdotcom/version.php b/provider/docsdotcom/version.php index bdafbbe..80cb93c 100644 --- a/provider/docsdotcom/version.php +++ b/provider/docsdotcom/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Microsoft docs.com + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/issuu/issuu.php b/provider/issuu/issuu.php index d919651..da47880 100644 --- a/provider/issuu/issuu.php +++ b/provider/issuu/issuu.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Issuu.com + * * @package filter_oembed * @author James McQuillan * @author Mike Churchward @@ -24,16 +26,14 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for ISSUU */ class issuu extends provider { /** - * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * ISSUU provider constructor. + * @param any $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { diff --git a/provider/issuu/lang/en/oembedprovider_issuu.php b/provider/issuu/lang/en/oembedprovider_issuu.php index 4998dbd..7ef6bc9 100644 --- a/provider/issuu/lang/en/oembedprovider_issuu.php +++ b/provider/issuu/lang/en/oembedprovider_issuu.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Issuu.com + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'ISSUU'; \ No newline at end of file +$string['pluginname'] = 'ISSUU'; diff --git a/provider/issuu/version.php b/provider/issuu/version.php index b037764..d39dc4a 100644 --- a/provider/issuu/version.php +++ b/provider/issuu/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Issuu.com + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/o365video/lang/en/oembedprovider_o365video.php b/provider/o365video/lang/en/oembedprovider_o365video.php index 9927b0e..f483199 100644 --- a/provider/o365video/lang/en/oembedprovider_o365video.php +++ b/provider/o365video/lang/en/oembedprovider_o365video.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Office365 video + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Office365 video'; \ No newline at end of file +$string['pluginname'] = 'Office365 video'; diff --git a/provider/o365video/o365video.php b/provider/o365video/o365video.php index 2cd24e7..e342069 100644 --- a/provider/o365video/o365video.php +++ b/provider/o365video/o365video.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Office365 video + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,16 +25,14 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** - * oEmbed provider implementation for Docs.com + * oEmbed provider implementation for Office365 video */ class o365video extends provider { /** - * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * Office365 provider Constructor. + * @param any $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { @@ -125,4 +125,4 @@ public function get_replacement($matched) { } return $matched[0]; } -} \ No newline at end of file +} diff --git a/provider/o365video/version.php b/provider/o365video/version.php index bf1fed1..8523285 100644 --- a/provider/o365video/version.php +++ b/provider/o365video/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Office365 video + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/officeforms/lang/en/oembedprovider_officeforms.php b/provider/officeforms/lang/en/oembedprovider_officeforms.php index a0608aa..6fda1eb 100644 --- a/provider/officeforms/lang/en/oembedprovider_officeforms.php +++ b/provider/officeforms/lang/en/oembedprovider_officeforms.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Microsoft Office Forms + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Officeforms'; \ No newline at end of file +$string['pluginname'] = 'Officeforms'; diff --git a/provider/officeforms/officeforms.php b/provider/officeforms/officeforms.php index 0fb5446..1da041d 100644 --- a/provider/officeforms/officeforms.php +++ b/provider/officeforms/officeforms.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Microsoft Office Forms + * * @package filter_oembed * @author Aashay Zajriya * @author Mike Churchward @@ -24,8 +26,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for Microsoft Forms */ @@ -33,7 +33,7 @@ class officeforms extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param any $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { diff --git a/provider/officeforms/version.php b/provider/officeforms/version.php index f8c5b58..97c5599 100644 --- a/provider/officeforms/version.php +++ b/provider/officeforms/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Microsoft Office Forms + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/pollev/lang/en/oembedprovider_pollev.php b/provider/pollev/lang/en/oembedprovider_pollev.php index 4bf0641..a9de75d 100644 --- a/provider/pollev/lang/en/oembedprovider_pollev.php +++ b/provider/pollev/lang/en/oembedprovider_pollev.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Poll Everywhere + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Poll Everywhere'; \ No newline at end of file +$string['pluginname'] = 'Poll Everywhere'; diff --git a/provider/pollev/pollev.php b/provider/pollev/pollev.php index 2004727..f4adc42 100644 --- a/provider/pollev/pollev.php +++ b/provider/pollev/pollev.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Poll Everywhere + * * @package filter_oembed * @author James McQuillan * @author Mike Churchward @@ -24,16 +26,17 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for Poll Everywhere + * + * As of 2022/11/24, Poll Everywhere doesn't seems to provide an oembed feature anymore :/ + * Test https://www.polleverywhere.com/services/oembed => Error 404 */ class pollev extends provider { /** - * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * Poll Everywhere oembed constructor. + * @param any $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { diff --git a/provider/pollev/version.php b/provider/pollev/version.php index 336fbe6..3346780 100644 --- a/provider/pollev/version.php +++ b/provider/pollev/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Poll Everywhere + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/powerbi/lang/en/oembedprovider_powerbi.php b/provider/powerbi/lang/en/oembedprovider_powerbi.php index f566660..21ae898 100644 --- a/provider/powerbi/lang/en/oembedprovider_powerbi.php +++ b/provider/powerbi/lang/en/oembedprovider_powerbi.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Power BI + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Power BI'; \ No newline at end of file +$string['pluginname'] = 'Power BI'; diff --git a/provider/powerbi/powerbi.php b/provider/powerbi/powerbi.php index ac0cc0d..f4c6c9e 100644 --- a/provider/powerbi/powerbi.php +++ b/provider/powerbi/powerbi.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Power BI + * * @package filter_oembed * @author Sushant Gawali * @author Mike Churchward @@ -24,8 +26,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for Docs.com */ @@ -33,7 +33,7 @@ class powerbi extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param any $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { @@ -104,6 +104,11 @@ public function get_replacement($matched) { return $matched[0]; } + /** + * [getembedhtml description] + * @param [type] $embedurl [description] + * @return string [description] + */ private function getembedhtml($embedurl) { return ''; diff --git a/provider/powerbi/rest/powerbi.php b/provider/powerbi/rest/powerbi.php index beff7b7..cd5ba34 100644 --- a/provider/powerbi/rest/powerbi.php +++ b/provider/powerbi/rest/powerbi.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * REST API client for Power BI + * * @package filter_oembed * @author Sushant Gawali * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,8 +25,6 @@ namespace filter_oembed\provider\powerbi\rest; -defined('MOODLE_INTERNAL') || die(); - /** * API client for Power BI. */ @@ -37,6 +37,7 @@ class powerbi extends \local_o365\rest\o365api { public function get_apiuri() { return "https://api.powerbi.com/beta/myorg/"; } + /** * Get the API client's oauth2 resource. * @@ -45,6 +46,13 @@ public function get_apiuri() { public static function get_resource() { return 'https://analysis.windows.net/powerbi/api'; } + + /** + * [getreportoembedurl description] + * @param int $reportid [description] + * @param any $reportsdata [description] + * @return string [description] + */ public function getreportoembedurl($reportid, $reportsdata) { $reportsdata = $this->process_apicall_response($reportsdata); foreach ($reportsdata['value'] as $report) { @@ -53,4 +61,4 @@ public function getreportoembedurl($reportid, $reportsdata) { } } } -} \ No newline at end of file +} diff --git a/provider/powerbi/version.php b/provider/powerbi/version.php index bc2374b..b09dac4 100644 --- a/provider/powerbi/version.php +++ b/provider/powerbi/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Power BI + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/settings.php b/settings.php index c58a481..c630cae 100644 --- a/settings.php +++ b/settings.php @@ -60,4 +60,4 @@ $ADMIN->add('filteroembedfolder', new admin_externalpage('filter_oembed_providers', get_string('manageproviders', 'filter_oembed'), new moodle_url('/filter/oembed/manageproviders.php'))); -$settings = null; \ No newline at end of file +$settings = null; diff --git a/templates/managementpage.mustache b/templates/managementpage.mustache index 64c2f53..634501c 100644 --- a/templates/managementpage.mustache +++ b/templates/managementpage.mustache @@ -48,7 +48,7 @@ Displayed if x was true. {{/x}}
- +
diff --git a/templates/managementpagerow.mustache b/templates/managementpagerow.mustache index dda248d..41e556d 100644 --- a/templates/managementpagerow.mustache +++ b/templates/managementpagerow.mustache @@ -36,8 +36,7 @@
{{providername}} -
-
+
{{{enableaction}}} {{{editaction}}} {{{deleteaction}}}
diff --git a/tests/behat/behat_filter_oembed.php b/tests/behat/behat_filter_oembed.php index 611d8bf..e7fbd82 100644 --- a/tests/behat/behat_filter_oembed.php +++ b/tests/behat/behat_filter_oembed.php @@ -16,6 +16,7 @@ /** * Oembed filter custom behat steps. + * * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -24,7 +25,11 @@ use Behat\Gherkin\Node\TableNode; require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); - +/** + * Oembed filter custom behat steps. + * + * @package filter_oembed + */ class behat_filter_oembed extends behat_base { /** @@ -83,6 +88,8 @@ protected function ensure_provider_status($provider, $enabled = true) { } /** + * Ensure that the provider status is disabled + * * @Given /^the provider "(?P[^"]*)" is disabled$/ * @param string $provider * @throws \Behat\Mink\Exception\ExpectationException @@ -92,6 +99,8 @@ public function the_provider_is_disabled($provider) { } /** + * Ensure that the provider status is enabled + * * @Given /^the provider "(?P[^"]*)" is enabled$/ * @param string $provider * @throws \Behat\Mink\Exception\ExpectationException @@ -101,8 +110,10 @@ public function the_provider_is_enabled($provider) { } /** + * i filter provider list + * * @Given /^I filter the provider list to "(?P[^"]*)"$/ - * @param $provider + * @param any $provider * @throws \Behat\Mink\Exception\ExpectationException */ public function i_filter_provider_list($provider) { @@ -133,6 +144,7 @@ protected function wait_for_edit_form($provider) { } /** + * i edit provider with values * @Given /^I edit the provider "(?P[^"]*)" with the values:$/ * @param string $provider * @param TableNode $table diff --git a/tests/oembed_test.php b/tests/filter_oembed_service_test.php similarity index 85% rename from tests/oembed_test.php rename to tests/filter_oembed_service_test.php index 0d2dcca..c559467 100644 --- a/tests/oembed_test.php +++ b/tests/filter_oembed_service_test.php @@ -23,15 +23,19 @@ * @copyright 2016 The POET Group */ +namespace filter_oembed; + defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/filter/oembed/tests/testable_oembed.php'); /** + * Unit tests for the filter_oembed. + * * @group filter_oembed */ -class filter_oembed_service_testcase extends advanced_testcase { +class filter_oembed_service_test extends \advanced_testcase { /** * Make sure providers array is correct. @@ -58,6 +62,7 @@ public function assert_providers_ok($providers) { /** * Test instance. + * @covers \filter_oembed\classes\service\oembed\get_instance */ public function test_instance() { $this->resetAfterTest(true); @@ -66,6 +71,10 @@ public function test_instance() { $this->assertNotEmpty($oembed); } + /** + * Test set_providers + * @covers \filter_oembed\classes\service\oembed\set_providers + */ public function test_set_providers() { $this->resetAfterTest(true); $this->setAdminUser(); @@ -78,6 +87,7 @@ public function test_set_providers() { /** * Test providers. + * @covers \filter_oembed\classes\service\oembed\get_instance */ public function test_providers() { $this->resetAfterTest(true); @@ -90,8 +100,12 @@ public function test_providers() { /** * Test html. * TODO - have a local oembed service with test fixtures for performing test. + * @covers \filter_oembed\classes\service\oembed\html_output */ public function test_embed_html() { + if (!PHPUNIT_LONGTEST) { + $this->markTestSkipped('Turn on PHPUNIT_LONGTEST to perform test calling external urls.'); + } $this->resetAfterTest(true); set_config('lazyload', 0, 'filter_oembed'); $this->setAdminUser(); @@ -105,23 +119,28 @@ public function test_embed_html() { /** * Test lazy load html. * TODO - have a local oembed service with test fixtures for performing test. + * @covers \filter_oembed\classes\service\oembed\get_instance */ public function test_preloader_html() { + if (!PHPUNIT_LONGTEST) { + $this->markTestSkipped('Turn on PHPUNIT_LONGTEST to perform test calling external urls.'); + } $this->resetAfterTest(true); set_config('lazyload', 1, 'filter_oembed'); $this->setAdminUser(); $oembed = testable_oembed::get_instance(); $text = $oembed->html_output('https://youtu.be/abuQk-6M5R4'); $this->assertStringContainsString('
', $text); - $this->assertMatchesRegularExpression('/
/is', $text); + $this->assertMatchesRegularExpression('/
/is', $text); $this->assertMatchesRegularExpression('/
(?:.*)<\/div>/', $text); $this->assertStringContainsString('', $text); - } /** * Test download providers. + * @covers \filter_oembed\classes\service\oembed\download_providers */ public function test_download_providers() { $this->resetAfterTest(true); @@ -131,6 +150,7 @@ public function test_download_providers() { /** * Test get local providers. + * @covers \filter_oembed\classes\service\oembed\get_local_providers */ public function test_get_local_providers() { $this->resetAfterTest(true); @@ -140,6 +160,7 @@ public function test_get_local_providers() { /** * Test get plugin providers. + * @covers \filter_oembed\classes\service\oembed\get_plugin_providers */ public function test_get_plugin_providers() { $this->resetAfterTest(true); @@ -149,6 +170,7 @@ public function test_get_plugin_providers() { /** * Test match_provider_names. + * @covers \filter_oembed\classes\service\oembed\match_provider_names */ public function test_match_provider_names() { $this->resetAfterTest(true); @@ -192,6 +214,7 @@ public function test_match_provider_names() { /** * Test the "__get" magic method. + * @covers \filter_oembed\classes\service\oembed\__get */ public function test_get() { $this->resetAfterTest(true); @@ -214,16 +237,18 @@ public function test_get() { try { $noaccess = $oembed->noaccess; $this->assertTrue(false); - } catch (coding_exception $e) { + } catch (\coding_exception $e) { $expectedmessage = 'Coding error detected, it must be fixed by a programmer: ' . - 'noaccess is not a publicly accessible property of testable_oembed'; + 'noaccess is not a publicly accessible property of filter_oembed\testable_oembed'; $this->assertEquals($expectedmessage, $e->getMessage()); } } /** * Test enable and disable provider functions. - * Tests: enable_provider, disable_provider, set_provider_enable_value. + * @covers \filter_oembed\classes\service\oembed\enable_provider + * @covers \filter_oembed\classes\service\oembed\disable_provider + * @covers \filter_oembed\classes\service\oembed\set_provider_enable_value */ public function test_enable_disable_provider() { $this->resetAfterTest(true); diff --git a/tests/filter_test.php b/tests/filter_oembed_test.php similarity index 86% rename from tests/filter_test.php rename to tests/filter_oembed_test.php index fd09a67..c420830 100644 --- a/tests/filter_test.php +++ b/tests/filter_oembed_test.php @@ -26,16 +26,23 @@ * @copyright Microsoft, Inc. */ +namespace filter_oembed; + defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/filter/oembed/filter.php'); /** + * Unit tests for the filter_oembed. + * * @group filter_oembed */ -class filter_oembed_testcase extends advanced_testcase { - +class filter_oembed_test extends \advanced_testcase { + /** + * [$filter description] + * @var [type] + */ protected $filter; /** @@ -43,7 +50,7 @@ class filter_oembed_testcase extends advanced_testcase { */ protected function setUp(): void { parent::setUp(); - $this->filter = new filter_oembed(context_system::instance(), array()); + $this->filter = new \filter_oembed(\context_system::instance(), array()); // Ensure all tested providers are enabled. $oembed = \filter_oembed\service\oembed::get_instance('all'); foreach ($oembed->providers as $pid => $provider) { @@ -87,12 +94,16 @@ protected function setUp(): void { /** * Performs unit tests for all services supported by the filter. * - * Need to update this test to not contact external services. + * TODO: Need to update this test to not contact external services. + * @covers \filter_oembed\filter\filter */ public function test_filter() { + if (!PHPUNIT_LONGTEST) { + $this->markTestSkipped('Turn on PHPUNIT_LONGTEST to perform test calling external urls.'); + } $this->resetAfterTest(true); - $curl = new curl(); + $curl = new \curl(); try { $out = $curl->get('https://www.youtube.com'); } catch (Exception $e) { @@ -116,10 +127,8 @@ public function test_filter() { $tedlink = '

Ted

'; $slidesharelink = '

slideshare

'; $issuulink = '

issuu

'; - $polleverywherelink = '

'; - $polleverywherelink .= '$popolleverywhere

'; - $filterinput = $soundcloudlink.$youtubelink.$vimeolink.$tedlink.$slidesharelink.$issuulink.$polleverywherelink; + $filterinput = $soundcloudlink.$youtubelink.$vimeolink.$tedlink.$slidesharelink.$issuulink; $filteroutput = $this->filter->filter($filterinput); @@ -137,11 +146,6 @@ public function test_filter() { $tedoutput = '/.*assertMatchesRegularExpression($tedoutput, $filteroutput, 'Ted filter fails'); - $polleverywhereoutput = '/.*