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');
36 return array(
'AuthorDAO',
'OAIDAO',
'ArticleGalleyDAO');
43 return array(
'request');
51 $this->markTestSkipped(
'Skipped because of weird class interaction with ControlledVocabDAO.');
60 $pluginSettingsDao->updateSetting($journalId,
'doipubidplugin',
'enabled', 1);
61 $pluginSettingsDao->updateSetting($journalId,
'doipubidplugin',
'enableIssueDoi', 1);
62 $pluginSettingsDao->updateSetting($journalId,
'doipubidplugin',
'enablePublicationDoi', 1);
63 $pluginSettingsDao->updateSetting($journalId,
'doipubidplugin',
'enableRepresentationyDoi', 1);
66 import(
'classes.article.Author');
68 $author->setGivenName(
'author-firstname',
'en_US');
69 $author->setFamilyName(
'author-lastname',
'en_US');
70 $author->setAffiliation(
'author-affiliation',
'en_US');
71 $author->setEmail(
'someone@example.com');
74 import(
'classes.submission.Submission');
75 $article = $this->getMockBuilder(Submission::class)
76 ->setMethods(array(
'getBestId'))
78 $article->expects($this->any())
80 ->will($this->returnValue(9));
82 $article->setJournalId($journalId);
83 $author->setSubmissionId($article->getId());
84 $article->setPages(15);
85 $article->setType(
'art-type',
'en_US');
86 $article->setTitle(
'article-title-en',
'en_US');
87 $article->setTitle(
'article-title-de',
'de_DE');
88 $article->setDiscipline(
'article-discipline',
'en_US');
89 $article->setSubject(
'article-subject',
'en_US');
90 $article->setAbstract(
'article-abstract',
'en_US');
91 $article->setSponsor(
'article-sponsor',
'en_US');
92 $article->setStoredPubId(
'doi',
'article-doi');
93 $article->setLanguage(
'en_US');
96 import(
'classes.article.ArticleGalley');
99 $galley->setStoredPubId(
'doi',
'galley-doi');
100 $galleys = array($galley);
103 import(
'classes.journal.Journal');
104 $journal = $this->getMockBuilder(Journal::class)
105 ->setMethods(array(
'getSetting'))
107 $journal->expects($this->any())
108 ->method(
'getSetting')
109 ->will($this->returnCallback(array($this,
'getJournalSetting')));
110 $journal->setPrimaryLocale(
'en_US');
111 $journal->setPath(
'journal-path');
112 $journal->setId($journalId);
115 import(
'classes.journal.Section');
117 $section->setIdentifyType(
'section-identify-type',
'en_US');
120 import(
'classes.issue.Issue');
121 $issue = $this->getMockBuilder(Issue::class)
122 ->setMethods(array(
'getIssueIdentification'))
124 $issue->expects($this->any())
125 ->method(
'getIssueIdentification')
126 ->will($this->returnValue(
'issue-identification'));
128 $issue->setDatePublished(
'2010-11-05');
129 $issue->setStoredPubId(
'doi',
'issue-doi');
130 $issue->setJournalId($journalId);
138 import(
'lib.pkp.classes.core.PKPRouter');
139 $router = $this->getMockBuilder(PKPRouter::class)
140 ->setMethods(array(
'url'))
143 $router->setApplication($application);
144 $router->expects($this->any())
146 ->will($this->returnCallback(array($this,
'routerUrl')));
149 import(
'classes.core.Request');
150 $request = $this->getMockBuilder(Request::class)
151 ->setMethods(array(
'getRouter'))
153 $request->expects($this->any())
154 ->method(
'getRouter')
155 ->will($this->returnValue($router));
164 import(
'classes.article.AuthorDAO');
165 $authorDao = $this->getMockBuilder(AuthorDAO::class)
166 ->setMethods(array(
'getBySubmissionId'))
168 $authorDao->expects($this->any())
169 ->method(
'getBySubmissionId')
170 ->will($this->returnValue(array($author)));
174 import(
'classes.oai.ojs.OAIDAO');
175 $oaiDao = $this->getMockBuilder(OAIDAO::class)
176 ->setMethods(array(
'getJournal',
'getSection',
'getIssue'))
178 $oaiDao->expects($this->any())
179 ->method(
'getJournal')
180 ->will($this->returnValue($journal));
181 $oaiDao->expects($this->any())
182 ->method(
'getSection')
183 ->will($this->returnValue($section));
184 $oaiDao->expects($this->any())
186 ->will($this->returnValue($issue));
190 import(
'classes.article.ArticleGalleyDAO');
191 $articleGalleyDao = $this->getMockBuilder(ArticleGalleyDAO::class)
192 ->setMethods(array(
'getBySubmissionId'))
194 $articleGalleyDao->expects($this->any())
195 ->method(
'getBySubmissionId')
196 ->will($this->returnValue($galleys));
206 $record->setData(
'article', $article);
207 $record->setData(
'galleys', $galleys);
208 $record->setData(
'journal', $journal);
209 $record->setData(
'section', $section);
210 $record->setData(
'issue', $issue);
218 $xml = $mdFormat->toXml($record);
219 self::assertXmlStringEqualsXmlFile(
'tests/plugins/oaiMetadataFormats/dc/expectedResult.xml', $xml);
231 switch ($settingName) {
233 return array(
'en_US' =>
'journal-title');
236 return array(
'en_US' =>
'journal-copyright');
238 case 'publisherInstitution':
239 return array(
'journal-publisher');
248 self::fail(
'Required journal setting is not necessary for the purpose of this test.');
259 function routerUrl($request, $newContext =
null, $handler =
null,
$op =
null, $path =
null) {
260 return $handler.
'-'.
$op.
'-'.implode(
'-', $path);