mageekguy\atoum\asserters\dateTime::hasDay PHP 메소드

hasDay() 공개 메소드

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

Usage Example

예제 #1
0
 public function testHasDay()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->exception(function () use($asserter) {
         $asserter->hasDay(rand(0, PHP_INT_MAX));
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Instance of \\dateTime is undefined')->if($asserter->setWith($dateTime = new \DateTime('1976-10-06')))->then->exception(function () use(&$line, $asserter) {
         $line = __LINE__;
         $asserter->hasDay(1);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('Day is %02d instead of %02d'), 6, 1))->object($asserter->hasDay('06'))->isIdenticalTo($asserter)->object($asserter->hasDay('6'))->isIdenticalTo($asserter)->object($asserter->hasDay(6))->isIdenticalTo($asserter);
 }