How to use setWith method of integer class

Best Atoum code snippet using integer.setWith

phpArray.php

Source:phpArray.php Github

copy

Full Screen

...50 ->object($this->testedInstance->object->phpString)->isTestedInstance51 ->object($this->testedInstance->getInnerAsserter())->isEqualTo($generator->phpString)52 ->object($this->testedInstance->error)->isInstanceOf($generator->error)53 ->variable($this->testedInstance->getInnerAsserter())->isNull()54 ->if($this->testedInstance->setWith(array(55 0 => array(56 0 => array(57 1 => array('foo', 'bar')58 ),59 1 => array(1, new \mock\object())60 ),61 1 => 'foobar'62 )63 )64 )65 ->then66 ->object($this->testedInstance->phpArray[0][0][1]->isEqualTo(array('foo', 'bar')))->isTestedInstance67 ->object($this->testedInstance->phpString[1]->isEqualTo('foobar'))->isTestedInstance68 ->given($this->newTestedInstance->setWith(array($array1 = array('foo', 'bar'), $array2 = array(1, new \mock\object()))))69 ->then70 ->object($this->testedInstance->phpArray[0]->phpString[0]->isEqualTo('foo'))->isInstanceOf('mageekguy\atoum\asserters\phpArray')71 ->object($this->testedInstance->phpArray[1]->isEqualTo($array2))->isInstanceOf('mageekguy\atoum\asserters\phpArray')72 ;73 }74 public function testReset()75 {76 $this77 ->given($this->newTestedInstance)78 ->then79 ->object($this->testedInstance->reset())->isTestedInstance80 ->variable($this->testedInstance->getValue())->isNull()81 ->boolean($this->testedInstance->wasSet())->isFalse()82 ->boolean($this->testedInstance->isSetByReference())->isFalse()83 ->variable($this->testedInstance->getKey())->isNull()84 ->variable($this->testedInstance->getInnerAsserter())->isNull()85 ->variable($this->testedInstance->getInnerValue())->isNull()86 ->if($this->testedInstance->setWith(array()))87 ->then88 ->object($this->testedInstance->reset())->isTestedInstance89 ->variable($this->testedInstance->getValue())->isNull()90 ->boolean($this->testedInstance->wasSet())->isFalse()91 ->boolean($this->testedInstance->isSetByReference())->isFalse()92 ->variable($this->testedInstance->getKey())->isNull()93 ->variable($this->testedInstance->getInnerAsserter())->isNull()94 ->variable($this->testedInstance->getInnerValue())->isNull()95 ->if(96 $reference = range(1, 5),97 $this->testedInstance->setByReferenceWith($reference)98 )99 ->then100 ->object($this->testedInstance->reset())->isTestedInstance101 ->variable($this->testedInstance->getValue())->isNull()102 ->boolean($this->testedInstance->wasSet())->isFalse()103 ->boolean($this->testedInstance->isSetByReference())->isFalse()104 ->variable($this->testedInstance->getKey())->isNull()105 ->variable($this->testedInstance->getInnerAsserter())->isNull()106 ->variable($this->testedInstance->getInnerValue())->isNull()107 ->if($this->testedInstance->object)108 ->then109 ->object($this->testedInstance->reset())->isTestedInstance110 ->variable($this->testedInstance->getValue())->isNull()111 ->boolean($this->testedInstance->wasSet())->isFalse()112 ->boolean($this->testedInstance->isSetByReference())->isFalse()113 ->variable($this->testedInstance->getKey())->isNull()114 ->variable($this->testedInstance->getInnerAsserter())->isNull()115 ->variable($this->testedInstance->getInnerValue())->isNull()116 ->if(117 $this->testedInstance->setWith(range(1, 5)),118 $this->testedInstance->atKey(2)119 )120 ->then121 ->object($this->testedInstance->reset())->isTestedInstance122 ->variable($this->testedInstance->getValue())->isNull()123 ->boolean($this->testedInstance->wasSet())->isFalse()124 ->boolean($this->testedInstance->isSetByReference())->isFalse()125 ->variable($this->testedInstance->getKey())->isNull()126 ->variable($this->testedInstance->getInnerAsserter())->isNull()127 ->variable($this->testedInstance->getInnerValue())->isNull()128 ;129 }130 public function testSetWith()131 {132 $this133 ->given($asserter = $this->newTestedInstance134 ->setLocale($locale = new \mock\atoum\locale())135 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())136 )137 ->if(138 $this->calling($locale)->_ = $notAnArray = uniqid(),139 $this->calling($analyzer)->getTypeOf = $type = uniqid()140 )141 ->then142 ->exception(function() use ($asserter, & $value) { $asserter->setWith($value = uniqid()); })143 ->isInstanceOf('mageekguy\atoum\asserter\exception')144 ->hasMessage($notAnArray)145 ->mock($locale)->call('_')->withArguments('%s is not an array', $type)->once146 ->object($asserter->setWith($value = array()))->isIdenticalTo($asserter)147 ->array($asserter->getValue())->isEqualTo($value)148 ->variable($asserter->getKey())->isNull()149 ->variable($asserter->getInnerAsserter())->isNull()150 ->variable($asserter->getInnerValue())->isNull()151 ->boolean($asserter->isSetByReference())->isFalse()152 ->if($asserter->object)153 ->then154 ->variable($innerAsserter = $asserter->getInnerAsserter())->isNotNull()155 ->object($objectAsserter = $asserter->setWith($object = new \mock\object()))->isIdenticalTo($innerAsserter)156 ->object($objectAsserter->getValue())->isIdenticalTo($object)157 ->variable($asserter->getValue())->isNull()158 ->boolean($asserter->wasSet())->isFalse()159 ->boolean($asserter->isSetByReference())->isFalse()160 ->variable($asserter->getKey())->isNull()161 ->variable($asserter->getInnerAsserter())->isNull()162 ->variable($asserter->getInnerValue())->isNull()163 ;164 }165 public function testOffsetGet()166 {167 $this168 ->given($asserter = $this->newTestedInstance169 ->setLocale($locale = new \mock\atoum\locale())170 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())171 )172 ->then173 ->exception(function() use ($asserter) { $asserter[2]; })174 ->isInstanceOf('mageekguy\atoum\exceptions\logic')175 ->hasMessage('Array is undefined')176 ->if(177 $this->calling($locale)->_ = $notAnArray = uniqid(),178 $this->calling($analyzer)->getTypeOf = $type = uniqid(),179 $asserter->setWith(array(1, 2, $object = new \mock\object(), clone $object))180 )181 ->then182 ->exception(function() use ($asserter, & $value) { $asserter[2]; })183 ->isInstanceOf('mageekguy\atoum\asserter\exception')184 ->hasMessage($notAnArray)185 ->mock($locale)->call('_')->withArguments('Value %s at key %s is not an array', $type, 2)->once186 ->if($asserter->setWith(array(1, 2, $object = new \mock\object(), clone $object)))187 ->then188 ->object($asserter->object[2]->isIdenticalTo($object))->isIdenticalTo($asserter)189 ->object($asserter->object[2]->isIdenticalTo($object))->isIdenticalTo($asserter)190 ->object($asserter->object[3]->isCloneOf($object))->isIdenticalTo($asserter)191 ->object($asserter->object[2])->isIdenticalTo($asserter)192 ->given($asserter = $this->newTestedInstance193 ->setLocale($locale)194 ->setAnalyzer($analyzer)195 )196 ->if($asserter->setWith($array = array($integer = rand(1, PHP_INT_MAX), 2, $innerArray = array(3, 4, 5, $object))))197 ->then198 ->object($asserter[2])199 ->isIdenticalTo($asserter)200 ->array($asserter->getValue())->isEqualTo($innerArray)201 ->if($asserter->setWith($array))202 ->then203 ->object($asserter->integer[0]->isEqualTo($integer))->isIdenticalTo($asserter)204 ->object($asserter->object[2][3]->isIdenticalTo($object))->isIdenticalTo($asserter)205 ->object($asserter->object[2][3]->isIdenticalTo($object)->integer[0]->isEqualTo($integer))->isIdenticalTo($asserter)206 ->object($asserter->object[2][3]->isIdenticalTo($object)->integer($integer)->isEqualTo($integer))207 ->isNotIdenticalTo($asserter)208 ->isInstanceOf('mageekguy\atoum\asserters\integer')209 ->if(210 $this->calling($locale)->_ = $unknownKey = uniqid(),211 $this->calling($analyzer)->getTypeOf = function($value) use ($innerArray, & $innerArrayType, & $keyType) { return ($innerArray === $value ? ($innerArrayType = uniqid()) : ($keyType = uniqid())); }212 )213 ->then214 ->exception(function() use ($asserter) { $asserter->object[2][4]; })215 ->isInstanceOf('mageekguy\atoum\asserter\exception')216 ->hasMessage($unknownKey)217 ->mock($locale)->call('_')->withArguments('%s has no key %s', $innerArrayType, $keyType)->once218 ;219 }220 public function testOffsetSet()221 {222 $this223 ->given($asserter = $this->newTestedInstance)224 ->then225 ->exception(function() use ($asserter) { $asserter[rand(0, PHP_INT_MAX)] = rand(0, PHP_INT_MAX); })226 ->isInstanceOf('mageekguy\atoum\exceptions\logic')227 ->hasMessage('Tested array is read only')228 ;229 }230 public function testOffsetUnset()231 {232 $this233 ->given($asserter = $this->newTestedInstance)234 ->then235 ->exception(function() use ($asserter) { unset($asserter[rand(0, PHP_INT_MAX)]); })236 ->isInstanceOf('mageekguy\atoum\exceptions\logic')237 ->hasMessage('Array is read only')238 ;239 }240 public function testOffsetExists()241 {242 $this243 ->given($asserter = $this->newTestedInstance)244 ->then245 ->boolean(isset($asserter[rand(0, PHP_INT_MAX)]))->isFalse()246 ->if($asserter->setWith(array()))247 ->then248 ->boolean(isset($asserter[rand(0, PHP_INT_MAX)]))->isFalse()249 ->if($asserter->setWith(array(uniqid())))250 ->then251 ->boolean(isset($asserter[0]))->isTrue()252 ->boolean(isset($asserter[rand(1, PHP_INT_MAX)]))->isFalse()253 ->if($asserter->setWith(array($key = uniqid() => uniqid())))254 ->then255 ->boolean(isset($asserter[$key]))->isTrue()256 ->boolean(isset($asserter[0]))->isFalse()257 ->boolean(isset($asserter[rand(1, PHP_INT_MAX)]))->isFalse()258 ;259 }260 public function testHasSize()261 {262 $this263 ->given($asserter = $this->newTestedInstance264 ->setLocale($locale = new \mock\atoum\locale())265 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())266 )267 ->then268 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })269 ->isInstanceOf('mageekguy\atoum\exceptions\logic')270 ->hasMessage('Array is undefined')271 ->if(272 $this->calling($locale)->_ = $badSize = uniqid(),273 $this->calling($analyzer)->getTypeOf = $type = uniqid(),274 $asserter->setWith(array())275 )276 ->then277 ->exception(function() use ($asserter, & $size) { $asserter->hasSize($size = rand(1, PHP_INT_MAX)); })278 ->isInstanceOf('mageekguy\atoum\asserter\exception')279 ->hasMessage($badSize)280 ->mock($locale)->call('_')->withArguments('%s has size %d, expected size %d', $asserter, 0, $size)->once281 ->exception(function() use ($asserter, & $failMessage) { $asserter->hasSize(rand(1, PHP_INT_MAX), $failMessage = uniqid()); })282 ->isInstanceOf('mageekguy\atoum\asserter\exception')283 ->hasMessage($failMessage)284 ->object($asserter->hasSize(0))->isIdenticalTo($asserter)285 ->if($asserter->setWith(range(1, 5)))286 ->then287 ->object($asserter->hasSize(5))->isIdenticalTo($asserter)288 ;289 }290 public function testHasSizeOnInnerAsserter()291 {292 $this293 ->given($asserter = $this->newTestedInstance)294 ->then295 ->exception(function() use ($asserter) { $asserter->isEmpty(); })296 ->isInstanceOf('mageekguy\atoum\exceptions\logic')297 ->hasMessage('Array is undefined')298 ->if($asserter->setWith(array(range(1, 5))))299 ->then300 ->object($childAsserter = $asserter->child[0](function($child) { $child->hasSize(5); }))->isInstanceOf('mageekguy\atoum\asserters\phpArray\child')301 ->object($childAsserter->hasSize(1))->isIdenticalTo($asserter)302 ->given($asserter = $this->newTestedInstance)303 ->if($asserter->setWith(array(array(range(1, 5), range(1, 3)))))304 ->then305 ->object($childAsserter = $asserter->child[0][1](function($child) { $child->hasSize(3); }))->isInstanceOf('mageekguy\atoum\asserters\phpArray\child')306 ->object($childAsserter->hasSize(1))->isIdenticalTo($asserter)307 ;308 }309 public function testIsEmpty()310 {311 $this312 ->given($asserter = $this->newTestedInstance313 ->setLocale($locale = new \mock\atoum\locale())314 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())315 )316 ->then317 ->exception(function() use ($asserter) { $asserter->isEmpty(); })318 ->isInstanceOf('mageekguy\atoum\exceptions\logic')319 ->hasMessage('Array is undefined')320 ->if(321 $this->calling($locale)->_ = $notEmpty = uniqid(),322 $asserter->setWith(array(uniqid()))323 )324 ->then325 ->exception(function() use ($asserter) { $asserter->isEmpty(); })326 ->isInstanceOf('mageekguy\atoum\asserter\exception')327 ->hasMessage($notEmpty)328 ->mock($locale)->call('_')->withArguments('%s is not empty', $asserter)->once329 ->exception(function() use ($asserter) { $asserter->isEmpty; })330 ->isInstanceOf('mageekguy\atoum\asserter\exception')331 ->hasMessage($notEmpty)332 ->mock($locale)->call('_')->withArguments('%s is not empty', $asserter)->twice333 ->exception(function() use ($asserter, & $failMessage) { $asserter->isEmpty($failMessage = uniqid()); })334 ->isInstanceOf('mageekguy\atoum\asserter\exception')335 ->hasMessage($failMessage)336 ->if($asserter->setWith(array()))337 ->then338 ->object($asserter->isEmpty())->isIdenticalTo($asserter)339 ;340 }341 public function testIsNotEmpty()342 {343 $this344 ->given($asserter = $this->newTestedInstance345 ->setLocale($locale = new \mock\atoum\locale())346 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())347 )348 ->then349 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })350 ->isInstanceOf('mageekguy\atoum\exceptions\logic')351 ->hasMessage('Array is undefined')352 ->if(353 $this->calling($locale)->_ = $isEmpty = uniqid(),354 $this->calling($analyzer)->getTypeOf = $type = uniqid(),355 $asserter->setWith(array())356 )357 ->then358 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })359 ->isInstanceOf('mageekguy\atoum\asserter\exception')360 ->hasMessage($isEmpty)361 ->mock($locale)->call('_')->withArguments('%s is empty', $asserter)->once362 ->exception(function() use ($asserter) { $asserter->isNotEmpty; })363 ->isInstanceOf('mageekguy\atoum\asserter\exception')364 ->hasMessage($isEmpty)365 ->mock($locale)->call('_')->withArguments('%s is empty', $asserter)->twice366 ->exception(function() use ($asserter, & $failMessage) { $asserter->isNotEmpty($failMessage = uniqid()); })367 ->isInstanceOf('mageekguy\atoum\asserter\exception')368 ->hasMessage($failMessage)369 ->if($asserter->setWith(array(uniqid())))370 ->then371 ->object($asserter->isNotEmpty())->isIdenticalTo($asserter)372 ;373 }374 public function testAtKey()375 {376 $this377 ->given($asserter = $this->newTestedInstance378 ->setLocale($locale = new \mock\atoum\locale())379 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())380 )381 ->then382 ->exception(function() use ($asserter) { $asserter->atKey(uniqid()); })383 ->isInstanceOf('mageekguy\atoum\exceptions\logic')384 ->hasMessage('Array is undefined')385 ->if($asserter->setWith(array(uniqid(), uniqid(), $data = rand(1, PHP_INT_MAX), uniqid(), uniqid())))386 ->object($asserter->atKey(0))->isIdenticalTo($asserter)387 ->object($asserter->atKey('0'))->isIdenticalTo($asserter)388 ->object($asserter->atKey(1))->isIdenticalTo($asserter)389 ->object($asserter->atKey(2))->isIdenticalTo($asserter)390 ->object($asserter->atKey(3))->isIdenticalTo($asserter)391 ->object($asserter->atKey(4))->isIdenticalTo($asserter)392 ->if(393 $this->calling($locale)->_ = $unknownKey = uniqid(),394 $this->calling($analyzer)->getTypeOf = $type = uniqid()395 )396 ->then397 ->exception(function() use ($asserter, & $key) { $asserter->atKey($key = rand(5, PHP_INT_MAX)); })398 ->isInstanceOf('mageekguy\atoum\asserter\exception')399 ->hasMessage($unknownKey)400 ->mock($locale)->call('_')->withArguments('%s has no key %s', $asserter, $type)->once401 ->mock($analyzer)->call('getTypeOf')->withArguments($key)->once402 ->exception(function() use ($asserter, & $failMessage) { $asserter->atKey(rand(5, PHP_INT_MAX), $failMessage = uniqid()); })403 ->isInstanceOf('mageekguy\atoum\asserter\exception')404 ->hasMessage($failMessage)405 ;406 }407 public function testContains()408 {409 $this410 ->given($asserter = $this->newTestedInstance411 ->setLocale($locale = new \mock\atoum\locale())412 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())413 )414 ->then415 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })416 ->isInstanceOf('mageekguy\atoum\exceptions\logic')417 ->hasMessage('Array is undefined')418 ->if(419 $this->calling($locale)->_ = $notInArray = uniqid(),420 $this->calling($analyzer)->getTypeOf = $type = uniqid(),421 $asserter->setWith(array(uniqid(), uniqid(), $data = rand(1, PHP_INT_MAX), uniqid(), uniqid()))422 )423 ->then424 ->exception(function() use ($asserter, & $unknownValue) { $asserter->contains($unknownValue = uniqid()); })425 ->isInstanceOf('mageekguy\atoum\asserter\exception')426 ->hasMessage($notInArray)427 ->mock($locale)->call('_')->withArguments('%s does not contain %s', $asserter, $type)->once428 ->mock($analyzer)->call('getTypeOf')->withArguments($unknownValue)->once429 ->exception(function() use ($asserter, & $failMessage) { $asserter->contains(uniqid(), $failMessage = uniqid()); })430 ->isInstanceOf('mageekguy\atoum\asserter\exception')431 ->hasMessage($failMessage)432 ->object($asserter->contains($data))->isIdenticalTo($asserter)433 ->object($asserter->contains((string) $data))->isIdenticalTo($asserter)434 ->if(435 $this->calling($locale)->_ = $notInArrayAtKey = uniqid(),436 $this->calling($analyzer)->getTypeOf = $type = uniqid(),437 $asserter->setWith(array(uniqid(), uniqid(), $data = rand(1, PHP_INT_MAX), uniqid(), uniqid()))438 )439 ->then440 ->exception(function() use ($asserter, $data) { $asserter->atKey(0)->contains($data); })441 ->isInstanceOf('mageekguy\atoum\asserter\exception')442 ->hasMessage($notInArrayAtKey)443 ->object($asserter->contains($data))->isIdenticalTo($asserter)444 ->object($asserter->atKey(2)->contains($data))->isIdenticalTo($asserter)445 ->exception(function() use ($asserter, & $failMessage) { $asserter->atKey(0)->contains(uniqid(), $failMessage = uniqid()); })446 ->isInstanceOf('mageekguy\atoum\asserter\exception')447 ->hasMessage($failMessage)448 ;449 }450 public function testStrictlyContains()451 {452 $this453 ->given($asserter = $this->newTestedInstance454 ->setLocale($locale = new \mock\atoum\locale())455 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())456 )457 ->then458 ->exception(function() use ($asserter) { $asserter->strictlyContains(uniqid()); })459 ->isInstanceOf('mageekguy\atoum\exceptions\logic')460 ->hasMessage('Array is undefined')461 ->if(462 $this->calling($locale)->_ = $notInArray = uniqid(),463 $this->calling($analyzer)->getTypeOf = $type = uniqid(),464 $asserter->setWith(array(1, 2, 3, 4, 5, '3'))465 )466 ->then467 ->exception(function() use ($asserter) {$asserter->strictlyContains('1'); })468 ->isInstanceOf('mageekguy\atoum\asserter\exception')469 ->hasMessage($notInArray)470 ->mock($locale)->call('_')->withArguments('%s does not strictly contain %s', $asserter, $type)->once471 ->mock($analyzer)->call('getTypeOf')->withArguments('1')->once472 ->exception(function() use ($asserter, & $failMessage) {$asserter->strictlyContains('1', $failMessage = uniqid()); })473 ->isInstanceOf('mageekguy\atoum\asserter\exception')474 ->hasMessage($failMessage)475 ->object($asserter->strictlyContains(1))->isIdenticalTo($asserter)476 ->if($this->calling($analyzer)->getTypeOf = function($value) use (& $notInArrayType, & $keyType) { return ($value === 2 ? ($notInArrayType = uniqid()) : ($keyType = uniqid())); })477 ->then478 ->exception(function() use ($asserter) { $asserter->atKey(0)->strictlyContains(2); })479 ->isInstanceOf('mageekguy\atoum\asserter\exception')480 ->hasMessage($notInArray)481 ->mock($locale)->call('_')->withArguments('%s does not strictly contain %s at key %s', $asserter, $notInArrayType, $keyType)->once482 ->mock($analyzer)->call('getTypeOf')->withArguments(2)->once483 ->exception(function() use ($asserter, & $failMessage) { $asserter->atKey(0)->strictlyContains(2, $failMessage = uniqid()); })484 ->isInstanceOf('mageekguy\atoum\asserter\exception')485 ->hasMessage($failMessage)486 ;487 }488 public function testNotContains()489 {490 $this491 ->given($asserter = $this->newTestedInstance492 ->setLocale($locale = new \mock\atoum\locale())493 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())494 )495 ->then496 ->exception(function() use ($asserter) { $asserter->notContains(uniqid()); })497 ->isInstanceOf('mageekguy\atoum\exceptions\logic')498 ->hasMessage('Array is undefined')499 ->if($asserter->setWith(array(uniqid(), uniqid(), $isInArray = uniqid(), uniqid(), uniqid())))500 ->then501 ->object($asserter->notContains(uniqid()))->isIdenticalTo($asserter)502 ->if(503 $this->calling($locale)->_ = $inArray = uniqid(),504 $this->calling($analyzer)->getTypeOf = $type = uniqid()505 )506 ->then507 ->exception(function() use ($asserter, $isInArray) { $asserter->notContains($isInArray); })508 ->isInstanceOf('mageekguy\atoum\asserter\exception')509 ->hasMessage($inArray)510 ->mock($locale)->call('_')->withArguments('%s contains %s', $asserter, $type)->once511 ->mock($analyzer)->call('getTypeOf')->withArguments($isInArray)->once512 ->exception(function() use ($asserter, $isInArray, & $failMessage) { $asserter->notContains($isInArray, $failMessage = uniqid()); })513 ->isInstanceOf('mageekguy\atoum\asserter\exception')514 ->hasMessage($failMessage)515 ->object($asserter->atKey(0)->notContains($inArray))->isIdenticalTo($asserter)516 ->object($asserter->atKey(1)->notContains($inArray))->isIdenticalTo($asserter)517 ->object($asserter->atKey(3)->notContains($inArray))->isIdenticalTo($asserter)518 ->object($asserter->atKey(4)->notContains($inArray))->isIdenticalTo($asserter)519 ->if(520 $this->calling($locale)->_ = $inArray = uniqid(),521 $this->calling($analyzer)->getTypeOf = function($value) use ($isInArray, & $isInArrayType, & $keyType) { return ($isInArray === $value ? ($isInArrayType = uniqid()) : ($keyType = uniqid())); }522 )523 ->then524 ->exception(function() use ($asserter, $isInArray) { $asserter->atKey(2)->notContains($isInArray); })525 ->isInstanceOf('mageekguy\atoum\asserter\exception')526 ->hasMessage($inArray)527 ->mock($locale)->call('_')->withArguments('%s contains %s at key %s', $asserter, $isInArrayType, $keyType)->once528 ->mock($analyzer)529 ->call('getTypeOf')530 ->withArguments($isInArray)->twice531 ->withArguments(2)->once532 ->exception(function() use ($asserter, $isInArray, & $failMessage) { $asserter->atKey(2)->notContains($isInArray, $failMessage = 'FAIL'); })533 ->isInstanceOf('mageekguy\atoum\asserter\exception')534 ->hasMessage($failMessage)535 ;536 }537 public function testStrictlyNotContains()538 {539 $this540 ->given($asserter = $this->newTestedInstance541 ->setLocale($locale = new \mock\atoum\locale())542 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())543 )544 ->then545 ->exception(function() use ($asserter) { $asserter->strictlyNotContains(uniqid()); })546 ->isInstanceOf('mageekguy\atoum\exceptions\logic')547 ->hasMessage('Array is undefined')548 ->if(549 $this->calling($locale)->_ = $strictlyNotInArray = uniqid(),550 $this->calling($analyzer)->getTypeOf = $type = uniqid(),551 $asserter->setWith(array(1, 2, 3, 4, 5, '6'))552 )553 ->then554 ->exception(function() use ($asserter) {$asserter->strictlyNotContains(1); })555 ->isInstanceOf('mageekguy\atoum\asserter\exception')556 ->hasMessage($strictlyNotInArray)557 ->mock($locale)->call('_')->withArguments('%s strictly contains %s', $asserter, $type)->once558 ->mock($analyzer)->call('getTypeOf')->withArguments(1)->once559 ->exception(function() use ($asserter, & $failMessage) {$asserter->strictlyNotContains(1, $failMessage = uniqid()); })560 ->isInstanceOf('mageekguy\atoum\asserter\exception')561 ->hasMessage($failMessage)562 ->object($asserter->strictlyNotContains('1'))->isIdenticalTo($asserter)563 ->object($asserter->atKey(1)->strictlyNotContains(1))->isIdenticalTo($asserter)564 ->object($asserter->atKey(2)->strictlyNotContains(1))->isIdenticalTo($asserter)565 ->object($asserter->atKey(3)->strictlyNotContains(1))->isIdenticalTo($asserter)566 ->object($asserter->atKey(4)->strictlyNotContains(1))->isIdenticalTo($asserter)567 ->if($this->calling($analyzer)->getTypeOf = function($value) use (& $strictlyNotInArrayType, & $keyType) { return ($value === 1 ? ($strictlyNotInArrayType = uniqid()) : ($keyType = uniqid())); })568 ->then569 ->exception(function() use ($asserter) { $asserter->atKey(0)->strictlyNotContains(1); })570 ->isInstanceOf('mageekguy\atoum\asserter\exception')571 ->hasMessage($strictlyNotInArray)572 ->mock($locale)->call('_')->withArguments('%s strictly contains %s at key %s', $asserter, $strictlyNotInArrayType, $keyType)->once573 ->mock($analyzer)->call('getTypeOf')->withArguments(0)->once574 ;575 }576 public function testContainsValues()577 {578 $this579 ->given($asserter = $this->newTestedInstance580 ->setLocale($locale = new \mock\atoum\locale())581 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())582 )583 ->then584 ->exception(function() use ($asserter) { $asserter->containsValues(array(6)); })585 ->isInstanceOf('mageekguy\atoum\exceptions\logic')586 ->hasMessage('Array is undefined')587 ->if(588 $this->calling($locale)->_ = $notContainsValues = uniqid(),589 $this->calling($analyzer)->getTypeOf = $type = uniqid(),590 $asserter->setWith(array(1, 2, 3, 4, 5))591 )592 ->then593 ->exception(function() use ($asserter) { $asserter->containsValues(array(6)); })594 ->isInstanceOf('mageekguy\atoum\asserter\exception')595 ->hasMessage($notContainsValues)596 ->mock($locale)->call('_')->withArguments('%s does not contain values %s', $asserter, $type)->once597 ->mock($analyzer)->call('getTypeOf')->withArguments(array(6))->once598 ->exception(function() use ($asserter, & $failMessage) { $asserter->containsValues(array(6), $failMessage = uniqid()); })599 ->isInstanceOf('mageekguy\atoum\asserter\exception')600 ->hasMessage($failMessage)601 ->object($asserter->containsValues(array(1)))->isIdenticalTo($asserter)602 ->object($asserter->containsValues(array('1')))->isIdenticalTo($asserter)603 ->object($asserter->containsValues(array(1, 2, 4)))->isIdenticalTo($asserter)604 ->object($asserter->containsValues(array('1', 2, '4')))->isIdenticalTo($asserter)605 ;606 }607 public function testStrictlyContainsValues()608 {609 $this610 ->given($asserter = $this->newTestedInstance611 ->setLocale($locale = new \mock\atoum\locale())612 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())613 )614 ->then615 ->exception(function() use ($asserter) { $asserter->strictlyContainsValues(array(6)); })616 ->isInstanceOf('mageekguy\atoum\exceptions\logic')617 ->hasMessage('Array is undefined')618 ->if(619 $this->calling($locale)->_ = $strictlyNotContainsValues = uniqid(),620 $this->calling($analyzer)->getTypeOf = $type = uniqid(),621 $asserter->setWith(array(1, 2, 3, 4, 5))622 )623 ->then624 ->exception(function() use ($asserter) { $asserter->strictlyContainsValues(array(1, '5')); })625 ->isInstanceOf('mageekguy\atoum\asserter\exception')626 ->hasMessage($strictlyNotContainsValues)627 ->mock($locale)->call('_')->withArguments('%s does not contain strictly values %s', $asserter, $type)->once628 ->mock($analyzer)->call('getTypeOf')->withArguments(array('5'))->once629 ->exception(function() use ($asserter, & $failMessage) { $asserter->strictlyContainsValues(array('5'), $failMessage = uniqid()); })630 ->isInstanceOf('mageekguy\atoum\asserter\exception')631 ->hasMessage($failMessage)632 ->object($asserter->strictlyContainsValues(array(1)))->isIdenticalTo($asserter)633 ->object($asserter->strictlyContainsValues(array(1, 2)))->isIdenticalTo($asserter)634 ->object($asserter->strictlyContainsValues(array(1, 2, 3)))->isIdenticalTo($asserter)635 ->object($asserter->strictlyContainsValues(array(1, 2, 3, 4)))->isIdenticalTo($asserter)636 ->object($asserter->strictlyContainsValues(array(1, 2, 3, 4, 5)))->isIdenticalTo($asserter)637 ;638 }639 public function testNotContainsValues()640 {641 $this642 ->given($asserter = $this->newTestedInstance643 ->setLocale($locale = new \mock\atoum\locale())644 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())645 )646 ->then647 ->exception(function() use ($asserter) { $asserter->notContainsValues(array(1, 6)); })648 ->isInstanceOf('mageekguy\atoum\exceptions\logic')649 ->hasMessage('Array is undefined')650 ->if(651 $this->calling($locale)->_ = $containsValues = uniqid(),652 $this->calling($analyzer)->getTypeOf = $type = uniqid(),653 $asserter->setWith(array(1, 2, 3, 4, 5))654 )655 ->then656 ->exception(function() use ($asserter) { $asserter->notContainsValues(array(1, 6)); })657 ->isInstanceOf('mageekguy\atoum\asserter\exception')658 ->hasMessage($containsValues)659 ->mock($locale)->call('_')->withArguments('%s contains values %s', $asserter, $type)->once660 ->mock($analyzer)->call('getTypeOf')->withArguments(array(1))->once661 ->exception(function() use ($asserter, & $failMessage) { $asserter->notContainsValues(array(1, 6), $failMessage = uniqid()); })662 ->isInstanceOf('mageekguy\atoum\asserter\exception')663 ->hasMessage($failMessage)664 ->object($asserter->notContainsValues(array(6)))->isIdenticalTo($asserter)665 ->object($asserter->notContainsValues(array('6')))->isIdenticalTo($asserter)666 ->object($asserter->notContainsValues(array(6, 7)))->isIdenticalTo($asserter)667 ->object($asserter->notContainsValues(array('6', '7')))->isIdenticalTo($asserter)668 ->object($asserter->notContainsValues(array(6, 7, 8)))->isIdenticalTo($asserter)669 ->object($asserter->notContainsValues(array('6', 7, '8')))->isIdenticalTo($asserter)670 ;671 }672 public function testStrictlyNotContainsValues()673 {674 $this675 ->given($asserter = $this->newTestedInstance676 ->setLocale($locale = new \mock\atoum\locale())677 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())678 )679 ->then680 ->exception(function() use ($asserter) { $asserter->strictlyNotContainsValues(array(1, 6)); })681 ->isInstanceOf('mageekguy\atoum\exceptions\logic')682 ->hasMessage('Array is undefined')683 ->if(684 $this->calling($locale)->_ = $containsStrictlyValues = uniqid(),685 $this->calling($analyzer)->getTypeOf = $type = uniqid(),686 $asserter->setWith(array(1, 2, 3, 4, 5))687 )688 ->then689 ->exception(function() use ($asserter) { $asserter->strictlyNotContainsValues(array(1, '2', '4')); })690 ->isInstanceOf('mageekguy\atoum\asserter\exception')691 ->hasMessage($containsStrictlyValues)692 ->mock($locale)->call('_')->withArguments('%s contains strictly values %s', $asserter, $type)->once693 ->mock($analyzer)->call('getTypeOf')->withArguments(array(1))->once694 ->exception(function() use ($asserter, & $failMessage) { $asserter->strictlyNotContainsValues(array(1), $failMessage = uniqid()); })695 ->isInstanceOf('mageekguy\atoum\asserter\exception')696 ->hasMessage($failMessage)697 ->object($asserter->strictlyNotContainsValues(array('1')))->isIdenticalTo($asserter)698 ->object($asserter->strictlyNotContainsValues(array('1', '2')))->isIdenticalTo($asserter)699 ->object($asserter->strictlyNotContainsValues(array('1', '2', '3')))->isIdenticalTo($asserter)700 ->object($asserter->strictlyNotContainsValues(array('1', '2', '3', '4')))->isIdenticalTo($asserter)701 ->object($asserter->strictlyNotContainsValues(array('1', '2', '3', '4', '5')))->isIdenticalTo($asserter)702 ->object($asserter->strictlyNotContainsValues(array('6', '7')))->isIdenticalTo($asserter)703 ;704 }705 public function testHasKey()706 {707 $this708 ->given($asserter = $this->newTestedInstance709 ->setLocale($locale = new \mock\atoum\locale())710 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())711 )712 ->then713 ->exception(function() use ($asserter) { $asserter->hasKey(rand(0, PHP_INT_MAX)); })714 ->isInstanceOf('mageekguy\atoum\exceptions\logic')715 ->hasMessage('Array is undefined')716 ->if(717 $this->calling($locale)->_ = $notHasKey = uniqid(),718 $this->calling($analyzer)->getTypeOf = $type = uniqid(),719 $asserter->setWith(array())720 )721 ->then722 ->exception(function() use ($asserter, & $key) { $asserter->hasKey($key = rand(1, PHP_INT_MAX)); })723 ->isInstanceOf('mageekguy\atoum\asserter\exception')724 ->hasMessage($notHasKey)725 ->mock($locale)->call('_')->withArguments('%s has no key %s', $asserter, $type)->once726 ->mock($analyzer)->call('getTypeOf')->withArguments($key)->once727 ->exception(function() use ($asserter, & $key, & $failMessage) { $asserter->hasKey($key = rand(1, PHP_INT_MAX), $failMessage = uniqid()); })728 ->isInstanceOf('mageekguy\atoum\asserter\exception')729 ->hasMessage($failMessage)730 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid(), '5' => uniqid())))731 ->then732 ->object($asserter->hasKey(0))->isIdenticalTo($asserter)733 ->object($asserter->hasKey(1))->isIdenticalTo($asserter)734 ->object($asserter->hasKey(2))->isIdenticalTo($asserter)735 ->object($asserter->hasKey(3))->isIdenticalTo($asserter)736 ->object($asserter->hasKey(4))->isIdenticalTo($asserter)737 ->object($asserter->hasKey(5))->isIdenticalTo($asserter)738 ->object($asserter->hasKey('5'))->isIdenticalTo($asserter)739 ;740 }741 public function testNotHasKey()742 {743 $this744 ->given($asserter = $this->newTestedInstance745 ->setLocale($locale = new \mock\atoum\locale())746 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())747 )748 ->then749 ->exception(function() use ($asserter) { $asserter->notHasKey(rand(0, PHP_INT_MAX)); })750 ->isInstanceOf('mageekguy\atoum\exceptions\logic')751 ->hasMessage('Array is undefined')752 ->if($asserter->setWith(array()))753 ->then754 ->object($asserter->notHasKey(rand(-PHP_INT_MAX, PHP_INT_MAX)))->isIdenticalTo($asserter)755 ->object($asserter->notHasKey(uniqid()))->isIdenticalTo($asserter)756 ->if(757 $this->calling($locale)->_ = $hasKey = uniqid(),758 $this->calling($analyzer)->getTypeOf = $keyType = uniqid(),759 $asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid()))760 )761 ->then762 ->exception(function() use ($asserter) { $asserter->notHasKey(0); })763 ->isInstanceOf('mageekguy\atoum\asserter\exception')764 ->hasMessage($hasKey)765 ->mock($locale)->call('_')->withArguments('%s has key %s', $asserter, $keyType)->once766 ->mock($analyzer)->call('getTypeOf')->withArguments(0)->once767 ->exception(function() use ($asserter) { $asserter->notHasKey('0'); })768 ->isInstanceOf('mageekguy\atoum\asserter\exception')769 ->hasMessage($hasKey)770 ->mock($locale)->call('_')->withArguments('%s has key %s', $asserter, $keyType)->twice771 ->mock($analyzer)->call('getTypeOf')->withIdenticalArguments('0')->once772 ;773 }774 public function testNotHasKeys()775 {776 $this777 ->given($asserter = $this->newTestedInstance778 ->setLocale($locale = new \mock\atoum\locale())779 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())780 )781 ->then782 ->exception(function() use ($asserter) { $asserter->notHasKeys(array(rand(0, PHP_INT_MAX))); })783 ->isInstanceOf('mageekguy\atoum\exceptions\logic')784 ->hasMessage('Array is undefined')785 ->if($asserter->setWith(array()))786 ->then787 ->object($asserter->notHasKeys(range(1, 5)))->isIdenticalTo($asserter)788 ->object($asserter->notHasKeys(array(uniqid(), uniqid())))->isIdenticalTo($asserter)789 ->if(790 $this->calling($locale)->_ = $hasKeys = uniqid(),791 $this->calling($analyzer)->getTypeOf = $keysType = uniqid(),792 $asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid()))793 )794 ->then795 ->exception(function() use ($asserter) { $asserter->notHasKeys(array(0, 'premier', '2')); })796 ->isInstanceOf('mageekguy\atoum\asserter\exception')797 ->hasMessage($hasKeys)798 ->mock($locale)->call('_')->withArguments('%s has keys %s', $asserter, $keysType)->once799 ->mock($analyzer)->call('getTypeOf')->withIdenticalArguments(array(0 => 0, 2 => '2'))->once800 ->exception(function() use ($asserter, & $failMessage) { $asserter->notHasKeys(array(0, 'premier', 2), $failMessage = uniqid()); })801 ->isInstanceOf('mageekguy\atoum\asserter\exception')802 ->hasMessage($failMessage)803 ->object($asserter->notHasKeys(array(5, '6')))->isIdenticalTo($asserter)804 ;805 }806 public function testHasKeys()807 {808 $this809 ->given($asserter = $this->newTestedInstance810 ->setLocale($locale = new \mock\atoum\locale())811 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())812 )813 ->then814 ->exception(function() use ($asserter) { $asserter->hasKeys(array(rand(0, PHP_INT_MAX))); })815 ->isInstanceOf('mageekguy\atoum\exceptions\logic')816 ->hasMessage('Array is undefined')817 ->if(818 $this->calling($locale)->_ = $notHasKeys = uniqid(),819 $this->calling($analyzer)->getTypeOf = $keysType = uniqid(),820 $asserter->setWith(array())821 )822 ->then823 ->exception(function() use ($asserter) { $asserter->hasKeys(array(0, 1, 2)); })824 ->isInstanceOf('mageekguy\atoum\asserter\exception')825 ->hasMessage($notHasKeys)826 ->mock($locale)->call('_')->withArguments('%s has no keys %s', $asserter, $keysType)->once827 ->mock($analyzer)->call('getTypeOf')->withIdenticalArguments(array(0, 1, 2))->once828 ->exception(function() use ($asserter, & $failMessage) { $asserter->hasKeys(array(0), $failMessage = uniqid()); })829 ->isInstanceOf('mageekguy\atoum\asserter\exception')830 ->hasMessage($failMessage)831 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))832 ->then833 ->exception(function() use ($asserter) { $asserter->hasKeys(array(0, 'first', 2, 'second')); })834 ->isInstanceOf('mageekguy\atoum\asserter\exception')835 ->hasMessage($notHasKeys)836 ->mock($locale)->call('_')->withArguments('%s has no keys %s', $asserter, $keysType)->twice837 ->mock($analyzer)->call('getTypeOf')->withIdenticalArguments(array(1 => 'first', 3 => 'second'))->once838 ->object($asserter->hasKeys(array(0, 2, 4)))->isIdenticalTo($asserter)839 ;840 }841 public function testKeys()842 {843 $this844 ->given($asserter = $this->newTestedInstance)845 ->then846 ->exception(function() use ($asserter) { $asserter->keys; })847 ->isInstanceOf('mageekguy\atoum\exceptions\logic')848 ->hasMessage('Array is undefined')849 ->if($asserter->setWith(array()))850 ->then851 ->object($array = $asserter->keys)->isInstanceOf('mageekguy\atoum\asserters\phpArray')852 ->array($array->getValue())->isEqualTo(array())853 ->if($asserter->setWith(array($key1 = uniqid() => uniqid(), $key2 = uniqid() => uniqid())))854 ->then855 ->object($array = $asserter->keys)->isInstanceOf('mageekguy\atoum\asserters\phpArray')856 ->array($array->getValue())->isEqualTo(array($key1, $key2))857 ;858 }859 public function testSize()860 {861 $this862 ->given($asserter = $this->newTestedInstance)863 ->then864 ->exception(function() use ($asserter) { $asserter->size; })865 ->isInstanceOf('mageekguy\atoum\exceptions\logic')866 ->hasMessage('Array is undefined')867 ->if($asserter->setWith(array()))868 ->then869 ->object($integer = $asserter->size)->isInstanceOf('mageekguy\atoum\asserters\integer')870 ->integer($integer->getValue())->isEqualTo(0)871 ->if($asserter->setWith(array(uniqid(), uniqid())))872 ->then873 ->object($integer = $asserter->size)->isInstanceOf('mageekguy\atoum\asserters\integer')874 ->integer($integer->getValue())->isEqualTo(2)875 ;876 }877 public function testIsEqualTo()878 {879 $this880 ->given($asserter = $this->newTestedInstance881 ->setLocale($locale = new \mock\atoum\locale())882 ->setDiff($diff = new \mock\atoum\tools\diffs\variable())883 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())884 ->setGenerator($generator = new \mock\atoum\asserter\generator())885 )886 ->then887 ->exception(function() use ($asserter) { $asserter->isEqualTo(array()); })888 ->isInstanceOf('mageekguy\atoum\exceptions\logic')889 ->hasMessage('Array is undefined')890 ->if($asserter->setWith(array()))891 ->then892 ->object($asserter->isEqualTo(array()))->isIdenticalTo($asserter)893 ->if($asserter->setWith($array = range(1, 5)))894 ->then895 ->object($asserter->isEqualTo($array))->isIdenticalTo($asserter)896 ->if(897 $this->calling($locale)->_ = $localizedMessage = uniqid(),898 $this->calling($diff)->__toString = $diffValue = uniqid(),899 $this->calling($analyzer)->getTypeOf = $type = uniqid()900 )901 ->then902 ->exception(function() use ($asserter, & $notEqualValue) { $asserter->isEqualTo($notEqualValue = uniqid()); })903 ->isInstanceOf('mageekguy\atoum\asserter\exception')904 ->hasMessage($localizedMessage . PHP_EOL . $diffValue)905 ->mock($locale)->call('_')->withArguments('%s is not equal to %s', $asserter, $type)->once906 ->mock($analyzer)->call('getTypeOf')->withArguments($notEqualValue)->once907 ->object($asserter->isEqualTo($array))->isIdenticalTo($asserter)908 ->given(909 $this->calling($generator)->__get = $integerAsserter = new \mock\atoum\asserters\integer(),910 $this->calling($integerAsserter)->isEqualTo->throw = $exception = new \exception(uniqid())911 )912 ->if($asserter->integer)913 ->then914 ->exception(function() use ($asserter, & $notEqualValue) { $asserter->isEqualTo($notEqualValue = uniqid()); })915 ->isInstanceOf('mageekguy\atoum\asserter\exception')916 ->hasMessage($localizedMessage . PHP_EOL . $diffValue)917 ->mock($locale)->call('_')->withArguments('%s is not equal to %s', $asserter, $type)->twice918 ->mock($analyzer)->call('getTypeOf')->withArguments($notEqualValue)->once919 ->mock($integerAsserter)->call('isEqualTo')->never920 ->if($asserter->integer[2])921 ->then922 ->exception(function() use ($asserter, & $expectedValue) { $asserter->isEqualTo($expectedValue = rand(4, PHP_INT_MAX)); })923 ->isIdenticalTo($exception)924 ->mock($integerAsserter)->call('isEqualTo')->withArguments($expectedValue)->once925 ->if($this->method($integerAsserter)->isEqualTo->isFluent())926 ->then927 ->object($asserter->isEqualTo(3))->isIdenticalTo($asserter)928 ->mock($integerAsserter)->call('isEqualTo')->withArguments(3)->once929 ;930 }931 public function testIsNotEqualTo()932 {933 $this934 ->given($asserter = $this->newTestedInstance935 ->setLocale($locale = new \mock\atoum\locale())936 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())937 ->setGenerator($generator = new \mock\atoum\asserter\generator())938 )939 ->then940 ->exception(function() use ($asserter) { $asserter->isNotEqualTo(array()); })941 ->isInstanceOf('mageekguy\atoum\exceptions\logic')942 ->hasMessage('Array is undefined')943 ->if($asserter->setWith(array()))944 ->then945 ->object($asserter->isNotEqualTo(range(1, 2)))->isIdenticalTo($asserter)946 ->if(947 $this->calling($locale)->_ = $localizedMessage = uniqid(),948 $this->calling($analyzer)->getTypeOf = $type = uniqid()949 )950 ->then951 ->exception(function() use ($asserter) { $asserter->isNotEqualTo(array()); })952 ->isInstanceOf('mageekguy\atoum\asserter\exception')953 ->hasMessage($localizedMessage)954 ->mock($locale)->call('_')->withArguments('%s is equal to %s', $asserter, $type)->once955 ->mock($analyzer)->call('getTypeOf')->withArguments(array())->once956 ->if($asserter->setWith($array = range(1, 5)))957 ->then958 ->object($asserter->isNotEqualTo(array()))->isIdenticalTo($asserter)959 ->exception(function() use ($asserter, $array) { $asserter->isNotEqualTo($array); })960 ->isInstanceOf('mageekguy\atoum\asserter\exception')961 ->hasMessage($localizedMessage)962 ->mock($locale)->call('_')->withArguments('%s is equal to %s', $asserter, $type)->twice963 ->mock($analyzer)->call('getTypeOf')->withArguments($array)->once964 ->given(965 $this->calling($generator)->__get = $integerAsserter = new \mock\atoum\asserters\integer(),966 $this->calling($integerAsserter)->isNotEqualTo->throw = $exception = new \exception(uniqid())967 )968 ->if($asserter->integer)969 ->then970 ->object($asserter->isNotEqualTo(array()))->isIdenticalTo($asserter)971 ->exception(function() use ($asserter, $array) { $asserter->isNotEqualTo($array); })972 ->isInstanceOf('mageekguy\atoum\asserter\exception')973 ->hasMessage($localizedMessage)974 ->mock($locale)->call('_')->withArguments('%s is equal to %s', $asserter, $type)->thrice975 ->mock($analyzer)->call('getTypeOf')->withArguments($array)->twice976 ->mock($integerAsserter)->call('isNotIdenticalTo')->never977 ->if($asserter->integer[2])978 ->then979 ->exception(function() use ($asserter, & $expectedValue) { $asserter->isNotEqualTo($expectedValue = rand(4, PHP_INT_MAX)); })980 ->isIdenticalTo($exception)981 ->mock($integerAsserter)->call('isNotEqualTo')->withArguments($expectedValue)->once982 ->if($this->method($integerAsserter)->isNotEqualTo->isFluent())983 ->then984 ->object($asserter->isNotEqualTo(3))->isIdenticalTo($asserter)985 ->mock($integerAsserter)->call('isNotEqualTo')->withArguments(3)->once986 ;987 }988 public function testIsIdenticalTo()989 {990 $this991 ->given($asserter = $this->newTestedInstance992 ->setLocale($locale = new \mock\atoum\locale())993 ->setDiff($diff = new \mock\atoum\tools\diffs\variable())994 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())995 ->setGenerator($generator = new \mock\atoum\asserter\generator())996 )997 ->then998 ->exception(function() use ($asserter) { $asserter->isIdenticalTo(new \mock\object()); })999 ->isInstanceOf('mageekguy\atoum\exceptions\logic')1000 ->hasMessage('Array is undefined')1001 ->if($asserter->setWith(array($object = new \mock\object(), 2)))1002 ->then1003 ->object($asserter->isIdenticalTo(array($object, 2)))->isIdenticalTo($asserter)1004 ->if(1005 $this->calling($locale)->_ = $localizedMessage = uniqid(),1006 $this->calling($diff)->__toString = $diffValue = uniqid(),1007 $this->calling($analyzer)->getTypeOf = $type = uniqid()1008 )1009 ->then1010 ->exception(function() use ($asserter, & $notIdenticalValue) { $asserter->isIdenticalTo($notIdenticalValue = uniqid()); })1011 ->isInstanceOf('mageekguy\atoum\asserter\exception')1012 ->hasMessage($localizedMessage . PHP_EOL . $diffValue)1013 ->mock($locale)->call('_')->withArguments('%s is not identical to %s', $asserter, $type)->once1014 ->mock($analyzer)->call('getTypeOf')->withArguments($notIdenticalValue)->once1015 ->given(1016 $this->calling($generator)->__get = $integerAsserter = new \mock\atoum\asserters\integer(),1017 $this->calling($integerAsserter)->isIdenticalTo->throw = $exception = new \exception(uniqid())1018 )1019 ->if($asserter->integer)1020 ->then1021 ->object($asserter->isIdenticalTo(array($object, 2)))->isIdenticalTo($asserter)1022 ->exception(function() use ($asserter, & $notIdenticalValue) { $asserter->isIdenticalTo($notIdenticalValue = uniqid()); })1023 ->isInstanceOf('mageekguy\atoum\asserter\exception')1024 ->hasMessage($localizedMessage . PHP_EOL . $diffValue)1025 ->mock($locale)->call('_')->withArguments('%s is not identical to %s', $asserter, $type)->twice1026 ->mock($analyzer)->call('getTypeOf')->withArguments($notIdenticalValue)->once1027 ->if($asserter->integer[1])1028 ->then1029 ->exception(function() use ($asserter, & $expectedValue) { $asserter->isIdenticalTo($expectedValue = rand(4, PHP_INT_MAX)); })1030 ->isIdenticalTo($exception)1031 ->mock($integerAsserter)->call('isIdenticalTo')->withArguments($expectedValue)->once1032 ->if($this->method($integerAsserter)->isIdenticalTo->isFluent())1033 ->then1034 ->object($asserter->isEqualTo(2))->isIdenticalTo($asserter)1035 ->mock($integerAsserter)->call('isIdenticalTo')->withArguments($expectedValue)->once1036 ;1037 }1038 public function testIsNotIdenticalTo()1039 {1040 $this1041 ->given($asserter = $this->newTestedInstance1042 ->setLocale($locale = new \mock\atoum\locale())1043 ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer())1044 ->setGenerator($generator = new \mock\atoum\asserter\generator())1045 )1046 ->then1047 ->exception(function() use ($asserter) { $asserter->isNotIdenticalTo(new \mock\object()); })1048 ->isInstanceOf('mageekguy\atoum\exceptions\logic')1049 ->hasMessage('Array is undefined')1050 ->if($asserter->setWith($array = array(1, 2)))1051 ->then1052 ->object($asserter->isNotIdenticalTo(array('1', 2)))->isIdenticalTo($asserter)1053 ->if(1054 $this->calling($locale)->_ = $localizedMessage = uniqid(),1055 $this->calling($analyzer)->getTypeOf = $type = uniqid()1056 )1057 ->then1058 ->exception(function() use ($asserter, $array) { $asserter->isNotIdenticalTo($array); })1059 ->isInstanceOf('mageekguy\atoum\asserter\exception')1060 ->hasMessage($localizedMessage)1061 ->mock($locale)->call('_')->withArguments('%s is identical to %s', $asserter, $type)->once1062 ->mock($analyzer)->call('getTypeOf')->withArguments($array)->once1063 ->given(1064 $this->calling($generator)->__get = $integerAsserter = new \mock\atoum\asserters\integer(),...

Full Screen

Full Screen

utf8String.php

Source:utf8String.php Github

copy

Full Screen

...50 public function test__toString()51 {52 $this53 ->if($asserter = new sut($generator = new asserter\generator()))54 ->and($asserter->setWith($value = $this->getRandomUtf8String()))55 ->then56 ->castToString($asserter)->isEqualTo('string(' . mb_strlen($value, 'UTF-8') . ') \'' . $value . '\'')57 ->if($asserter->setWith($value = "\010" . $this->getRandomUtf8String() . "\010", null, $charlist = "\010"))58 ->then59 ->castToString($asserter)->isEqualTo('string(' . mb_strlen($value, 'UTF-8') . ') \'' . addcslashes($value, "\010") . '\'')60 ;61 }62 public function testSetWith()63 {64 $this65 ->if($asserter = new sut($generator = new asserter\generator()))66 ->then67 ->exception(function() use ($asserter, & $value) { $asserter->setwith($value = rand(- PHP_INT_MAX, PHP_INT_MAX)); })68 ->isinstanceof('mageekguy\atoum\asserter\exception')69 ->hasmessage(sprintf($generator->getlocale()->_('%s is not a string'), $asserter->gettypeof($value)))70 ->exception(function() use ($asserter, & $value) { $asserter->setwith("\xf0\x28\x8c\xbc"); })71 ->isinstanceof('mageekguy\atoum\asserter\exception')72 ->hasmessage(sprintf($generator->getlocale()->_('\'%s\' is not an UTF-8 string'), "\xf0\x28\x8c\xbc"))73 ->exception(function() use ($asserter, & $value) { $asserter->setwith("\xf8\xa1\xa1\xa1\xa1"); })74 ->isinstanceof('mageekguy\atoum\asserter\exception')75 ->hasmessage(sprintf($generator->getlocale()->_('\'%s\' is not an UTF-8 string'), "\xf8\xa1\xa1\xa1\xa1"))76 ->object($asserter->setWith(uniqid()))->isIdenticalTo($asserter)77 ;78 }79 public function testIsEqualTo()80 {81 $this82 ->if($asserter = new sut($generator = new asserter\generator()))83 ->then84 ->boolean($asserter->wasSet())->isFalse()85 ->exception(function() use ($asserter) { $asserter->isEqualTo(uniqid()); })86 ->isInstanceOf('mageekguy\atoum\exceptions\logic')87 ->hasMessage('Value is undefined')88 ->if($asserter->setWith($firstString = $this->getRandomUtf8String()))89 ->and($diff = new diffs\variable())90 ->and($secondString = $this->getRandomUtf8String())91 ->then92 ->exception(function() use ($asserter, $secondString) { $asserter->isEqualTo($secondString); })93 ->isInstanceOf('mageekguy\atoum\asserter\exception')94 ->hasMessage($generator->getLocale()->_('strings are not equals') . PHP_EOL . $diff->setExpected($secondString)->setActual($firstString))95 ->object($asserter->isEqualTo($firstString))->isIdenticalTo($asserter)96 ;97 }98 public function testIsEqualToFileContents()99 {100 $this101 ->if($asserter = new sut($generator = new asserter\generator(), $adapter = new atoum\test\adapter()))102 ->then103 ->boolean($asserter->wasSet())->isFalse()104 ->exception(function() use ($asserter) { $asserter->isEqualToContentsOfFile(uniqid()); })105 ->isInstanceOf('mageekguy\atoum\exceptions\logic')106 ->hasMessage('Value is undefined')107 ->if($asserter->setWith($firstString = $this->getRandomUtf8String()))108 ->and($adapter->file_get_contents = false)109 ->then110 ->exception(function() use ($asserter, & $path) { $asserter->isEqualToContentsOfFile($path = uniqid()); })111 ->isInstanceOf('mageekguy\atoum\asserter\exception')112 ->hasMessage(sprintf($generator->getLocale()->_('Unable to get contents of file %s'), $path))113 ->if($adapter->file_get_contents = $fileContents = $this->getRandomUtf8String())114 ->and($diff = new diffs\variable())115 ->then116 ->exception(function() use ($asserter, & $path) { $asserter->isEqualToContentsOfFile($path); })117 ->isInstanceOf('mageekguy\atoum\asserter\exception')118 ->hasMessage(sprintf($generator->getLocale()->_('string is not equals to contents of file %s'), $path) . PHP_EOL . $diff->setExpected($fileContents)->setActual($firstString))119 ->if($adapter->file_get_contents = $firstString)120 ->then121 ->object($asserter->isEqualToContentsOfFile($this->getRandomUtf8String()))->isIdenticalTo($asserter)122 ;123 }124 public function testIsEmpty()125 {126 $this127 ->if($asserter = new sut($generator = new asserter\generator()))128 ->then129 ->exception(function() use ($asserter) { $asserter->isEmpty(); })130 ->isInstanceOf('mageekguy\atoum\exceptions\logic')131 ->hasMessage('Value is undefined')132 ->if($asserter->setWith($string = $this->getRandomUtf8String()))133 ->and($diff = new diffs\variable())134 ->then135 ->exception(function() use ($asserter) { $asserter->isEmpty(); })136 ->isInstanceOf('mageekguy\atoum\asserter\exception')137 ->hasMessage($generator->getLocale()->_('strings are not equals') . PHP_EOL . $diff->setExpected('')->setActual($string))138 ->if($asserter->setWith(''))139 ->then140 ->object($asserter->isEmpty())->isIdenticalTo($asserter)141 ;142 }143 public function testIsNotEmpty()144 {145 $this146 ->if($asserter = new sut($generator = new asserter\generator()))147 ->then148 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })149 ->isInstanceOf('mageekguy\atoum\exceptions\logic')150 ->hasMessage('Value is undefined')151 ->if($asserter->setWith(''))152 ->and($diff = new diffs\variable())153 ->then154 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })155 ->isInstanceOf('mageekguy\atoum\asserter\exception')156 ->hasMessage($generator->getLocale()->_('string is empty'))157 ->if($asserter->setWith($string = $this->getRandomUtf8String()))158 ->then159 ->object($asserter->isNotEmpty())->isIdenticalTo($asserter)160 ;161 }162 public function testHasLength()163 {164 $this165 ->if($asserter = new sut($generator = new asserter\generator()))166 ->then167 ->exception(function() use ($asserter) { $asserter->hasLength(rand(0, PHP_INT_MAX)); })168 ->isInstanceOf('mageekguy\atoum\exceptions\logic')169 ->hasMessage('Value is undefined')170 ->if($asserter->setWith(''))171 ->and($diff = new diffs\variable())172 ->then173 ->exception(function() use ($asserter, & $requiredLength) { $asserter->hasLength($requiredLength = rand(1, PHP_INT_MAX)); })174 ->isInstanceOf('mageekguy\atoum\asserter\exception')175 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not %d'), $asserter->getTypeOf(''), $requiredLength))176 ->object($asserter->hasLength(0))->isIdenticalTo($asserter)177 ->if($asserter->setWith($string = $this->getRandomUtf8String()))178 ->then179 ->object($asserter->hasLength(mb_strlen($string, 'UTF-8')))->isIdenticalTo($asserter)180 ;181 }182 public function testHasLengthGreaterThan()183 {184 $this185 ->if($asserter = new sut($generator = new asserter\generator()))186 ->then187 ->exception(function() use ($asserter) { $asserter->hasLengthGreaterThan(rand(0, PHP_INT_MAX)); })188 ->isInstanceOf('mageekguy\atoum\exceptions\logic')189 ->hasMessage('Value is undefined')190 ->if($asserter->setWith($string = $this->getRandomUtf8String()))191 ->and($diff = new diffs\variable())192 ->then193 ->exception(function() use ($asserter, $string) { $asserter->hasLengthGreaterThan(mb_strlen($string, 'UTF-8')); })194 ->isInstanceOf('mageekguy\atoum\asserter\exception')195 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not greater than %d'), $asserter->getTypeOf($string), mb_strlen($string, 'UTF-8')))196 ->object($asserter->hasLengthGreaterThan(0))->isIdenticalTo($asserter)197 ->if($asserter->setWith($string = $this->getRandomUtf8String()))198 ->then199 ->object($asserter->hasLengthGreaterThan(mb_strlen($string, 'UTF-8') - 1))->isIdenticalTo($asserter)200 ;201 }202 public function testHasLengthLessThan()203 {204 $this205 ->if($asserter = new sut($generator = new asserter\generator()))206 ->then207 ->exception(function() use ($asserter) { $asserter->hasLengthLessThan(rand(0, PHP_INT_MAX)); })208 ->isInstanceOf('mageekguy\atoum\exceptions\logic')209 ->hasMessage('Value is undefined')210 ->if($asserter->setWith($string = $this->getRandomUtf8String()))211 ->and($diff = new diffs\variable())212 ->then213 ->exception(function() use ($asserter, $string) { $asserter->hasLengthLessThan(mb_strlen($string, 'UTF-8')); })214 ->isInstanceOf('mageekguy\atoum\asserter\exception')215 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not less than %d'), $asserter->getTypeOf($string), mb_strlen($string, 'UTF-8')))216 ->object($asserter->hasLengthLessThan(20))->isIdenticalTo($asserter)217 ->if($asserter->setWith($string = $this->getRandomUtf8String()))218 ->then219 ->object($asserter->hasLengthLessThan(mb_strlen($string, 'UTF-8') + 1))->isIdenticalTo($asserter)220 ;221 }222 public function testContains()223 {224 $this225 ->if($asserter = new sut($generator = new asserter\generator()))226 ->then227 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })228 ->isInstanceOf('mageekguy\atoum\exceptions\logic')229 ->hasMessage('Value is undefined')230 ->if($asserter->setWith($string = $this->getRandomUtf8String()))231 ->and($diff = new diffs\variable())232 ->and($fragment = $this->getRandomUtf8String())233 ->then234 ->exception(function() use ($asserter, $fragment) { $asserter->contains($fragment); })235 ->isInstanceOf('mageekguy\atoum\asserter\exception')236 ->hasMessage(sprintf($this->getLocale()->_('String does not contain %s'), $fragment))237 ->object($asserter->contains($string))->isIdenticalTo($asserter)238 ->if($asserter->setWith($this->getRandomUtf8String() . $string . $this->getRandomUtf8String()))239 ->then240 ->object($asserter->contains($string))->isIdenticalTo($asserter)241 ->exception(function() use ($asserter, $string, & $fragment) { $asserter->contains($fragment = mb_strtoupper($string, 'UTF-8')); })242 ->isInstanceOf('mageekguy\atoum\asserter\exception')243 ->hasMessage(sprintf($this->getLocale()->_('String does not contain %s'), $fragment))244 ->exception(function() use ($asserter) {245 $asserter->contains("\xf0\x28\x8c\xbc");246 }247 )248 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')249 ->hasMessage('Fragment \'' . "\xf0\x28\x8c\xbc" . '\' is not an UTF-8 string')250 ;251 }252 public function testNotContains()253 {254 $this255 ->if($asserter = new sut($generator = new asserter\generator()))256 ->then257 ->exception(function() use ($asserter) { $asserter->notContains(uniqid()); })258 ->isInstanceOf('mageekguy\atoum\exceptions\logic')259 ->hasMessage('Value is undefined')260 ->if($asserter->setWith($string = 'FreeAgent scans the field'))261 ->and($fragment = 'Agent')262 ->then263 ->exception(function() use ($asserter, $fragment) { $asserter->notContains($fragment); })264 ->isInstanceOf('mageekguy\atoum\asserter\exception')265 ->hasMessage(sprintf($this->getLocale()->_('String contains %s'), $fragment))266 ->object($asserter->notContains('coach'))->isIdenticalTo($asserter)267 ->exception(function() use ($asserter) {268 $asserter->notContains("\xf0\x28\x8c\xbc");269 }270 )271 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')272 ->hasMessage('Fragment \'' . "\xf0\x28\x8c\xbc" . '\' is not an UTF-8 string')273 ;274 }275 public function testStartWith()276 {277 $this278 ->if($asserter = new sut($generator = new asserter\generator()))279 ->then280 ->exception(function() use ($asserter) { $asserter->startWith(uniqid()); })281 ->isInstanceOf('mageekguy\atoum\exceptions\logic')282 ->hasMessage('Value is undefined')283 ->if($asserter->setWith($string = $this->getRandomUtf8String()))284 ->and($diff = new diffs\variable())285 ->and($fragment = $this->getRandomUtf8String())286 ->then287 ->exception(function() use ($asserter, $fragment) { $asserter->startWith($fragment); })288 ->isInstanceOf('mageekguy\atoum\asserter\exception')289 ->hasMessage(sprintf($this->getLocale()->_('String does not start with %s'), $fragment))290 ->object($asserter->startWith($string))->isIdenticalTo($asserter)291 ->if($asserter->setWith(uniqid() . $string))292 ->then293 ->exception(function() use ($asserter, $string) { $asserter->startWith($string); })294 ->isInstanceOf('mageekguy\atoum\asserter\exception')295 ->hasMessage(sprintf($this->getLocale()->_('String does not start with %s'), $string))296 ->if($asserter->setWith($string . uniqid()))297 ->then298 ->object($asserter->startWith($string))->isIdenticalTo($asserter)299 ->exception(function() use ($asserter, $string, & $fragment) { $asserter->startWith($fragment = mb_strtoupper($string, 'UTF-8')); })300 ->isInstanceOf('mageekguy\atoum\asserter\exception')301 ->hasMessage(sprintf($this->getLocale()->_('String does not start with %s'), $fragment))302 ;303 }304 public function testNotStartWith()305 {306 $this307 ->if($asserter = new sut($generator = new asserter\generator()))308 ->then309 ->exception(function() use ($asserter) { $asserter->notStartWith(uniqid()); })310 ->isInstanceOf('mageekguy\atoum\exceptions\logic')311 ->hasMessage('Value is undefined')312 ->if($asserter->setWith($string = $this->getRandomUtf8String()))313 ->then314 ->exception(function() use ($asserter, $string) { $asserter->notStartWith($string); })315 ->isInstanceOf('mageekguy\atoum\asserter\exception')316 ->hasMessage(sprintf($this->getLocale()->_('String start with %s'), $string))317 ->object($asserter->notStartWith(uniqid()))->isIdenticalTo($asserter)318 ;319 }320 public function testEndWith()321 {322 $this323 ->if($asserter = new sut($generator = new asserter\generator()))324 ->then325 ->exception(function() use ($asserter) { $asserter->endWith(uniqid()); })326 ->isInstanceOf('mageekguy\atoum\exceptions\logic')327 ->hasMessage('Value is undefined')328 ->if($asserter->setWith($string = $this->getRandomUtf8String()))329 ->and($diff = new diffs\variable())330 ->and($fragment = $this->getRandomUtf8String())331 ->then332 ->exception(function() use ($asserter, $fragment) { $asserter->endWith($fragment); })333 ->isInstanceOf('mageekguy\atoum\asserter\exception')334 ->hasMessage(sprintf($this->getLocale()->_('String does not end with %s'), $fragment))335 ->object($asserter->endWith($string))->isIdenticalTo($asserter)336 ->if($asserter->setWith($string . uniqid()))337 ->then338 ->exception(function() use ($asserter, $string) { $asserter->endWith($string); })339 ->isInstanceOf('mageekguy\atoum\asserter\exception')340 ->hasMessage(sprintf($this->getLocale()->_('String does not end with %s'), $string))341 ->if($asserter->setWith(uniqid() . $string))342 ->then343 ->object($asserter->endWith($string))->isIdenticalTo($asserter)344 ->exception(function() use ($asserter, $string, & $fragment) { $asserter->endWith($fragment = mb_strtoupper($string, 'UTF-8')); })345 ->isInstanceOf('mageekguy\atoum\asserter\exception')346 ->hasMessage(sprintf($this->getLocale()->_('String does not end with %s'), $fragment))347 ;348 }349 public function testNotEndWith()350 {351 $this352 ->if($asserter = new sut($generator = new asserter\generator()))353 ->then354 ->exception(function() use ($asserter) { $asserter->notEndWith(uniqid()); })355 ->isInstanceOf('mageekguy\atoum\exceptions\logic')356 ->hasMessage('Value is undefined')357 ->if($asserter->setWith($string = $this->getRandomUtf8String()))358 ->then359 ->exception(function() use ($asserter, $string) { $asserter->notEndWith($string); })360 ->isInstanceOf('mageekguy\atoum\asserter\exception')361 ->hasMessage(sprintf($this->getLocale()->_('String end with %s'), $string))362 ->object($asserter->notEndWith(uniqid()))->isIdenticalTo($asserter)363 ;364 }365 public function testLength()366 {367 $this368 ->if($asserter = new sut($generator = new asserter\generator()))369 ->then370 ->exception(function() use ($asserter) { $asserter->length; })371 ->isInstanceOf('mageekguy\atoum\exceptions\logic')372 ->hasMessage('Value is undefined')373 ->if($asserter->setWith(''))374 ->then375 ->object($integer = $asserter->length)376 ->isInstanceOf('mageekguy\atoum\asserters\integer')377 ->integer($integer->getValue())378 ->isEqualTo(0)379 ->if($asserter->setWith($str = uniqid()))380 ->then381 ->object($integer = $asserter->length)382 ->isInstanceOf('mageekguy\atoum\asserters\integer')383 ->integer($integer->getValue())384 ->isEqualTo(strlen($str))385 ->if($asserter->setWith($str = $this->getRandomUtf8String()))386 ->then387 ->object($integer = $asserter->length)388 ->isInstanceOf('mageekguy\atoum\asserters\integer')389 ->integer($integer->getValue())390 ->isEqualTo(mb_strlen($str, 'UTF-8'))391 ;392 }393 private function getRandomUtf8String()394 {395 $characters = 'àâäéèêëîïôöùüŷÿ';396 $characters = mb_convert_encoding($characters, 'UTF-8', mb_detect_encoding($characters));397 $charactersLength = mb_strlen($characters, 'UTF-8');398 $utf8String = '';399 for($i = 0; $i < 16; $i++)...

Full Screen

Full Screen

HoaOptionAsserter.php

Source:HoaOptionAsserter.php Github

copy

Full Screen

...19 ->and($value = None())20 ->then21 ->exception(function() use ($asserter)22 {23 $asserter->setWith(new \stdClass);24 })25 ->isInstanceOf('mageekguy\atoum\asserter\exception')26 ->hasMessage('object(stdClass) is not an Option instance')27 ->object($this->testedInstance->setWith($value))28 ->isTestedInstance29 ->object($asserter->getValue())30 ->isIdenticalTo($value)31 ;32 }33 public function testIsNone()34 {35 $this36 ->given($value = None())37 ->if($asserter = $this->newTestedInstance)38 ->then39 ->assert('Check none value')40 ->exception(function() use ($asserter)41 {42 $asserter43 ->setWith(Some(42))44 ->isNone();45 })46 ->isInstanceOf('mageekguy\atoum\asserter\exception')47 ->hasMessage('Option::some() "integer(42)" contains a value')48 ->assert('Check none value with custom fail message')49 ->exception(function() use ($asserter)50 {51 $asserter52 ->setWith(Some(42))53 ->isNone('yolo');54 })55 ->isInstanceOf('mageekguy\atoum\asserter\exception')56 ->hasMessage('yolo')57 ->assert('Check assertion return the asserter to chain')58 ->object($this->testedInstance->setWith($value)->isNone())59 ->isTestedInstance()60 ;61 }62 public function testIsSome()63 {64 $this65 ->given($value = Some(42))66 ->if($asserter = $this->newTestedInstance)67 ->then68 ->assert('Check some value')69 ->exception(function() use ($asserter)70 {71 $asserter72 ->setWith(None())73 ->isSome();74 })75 ->isInstanceOf('mageekguy\atoum\asserter\exception')76 ->hasMessage('Option::none() doesn\'t contains a value')77 ->assert('Check some value with custom fail message')78 ->exception(function() use ($asserter)79 {80 $asserter81 ->setWith(None())82 ->isSome('yolo');83 })84 ->isInstanceOf('mageekguy\atoum\asserter\exception')85 ->hasMessage('yolo')86 ->assert('Check assertion return the asserter to chain')87 ->object($this->testedInstance->setWith($value)->isSome())88 ->isTestedInstance()89 ;90 }91 public function testSome()92 {93 $this94 ->given($value = Some(42))95 ->if($asserter = $this->newTestedInstance)96 ->then97 ->assert('Check some value')98 ->exception(function() use ($asserter)99 {100 $asserter101 ->setWith(None())102 ->some();103 })104 ->isInstanceOf('mageekguy\atoum\asserter\exception')105 ->hasMessage('Option::none() doesn\'t contains a value')106 ->assert('Check assertion return the asserter to chain with')107 ->object($this->testedInstance->setWith($value)->some())108 ->isTestedInstance()109 ->assert('Check unwrapped value define the new value')110 ->if($this->testedInstance->setWith($value)->some())111 ->integer($this->testedInstance->getValue())112 ->isIdenticalTo(42)113 ->assert('Check unwrapped value type')114 ->variable($this->testedInstance->setWith($value)->some()->integer)115 ->assert('Check unwrapped value value')116 ->variable($this->testedInstance->setWith($value)->some()->isEqualTo(42))117 ->assert('Check unwrapped value full assertion')118 ->if($this->testedInstance->setWith($value)->some())119 ->variable($this->testedInstance->integer($this->testedInstance->getValue())->isEqualTo(42))120 ;121 }122 public function testShortSyntax()123 {124 $this125 ->given($value = Some(42), $none = None())126 ->if($this->newTestedInstance)127 ->then128 ->assert('Check some short syntax value')129 ->object($this->testedInstance->setWith($value)->some->isEqualTo(42))130 ->isTestedInstance()131 ->assert('Check isSome short syntax')132 ->object($this->testedInstance->setWith($value)->isSome)133 ->isTestedInstance()134 ->assert('Check isNome short syntax')135 ->object($this->testedInstance->setWith($none)->isNone)136 ->isTestedInstance()137 ;138 }139}...

Full Screen

Full Screen

setWith

Using AI Code Generation

copy

Full Screen

1$integer = new Integer();2$integer->setWith(10);3echo $integer->getValue();4$integer = new Integer();5$integer->setWith(10);6echo $integer->getValue();7$integer = new Integer();8$integer->setWith(10);9echo $integer->getValue();10$integer = new Integer();11$integer->setWith(10);12echo $integer->getValue();13$integer = new Integer();14$integer->setWith(10);15echo $integer->getValue();16$integer = new Integer();17$integer->setWith(10);18echo $integer->getValue();19$integer = new Integer();20$integer->setWith(10);21echo $integer->getValue();22$integer = new Integer();23$integer->setWith(10);24echo $integer->getValue();25$integer = new Integer();26$integer->setWith(10);27echo $integer->getValue();28$integer = new Integer();29$integer->setWith(10);30echo $integer->getValue();31$integer = new Integer();32$integer->setWith(10);33echo $integer->getValue();34$integer = new Integer();35$integer->setWith(10);36echo $integer->getValue();37$integer = new Integer();38$integer->setWith(10);39echo $integer->getValue();

Full Screen

Full Screen

setWith

Using AI Code Generation

copy

Full Screen

1$integer = new Integer(2);2$integer->setWith(3);3$integer = new Integer(2);4$integer->setWith('3');5$integer = new Integer(2);6$integer->setWith('abc');7$integer = new Integer(2);8$integer->setWith(3.5);9{10 private $value;11 public function __construct($value)12 {13 $this->setWith($value);14 }15 public function setWith($value)16 {17 $this->value = intval($value);18 }19 public function get()20 {21 return $this->value;22 }23}24$integer = new Integer(2);25$integer->setWith(3);26$integer->setWith('3');27$integer->setWith('abc');

Full Screen

Full Screen

setWith

Using AI Code Generation

copy

Full Screen

1$int = new Integer(2);2$int->setWith(3);3echo $int->get();4$str = new String("Hello");5$str->setWith("World");6echo $str->get();7$float = new Float(2.5);8$float->setWith(3.5);9echo $float->get();10$double = new Double(2.5);11$double->setWith(3.5);12echo $double->get();13$boolean = new Boolean(true);14$boolean->setWith(false);15echo $boolean->get();16$char = new Char("a");17$char->setWith("b");18echo $char->get();19$byte = new Byte(2);20$byte->setWith(3);21echo $byte->get();22$short = new Short(2);23$short->setWith(3);24echo $short->get();25$long = new Long(2);26$long->setWith(3);27echo $long->get();

Full Screen

Full Screen

setWith

Using AI Code Generation

copy

Full Screen

1$integer = new Integer(5);2$integer->setWith(10);3echo $integer->get();4$string = new String('test');5$string->setWith('test2');6echo $string->get();7$array = new Array([1,2,3]);8$array->setWith([4,5,6]);9echo $array->get();10$object = new Object(new stdClass());11$object->setWith(new stdClass());12echo $object->get();

Full Screen

Full Screen

setWith

Using AI Code Generation

copy

Full Screen

1require_once 'integer.php';2$obj = new integer();3$obj->setWith(12);4echo $obj->getValue();5require_once 'integer.php';6$obj = new integer();7$obj->setWith(12);8$obj->getWith();9echo $obj->getValue();10require_once 'integer.php';11$obj = new integer();12$obj->setWith(12);13$obj->add(2);14echo $obj->getValue();15require_once 'integer.php';16$obj = new integer();17$obj->setWith(12);18$obj->sub(2);19echo $obj->getValue();20require_once 'integer.php';21$obj = new integer();22$obj->setWith(12);23$obj->mul(2);24echo $obj->getValue();25require_once 'integer.php';26$obj = new integer();27$obj->setWith(12);28$obj->div(2);29echo $obj->getValue();30require_once 'integer.php';31$obj = new integer();32$obj->setWith(12);33$obj->mod(2);34echo $obj->getValue();35require_once 'integer.php';36$obj = new integer();37$obj->setWith(12);38$obj->pow(2);39echo $obj->getValue();40require_once 'integer.php';41$obj = new integer();42$obj->setWith(12);43$obj->sqrt();44echo $obj->getValue();45require_once 'integer.php';46$obj = new integer();47$obj->setWith(12);48$obj->abs();49echo $obj->getValue();

Full Screen

Full Screen

setWith

Using AI Code Generation

copy

Full Screen

1$int = new integer(5);2$int->setWith(10);3$int = new integer(5);4$int->setWith(10);5$int = new integer(5);6$int->setWith(10);7$int = new integer(5);8$int->setWith(10);9$int = new integer(5);10$int->setWith(10);11$int = new integer(5);12$int->setWith(10);13$int = new integer(5);14$int->setWith(10);15$int = new integer(5);16$int->setWith(

Full Screen

Full Screen

setWith

Using AI Code Generation

copy

Full Screen

1require_once 'integer.php';2$integer = new integer();3$integer->setWith(5);4echo $integer->get();5echo $integer->getWith();6{7    private $value;8    public function setWith($value)9    {10        $this->value = $value;11    }12    public function get()13    {14        return $this->value;15    }16    public function getWith()17    {18        return $this->value;19    }20}21So, in the above example, the setWith() method is setting the value of the $value property. The get() method is returning the value of the $value property. The getWith() method is also returning the value of the $value property. So, what is the difference between the get() and getWith() methods? There is no difference. The get() method is not doing anything special. It is just returning the value of the $value property. The getWith() method is also not doing anything special. It is also just returning the value of the $value property. There is no difference between the get() and getWith() methods. So, why did we create the getWith() method? It is not doing anything special. It is just returning the value of the $value property. So, why did we create the getWith() method? It is not doing anything special. It is just returning the value of the $value property. So, why did we create the getWith() method? It is not doing anything special. It is just returning the value of the $value property. So, why did we create the getWith() method? It is not doing anything special. It is just returning the value of the $value property. So, why did we create the getWith() method? It is not doing anything special. It is just returning the value of the $value property. So, why did we create the getWith() method? It is not doing anything special. It is just returning the value of the $value property. So, why did we create the getWith() method? It is not doing anything special. It is just returning the value of the $value property. So, why did we create the getWith() method? It is not doing anything special. It is just returning the value of the

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger setWith code on LambdaTest Cloud Grid

Execute automation tests with setWith on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful