From 51122d6c6739a8c1acc7b5fe322b27360bee7f71 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Mon, 13 Oct 2008 10:20:05 +0000 Subject: [PATCH] MDL-16587 & MDL-15666: portfolio unit test framework expanded to do 3d rather than 2d testing (caller + plugin + new: exportformat) --- lib/simpletest/portfolio_testclass.php | 38 ++++++++++++++++++-------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/lib/simpletest/portfolio_testclass.php b/lib/simpletest/portfolio_testclass.php index a6133a31ec..df570f114e 100644 --- a/lib/simpletest/portfolio_testclass.php +++ b/lib/simpletest/portfolio_testclass.php @@ -227,6 +227,8 @@ class portfoliolib_test extends MoodleUnitTestCase { $caller->set('user', $user); } $caller->load_data(); + // set any format + $caller->get('exporter')->set('format', array_shift($caller->supported_formats())); return $caller; } @@ -239,20 +241,32 @@ class portfoliolib_test extends MoodleUnitTestCase { $plugin_class = "partialmock_plugin_$plugin"; $plugin = new $plugin_class(&$this); - // Create a new fake exporter - $exporter = $this->caller->get('exporter'); // new partialmock_exporter(&$this); - $exporter->set('caller', $this->caller); - $exporter->set('instance', $plugin); - $exporter->set('user', $this->caller->get('user')); - - $exception = false; - try { - $exporter->process_stage_package(); - } catch (Exception $e) { - $exception = $e->getMessage(); + // figure out our format intersection and test all of them. + $formats = portfolio_supported_formats_intersect($this->caller->supported_formats(), $plugin->supported_formats()); + if (count($formats) == 0) { + // bail. no common formats. + continue; } - $this->assertFalse($exception, "Unwanted exception: $exception"); + foreach ($formats as $format) { + // Create a new fake exporter + $exporter =& $this->caller->get('exporter'); // new partialmock_exporter(&$this); + $exporter->set('caller', $this->caller); + $exporter->set('instance', $plugin); + $exporter->set('format', $format); + $this->caller->set_export_config(array('format' => $format)); + $plugin->set_export_config(array('format' => $format)); + $exporter->set('user', $this->caller->get('user')); + + $exception = false; + try { + $exporter->process_stage_package(); + } catch (Exception $e) { + $exception = $e->getMessage(); + } + + $this->assertFalse($exception, "Unwanted exception: $exception"); + } } } } -- 2.39.5