mageekguy\atoum\asserters\object::hasSize PHP Method

hasSize() public method

public hasSize ( $size, $failMessage = null )
    public function hasSize($size, $failMessage = null)
    {
        if (sizeof($this->valueIsSet()->value) == $size) {
            $this->pass();
        } else {
            $this->fail($failMessage ?: $this->_('%s has size %d, expected size %d', $this, sizeof($this->valueIsSet()->value), $size));
        }
        return $this;
    }

Usage Example

Esempio n. 1
0
 public function testIsEmpty()
 {
     $this->if($asserter = new asserters\object($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->hasSize(rand(0, PHP_INT_MAX));
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Object is undefined')->if($asserter->setWith($this))->then->exception(function () use($asserter) {
         $asserter->isEmpty();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s has size %d'), $asserter, sizeof($this)))->if($asserter->setWith(new \arrayIterator()))->then->object($asserter->isEmpty())->isIdenticalTo($asserter);
 }