/** * Returns Opus_Date values formatted as string. * @param Opus_Date $date * @return string Formatted date */ public function formatDate($date) { if (!$date instanceof Opus_Date) { return $date; } else { return $this->_dates->getDateString($date); } }
/** * Kann nur passieren wenn POST manipuliert wurde. * * Ungültige IDs werden ignoriert und Patent wie ein neues behandelt. */ public function testGetModelInvalidId() { $this->useEnglish(); $form = new Admin_Form_Document_Patent(); $form->getElement('Id')->setValue('notvalid'); $form = new Admin_Form_Document_Patent(); $form->getElement('Number')->setValue('323'); $form->getElement('Countries')->setValue('Germany'); $form->getElement('YearApplied')->setValue('1987'); $form->getElement('Application')->setValue('Patent Title'); $form->getElement('DateGranted')->setValue('2008/03/20'); $patent = $form->getModel(); $datesHelper = new Application_Controller_Action_Helper_Dates(); $this->assertNull($patent->getId()); $this->assertEquals('323', $patent->getNumber()); $this->assertEquals('Germany', $patent->getCountries()); $this->assertEquals('1987', $patent->getYearApplied()); $this->assertEquals('Patent Title', $patent->getApplication()); $this->assertEquals('2008/03/20', $datesHelper->getDateString($patent->getDateGranted())); }
public function testUpdateModel() { $this->useEnglish(); $form = new Admin_Form_Document_Bibliographic(); $form->getElement('ContributingCorporation')->setValue('contribcorp'); $form->getElement('CreatingCorporation')->setValue('creatingcorp'); $form->getElement('Edition')->setValue('2nd'); $form->getElement('Issue')->setValue('3'); $form->getElement('PageFirst')->setValue(34); $form->getElement('PageLast')->setValue(38); $form->getElement('PageCount')->setValue('5'); $form->getElement('PublisherName')->setValue('Wizard'); $form->getElement('PublisherPlace')->setValue('Oz'); $form->getElement('Volume')->setValue('5'); $form->getElement('ThesisDateAccepted')->setValue('2010/04/21'); $form->getElement('ThesisYearAccepted')->setValue('2010'); $form->getElement('BelongsToBibliography')->setValue(true); $model = $this->createTestDocument(); $form->updateModel($model); $this->assertEquals('contribcorp', $model->getContributingCorporation()); $this->assertEquals('creatingcorp', $model->getCreatingCorporation()); $this->assertEquals('2nd', $model->getEdition()); $this->assertEquals('3', $model->getIssue()); $this->assertEquals(34, $model->getPageFirst()); $this->assertEquals('38', $model->getPageLast()); $this->assertEquals(5, $model->getPageNumber()); $this->assertEquals('Wizard', $model->getPublisherName()); $this->assertEquals('Oz', $model->getPublisherPlace()); $this->assertEquals('5', $model->getVolume()); $datesHelper = new Application_Controller_Action_Helper_Dates(); $this->assertEquals('2010/04/21', $datesHelper->getDateString($model->getThesisDateAccepted())); $this->assertEquals('2010', $model->getThesisYearAccepted()); $this->assertTrue($model->getBelongsToBibliography()); $form->getElement('BelongsToBibliography')->setValue(false); $form->updateModel($model); // Funktion liefert '0' zurück, assertFalse funktioniert nicht $this->assertEquals(0, $model->getBelongsToBibliography()); }
public function testGetCompletedDate() { $this->useGerman(); $dates = new Application_Controller_Action_Helper_Dates(); $doc = $this->createTestDocument(); $doc->setCompletedDate($dates->getOpusDate('19.10.2010')); $docId = $doc->store(); $adapter = new Application_Util_DocumentAdapter(null, $doc); $this->assertEquals('2010', $adapter->getCompletedDate(true)); $this->assertEquals('19.10.2010', $adapter->getCompletedDate(false)); $doc->setCompletedYear(2012); $this->assertEquals('2010', $adapter->getCompletedDate(true)); $this->assertEquals('19.10.2010', $adapter->getCompletedDate(false)); // PublishedDate preferred $doc->setCompletedDate(null); $this->assertEquals('2012', $adapter->getCompletedDate(true)); $this->assertEquals('2012', $adapter->getCompletedDate(false)); }