mageekguy\atoum\asserters\dateTime::hasSeconds PHP Method

hasSeconds() public method

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

Usage Example

Ejemplo n.º 1
0
 public function testHasSeconds()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->exception(function () use($asserter) {
         $asserter->hasSeconds(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->hasSeconds(1);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('Seconds are %02d instead of %02d'), 3, 1))->object($asserter->hasSeconds('03'))->isIdenticalTo($asserter)->object($asserter->hasSeconds('3'))->isIdenticalTo($asserter)->object($asserter->hasSeconds(3))->isIdenticalTo($asserter);
 }