예제 #1
0
 /**
  * Assert the value is valid for the expectation
  *
  * @param mixed $value
  * @param array $options
  * @return bool
  */
 public static function assert($value, array $options = [])
 {
     $format = Arr::pluck($options, 'format', self::$format);
     $date = DT::createFromFormat($format, $value);
     if ($date && $date->format($format) == $value) {
         return true;
     }
     throw new AssertionException(sprintf('%s is not a valid datetime', $value));
 }
예제 #2
0
 /** @test */
 public function should_accept_custom_format()
 {
     $this->assertTrue(DateTime::assert('2015-08-09 13:57:33', ['format' => 'Y-m-d H:i:s']));
 }