]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16587 & MDL-15666: portfolio unit test framework expanded to do 3d rather than...
authormjollnir_ <mjollnir_>
Mon, 13 Oct 2008 10:20:05 +0000 (10:20 +0000)
committermjollnir_ <mjollnir_>
Mon, 13 Oct 2008 10:20:05 +0000 (10:20 +0000)
lib/simpletest/portfolio_testclass.php

index a6133a31ecd83634aa51abab6ca3a61b7cfc8195..df570f114ec7d69f47d0f8fb46c19781f526aef2 100644 (file)
@@ -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");
+                }
             }
         }
     }