hasSize() public method

public hasSize ( $size, $failMessage = null )
Exemplo n.º 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);
 }
Exemplo n.º 2
0
 public function testHasKeys()
 {
     $this->if($asserter = new asserters\phpArray($generator = new asserter\generator()))->then->boolean($asserter->wasSet())->isFalse()->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->exception(function () use($asserter) {
         $asserter->hasKeys(array(0));
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s should have keys %s'), $asserter, $asserter->getTypeOf(array(0))))->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))->then->exception(function () use($asserter) {
         $asserter->hasKeys(array(0, 'first', 2, 'second'));
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s should have keys %s'), $asserter, $asserter->getTypeOf(array('first', 'second'))))->object($asserter->hasKeys(array(0, 2, 4)))->isIdenticalTo($asserter);
 }