public function testSetWith() { $this->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter, &$value) { $asserter->setWith($value = uniqid()); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not an array'), $asserter->getTypeOf($value)))->object($asserter->setWith($value = array()))->isIdenticalTo($asserter)->array($asserter->getValue())->isEqualTo($value)->variable($asserter->getKey())->isNull()->variable($asserter->getInnerAsserter())->isNull()->variable($asserter->getInnerValue())->isNull()->boolean($asserter->isSetByReference())->isFalse()->if($asserter->object)->then->variable($innerAsserter = $asserter->getInnerAsserter())->isNotNull()->object($objectAsserter = $asserter->setWith($object = new \mock\object()))->isIdenticalTo($innerAsserter)->object($objectAsserter->getValue())->isIdenticalTo($object)->variable($asserter->getValue())->isNull()->boolean($asserter->wasSet())->isFalse()->boolean($asserter->isSetByReference())->isFalse()->variable($asserter->getKey())->isNull()->variable($asserter->getInnerAsserter())->isNull()->variable($asserter->getInnerValue())->isNull(); }
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); }