Inheritance: extends variable
Exemple #1
0
 public function testIsNotInstanceOf()
 {
     $this->object(new stdClass())->isNotInstanceOf('exception')->if($asserter = new sut($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->object(new stdClass())->isNotInstanceOf('\\stdClass');
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage('object(stdClass) is an instance of \\stdClass')->exception(function () use($asserter) {
         $asserter->object(new stdClass())->isNotInstanceOf(new stdClass());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage('object(stdClass) is an instance of object(stdClass)');
 }
 protected function matches($actual)
 {
     $asserter = new asserters\object();
     try {
         $asserter->setWith($actual)->isNotInstanceOf($this->expected);
     } catch (logic $exception) {
         throw new \PHPUnit_Framework_Exception($exception->getMessage());
     }
 }
 protected function matches($actual)
 {
     if ($this->analyzer->isArray($actual) === false && $actual instanceof \traversable === false) {
         throw new \PHPUnit_Framework_Exception('Actual value of ' . __CLASS__ . ' must be an array or a traversable object');
     }
     try {
         $asserter = new asserters\object(null, $this->analyzer);
         foreach ($actual as $value) {
             $asserter->setWith($value)->isInstanceOf($this->expected);
         }
     } catch (exceptions\logic $exception) {
         throw new \PHPUnit_Framework_Exception('Expected value of ' . __CLASS__ . ' must be a class instance or class name');
     }
 }
 protected function valueIsSet($message = 'Interval is undefined')
 {
     if (self::isDateInterval(parent::valueIsSet($message)->value) === false) {
         throw new exceptions\logic($message);
     }
     return $this;
 }
Exemple #5
0
 /**
  * @param mixed $value
  * @param bool  $checkType
  *
  * @return $this
  */
 public function setWith($value, $checkType = false)
 {
     parent::setWith($value, $checkType);
     if (self::isCrawler($this->value) === false) {
         $this->fail(sprintf($this->getLocale()->_('%s is not a crawler'), $this));
     } else {
         $this->pass();
     }
     return $this;
 }
Exemple #6
0
 /**
  * @param mixed       $value
  * @param string|null $selector
  *
  * @return $this
  */
 public function setWith($value, $selector = null)
 {
     parent::setWith($value, false);
     if (self::isCrawler($this->value) === false) {
         $this->fail(sprintf($this->getLocale()->_('%s is not a crawler'), $this));
     } else {
         $this->pass();
     }
     $this->selector = $selector;
     return $this;
 }
Exemple #7
0
 /**
  * @param mixed $value
  * @param bool  $checkType
  *
  * @return $this
  */
 public function setWith($value, $checkType = true)
 {
     parent::setWith($value, false);
     if ($checkType === true) {
         if (self::isResponse($this->value) === false) {
             $this->fail(sprintf($this->getLocale()->_('%s is not a response'), $this->getTypeOf($this->value)));
         } else {
             $this->pass();
         }
     }
     return $this;
 }
Exemple #8
0
 public function setWith($value, $checkType = true)
 {
     parent::setWith($value, $checkType);
     if ($checkType === true) {
         if (self::isIterator($this->value) === false) {
             $this->fail($this->getLocale()->_('%s is not an iterator', $this));
         } else {
             $this->pass();
         }
     }
     return $this;
 }
 /**
  * @param Client $client
  * @param \closure $callback
  * @param Configuration $config
  *
  * @return $this
  */
 public function setWith($client, $callback = null, $config = null)
 {
     if (!$client instanceof Client) {
         $this->fail($this->_('%s is not a blackfire client', $this));
     }
     if (!$callback instanceof \closure) {
         $this->fail($this->_('%s is not a closure', $this));
     }
     if (!$config instanceof Configuration) {
         $this->fail($this->_('%s is not a profile configuration', $this));
     }
     try {
         $probe = $client->createProbe($config);
         $callback();
         $profile = $client->endProbe($probe);
     } catch (ExceptionInterface $e) {
         $this->fail($e->getMessage());
     }
     parent::setWith($profile);
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 protected function valueIsSet($message = 'DataSource is undefined')
 {
     return parent::valueIsSet($message);
 }
 protected function valueIsSet($message = 'Exception is undefined')
 {
     return parent::valueIsSet($message);
 }
Exemple #12
0
 protected function valueIsSet($message = 'Instance of \\dateTime is undefined')
 {
     if (parent::valueIsSet($message)->value instanceof \dateTime === false) {
         throw new exceptions\logic($message);
     }
     return $this;
 }
Exemple #13
0
 public function testToString()
 {
     $this->if($asserter = new asserters\object($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->toString();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Object is undefined')->if($asserter->setWith($this))->then->object($asserter->toString())->isInstanceOf('mageekguy\\atoum\\asserters\\castToString');
 }
Exemple #14
0
 protected static function isException($value)
 {
     return parent::isObject($value) === true && $value instanceof \exception === true;
 }
 /**
  * {@inheritdoc}
  */
 protected function valueIsSet($message = 'Enumerable is undefined')
 {
     return parent::valueIsSet($message);
 }
Exemple #16
0
 protected function valueIsSet($message = null)
 {
     $message = $message ?: 'Value is not an instance of \\dateTime or \\dateTimeInterface';
     if (self::isDateTime(parent::valueIsSet($message)->value) === false) {
         throw new exceptions\logic($message);
     }
     return $this;
 }