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

hasDate() 공개 메소드

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

Usage Example

예제 #1
0
 public function testHasDate()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->hasDate(1976, 10, 6);
     })->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->hasDate(1980, 8, 14);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('Date is %s instead of %s'), '1976-10-06', '1980-08-14'))->object($asserter->hasDate(1976, 10, 6))->isIdenticalTo($asserter)->object($asserter->hasDate('1976', '10', '6'))->isIdenticalTo($asserter)->object($asserter->hasDate('1976', '10', '06'))->isIdenticalTo($asserter);
 }