Exemplo n.º 1
0
 /**
  * @depends testParseICalendarDate
  * @expectedException LogicException
  */
 function testParseICalendarDateBadFormat()
 {
     $dateTime = DateTimeParser::parseDate('20100316T141405');
 }
Exemplo n.º 2
0
 /**
  * Validates the node for correctness.
  *
  * The following options are supported:
  *   Node::REPAIR - May attempt to automatically repair the problem.
  *
  * This method returns an array with detected problems.
  * Every element has the following properties:
  *
  *  * level - problem level.
  *  * message - A human-readable string describing the issue.
  *  * node - A reference to the problematic node.
  *
  * The level means:
  *   1 - The issue was repaired (only happens if REPAIR was turned on)
  *   2 - An inconsequential issue
  *   3 - A severe issue.
  *
  * @param int $options
  * @return array
  */
 public function validate($options = 0)
 {
     $messages = parent::validate($options);
     $valueType = $this->getValueType();
     $value = $this->getValue();
     try {
         switch ($valueType) {
             case 'DATE':
                 $foo = DateTimeParser::parseDate($value);
                 break;
             case 'DATE-TIME':
                 $foo = DateTimeParser::parseDateTime($value);
                 break;
         }
     } catch (\LogicException $e) {
         $messages[] = array('level' => 3, 'message' => 'The supplied value (' . $value . ') is not a correct ' . $valueType, 'node' => $this);
     }
     return $messages;
 }
Exemplo n.º 3
0
 /**
  * Validates the node for correctness.
  *
  * The following options are supported:
  *   Node::REPAIR - May attempt to automatically repair the problem.
  *
  * This method returns an array with detected problems.
  * Every element has the following properties:
  *
  *  * level - problem level.
  *  * message - A human-readable string describing the issue.
  *  * node - A reference to the problematic node.
  *
  * The level means:
  *   1 - The issue was repaired (only happens if REPAIR was turned on)
  *   2 - An inconsequential issue
  *   3 - A severe issue.
  *
  * @param int $options
  *
  * @return array
  */
 function validate($options = 0)
 {
     $messages = parent::validate($options);
     $valueType = $this->getValueType();
     $values = $this->getParts();
     try {
         foreach ($values as $value) {
             switch ($valueType) {
                 case 'DATE':
                     DateTimeParser::parseDate($value);
                     break;
                 case 'DATE-TIME':
                     DateTimeParser::parseDateTime($value);
                     break;
             }
         }
     } catch (InvalidDataException $e) {
         $messages[] = ['level' => 3, 'message' => 'The supplied value (' . $value . ') is not a correct ' . $valueType, 'node' => $this];
     }
     return $messages;
 }
Exemplo n.º 4
0
 /**
  * @depends testParseICalendarDate
  * @expectedException \Sabre\VObject\InvalidDataException
  */
 function testParseICalendarDateInvalidDate()
 {
     $dateTime = DateTimeParser::parseDate('20101331');
 }