Esempio n. 1
0
 public function testGetExceptions()
 {
     $exceptions = $this->object->getExceptions();
     self::assertTrue(is_array($exceptions) || $exceptions instanceof Countable, 'exceptions can be counted');
     // 		will be covered by checking associated exceptions
     //		self::assertEquals(3, count($exceptions), 'exactly three exceptions are assigned');
     self::assertEachIsInstanceOf($exceptions, 'Tx_CzSimpleCal_Domain_Model_Exception', 'only Tx_CzSimpleCal_Domain_Model_Exception are given (no exceptionGroups)');
     $exceptionTitles = array();
     foreach ($exceptions as $exception) {
         $exceptionTitles[] = $exception->getTitle();
     }
     self::assertTrue(in_array('testException1', $exceptionTitles), 'assigned exception is present');
     self::assertTrue(in_array('testException2', $exceptionTitles), 'exception from exceptionGroup is present #1');
     self::assertTrue(in_array('testException3', $exceptionTitles), 'exception from exceptionGroup is present #2');
     self::assertFalse(in_array('testExceptionThatIsNotUsed', $exceptionTitles), 'not assigned exception is not present');
 }
Esempio n. 2
0
 /**
  * build the exception timeline
  * 
  * @return Tx_CzSimpleCal_Recurrance_Timeline_Exception
  */
 protected function buildExceptionTimeline()
 {
     $exceptionTimeline = new Tx_CzSimpleCal_Recurrance_Timeline_Exception();
     foreach ($this->event->getExceptions() as $exception) {
         $type = $exception->getRecurranceType();
         if (empty($type)) {
             throw new RuntimeException('The recurrance_type should not be empty.');
         }
         $className = 'Tx_CzSimpleCal_Recurrance_Type_' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($type);
         if (!class_exists($className)) {
             throw new BadMethodCallException(sprintf('The class %s does not exist for creating recurring events.', $className));
         }
         $class = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className);
         if (!$class instanceof Tx_CzSimpleCal_Recurrance_Type_Base) {
             throw new BadMethodCallException(sprintf('The class %s does not implement Tx_CzSimpleCal_Recurrance_Type_Base.', get_class($class)));
         }
         $exceptionTimeline = $class->build($exception, $exceptionTimeline);
     }
     return $exceptionTimeline;
 }