diff --git a/contentbank/tests/fixtures/testable_content.php b/contentbank/tests/fixtures/testable_content.php new file mode 100644 index 00000000000..d379dea3374 --- /dev/null +++ b/contentbank/tests/fixtures/testable_content.php @@ -0,0 +1,36 @@ +. + +/** + * Testable content plugin class. + * + * @package core_contentbank + * @category test + * @copyright 2020 Amaia Anabitarte + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace contenttype_testable; + +/** + * Testable content plugin class. + * + * @package core_contentbank + * @copyright 2020 Amaia Anabitarte + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class content extends \core_contentbank\content { +} diff --git a/contentbank/tests/fixtures/testable_contenttype.php b/contentbank/tests/fixtures/testable_contenttype.php new file mode 100644 index 00000000000..850d4efc7ec --- /dev/null +++ b/contentbank/tests/fixtures/testable_contenttype.php @@ -0,0 +1,82 @@ +. + +/** + * Testable contenttype plugin class. + * + * @package core_contentbank + * @category test + * @copyright 2020 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace contenttype_testable; + +/** + * Testable contenttype plugin class. + * + * @package core_contentbank + * @copyright 2020 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class contenttype extends \core_contentbank\contenttype { + + /** Feature for testing */ + const CAN_TEST = 'test'; + + /** + * Returns the URL where the content will be visualized. + * + * @param stdClass $record Th content to be displayed. + * @return string URL where to visualize the given content. + */ + public function get_view_url(\stdClass $record): string { + $fileurl = $this->get_file_url($record->id); + $url = $fileurl."?forcedownload=1"; + + return $url; + } + + /** + * Returns the HTML code to render the icon for content bank contents. + * + * @param string $contentname The contentname to add as alt value to the icon. + * @return string HTML code to render the icon + */ + public function get_icon(string $contentname): string { + global $OUTPUT; + + return $OUTPUT->pix_icon('f/archive-64', $contentname, 'moodle', ['class' => 'iconsize-big']); + } + + /** + * Return an array of implemented features by this plugin. + * + * @return array + */ + protected function get_implemented_features(): array { + return [self::CAN_TEST]; + } + + /** + * Return an array of extensions this plugin could manage. + * + * @return array + */ + public function get_manageable_extensions(): array { + return ['.txt', '.png', '.h5p']; + } +}