mageekguy\atoum\asserters\mysqlDateTime::setWith PHP Метод

setWith() публичный Метод

public setWith ( $value, $checkType = true )
    public function setWith($value, $checkType = true)
    {
        $phpDate = \dateTime::createFromFormat(self::mysqlDateTimeFormat, $value);
        if ($phpDate !== false) {
            parent::setWith($phpDate, $checkType);
        } else {
            parent::setWith($value, false);
            if ($checkType === true) {
                $this->fail($this->_('%s is not in format Y-m-d H:i:s', $this));
            }
        }
        return $this;
    }

Usage Example

Пример #1
0
 public function testSetWith()
 {
     $this->if($asserter = new asserters\mysqlDateTime($generator = new asserter\generator()))->then->exception(function () use($asserter, &$value) {
         $asserter->setWith($value = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not in format Y-m-d H:i:s'), $asserter->getTypeOf($value)))->string($asserter->getValue())->isEqualTo($value)->object($asserter->setWith($value = '1976-10-06 14:05:54'))->isIdenticalTo($asserter)->string($asserter->getValue())->isIdenticalTo($value)->object($asserter->setWith($value = uniqid(), false))->isIdenticalTo($asserter)->string($asserter->getValue())->isEqualTo($value);
 }
mysqlDateTime