isIdenticalTo() public method

public isIdenticalTo ( $value, $failMessage = null )
Example #1
0
 protected function matches($actual)
 {
     if ($this->analyzer->isArray($actual) === false) {
         throw new \PHPUnit_Framework_Exception('Actual value of ' . __CLASS__ . ' must be an array');
     }
     $patched = array_replace_recursive($actual, $this->expected);
     $asserter = new asserters\phpArray(null, $this->analyzer);
     $asserter->setWith($actual);
     if ($this->strict) {
         $asserter->isIdenticalTo($patched);
     } else {
         $asserter->isEqualTo($patched);
     }
 }
Example #2
0
 public function testIsIdenticalTo()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->isIdenticalTo(new \mock\object());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Array is undefined')->if($asserter->setWith(array($object = new \mock\object(), 2)))->then->object($asserter->isIdenticalTo(array($object, 2)))->isIdenticalTo($asserter)->if($diff = new diffs\variable())->then->exception(function () use($asserter, &$notIdenticalValue, $object) {
         $asserter->isIdenticalTo($notIdenticalValue = array(clone $object, 2));
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not identical to %s'), $asserter, $asserter->getTypeOf($notIdenticalValue)) . PHP_EOL . $diff->setExpected($notIdenticalValue)->setActual($asserter->getValue()))->exception(function () use($asserter, &$notIdenticalValue, $object) {
         $asserter->isIdenticalTo($notIdenticalValue = array($object, '2'));
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not identical to %s'), $asserter, $asserter->getTypeOf($notIdenticalValue)) . PHP_EOL . $diff->setExpected($notIdenticalValue)->setActual($asserter->getValue()))->if($asserter->integer)->then->object($asserter->isIdenticalTo(array($object, 2)))->isIdenticalTo($asserter)->if($asserter->integer[1])->then->object($asserter->isEqualTo(2))->isIdenticalTo($asserter)->object($asserter->isEqualTo(2)->isNotEqualTo(5))->isIdenticalTo($asserter)->exception(function () use($asserter, &$expectedValue) {
         $asserter->isEqualTo($expectedValue = rand(3, PHP_INT_MAX));
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not equal to %s'), $asserter->getTypeOf($asserter->getInnerValue()), $asserter->getTypeOf($expectedValue)) . PHP_EOL . $diff->setExpected($expectedValue)->setActual(2));
 }