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

notHasKey() public method

public notHasKey ( $key, $failMessage = null )
    public function notHasKey($key, $failMessage = null)
    {
        if (array_key_exists($key, $this->valueIsSet()->value) === false) {
            $this->pass();
        } else {
            $this->fail($failMessage ?: $this->_('%s has key %s', $this, $this->getTypeOf($key)));
        }
        return $this;
    }

Usage Example

コード例 #1
0
ファイル: phpArray.php プロジェクト: andrewolobo/mpTracker
 public function testNotHasKey()
 {
     $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->notHasKey(1))->isIdenticalTo($asserter)->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))->then->exception(function () use($asserter) {
         $asserter->notHasKey(0);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s has a key %s'), $asserter, $asserter->getTypeOf(0)))->exception(function () use($asserter, &$message) {
         $asserter->notHasKey(0, $message = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage($message)->object($asserter->notHasKey(5))->isIdenticalTo($asserter);
 }