public function testFromInvalidObject()
 {
     $this->setExpectedException('\\InvalidArgumentException');
     $component = new stdClass();
     $factory = new MarshallerFactory();
     $marshaller = $factory->createMarshaller($component);
 }
 public function __invoke($params)
 {
     // load constants...
     \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->load();
     if (empty($params[0]) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Test URI not provided as parameter 1.');
     }
     if (empty($params[1]) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'AssessmentItemRefIdentifier not provided as parameter 2.');
     }
     $testResource = new \core_kernel_classes_Resource($params[0]);
     if ($testResource->exists() === false) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No RDFS Resource found for URI ' . $params[0] . '.');
     }
     $qtiService = \taoQtiTest_models_classes_QtiTestService::singleton();
     $testDoc = $qtiService->getDoc($testResource);
     $test = $testDoc->getDocumentComponent();
     $assessmentItemRef = $test->getComponentByIdentifier($params[1]);
     if (!$assessmentItemRef) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI assessmentItemRef with identifier ' . $params[1] . ' found in the QTI Test definition.');
     }
     $input = file_get_contents('php://stdin');
     if (empty($input) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI-XML input provided in stdin.');
     } else {
         $dom = new \DOMDocument('1.0', 'UTF-8');
         if (@$dom->loadXML($input)) {
             $element = $dom->documentElement;
             $marshallerFactory = new MarshallerFactory();
             $marshaller = $marshallerFactory->createMarshaller($element);
             $component = $marshaller->unmarshall($element);
             if (!$component instanceof BranchRule) {
                 return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI branchRule component found in stdin.');
             }
             $assessmentItemRef->setBranchRules(new BranchRuleCollection(array($component)));
             $qtiService->getQtiTestFile($testResource)->update($testDoc->saveToString());
         } else {
             return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Invalid QTI-XML input provided in stdin.');
         }
     }
     return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, "BranchRule found in stdin successfully appended to assessmentItemRef '" . $params[1] . "' part of QTI Test with URI '" . $params[0] . "'.");
 }