From 05fc001c64f1ee21c7378f73386fa00b30e90e49 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 23 Sep 2016 14:52:48 +0200 Subject: [PATCH 1/4] Variable renaming + error message. --- src/qtism/data/storage/xml/XmlDocument.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); } } From ac3b5e6a78df09c3aebfe3906463f1060a28d070 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 23 Sep 2016 15:03:31 +0200 Subject: [PATCH 2/4] test with xInclude with no component registered yet. --- test/qtismtest/data/storage/xml/XmlDocumentTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/qtismtest/data/storage/xml/XmlDocumentTest.php b/test/qtismtest/data/storage/xml/XmlDocumentTest.php index 0540e8443..8f35f7763 100644 --- a/test/qtismtest/data/storage/xml/XmlDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlDocumentTest.php @@ -397,4 +397,15 @@ 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(); + } } From b58ccb4fef264f09444c0d07104e2c3cc37d667f Mon Sep 17 00:00:00 2001 From: = Date: Fri, 23 Sep 2016 15:14:40 +0200 Subject: [PATCH 3/4] More XmlDocument testing. --- .../data/storage/xml/XmlDocumentTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/qtismtest/data/storage/xml/XmlDocumentTest.php b/test/qtismtest/data/storage/xml/XmlDocumentTest.php index 8f35f7763..88d02149d 100644 --- a/test/qtismtest/data/storage/xml/XmlDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlDocumentTest.php @@ -408,4 +408,26 @@ public function testXIncludeNoComponent() ); $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(); + } } From 8c6adf401c0fae5b16329318a7cb6f2084681419 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 23 Sep 2016 15:34:25 +0200 Subject: [PATCH 4/4] Additional tests for XmlDocumentTest. --- test/qtismtest/data/storage/xml/XmlDocumentTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/qtismtest/data/storage/xml/XmlDocumentTest.php b/test/qtismtest/data/storage/xml/XmlDocumentTest.php index 88d02149d..dc154865d 100644 --- a/test/qtismtest/data/storage/xml/XmlDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlDocumentTest.php @@ -430,4 +430,16 @@ public function testIncludeAssessmentSectionRefsNoComponent() ); $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'); + } }