示例#1
0
 /**
  * Mock and register a SuppFileDAO as a test
  * back end for the SolrWebService class.
  */
 private function _registerMockSuppFileDAO()
 {
     // Mock an SuppFileDAO.
     $suppFileDao = $this->getMock('SuppFileDAO', array('getSuppFilesByArticle'), array(), '', false);
     // Mock a list of supplementary files.
     $suppFile1 = new SuppFile();
     $suppFile1->setId(2);
     $suppFile1->setLanguage('de');
     $suppFile1->setFileType('application/pdf');
     $suppFile1->setFileName('suppFile1.pdf');
     $suppFile2 = new SuppFile();
     $suppFile2->setId(3);
     $suppFile2->setLanguage('tu');
     $suppFile2->setFileType('text/html');
     $suppFile2->setFileName('suppFile2.html');
     $suppFile2->setTitle('Titel', 'de_DE');
     $suppFile2->setCreator('Autor', 'de_DE');
     $suppFile2->setSubject('Thema', 'de_DE');
     $suppFile2->setTypeOther('Sonstiger Typ', 'de_DE');
     $suppFile2->setDescription('Beschreibung', 'de_DE');
     $suppFile2->setSource('Quelle', 'de_DE');
     $suppFiles = array($suppFile1, $suppFile2);
     // Mock the getSuppFilesByArticle() method.
     $suppFileDao->expects($this->any())->method('getSuppFilesByArticle')->will($this->returnValue($suppFiles));
     // Register the mock DAO.
     DAORegistry::registerDAO('SuppFileDAO', $suppFileDao);
 }
示例#2
0
 /**
  * Internal function to return a SuppFile object from a row.
  * @param $row array
  * @return SuppFile
  */
 function &_returnSuppFileFromRow(&$row)
 {
     $suppFile = new SuppFile();
     $suppFile->setId($row['supp_id']);
     $suppFile->setPublicSuppFileId($row['public_supp_file_id']);
     $suppFile->setFileId($row['file_id']);
     $suppFile->setArticleId($row['article_id']);
     $suppFile->setType($row['type']);
     $suppFile->setDateCreated($this->dateFromDB($row['date_created']));
     $suppFile->setLanguage($row['language']);
     $suppFile->setShowReviewers($row['show_reviewers']);
     $suppFile->setDateSubmitted($this->datetimeFromDB($row['date_submitted']));
     $suppFile->setSequence($row['seq']);
     $suppFile->setSuppAssocId($row['assoc_id']);
     //ArticleFile set methods
     $suppFile->setFileName($row['file_name']);
     $suppFile->setOriginalFileName($row['original_file_name']);
     $suppFile->setFileType($row['file_type']);
     $suppFile->setFileSize($row['file_size']);
     $suppFile->setDateModified($this->datetimeFromDB($row['date_modified']));
     $suppFile->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
     $this->getDataObjectSettings('article_supp_file_settings', 'supp_id', $row['supp_id'], $suppFile);
     HookRegistry::call('SuppFileDAO::_returnSuppFileFromRow', array(&$suppFile, &$row));
     return $suppFile;
 }
示例#3
0
 /**
  * @covers OAIMetadataFormat_DC
  * @covers Dc11SchemaArticleAdapter
  */
 public function testToXml()
 {
     //
     // Create test data.
     //
     // Author
     import('classes.article.Author');
     $author = new Author();
     $author->setFirstName('author-firstname');
     $author->setLastName('author-lastname');
     $author->setAffiliation('author-affiliation', 'en_US');
     $author->setEmail('*****@*****.**');
     // Supplementary file
     import('classes.article.SuppFile');
     $suppFile = new SuppFile();
     $suppFile->setId(97);
     $suppFile->setFileId(999);
     $suppFile->setStoredPubId('doi', 'supp-file-doi');
     // Article
     import('classes.article.PublishedArticle');
     $article = $this->getMock('PublishedArticle', array('getBestArticleId'));
     /* @var $article PublishedArticle */
     $article->expects($this->any())->method('getBestArticleId')->will($this->returnValue(9));
     $article->setId(9);
     $article->setJournalId(1);
     $author->setSubmissionId($article->getId());
     $article->setSuppFiles(array($suppFile));
     $article->setPages(15);
     $article->setType('art-type', 'en_US');
     $article->setTitle('article-title-en', 'en_US');
     $article->setTitle('article-title-de', 'de_DE');
     $article->setDiscipline('article-discipline', 'en_US');
     $article->setSubject('article-subject', 'en_US');
     $article->setSubjectClass('article-subject-class', 'en_US');
     $article->setAbstract('article-abstract', 'en_US');
     $article->setSponsor('article-sponsor', 'en_US');
     $article->setStoredPubId('doi', 'article-doi');
     $article->setLanguage('en_US');
     $article->setCoverageGeo('article-coverage-geo', 'en_US');
     $article->setCoverageChron('article-coverage-chron', 'en_US');
     $article->setCoverageSample('article-coverage-sample', 'en_US');
     // Galleys
     import('classes.article.ArticleGalley');
     $galley = new ArticleGalley();
     $galley->setId(98);
     $galley->setFileType('galley-filetype');
     $galley->setStoredPubId('doi', 'galley-doi');
     $galleys = array($galley);
     // Journal
     import('classes.journal.Journal');
     $journal = $this->getMock('Journal', array('getSetting'));
     /* @var $journal Journal */
     $journal->expects($this->any())->method('getSetting')->will($this->returnCallback(array($this, 'getJournalSetting')));
     $journal->setPrimaryLocale('en_US');
     $journal->setPath('journal-path');
     $journal->setId(1);
     // Section
     import('classes.journal.Section');
     $section = new Section();
     $section->setIdentifyType('section-identify-type', 'en_US');
     // Issue
     import('classes.issue.Issue');
     $issue = $this->getMock('Issue', array('getIssueIdentification'));
     /* @var $issue Issue */
     $issue->expects($this->any())->method('getIssueIdentification')->will($this->returnValue('issue-identification'));
     $issue->setId(96);
     $issue->setDatePublished('2010-11-05');
     $issue->setStoredPubId('doi', 'issue-doi');
     $issue->setJournalId(1);
     //
     // Create infrastructural support objects
     //
     // Router
     import('lib.pkp.classes.core.PKPRouter');
     $router = $this->getMock('PKPRouter', array('url'));
     $application = PKPApplication::getApplication();
     $router->setApplication($application);
     $router->expects($this->any())->method('url')->will($this->returnCallback(array($this, 'routerUrl')));
     // Request
     import('classes.core.Request');
     $request = $this->getMock('Request', array('getRouter'));
     $request->expects($this->any())->method('getRouter')->will($this->returnValue($router));
     Registry::set('request', $request);
     //
     // Create mock DAOs
     //
     // Create a mocked AuthorDAO that returns our test author.
     import('classes.article.AuthorDAO');
     $authorDao = $this->getMock('AuthorDAO', array('getAuthorsBySubmissionId'));
     $authorDao->expects($this->any())->method('getAuthorsBySubmissionId')->will($this->returnValue(array($author)));
     DAORegistry::registerDAO('AuthorDAO', $authorDao);
     // Create a mocked OAIDAO that returns our test data.
     import('classes.oai.ojs.OAIDAO');
     $oaiDao = $this->getMock('OAIDAO', array('getJournal', 'getSection', 'getIssue'));
     $oaiDao->expects($this->any())->method('getJournal')->will($this->returnValue($journal));
     $oaiDao->expects($this->any())->method('getSection')->will($this->returnValue($section));
     $oaiDao->expects($this->any())->method('getIssue')->will($this->returnValue($issue));
     DAORegistry::registerDAO('OAIDAO', $oaiDao);
     // Create a mocked ArticleGalleyDAO that returns our test data.
     import('classes.article.ArticleGalleyDAO');
     $articleGalleyDao = $this->getMock('ArticleGalleyDAO', array('getGalleysByArticle'));
     $articleGalleyDao->expects($this->any())->method('getGalleysByArticle')->will($this->returnValue($galleys));
     DAORegistry::registerDAO('ArticleGalleyDAO', $articleGalleyDao);
     // Create a mocked PublishedArticleDAO that returns our test article.
     import('classes.article.PublishedArticleDAO');
     $articleDao = $this->getMock('PublishedArticleDAO', array('getPublishedArticleByArticleId'));
     $articleDao->expects($this->any())->method('getPublishedArticleByArticleId')->will($this->returnValue($article));
     DAORegistry::registerDAO('PublishedArticleDAO', $articleDao);
     //
     // Test
     //
     // OAI record
     $record = new OAIRecord();
     $record->setData('article', $article);
     $record->setData('galleys', $galleys);
     $record->setData('journal', $journal);
     $record->setData('section', $section);
     $record->setData('issue', $issue);
     // Instantiate the OAI meta-data format.
     $prefix = OAIMetadataFormatPlugin_DC::getMetadataPrefix();
     $schema = OAIMetadataFormatPlugin_DC::getSchema();
     $namespace = OAIMetadataFormatPlugin_DC::getNamespace();
     $mdFormat = new OAIMetadataFormat_DC($prefix, $schema, $namespace);
     $xml = $mdFormat->toXml($record);
     self::assertXmlStringEqualsXmlFile('tests/plugins/oaiMetadataFormats/dc/expectedResult.xml', $xml);
 }