Ejemplo n.º 1
0
 /**
  * Internal function to return an ArticleGalley object from a row.
  * @param $row array
  * @return ArticleGalley
  */
 function &_returnGalleyFromRow(&$row)
 {
     if ($row['html_galley']) {
         $galley = new ArticleHTMLGalley();
         // HTML-specific settings
         $galley->setStyleFileId($row['style_file_id']);
         if ($row['style_file_id']) {
             $galley->setStyleFile($this->articleFileDao->getArticleFile($row['style_file_id']));
         }
         // Retrieve images
         $images =& $this->getGalleyImages($row['galley_id']);
         $galley->setImageFiles($images);
     } else {
         $galley = new ArticleGalley();
     }
     $galley->setId($row['galley_id']);
     $galley->setArticleId($row['article_id']);
     $galley->setLocale($row['locale']);
     $galley->setFileId($row['file_id']);
     $galley->setLabel($row['label']);
     $galley->setFileStage($row['file_stage']);
     $galley->setSequence($row['seq']);
     $galley->setRemoteURL($row['remote_url']);
     // ArticleFile set methods
     $galley->setFileName($row['file_name']);
     $galley->setOriginalFileName($row['original_file_name']);
     $galley->setFileType($row['file_type']);
     $galley->setFileSize($row['file_size']);
     $galley->setDateModified($this->datetimeFromDB($row['date_modified']));
     $galley->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
     $this->getDataObjectSettings('article_galley_settings', 'galley_id', $row['galley_id'], $galley);
     HookRegistry::call('ArticleGalleyDAO::_returnGalleyFromRow', array(&$galley, &$row));
     return $galley;
 }
Ejemplo n.º 2
0
 /**
  * @covers PubObjectCache
  */
 public function testAddSeveralGalleys()
 {
     $nullVar = null;
     $cache = new PubObjectCache();
     $article = new PublishedArticle();
     $article->setId('2');
     $article->setIssueId('1');
     $articleGalley1 = new ArticleGalley();
     $articleGalley1->setId('3');
     $articleGalley1->setArticleId($article->getId());
     $articleGalley2 = new ArticleGalley();
     $articleGalley2->setId('4');
     $articleGalley2->setArticleId($article->getId());
     // Add galleys in the wrong order.
     $cache->add($articleGalley2, $article);
     $cache->add($articleGalley1, $article);
     $cache->markComplete('galleysByArticle', $article->getId());
     // Retrieve them in the right order.
     $retrievedGalleys = $cache->get('galleysByArticle', $article->getId());
     $expectedGalleys = array(3 => $articleGalley1, 4 => $articleGalley2);
     self::assertEquals($expectedGalleys, $retrievedGalleys);
     // And they should still be cached.
     self::assertTrue($cache->isCached('galleysByArticle', $article->getId()));
 }
Ejemplo n.º 3
0
 /**
  * @covers OAIMetadataFormat_DC
  * @covers Dc11SchemaArticleAdapter
  */
 public function testToXml()
 {
     $this->markTestSkipped('Skipped because of weird class interaction with ControlledVocabDAO.');
     //
     // Create test data.
     //
     $journalId = 1;
     // Enable the DOI plugin.
     $pluginSettingsDao = DAORegistry::getDAO('PluginSettingsDAO');
     /* @var $pluginSettingsDao PluginSettingsDAO */
     $pluginSettingsDao->updateSetting($journalId, 'doipubidplugin', 'enabled', 1);
     $pluginSettingsDao->updateSetting($journalId, 'doipubidplugin', 'enableIssueDoi', 1);
     $pluginSettingsDao->updateSetting($journalId, 'doipubidplugin', 'enableArticleDoi', 1);
     $pluginSettingsDao->updateSetting($journalId, 'doipubidplugin', 'enableGalleyDoi', 1);
     // Author
     import('classes.article.Author');
     $author = new Author();
     $author->setFirstName('author-firstname');
     $author->setLastName('author-lastname');
     $author->setAffiliation('author-affiliation', 'en_US');
     $author->setEmail('*****@*****.**');
     // 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($journalId);
     $author->setSubmissionId($article->getId());
     $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->setAbstract('article-abstract', 'en_US');
     $article->setSponsor('article-sponsor', 'en_US');
     $article->setStoredPubId('doi', 'article-doi');
     $article->setLanguage('en_US');
     // Galleys
     import('classes.article.ArticleGalley');
     $galley = new ArticleGalley();
     $galley->setId(98);
     $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($journalId);
     // 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($journalId);
     //
     // 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('getBySubmissionId'));
     $authorDao->expects($this->any())->method('getBySubmissionId')->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('getBySubmissionId'));
     $articleGalleyDao->expects($this->any())->method('getBySubmissionId')->will($this->returnValue($galleys));
     DAORegistry::registerDAO('ArticleGalleyDAO', $articleGalleyDao);
     // FIXME: ArticleGalleyDAO::getBySubmissionId returns iterator; array expected here. Fix expectations.
     // 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);
 }
Ejemplo n.º 4
0
 /**
  * Internal function to return an ArticleGalley object from a row.
  * @param $row array
  * @return ArticleGalley
  */
 function &_returnGalleyFromRow($row)
 {
     $galley = new ArticleGalley();
     $galley->setId($row['galley_id']);
     $galley->setSubmissionId($row['submission_id']);
     $galley->setLocale($row['locale']);
     $galley->setLabel($row['label']);
     $galley->setSequence($row['seq']);
     $galley->setRemoteURL($row['remote_url']);
     $galley->setIsAvailable($row['is_available']);
     $galley->setGalleyType($row['galley_type']);
     $this->getDataObjectSettings('submission_galley_settings', 'galley_id', $row['galley_id'], $galley);
     HookRegistry::call('ArticleGalleyDAO::_returnGalleyFromRow', array(&$galley, &$row));
     return $galley;
 }
Ejemplo n.º 5
0
 /**
  * Mock and register a ArticleGalleyDAO as a test
  * back end for the SolrWebService class.
  */
 private function _registerMockArticleGalleyDAO()
 {
     // Mock an ArticleGalleyDAO.
     $galleyDao = $this->getMock('ArticleGalleyDAO', array('getGalleysByArticle'), array(), '', false);
     // Mock a list of supplementary files.
     $galley1 = new ArticleGalley();
     $galley1->setId(4);
     $galley1->setLocale('de_DE');
     $galley1->setFileType('application/pdf');
     $galley1->setFileName('galley1.pdf');
     $galley2 = new ArticleGalley();
     $galley2->setId(5);
     $galley2->setLocale('en_US');
     $galley2->setFileType('text/html');
     $galley2->setFileName('galley2.html');
     $galleys = array($galley1, $galley2);
     // Mock the getGalleysByArticle() method.
     $galleyDao->expects($this->any())->method('getGalleysByArticle')->will($this->returnValue($galleys));
     // Register the mock DAO.
     DAORegistry::registerDAO('ArticleGalleyDAO', $galleyDao);
 }
 /**
  * Internal function to return an ArticleGalley object from a row.
  * @param $row array
  * @return ArticleGalley
  */
 function &_returnGalleyFromRow(&$row)
 {
     if ($row['html_galley']) {
         $galley = new ArticleHTMLGalley();
         // HTML-specific settings
         $galley->setStyleFileId($row['style_file_id']);
         if ($row['style_file_id']) {
             $galley->setStyleFile($this->articleFileDao->getArticleFile($row['style_file_id']));
         }
         // Retrieve images
         $images =& $this->getGalleyImages($row['galley_id']);
         $galley->setImageFiles($images);
     } else {
         $galley = new ArticleGalley();
     }
     $galley->setId($row['galley_id']);
     $galley->setPublicGalleyId($row['public_galley_id']);
     $galley->setArticleId($row['article_id']);
     $galley->setLocale($row['locale']);
     $galley->setFileId($row['file_id']);
     $galley->setLabel($row['label']);
     $galley->setType($row['type']);
     $galley->setSequence($row['seq']);
     $galley->setViews($row['views']);
     // ArticleFile set methods
     $galley->setFileName($row['file_name']);
     $galley->setOriginalFileName($row['original_file_name']);
     $galley->setFileType($row['file_type']);
     $galley->setFileSize($row['file_size']);
     $galley->setDateModified($this->datetimeFromDB($row['date_modified']));
     $galley->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
     //%LP% Fedora set methods (ArticleFile)
     $galley->setFedoraPid($row['fedora_pid']);
     $galley->setFedoraNamespace($row['fedora_namespace']);
     $galley->setFedoraDsid($row['fedora_dsid']);
     HookRegistry::call('ArticleGalleyDAO::_returnGalleyFromRow', array(&$galley, &$row));
     return $galley;
 }