Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions library/Opus/Model/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,7 @@ public function setType($type)
$this->type = $type;
}

/**
* @return string|null
*/
public function getType()
public function getType(): string|null
{
return $this->type;
}
Expand Down
3 changes: 3 additions & 0 deletions library/Opus/Model/Xml/AbstractVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ public function getFieldValues($field)
if ($fieldValues instanceof DateTimeZone) {
$fieldValues = $fieldValues->getName();
}
if ($field->getType() === 'bool') {
$fieldValues = $fieldValues ? '1' : '0';
}

return trim($fieldValues ?? '');
}
Expand Down
16 changes: 14 additions & 2 deletions tests/Opus/Model/Xml/Version1Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,6 @@ public function testDateXml()
$xml->setModel($document);
$dom = $xml->getDomDocument();

$output = $dom->saveXml();

$elements = $dom->getElementsByTagName('CompletedDate');
$this->assertCount(1, $elements);

Expand All @@ -971,4 +969,18 @@ public function testDateXml()
$this->assertTrue($completedDate->hasAttribute('Timezone'));
$this->assertTrue($completedDate->hasAttribute('UnixTimestamp'));
}

public function testOutputBelongsToBibliographyFalseAsZero()
{
$doc = Document::new();
$doc->setBelongsToBibliography(false);

$xml = new Xml();
$xml->setStrategy(new Version1());
$xml->setModel($doc);
$dom = $xml->getDomDocument();

$docElement = $dom->getElementsByTagName('Opus_Document')->item(0);
$this->assertEquals('0', $docElement->attributes->getNamedItem('BelongsToBibliography')->nodeValue);
}
}
Loading