Skip to content

Commit

Permalink
#1101 Fixed class name, fixed output
Browse files Browse the repository at this point in the history
  • Loading branch information
j3nsch committed Nov 1, 2023
1 parent a4b3ae1 commit cfd354c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/**
* View helper for rendering metadata formats list.
*/
class Oai_View_Helper_ListMetaDataFormats extends Application_View_Helper_Abstract
class Oai_View_Helper_ListMetadataFormats extends Application_View_Helper_Abstract
{
/**
* Returns XML for rendering the metadata formats list.
Expand Down Expand Up @@ -71,14 +71,16 @@ public function listMetadataFormats()
throw new Exception($message);
}

$output .= '<metadataFormat>'
. "<metadataPrefix><xsl:text>$prefix</xsl:text></metadataPrefix>"
. "<schema><xsl:text>$schemaUrl</xsl:text></schema>"
. "<metadataNamespace><xsl:text>$metadataNamespaceUrl</xsl:text></metadataNamespace>"
. '</metadataFormat>';
$output .= PHP_EOL;
$output .= ' <metadataFormat>' . PHP_EOL;
$output .= " <metadataPrefix>$prefix</metadataPrefix>" . PHP_EOL;
$output .= " <schema>$schemaUrl</schema>" . PHP_EOL;
$output .= " <metadataNamespace>$metadataNamespaceUrl</metadataNamespace>" . PHP_EOL;
$output .= ' </metadataFormat>';
}
}
}
$output .= PHP_EOL . ' ';
}

return $output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

class Oai_View_Helper_ListMetaDataFormatsTest extends ControllerTestCase
class Oai_View_Helper_ListMetadataFormatsTest extends ControllerTestCase
{
/** @var string */
protected $additionalResources = 'database';
Expand All @@ -39,53 +39,61 @@ class Oai_View_Helper_ListMetaDataFormatsTest extends ControllerTestCase
*/
protected function getExpectedMetadaFormats()
{
return '<metadataFormat>'
. '<metadataPrefix><xsl:text>oai_dc</xsl:text></metadataPrefix>'
. '<schema><xsl:text>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</xsl:text></schema>'
. '<metadataNamespace><xsl:text>http://www.openarchives.org/OAI/2.0/oai_dc/</xsl:text></metadataNamespace>'
. '</metadataFormat>'
. '<metadataFormat>'
. '<metadataPrefix><xsl:text>epicur</xsl:text></metadataPrefix>'
. '<schema><xsl:text>http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd</xsl:text></schema>'
. '<metadataNamespace><xsl:text>urn:nbn:de:1111-2004033116</xsl:text></metadataNamespace>'
. '</metadataFormat>'
. '<metadataFormat>'
. '<metadataPrefix><xsl:text>xMetaDissPlus</xsl:text></metadataPrefix>'
. '<schema><xsl:text>http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd</xsl:text></schema>'
. '<metadataNamespace><xsl:text>http://www.d-nb.de/standards/xmetadissplus/</xsl:text></metadataNamespace>'
. '</metadataFormat>'
. '<metadataFormat>'
. '<metadataPrefix><xsl:text>MARC21</xsl:text></metadataPrefix><schema>'
. '<xsl:text>https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</xsl:text></schema><metadataNamespace>'
. '<xsl:text>http://www.loc.gov/MARC21/slim</xsl:text></metadataNamespace>'
. '</metadataFormat>';
return <<<TEXT
<metadataFormat>
<metadataPrefix>oai_dc</metadataPrefix>
<schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema>
<metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>epicur</metadataPrefix>
<schema>http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd</schema>
<metadataNamespace>urn:nbn:de:1111-2004033116</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>xMetaDissPlus</metadataPrefix>
<schema>http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd</schema>
<metadataNamespace>http://www.d-nb.de/standards/xmetadissplus/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>MARC21</metadataPrefix>
<schema>https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</schema>
<metadataNamespace>http://www.loc.gov/MARC21/slim</metadataNamespace>
</metadataFormat>
TEXT;
}

/**
* @return string
*/
protected function getExpectedMetadaFormatsWithoutOaiDc()
{
return '<metadataFormat>'
. '<metadataPrefix><xsl:text>epicur</xsl:text></metadataPrefix>'
. '<schema><xsl:text>http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd</xsl:text></schema>'
. '<metadataNamespace><xsl:text>urn:nbn:de:1111-2004033116</xsl:text></metadataNamespace>'
. '</metadataFormat>'
. '<metadataFormat>'
. '<metadataPrefix><xsl:text>xMetaDissPlus</xsl:text></metadataPrefix>'
. '<schema><xsl:text>http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd</xsl:text></schema>'
. '<metadataNamespace><xsl:text>http://www.d-nb.de/standards/xmetadissplus/</xsl:text></metadataNamespace>'
. '</metadataFormat>'
. '<metadataFormat>'
. '<metadataPrefix><xsl:text>MARC21</xsl:text></metadataPrefix><schema>'
. '<xsl:text>https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</xsl:text></schema><metadataNamespace>'
. '<xsl:text>http://www.loc.gov/MARC21/slim</xsl:text></metadataNamespace>'
. '</metadataFormat>';
return <<<TEXT
<metadataFormat>
<metadataPrefix>epicur</metadataPrefix>
<schema>http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd</schema>
<metadataNamespace>urn:nbn:de:1111-2004033116</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>xMetaDissPlus</metadataPrefix>
<schema>http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd</schema>
<metadataNamespace>http://www.d-nb.de/standards/xmetadissplus/</metadataNamespace>
</metadataFormat>
<metadataFormat>
<metadataPrefix>MARC21</metadataPrefix>
<schema>https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd</schema>
<metadataNamespace>http://www.loc.gov/MARC21/slim</metadataNamespace>
</metadataFormat>
TEXT;
}

public function testListMetadataFormats()
{
$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormats(), $listMetaDataFormats->listMetadataFormats());
}

Expand All @@ -104,7 +112,7 @@ public function testListMetadataFormatsFormatNotVisible()
],
]);

$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormatsWithoutOaiDc(), $listMetaDataFormats->listMetadataFormats());
}

Expand All @@ -123,7 +131,7 @@ public function testListMetadataFormatsFormatNotVisibleAndAdminOnly()
],
]);

$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormatsWithoutOaiDc(), $listMetaDataFormats->listMetadataFormats());
}

Expand All @@ -142,7 +150,7 @@ public function testListMetadataFormatsFormatVisible()
],
]);

$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormats(), $listMetaDataFormats->listMetadataFormats());
}

Expand All @@ -161,7 +169,7 @@ public function testListMetadataFormatsFormatVisibleAndAdminOnly()
],
]);

$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormatsWithoutOaiDc(), $listMetaDataFormats->listMetadataFormats());
}

Expand All @@ -181,7 +189,7 @@ public function testListMetadataFormatsAsAdminWithFormatNotVisible()
],
]);

$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$formatList = $listMetaDataFormats->listMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormatsWithoutOaiDc(), $listMetaDataFormats->listMetadataFormats());
}
Expand All @@ -202,7 +210,7 @@ public function testListMetadataFormatsAsAdminWithFormatNotVisibleAndAdminOnly()
],
]);

$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormatsWithoutOaiDc(), $listMetaDataFormats->listMetadataFormats());
}

Expand All @@ -222,7 +230,7 @@ public function testListMetadataFormatsAsAdminWithFormatVisible()
],
]);

$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormats(), $listMetaDataFormats->listMetadataFormats());
}

Expand All @@ -242,7 +250,7 @@ public function testListMetadataFormatsAsAdminWithFormatVisibleAndAdminOnly()
],
]);

$listMetaDataFormats = new Oai_View_Helper_ListMetaDataFormats();
$listMetaDataFormats = new Oai_View_Helper_ListMetadataFormats();
$this->assertEquals($this->getExpectedMetadaFormats(), $listMetaDataFormats->listMetadataFormats());
}
}

0 comments on commit cfd354c

Please sign in to comment.