mageekguy\atoum\asserters\dateTime::hasMinutes PHP Метод

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

public hasMinutes ( $minutes, $failMessage = null )
    public function hasMinutes($minutes, $failMessage = null)
    {
        if ($this->valueIsSet()->value->format('i') === sprintf('%02d', $minutes)) {
            $this->pass();
        } else {
            $this->fail($failMessage ?: $this->_('Minutes are %s instead of %02d', $this->value->format('i'), $minutes));
        }
        return $this;
    }

Usage Example

Пример #1
0
 public function testHasMinutes()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->exception(function () use($asserter) {
         $asserter->hasMinutes(rand(0, PHP_INT_MAX));
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Instance of \\dateTime is undefined')->if($asserter->setWith($dateTime = new \DateTime('01:02:03')))->then->exception(function () use(&$line, $asserter) {
         $line = __LINE__;
         $asserter->hasMinutes(1);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('Minutes are %02d instead of %02d'), 2, 1))->object($asserter->hasMinutes('02'))->isIdenticalTo($asserter)->object($asserter->hasMinutes('2'))->isIdenticalTo($asserter)->object($asserter->hasMinutes(2))->isIdenticalTo($asserter);
 }