From 13c01a8e16bde32264b0614b56f66d890bb7af88 Mon Sep 17 00:00:00 2001 From: Sarah Cotton Date: Fri, 2 Dec 2022 13:57:30 +0000 Subject: [PATCH 1/3] Fix to use correct DEBUG_ const causing unit test to fail --- classes/converter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/converter.php b/classes/converter.php index 57d5130..7fa89fa 100644 --- a/classes/converter.php +++ b/classes/converter.php @@ -282,7 +282,7 @@ public static function are_requirements_met() { $converter = new \fileconverter_librelambda\converter(); // First check that we have the basic configuration settings set. if (!$converter->is_config_set()) { - debugging(get_string('settings:confignotset', 'fileconverter_librelambda'), 'notifyproblem'); + debugging(get_string('settings:confignotset', 'fileconverter_librelambda'), DEBUG_NORMAL); return false; } $converter->create_client(); From 356bf869585c010566d4bd1e81d1f2766d403645 Mon Sep 17 00:00:00 2001 From: Sarah Cotton Date: Fri, 2 Dec 2022 15:54:47 +0000 Subject: [PATCH 2/3] Fix moodle-ci tools issues --- README.md | 2 +- classes/event/poll_conversion_status.php | 9 ++++++++ classes/event/start_document_conversion.php | 9 ++++++++ classes/provision.php | 3 +++ cli/get_files.php | 4 +++- cli/provision.php | 5 ++++- tests/converter_test.php | 7 +++++- tests/events_test.php | 6 ++++- tests/provision_test.php | 25 ++++++++++++--------- 9 files changed, 54 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bd4555d..b4a361d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://github.com/catalyst/moodle-fileconverter_librelambda/workflows/Run%20all%20tests%20for%20Moodle%2034+/badge.svg)](https://github.com/catalyst/moodle-fileconverter_librelambda/actions) +![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/catalyst/moodle-fileconverter_librelambda/ci.yml?branch=master) # Libre Lambda Document Converter # diff --git a/classes/event/poll_conversion_status.php b/classes/event/poll_conversion_status.php index 01efa2b..e6c2e08 100644 --- a/classes/event/poll_conversion_status.php +++ b/classes/event/poll_conversion_status.php @@ -33,16 +33,25 @@ */ class poll_conversion_status extends \core\event\base { + /** + * Init function. + */ protected function init() { $this->data['crud'] = 'c'; $this->data['edulevel'] = self::LEVEL_PARTICIPATING; } + /** + * Get event name. + */ public static function get_name() { return get_string('event:poll_conversion_status', 'fileconverter_librelambda'); } + /** + * Get event description. + */ public function get_description() { return "The conversion with id '{$this->other['id']}' has been polled and returned the status '{$this->other['status']}'."; } diff --git a/classes/event/start_document_conversion.php b/classes/event/start_document_conversion.php index dabb7d1..cc4cc43 100644 --- a/classes/event/start_document_conversion.php +++ b/classes/event/start_document_conversion.php @@ -33,16 +33,25 @@ */ class start_document_conversion extends \core\event\base { + /** + * Init function. + */ protected function init() { $this->data['crud'] = 'c'; $this->data['edulevel'] = self::LEVEL_PARTICIPATING; } + /** + * Get event name. + */ public static function get_name() { return get_string('event:start_document_conversion', 'fileconverter_librelambda'); } + /** + * Get event description. + */ public function get_description() { return "The conversion with id '{$this->other['id']}' has been commenced with status '{$this->other['status']}'."; } diff --git a/classes/provision.php b/classes/provision.php index a0eb787..7711750 100644 --- a/classes/provision.php +++ b/classes/provision.php @@ -41,7 +41,10 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provision { + /** The default stack name */ const DEFAULT_STACK_NAME = 'LambdaConvert'; + + /** The max bucket prefix length */ const MAX_BUCKET_PREFIX_LEN = 52; /** diff --git a/cli/get_files.php b/cli/get_files.php index 715d6aa..4e7b940 100644 --- a/cli/get_files.php +++ b/cli/get_files.php @@ -15,7 +15,9 @@ // along with Moodle. If not, see . /** - * This command line script will get all document files from S3 in a site that + * The command line script. + * + * Will get all document files from S3 in a site that * uses the object fs plugin and download them locally * * @package fileconverter_librelambda diff --git a/cli/provision.php b/cli/provision.php index f5bf5be..58c24b6 100644 --- a/cli/provision.php +++ b/cli/provision.php @@ -66,7 +66,10 @@ "; $stacknotexistsmsg = "Stack does not exsist."; -function abort($msg) { +/** Abort function + * @param string $msg + */ +function abort(string $msg) { echo "$msg\n"; die; } diff --git a/tests/converter_test.php b/tests/converter_test.php index 00ddd88..7d0ef10 100644 --- a/tests/converter_test.php +++ b/tests/converter_test.php @@ -22,6 +22,9 @@ * @copyright 2018 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +namespace fileconverter_librelambda; + defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -33,6 +36,8 @@ use Psr\Http\Message\RequestInterface; use Aws\S3\Exception\S3Exception; use \core_files\conversion; +use \context_module; +use \ReflectionMethod; /** * PHPUnit tests for Libre Lambda file converter. @@ -41,7 +46,7 @@ * @copyright 2018 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class fileconverter_librelambda_converter_testcase extends advanced_testcase { +class converter_test extends \advanced_testcase { /** * Test is_config_set method with missing configuration. diff --git a/tests/events_test.php b/tests/events_test.php index efa159c..3da6f60 100644 --- a/tests/events_test.php +++ b/tests/events_test.php @@ -22,6 +22,9 @@ * @copyright 2018 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +namespace fileconverter_librelambda; + defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -33,6 +36,7 @@ use Psr\Http\Message\RequestInterface; use Aws\S3\Exception\S3Exception; use \core_files\conversion; +use \context_module; /** * PHPUnit tests for Libre Lambda file converter. @@ -41,7 +45,7 @@ * @copyright 2018 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class fileconverter_librelambda_events_testcase extends advanced_testcase { +class events_test extends \advanced_testcase { /** * Test start document conversion method. diff --git a/tests/provision_test.php b/tests/provision_test.php index dc5e199..4e59694 100644 --- a/tests/provision_test.php +++ b/tests/provision_test.php @@ -22,13 +22,16 @@ * @copyright 2018 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +namespace fileconverter_librelambda; + defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php'); -use Aws\Result; use Aws\MockHandler; +use Aws\Result; use Aws\CommandInterface; use Psr\Http\Message\RequestInterface; use Aws\S3\Exception\S3Exception; @@ -41,7 +44,7 @@ * @copyright 2018 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class mock_provision extends \fileconverter_librelambda\provision { +class provision_mock extends provision { /** * * @var MockHandler @@ -100,7 +103,6 @@ public function check_bucket_exists($bucketname) { * Create an S3 Bucket in AWS. * Upgrade to public. * - * @param string $bucketname The name to use for the S3 bucket. * @return \stdClass $result The result of the bucket creation. */ public function create_resource_bucket() { @@ -108,6 +110,7 @@ public function create_resource_bucket() { } } + /** * PHPUnit tests for Libre Lambda AWS provision. * @@ -115,14 +118,14 @@ public function create_resource_bucket() { * @copyright 2018 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class fileconverter_librelambda_provision_testcase extends advanced_testcase { +class provision_test extends \advanced_testcase { /** * Test the does bucket exist method. Should return false. * We mock out the S3 client response as we are not trying to connect to the live AWS API. */ public function test_create_resource_bucket_exists_false() { - $provisioner = new mock_provision(); + $provisioner = new provision_mock(); $provisioner->mocks3handler->append(function (CommandInterface $cmd, RequestInterface $req) { return new S3Exception('Mock exception', $cmd, ['code' => 'NotFound']); @@ -144,7 +147,7 @@ public function test_create_resource_bucket_exists_false() { * We mock out the S3 client response as we are not trying to connect to the live AWS API. */ public function test_create_resource_bucket_exists_true() { - $provisioner = new mock_provision(); + $provisioner = new provision_mock(); $provisioner->mocks3handler->append(new Result([])); @@ -161,7 +164,7 @@ public function test_create_resource_bucket_exists_true() { * We mock out the S3 client response as we are not trying to connect to the live AWS API. */ public function test_create_resource_bucket_exists_forbidden() { - $provisioner = new mock_provision(); + $provisioner = new provision_mock(); $bucketname = 'foobar'; $provisioner->mocks3handler->append(function (CommandInterface $cmd, RequestInterface $req) { @@ -179,7 +182,7 @@ public function test_create_resource_bucket_exists_forbidden() { public function test_provision_stack_exists_no_replace() { global $CFG; - $provisioner = new mock_provision(); + $provisioner = new provision_mock(); $provisioner->mocks3handler->append(new Result([])); $provisioner->mocks3handler->append(new Result(['ObjectURL' => "https://amazon/lambdaconvert.zip"])); @@ -212,7 +215,7 @@ public function test_provision_stack_exists_replace() { global $CFG; $lambdazip = 'lambdaconvert.zip'; - $provisioner = new mock_provision(); + $provisioner = new provision_mock(); $provisioner->mocks3handler->append(new Result([])); $provisioner->mocks3handler->append(new Result(['ObjectURL' => "https://amazon/$lambdazip"])); @@ -268,7 +271,7 @@ public function test_provision_stack_not_exists() { $stack = 'AnotherStack'; $lambdazip = 'lambdaconvert.zip'; - $provisioner = new mock_provision($stack); + $provisioner = new provision_mock($stack); $provisioner->mocks3handler->append(new Result([])); $provisioner->mocks3handler->append(new Result(['ObjectURL' => "https://amazon/$lambdazip"])); @@ -323,7 +326,7 @@ public function test_remove_stack_remove_objects_ok() { global $CFG; $filename = 'some.file'; - $provisioner = new mock_provision(); + $provisioner = new provision_mock(); $cloudformationpath = $CFG->dirroot . '/files/converter/librelambda/lambda/stack.template'; $provisioner->mockcloudformationhandler->append(new Result([ From af76b533874b5d2f09c29589a9ad6ea6088880ce Mon Sep 17 00:00:00 2001 From: Sarah Cotton Date: Mon, 9 Jan 2023 12:16:49 +0000 Subject: [PATCH 3/3] Version bump --- version.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/version.php b/version.php index 18130fa..ad6ceac 100644 --- a/version.php +++ b/version.php @@ -25,11 +25,11 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'fileconverter_librelambda'; -$plugin->release = 2022011500; -$plugin->version = 2022011500; +$plugin->release = 2023010900; +$plugin->version = 2023010900; $plugin->requires = 2017111309; $plugin->maturity = MATURITY_STABLE; $plugin->dependencies = array( - 'local_aws' => 2020061500 + 'local_aws' => 2022033100 ); -$plugin->supported = [34, 311]; // A range of branch numbers of supported moodle versions. +$plugin->supported = [34, 401]; // A range of branch numbers of supported moodle versions.