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

hasTime() public method

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

Usage Example

Beispiel #1
0
 public function testHasTime()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->hasTime(1, 2, 3);
     })->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->hasTime(4, 5, 6);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('Time is %s instead of %s'), '01:02:03', '04:05:06'))->object($asserter->hasTime('01', '02', '03'))->isIdenticalTo($asserter)->object($asserter->hasTime('1', '2', '3'))->isIdenticalTo($asserter)->object($asserter->hasTime(1, 2, 3))->isIdenticalTo($asserter);
 }