public function testHasLength() { $this->if($asserter = new asserters\string($generator = new asserter\generator()))->then->exception(function () use($asserter) { $asserter->hasLength(rand(0, PHP_INT_MAX)); })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Value is undefined')->if($asserter->setWith(''))->and($diff = new diffs\variable())->then->exception(function () use($asserter, &$requiredLength) { $asserter->hasLength($requiredLength = rand(1, PHP_INT_MAX)); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('length of %s is not %d'), $asserter->getTypeOf(''), $requiredLength))->object($asserter->hasLength(0))->isIdenticalTo($asserter)->if($asserter->setWith($string = uniqid()))->then->object($asserter->hasLength(strlen($string)))->isIdenticalTo($asserter); }
public function getTypeOf($mixed) { return is_string($mixed) === false ? parent::getTypeOf($mixed) : sprintf($this->getLocale()->_('string(%s) \'%s\''), mb_strlen($mixed, 'UTF-8'), $mixed); }