diff --git a/src/qtism/data/storage/xml/XmlDocument.php b/src/qtism/data/storage/xml/XmlDocument.php index 01ae9c928..dd752a677 100644 --- a/src/qtism/data/storage/xml/XmlDocument.php +++ b/src/qtism/data/storage/xml/XmlDocument.php @@ -14,7 +14,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2013-2015 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); + * Copyright (c) 2013-2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); * * @author Jérôme Bogaerts * @license GPLv2 @@ -270,9 +270,9 @@ public function saveToString($formatOutput = true) */ protected function saveImplementation($uri = '', $formatOutput = true) { - $assessmentTest = $this->getDocumentComponent(); + $qtiComponent = $this->getDocumentComponent(); - if (!empty($assessmentTest)) { + if (!empty($qtiComponent)) { $this->setDomDocument(new DOMDocument('1.0', 'UTF-8')); if ($formatOutput == true) { @@ -323,7 +323,7 @@ protected function saveImplementation($uri = '', $formatOutput = true) throw new XmlStorageException($msg, XmlStorageException::VERSION, $e); } } else { - $msg = "The Assessment Document cannot be saved. No AssessmentTest object provided."; + $msg = "The document cannot be saved. No document component object to be saved."; throw new XmlStorageException($msg, XmlStorageException::WRITE); } } diff --git a/test/qtismtest/data/storage/xml/XmlDocumentTest.php b/test/qtismtest/data/storage/xml/XmlDocumentTest.php index 0540e8443..dc154865d 100644 --- a/test/qtismtest/data/storage/xml/XmlDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlDocumentTest.php @@ -397,4 +397,49 @@ public function testSchemaValidateUnknownFile() $doc->schemaValidate('blub'); } + + public function testXIncludeNoComponent() + { + $doc = new XmlDocument(); + + $this->setExpectedException( + '\\LogicException', + 'Cannot include fragments via XInclude before loading any file.' + ); + $doc->xInclude(); + } + + public function testResolveTemplateLocationNoComponent() + { + $doc = new XmlDocument(); + + $this->setExpectedException( + '\\LogicException', + 'Cannot resolve template location before loading any file.' + ); + $doc->resolveTemplateLocation(); + } + + public function testIncludeAssessmentSectionRefsNoComponent() + { + $doc = new XmlDocument(); + + $this->setExpectedException( + '\\LogicException', + 'Cannot resolve assessmentSectionRefs before loading any file.' + ); + $doc->includeAssessmentSectionRefs(); + } + + public function testSaveNoComponent() + { + $doc = new XmlDocument(); + + $this->setExpectedException( + 'qtism\data\storage\xml\XmlStorageException', + 'The document cannot be saved. No document component object to be saved.' + ); + + $doc->save('path.xml'); + } }