Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Sep 23, 2016
2 parents f9fd58e + 8c6adf4 commit bceda9e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/qtism/data/storage/xml/XmlDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* @license GPLv2
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down
45 changes: 45 additions & 0 deletions test/qtismtest/data/storage/xml/XmlDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit bceda9e

Please sign in to comment.