mageekguy\atoum\asserters\phpArray::notHasKeys PHP Method

notHasKeys() public method

public notHasKeys ( array $keys, $failMessage = null )
$keys array
    public function notHasKeys(array $keys, $failMessage = null)
    {
        $this->valueIsSet();
        if (sizeof($definedKeys = array_intersect($keys, array_keys($this->value))) <= 0) {
            $this->pass();
        } else {
            $this->fail($failMessage ?: $this->_('%s has keys %s', $this, $this->getTypeOf($definedKeys)));
        }
        return $this;
    }

Usage Example

示例#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);
 }