public function setWith($value, $charlist = null, $checkType = true) { parent::setWith($value, $charlist, $checkType); if ($checkType === true) { if ($this->analyzer->isUtf8($this->value) === true) { $this->pass(); } else { $this->fail($this->_('%s is not an UTF-8 string', $this)); } } return $this; }
public function __get($asserter) { switch (strtolower($asserter)) { case 'issha1': case 'issha256': case 'issha512': case 'ismd5': return $this->{$asserter}(); default: return parent::__get($asserter); } }
public function setWith($value, $charlist = null, $checkType = true) { parent::setWith($value, $charlist, false); if ($checkType === true) { if (self::isObject($value) === false) { $this->fail($this->_('%s is not an object', $this->getTypeOf($value))); } else { $this->pass(); $this->value = (string) $this->value; } } return $this; }
public function setWith($value = null, $charlist = null, $checkType = true) { if ($value instanceof \closure) { ob_start(); $value($this->getTest()); $value = ob_get_clean(); } else { if ($value === null && ob_get_level() > 0) { $value = ob_get_clean(); ob_start(); } } return parent::setWith($value, $charlist, $checkType); }
protected function matches($actual) { $expected = $this->expected; switch (true) { case $this->analyzer->isArray($actual): $asserter = new asserters\phpArray(null, $this->analyzer); $asserter->setWith($actual); break; case $actual instanceof \iterator: $asserter = new asserters\iterator(null, $this->analyzer); $asserter = $asserter->setWith($actual)->toArray; break; case $this->analyzer->isString($actual): $asserter = new asserters\phpString(null, $this->analyzer); if ($this->ignoreCase) { $actual = strtolower($actual); $expected = strtolower($expected); } $asserter->setWith($actual); break; default: throw new \PHPUnit_Framework_Exception('Actual value of ' . __CLASS__ . ' must be an array, a string or a traversable object'); } try { if ($this->analyzer->isObject($expected)) { if ($this->checkForObjectIdentity) { $asserter->strictlyContains($expected); } else { $asserter->contains($expected); } } else { if ($this->checkForNonObjectIdentity) { $asserter->strictlyContains($expected); } else { $asserter->contains($expected); } } } catch (exception $exception) { throw new exception($asserter, $this->analyzer->getTypeOf($actual) . ' does not contain ' . $this->analyzer->getTypeOf($expected)); } }