isReferenceTo() public method

public isReferenceTo ( &$reference, $failMessage = null )
Exemplo n.º 1
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)));
 }