From c50466705e2eed871224c5d360f656e7618f7efb Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Mon, 15 Sep 2008 16:08:59 +0000 Subject: [PATCH] MDL-15666 - fixing bugs in resource unit test implementation --- lang/en_utf8/resource.php | 2 +- mod/resource/lib.php | 3 +++ mod/resource/simpletest/test_resource_portfolio_callers.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lang/en_utf8/resource.php b/lang/en_utf8/resource.php index a9ead0d125..1120242fbf 100644 --- a/lang/en_utf8/resource.php +++ b/lang/en_utf8/resource.php @@ -98,7 +98,7 @@ $string['parameter'] = 'Parameter'; $string['parameters'] = 'Parameters'; $string['popupresource'] = 'This resource should appear in a popup window.'; $string['popupresourcelink'] = 'If it didn\'t, click here: $a'; -$string['portfolionotimplemented'] = 'You are trying to export content from a resource type that doesn\'t support it!'; +$string['portfolionotimplemented'] = 'You are trying to export content from a resource type ($a) that doesn\'t support it!'; $string['preview'] = 'Preview'; $string['previous'] = 'Previous'; $string['redeploy'] = 'Deploy again'; diff --git a/mod/resource/lib.php b/mod/resource/lib.php index 31e09fcf56..14f2b31a1c 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -727,6 +727,9 @@ class resource_portfolio_caller extends portfolio_module_caller_base { $this->resourcefile = $CFG->dirroot.'/mod/resource/type/'.$this->cm->type.'/resource.class.php'; require_once($this->resourcefile); $this->resource= new $resourceclass($this->cm->id); + if (!is_callable(array($resource, 'portfolio_prepare_package')) || !is_callable(array($resource, 'portfolio_get_sha1'))) { + throw new portfolio_exception('portfolionotimplemented', 'resource', null, $this->cm->type); + } $this->supportedformats = array(self::type_to_format($this->cm->type)); } diff --git a/mod/resource/simpletest/test_resource_portfolio_callers.php b/mod/resource/simpletest/test_resource_portfolio_callers.php index b0f109edb9..08e6de96d2 100644 --- a/mod/resource/simpletest/test_resource_portfolio_callers.php +++ b/mod/resource/simpletest/test_resource_portfolio_callers.php @@ -28,7 +28,7 @@ class testResourcePortfolioCallers extends portfoliolib_test { $first_module = reset($this->modules); $cm = get_coursemodule_from_instance($this->module_type, $first_module->id); - $this->caller = parent::setup_caller('resource_portfolio_caller', array('id' => $cm->id)); + $this->caller = parent::setup_caller('resource_portfolio_caller', array('id' => $cm->instance)); } public function tearDown() { -- 2.39.5