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

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

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

Usage Example

Пример #1
0
 public function testHasMonth()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->exception(function () use($asserter) {
         $asserter->hasMonth(rand(0, PHP_INT_MAX));
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Instance of \\dateTime is undefined')->if($asserter->setWith($dateTime = new \DateTime('1976-09-06')))->then->exception(function () use(&$line, $asserter) {
         $line = __LINE__;
         $asserter->hasMonth(1);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('Month is %02d instead of %02d'), 9, 1))->object($asserter->hasMonth(9))->isIdenticalTo($asserter)->if($asserter->setWith($dateTime = new \DateTime('1980-08-14')))->then->object($asserter->hasMonth('08'))->isIdenticalTo($asserter)->object($asserter->hasMonth('8'))->isIdenticalTo($asserter)->object($asserter->hasMonth(8))->isIdenticalTo($asserter);
 }