setWith() public method

public setWith ( $value )
Beispiel #1
0
 protected function matches($actual)
 {
     if ($this->delta == null && $this->analyzer->isFloat($actual) === false && $this->analyzer->isFloat($this->expected) === false) {
         $asserter = new asserters\variable(null, $this->analyzer);
         if ($this->analyzer->isString($actual) && $this->ignoreCase) {
             $actual = strtolower($actual);
         }
         if ($this->analyzer->isArray($actual) && $this->canonicalize) {
             $actual = sort($actual);
         }
         $asserter->setWith($actual);
         if ($actual === 0 && $this->expected == '' || $actual == '' && $this->expected === 0) {
             $asserter->isIdenticalTo($this->expected);
         } else {
             $expected = $this->expected;
             if ($this->analyzer->isString($expected) && $this->ignoreCase) {
                 $expected = strtolower($expected);
             }
             if ($this->analyzer->isArray($expected) && $this->canonicalize) {
                 $expected = sort($expected);
             }
             $asserter->isEqualTo($expected);
         }
     } else {
         $asserter = new asserters\phpFloat(null, $this->analyzer);
         $asserter->setWith((double) $actual)->isNearlyEqualTo((double) $this->expected, $this->delta);
     }
 }
Beispiel #2
0
 public function setWith($value, $label = null)
 {
     parent::setWith($value, $label);
     if (self::isArray($this->value) === false) {
         $this->fail(sprintf($this->getLocale()->_('%s is not an array'), $this));
     } else {
         $this->pass();
     }
     return $this;
 }
Beispiel #3
0
 public function setWith($value, $label = null)
 {
     variable::setWith($value, $label);
     if (self::isFloat($this->value) === false) {
         $this->fail(sprintf($this->getLocale()->_('%s is not a float'), $this));
     } else {
         $this->pass();
     }
     return $this;
 }
 public function setWith($value)
 {
     variable::setWith($value);
     if ($this->analyzer->isFloat($this->value) === true) {
         $this->pass();
     } else {
         $this->fail($this->_('%s is not a float', $this));
     }
     return $this;
 }
Beispiel #5
0
 public function setWith($value)
 {
     parent::setWith($value);
     if ($this->analyzer->isBoolean($this->value) === true) {
         $this->pass();
     } else {
         $this->fail($this->_('%s is not a boolean', $this));
     }
     return $this;
 }
 public function setWith($value, $checkType = true)
 {
     parent::setWith($value, $checkType);
     if ($checkType === true) {
         if ($this->value instanceof DependencyInjection\Definition) {
             $this->pass();
         } else {
             $this->fail($this->_('%s is not an instance of Symfony\\Component\\DependencyInjection\\Definition', get_class($this->value)));
         }
     }
     return $this;
 }
Beispiel #7
0
 public function setWith($value, $checkType = true)
 {
     parent::setWith($value);
     if ($checkType === true) {
         if (self::isObject($this->value) === false) {
             $this->fail(sprintf($this->getLocale()->_('%s is not an object'), $this));
         } else {
             $this->pass();
         }
     }
     return $this;
 }
Beispiel #8
0
 public function setWith($value, $checkType = true)
 {
     parent::setWith($value);
     if ($checkType === true) {
         if ($this->analyzer->isObject($this->value) === true) {
             $this->pass();
         } else {
             $this->fail($this->_('%s is not an object', $this));
         }
     }
     return $this;
 }
 public function setWith($value, $checkType = true)
 {
     parent::setWith($value, $checkType);
     if ($checkType === true) {
         if ($this->value instanceof DependencyInjection\ContainerBuilder) {
             $this->pass();
         } else {
             $this->fail($this->_('%s is not an instance of Symfony\\Component\\DependencyInjection\\ContainerBuilder', is_object($this->value) ? get_class($this->value) : gettype($this->value)));
         }
     }
     return $this;
 }
Beispiel #10
0
 public function setWith($value, $label = null, $charlist = null, $checkType = true)
 {
     parent::setWith($value, $label);
     $this->charlist = $charlist;
     if ($checkType === true) {
         if (self::isString($this->value) === true) {
             $this->pass();
         } else {
             $this->fail(sprintf($this->getLocale()->_('%s is not a string'), $this));
         }
     }
     return $this;
 }
Beispiel #11
0
 public function setWith($value, $charlist = null, $checkType = true)
 {
     parent::setWith($value);
     $this->charlist = $charlist;
     if ($checkType === true) {
         if ($this->analyzer->isString($this->value) === true) {
             $this->pass();
         } else {
             $this->fail($this->_('%s is not a string', $this));
         }
     }
     return $this;
 }
Beispiel #12
0
 public function testIsNotTrue()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->boolean($asserter->wasSet())->isFalse()->exception(function () use($asserter) {
         $asserter->isNotNull(rand(-PHP_INT_MAX, PHP_INT_MAX));
     })->isInstanceOf('logicException')->hasMessage('Value is undefined')->if($asserter->setWith(uniqid()))->then->object($asserter->isNotTrue())->isIdenticalTo($asserter)->if($asserter->setWith(true))->then->exception(function () use($asserter) {
         $asserter->isNotTrue();
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is true'), $asserter));
 }
 public function setWith($value)
 {
     $innerAsserter = $this->innerAsserter;
     if ($innerAsserter !== null) {
         $this->reset();
         return $innerAsserter->setWith($value);
     } else {
         parent::setWith($value);
         if ($this->analyzer->isArray($this->value) === true) {
             $this->pass();
         } else {
             $this->fail($this->_('%s is not an array', $this));
         }
         return $this;
     }
 }
Beispiel #14
0
 protected function matches($actual)
 {
     $asserter = new asserters\variable();
     $asserter->setWith($actual)->isNotIdenticalTo($this->expected);
 }
Beispiel #15
0
 public function testIsReferenceTo()
 {
     $this->if($asserter = new asserters\variable($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 #16
0
 protected function matches($actual)
 {
     $asserter = new asserters\variable();
     $asserter->setWith($actual)->isNotNull();
 }
Beispiel #17
0
 public function setWith($value)
 {
     $innerAsserter = $this->innerAsserter;
     if ($innerAsserter !== null) {
         $this->reset();
         return $innerAsserter->setWith($value);
     } else {
         parent::setWith($value);
         if (self::isArray($this->value) === true) {
             $this->pass();
         } else {
             $this->fail(sprintf($this->getLocale()->_('%s is not an array'), $this));
         }
         return $this;
     }
 }