protected function setUp()
 {
     // Create a test file on the file system.
     $this->testFile = tempnam(TMP_FILES, 'SubmissionFile');
     // Mock a press
     import('classes.press.Press');
     $press = new Press();
     $press->setPrimaryLocale('en_US');
     $press->setPath('press-path');
     $press->setId(SUBMISSION_FILE_DAO_TEST_PRESS_ID);
     // Mock a request
     $mockRequest = $this->getMock('PKPRequest', array('getContext'));
     $mockRequest->expects($this->any())->method('getContext')->will($this->returnValue($press));
     Registry::get('request', true, $mockRequest);
     // Register a mock monograph DAO.
     $monographDao = $this->getMock('MonographDAO', array('getById'));
     $monograph = new Monograph();
     $monograph->setId(SUBMISSION_FILE_DAO_TEST_SUBMISSION_ID);
     $monograph->setPressId(SUBMISSION_FILE_DAO_TEST_PRESS_ID);
     $monographDao->expects($this->any())->method('getById')->will($this->returnValue($monograph));
     DAORegistry::registerDAO('MonographDAO', $monographDao);
     // Register a mock genre DAO.
     $genreDao = $this->getMock('GenreDAO', array('getById'));
     DAORegistry::registerDAO('GenreDAO', $genreDao);
     $genreDao->expects($this->any())->method('getById')->will($this->returnCallback(array($this, 'getTestGenre')));
     $this->_cleanFiles();
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     if (is_null($request->getRouter())) {
         $router = new PKPRouter();
         $request->setRouter($router);
     }
 }
Beispiel #2
0
 /**
  * Internal function to return a Press object from a row.
  * @param $row array
  * @return Press
  */
 function &_returnPressFromRow(&$row)
 {
     $press = new Press();
     $press->setId($row['press_id']);
     $press->setPath($row['path']);
     $press->setSequence($row['seq']);
     $press->setEnabled($row['enabled']);
     $press->setPrimaryLocale($row['primary_locale']);
     HookRegistry::call('PressDAO::_returnPressFromRow', array(&$press, &$row));
     return $press;
 }