setWith() public method

public setWith ( $value )
Ejemplo n.º 1
0
 public function testSetWith()
 {
     $this->if($asserter = new sut($generator = new asserter\generator()))->then->assert('Set the asserter with something else than a boolean throw an exception')->exception(function () use(&$line, $asserter, &$value) {
         $line = __LINE__;
         $asserter->setWith($value = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('%s is not a boolean'), $asserter->getTypeOf($value)))->assert('The asserter was returned when it set with a boolean')->string($asserter->getValue())->isEqualTo($value)->object($asserter->setWith(true))->isIdenticalTo($asserter)->boolean($asserter->getValue())->isTrue();
 }
Ejemplo n.º 2
0
 protected function matches($actual)
 {
     $asserter = new asserters\boolean();
     try {
         $asserter->setWith(is_infinite($actual))->isTrue();
     } catch (exception $exception) {
         throw new exception($asserter, $this->analyzer->getTypeOf($actual) . ' is not infinite');
     }
 }
Ejemplo n.º 3
0
 protected function matches($actual)
 {
     if ($this->analyzer->isBoolean($this->expected) === false) {
         throw new \PHPUnit_Framework_Exception('Expected value of ' . __CLASS__ . ' must be a boolean');
     }
     $asserter = new asserters\boolean(null, $this->analyzer);
     $asserter->setWith($actual);
     if ($this->expected) {
         $asserter->isTrue();
     } else {
         $asserter->isFalse();
     }
 }
Ejemplo n.º 4
0
 protected function matches($actual)
 {
     if (is_null($this->expected)) {
         throw new \PHPUnit_Framework_Exception('Expected value of ' . __CLASS__ . ' must not be null');
     }
     if ($this->analyzer->isArray($actual) === false && $actual instanceof \arrayAccess === false) {
         throw new \PHPUnit_Framework_Exception('Actual value of ' . __CLASS__ . ' must be an array or an arrayAccess instance');
     }
     if ($this->analyzer->isArray($actual)) {
         $asserter = new asserters\phpArray(null, $this->analyzer);
         $asserter->setWith($actual)->hasKey($this->expected);
     } else {
         $asserter = new asserters\boolean(null, $this->analyzer);
         try {
             $asserter->setWith(isset($actual[$this->expected]))->isTrue();
         } catch (exception $exception) {
             throw new exception($asserter, $this->analyzer->getTypeOf($actual) . ' has no key ' . $this->analyzer->getTypeOf($this->expected));
         }
     }
 }