17 import(
'lib.pkp.tests.PKPTestCase');
18 import(
'plugins.importexport.medra.classes.MedraWebservice');
23 protected function setUp() : void {
26 if (empty($medraPassword)) {
27 $this->markTestSkipped(
28 'Please set webtest_medra_pw in your config.php\'s ' .
29 '[debug] section to the password of your Medra test account.'
33 $this->ws =
new MedraWebservice(MEDRA_WS_ENDPOINT_DEV,
'TEST_OJS', $medraPassword);
41 self::assertTrue($this->ws->upload($this->getTestData()));
48 $metadata = str_replace(
'SerialVersion',
'UnknownElement', $this->getTestData());
49 $expectedError =
"mEDRA: 200 - uploaded file is not valid cvc-complex-type.2.4.a: ".
50 "Invalid content was found starting with element 'UnknownElement'. " .
51 "One of '{\"http://www.editeur.org/onix/DOIMetadata/2.0\":SerialVersion}' is expected.";
52 self::assertEquals($expectedError, $this->ws->upload($metadata));
59 $dom =
new DOMDocument(
'1.0',
'utf-8');
60 $dom->loadXML($this->getTestData());
61 $elem = $dom->getElementsByTagName(
'DOISerialIssueWork')->item(0);
62 $attr = $dom->createAttribute(
'xmlns');
63 $attr->value =
'http://www.editeur.org/onix/DOIMetadata/2.0';
64 $elem->appendChild($attr);
66 $result = str_replace(
67 '<NotificationType>07</NotificationType>',
68 '<NotificationType>06</NotificationType>',
69 $this->ws->viewMetadata(
'1749/t.v1i1')
72 self::assertXmlStringEqualsXmlString($dom->saveXml($elem), $result);
79 private function getTestData() {
80 $sampleFile =
'./tests/functional/plugins/importexport/medra/serial-issue-as-work.xml';
81 return file_get_contents($sampleFile);