/** * @dataProvider stringFormats * @param string $format * @param string $string * @param string $result */ public function testCreateFromString($format, $string, $result) { $this->_setPrefs("Y-m-d", $format, "GMT"); $tz = new DateTimeZone("GMT"); SugarDateTime::$use_php_parser = true; $date = SugarDateTime::createFromFormat($format, $string, $tz); $this->assertInstanceOf("SugarDateTime", $date, "Parsing {$string} failed with PHP parser"); $this->assertEquals($result, $this->time_date->getTimePart($date->asDb())); SugarDateTime::$use_php_parser = false; $date = SugarDateTime::createFromFormat($format, $string, $tz); $this->assertInstanceOf("SugarDateTime", $date, "Parsing {$string} failed with strptime"); $this->assertEquals($result, $this->time_date->getTimePart($date->asDb())); SugarDateTime::$use_strptime = false; $date = SugarDateTime::createFromFormat($format, $string, $tz); $this->assertInstanceOf("SugarDateTime", $date, "Parsing {$string} failed with manual parser"); $this->assertEquals($result, $this->time_date->getTimePart($date->asDb())); SugarDateTime::$use_php_parser = true; SugarDateTime::$use_strptime = true; }