21 require_mock_env(
'env2');
23 import(
'lib.pkp.tests.PKPTestCase');
25 import(
'lib.pkp.classes.oai.OAIStruct');
26 import(
'lib.pkp.classes.oai.OAIUtils');
27 import(
'plugins.oaiMetadataFormats.dc.OAIMetadataFormat_DC');
28 import(
'plugins.oaiMetadataFormats.dc.OAIMetadataFormatPlugin_DC');
30 import(
'lib.pkp.classes.services.PKPSchemaService');
38 return array(
'AuthorDAO',
'OAIDAO',
'ArticleGalleyDAO');
45 return array(
'request');
53 $this->markTestSkipped(
'Skipped because of weird class interaction with ControlledVocabDAO.');
62 $pluginSettingsDao->updateSetting($journalId,
'doipubidplugin',
'enabled', 1);
63 $pluginSettingsDao->updateSetting($journalId,
'doipubidplugin',
'enableIssueDoi', 1);
64 $pluginSettingsDao->updateSetting($journalId,
'doipubidplugin',
'enablePublicationDoi', 1);
65 $pluginSettingsDao->updateSetting($journalId,
'doipubidplugin',
'enableRepresentationyDoi', 1);
68 import(
'classes.article.Author');
70 $author->setGivenName(
'author-firstname',
'en_US');
71 $author->setFamilyName(
'author-lastname',
'en_US');
72 $author->setAffiliation(
'author-affiliation',
'en_US');
73 $author->setEmail(
'someone@example.com');
76 import(
'classes.submission.Submission');
77 $article = $this->getMockBuilder(Submission::class)
78 ->setMethods(array(
'getBestId'))
80 $article->expects($this->any())
82 ->will($this->returnValue(9));
84 $article->setJournalId($journalId);
85 $author->setSubmissionId($article->getId());
86 $article->setPages(15);
87 $article->setType(
'art-type',
'en_US');
88 $article->setTitle(
'article-title-en',
'en_US');
89 $article->setTitle(
'article-title-de',
'de_DE');
90 $article->setDiscipline(
'article-discipline',
'en_US');
91 $article->setSubject(
'article-subject',
'en_US');
92 $article->setAbstract(
'article-abstract',
'en_US');
93 $article->setSponsor(
'article-sponsor',
'en_US');
94 $article->setStoredPubId(
'doi',
'article-doi');
95 $article->setLanguage(
'en_US');
98 import(
'classes.article.ArticleGalley');
101 $galley->setStoredPubId(
'doi',
'galley-doi');
102 $galleys = array($galley);
105 import(
'classes.journal.Journal');
106 $journal = $this->getMockBuilder(Journal::class)
107 ->setMethods(array(
'getSetting'))
109 $journal->expects($this->any())
110 ->method(
'getSetting')
111 ->will($this->returnCallback(array($this,
'getJournalSetting')));
112 $journal->setPrimaryLocale(
'en_US');
113 $journal->setPath(
'journal-path');
114 $journal->setId($journalId);
117 import(
'classes.journal.Section');
119 $section->setIdentifyType(
'section-identify-type',
'en_US');
122 import(
'classes.issue.Issue');
123 $issue = $this->getMockBuilder(Issue::class)
124 ->setMethods(array(
'getIssueIdentification'))
126 $issue->expects($this->any())
127 ->method(
'getIssueIdentification')
128 ->will($this->returnValue(
'issue-identification'));
130 $issue->setDatePublished(
'2010-11-05');
131 $issue->setStoredPubId(
'doi',
'issue-doi');
132 $issue->setJournalId($journalId);
140 import(
'lib.pkp.classes.core.PKPRouter');
141 $router = $this->getMockBuilder(PKPRouter::class)
142 ->setMethods(array(
'url'))
146 $router->expects($this->any())
148 ->will($this->returnCallback(array($this,
'routerUrl')));
151 import(
'classes.core.Request');
152 $request = $this->getMockBuilder(Request::class)
153 ->setMethods(array(
'getRouter'))
155 $request->expects($this->any())
156 ->method(
'getRouter')
157 ->will($this->returnValue($router));
166 import(
'classes.article.AuthorDAO');
167 $authorDao = $this->getMockBuilder(AuthorDAO::class)
168 ->setMethods(array(
'getBySubmissionId'))
170 $authorDao->expects($this->any())
171 ->method(
'getBySubmissionId')
172 ->will($this->returnValue(array($author)));
176 import(
'classes.oai.ojs.OAIDAO');
177 $oaiDao = $this->getMockBuilder(OAIDAO::class)
178 ->setMethods(array(
'getJournal',
'getSection',
'getIssue'))
180 $oaiDao->expects($this->any())
181 ->method(
'getJournal')
182 ->will($this->returnValue($journal));
183 $oaiDao->expects($this->any())
184 ->method(
'getSection')
185 ->will($this->returnValue($section));
186 $oaiDao->expects($this->any())
188 ->will($this->returnValue($issue));
192 import(
'classes.article.ArticleGalleyDAO');
193 $articleGalleyDao = $this->getMockBuilder(ArticleGalleyDAO::class)
194 ->setMethods(array(
'getBySubmissionId'))
196 $articleGalleyDao->expects($this->any())
197 ->method(
'getBySubmissionId')
198 ->will($this->returnValue($galleys));
208 $record->setData(
'article', $article);
209 $record->setData(
'galleys', $galleys);
210 $record->setData(
'journal', $journal);
211 $record->setData(
'section', $section);
212 $record->setData(
'issue', $issue);
220 $xml = $mdFormat->toXml($record);
221 self::assertXmlStringEqualsXmlFile(
'tests/plugins/oaiMetadataFormats/dc/expectedResult.xml', $xml);
233 switch ($settingName) {
235 return array(
'en_US' =>
'journal-title');
238 return array(
'en_US' =>
'journal-copyright');
240 case 'publisherInstitution':
241 return array(
'journal-publisher');
250 self::fail(
'Required journal setting is not necessary for the purpose of this test.');
261 function routerUrl($request, $newContext =
null, $handler =
null,
$op =
null, $path =
null) {
262 return $handler.
'-'.
$op.
'-'.implode(
'-', $path);