setByReferenceWith() public method

public setByReferenceWith ( &$value )
 public function setByReferenceWith(&$value)
 {
     if ($this->innerAsserter !== null) {
         return $this->innerAsserter->setByReferenceWith($value);
     } else {
         parent::setByReferenceWith($value);
         if ($this->analyzer->isArray($this->value) === true) {
             $this->pass();
         } else {
             $this->fail($this->_('%s is not an array', $this));
         }
         return $this;
     }
 }
Beispiel #2
0
 public function testIsReferenceTo()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->and($value = uniqid())->then->boolean($asserter->wasSet())->isFalse()->exception(function () use($asserter, $value) {
         $asserter->isReferenceTo($value);
     })->isInstanceOf('logicException')->hasMessage('Value is undefined')->if($asserter->setWith($value))->then->boolean($asserter->isSetByReference())->isFalse()->exception(function () use($asserter, $value) {
         $asserter->isReferenceTo($value);
     })->isInstanceOf('logicException')->hasMessage('Value is not set by reference')->if($asserter->setByReferenceWith($value))->and($reference =& $value)->then->boolean($asserter->wasSet())->isTrue()->boolean($asserter->isSetByReference())->isTrue()->object($asserter->isReferenceTo($reference))->isIdenticalTo($asserter)->if($notReference = uniqid())->then->exception(function () use($asserter, $notReference) {
         $asserter->isReferenceTo($notReference);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not a reference to %s'), $asserter, $asserter->getTypeOf($notReference)))->if($value = new \exception())->and($reference = $value)->and($asserter->setByReferenceWith($value))->then->boolean($asserter->wasSet())->isTrue()->boolean($asserter->isSetByReference())->isTrue()->object($asserter->isReferenceTo($reference))->isIdenticalTo($asserter)->if($notReference = new \exception())->then->exception(function () use($asserter, $notReference) {
         $asserter->isReferenceTo($notReference);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not a reference to %s'), $asserter, $asserter->getTypeOf($notReference)));
 }
Beispiel #3
0
 public function setByReferenceWith(&$value)
 {
     if ($this->innerAsserter !== null) {
         return $this->innerAsserter->setByReferenceWith($value);
     } else {
         parent::setByReferenceWith($value);
         if (self::isArray($this->value) === true) {
             $this->pass();
         } else {
             $this->fail(sprintf($this->getLocale()->_('%s is not an array'), $this));
         }
         return $this;
     }
 }