mageekguy\atoum\asserters\utf8String::setWith PHP Method

setWith() public method

public setWith ( $value, $charlist = null, $checkType = true )
    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;
    }

Usage Example

コード例 #1
0
ファイル: utf8String.php プロジェクト: ronan-gloo/atoum
 public function testContains()
 {
     $this->if($asserter = new asserters\utf8String($generator = new asserter\generator()))->then->exception(function () use($asserter) {
         $asserter->contains(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Value is undefined')->if($asserter->setWith($string = $this->getRandomUtf8String()))->and($diff = new diffs\variable())->and($fragment = $this->getRandomUtf8String())->then->exception(function () use($asserter, $fragment) {
         $asserter->contains($fragment);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($this->getLocale()->_('String does not contain %s'), $fragment))->object($asserter->contains($string))->isIdenticalTo($asserter)->if($asserter->setWith($this->getRandomUtf8String() . $string . $this->getRandomUtf8String()))->then->object($asserter->contains($string))->isIdenticalTo($asserter)->exception(function () use($asserter, $string, &$fragment) {
         $asserter->contains($fragment = mb_strtoupper($string, 'UTF-8'));
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($this->getLocale()->_('String does not contain %s'), $fragment));
 }