mageekguy\atoum\asserters\phpArray::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

Beispiel #1
0
 public function testNotHasKeys()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->hasSize(rand(0, PHP_INT_MAX));
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Array is undefined')->if($asserter->setWith(array()))->then->object($asserter->notHasKeys(array(1)))->isIdenticalTo($asserter)->object($asserter->notHasKeys(array(0, 1)))->isIdenticalTo($asserter)->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))->then->exception(function () use($asserter) {
         $asserter->notHasKeys(array(0, 'premier', 2));
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s should not have keys %s'), $asserter, $asserter->getTypeOf(array(0, 2))))->exception(function () use($asserter, &$message) {
         $asserter->notHasKeys(array(0, 'premier', 2), $message = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage($message)->object($asserter->notHasKeys(array(5, '6')))->isIdenticalTo($asserter);
 }
All Usage Examples Of mageekguy\atoum\asserters\phpArray::hasSize