/**
  * @covers FormularValueParser::parse
  * @todo Implement testParse().
  */
 public function testParse()
 {
     $date = time();
     $this->object->parse($date, FormularValueParser::$PARSER_DATE);
     $this->assertEquals($date, date('d.m.Y'));
     $daytime = time();
     $this->object->parse($daytime, FormularValueParser::$PARSER_DAYTIME);
     $this->assertEquals($daytime, date('H:i'));
     $int = 27;
     $this->object->parse($int, FormularValueParser::$PARSER_INT);
     $this->assertEquals($int, 27);
     $string = 'Test';
     $this->object->parse($string, FormularValueParser::$PARSER_STRING);
     $this->assertEquals($string, 'Test');
 }
Exemplo n.º 2
0
 public function testParsingTemperature()
 {
     Configuration::General()->temperatureUnit()->set(TemperatureUnit::CELSIUS);
     $null = null;
     $this->object->parse($null, FormularValueParser::$PARSER_TEMPERATURE);
     $this->assertEquals('', $null);
     $zero = 0;
     $this->object->parse($zero, FormularValueParser::$PARSER_TEMPERATURE);
     $this->assertEquals('0', $zero);
     $celsius = 10;
     $this->object->parse($celsius, FormularValueParser::$PARSER_TEMPERATURE);
     $this->assertEquals('10', $celsius);
     Configuration::General()->temperatureUnit()->set(TemperatureUnit::FAHRENHEIT);
     $this->object->parse($celsius, FormularValueParser::$PARSER_TEMPERATURE);
     $this->assertEquals('50', $celsius);
 }
Exemplo n.º 3
0
 /**
  * Parse value for display
  */
 protected final function parseForDisplay()
 {
     FormularValueParser::parse($this->value, $this->parser, $this->parserOptions);
     if (self::hasKeyFailed($this->name)) {
         $this->addCSSclass(self::$CSS_VALIDATION_FAILED);
     }
 }