Best Atoum code snippet using testedClass.setWith
phpArray.php
Source:phpArray.php
...27 {28 $this29 ->if($asserter = new testedClass($generator = new asserter\generator()))30 ->then31 ->exception(function() use ($asserter, & $value) { $asserter->setWith($value = uniqid()); })32 ->isInstanceOf('mageekguy\atoum\asserter\exception')33 ->hasMessage(sprintf($generator->getLocale()->_('%s is not an array'), $asserter->getTypeOf($value)))34 ->object($asserter->setWith($value = array()))->isIdenticalTo($asserter)35 ->array($asserter->getValue())->isEqualTo($value)36 ;37 }38 public function testHasSize()39 {40 $this41 ->if($asserter = new testedClass($generator = new asserter\generator()))42 ->then43 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })44 ->isInstanceOf('mageekguy\atoum\exceptions\logic')45 ->hasMessage('Array is undefined')46 ->if($asserter->setWith(array()))47 ->then48 ->exception(function() use ($asserter, & $size) { $asserter->hasSize($size = rand(1, PHP_INT_MAX)); })49 ->isInstanceOf('mageekguy\atoum\asserter\exception')50 ->hasMessage(sprintf($generator->getLocale()->_('%s has not size %d'), $asserter, $size))51 ->exception(function() use ($asserter, & $size, & $message) { $asserter->hasSize($size = rand(1, PHP_INT_MAX), $message = uniqid()); })52 ->isInstanceOf('mageekguy\atoum\asserter\exception')53 ->hasMessage($message)54 ->object($asserter->hasSize(0))->isIdenticalTo($asserter)55 ;56 }57 public function testIsEmpty()58 {59 $this->assert60 ->if($asserter = new testedClass($generator = new asserter\generator()))61 ->then62 ->exception(function() use ($asserter) { $asserter->isEmpty(); })63 ->isInstanceOf('mageekguy\atoum\exceptions\logic')64 ->hasMessage('Array is undefined')65 ->if($asserter->setWith(array(uniqid())))66 ->then67 ->exception(function() use ($asserter) { $asserter->isEmpty(); })68 ->isInstanceOf('mageekguy\atoum\asserter\exception')69 ->hasMessage(sprintf($generator->getLocale()->_('%s is not empty'), $asserter))70 ->exception(function() use ($asserter, & $message) { $asserter->isEmpty($message = uniqid()); })71 ->isInstanceOf('mageekguy\atoum\asserter\exception')72 ->hasMessage($message)73 ->if($asserter->setWith(array()))74 ->then75 ->object($asserter->isEmpty())->isIdenticalTo($asserter)76 ;77 }78 public function testIsNotEmpty()79 {80 $this81 ->if($asserter = new testedClass($generator = new asserter\generator()))82 ->then83 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })84 ->isInstanceOf('mageekguy\atoum\exceptions\logic')85 ->hasMessage('Array is undefined')86 ->if($asserter->setWith(array()))87 ->then88 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })89 ->isInstanceOf('mageekguy\atoum\asserter\exception')90 ->hasMessage(sprintf($generator->getLocale()->_('%s is empty'), $asserter))91 ->exception(function() use ($asserter, & $message) { $asserter->isNotEmpty($message = uniqid()); })92 ->isInstanceOf('mageekguy\atoum\asserter\exception')93 ->hasMessage($message)94 ->if($asserter->setWith(array(uniqid())))95 ->then96 ->object($asserter->isNotEmpty())->isIdenticalTo($asserter)97 ;98 }99 public function testAtKey()100 {101 $this102 ->if($asserter = new testedClass($generator = new asserter\generator()))103 ->then104 ->exception(function() use ($asserter) { $asserter->atKey(uniqid()); })105 ->isInstanceOf('mageekguy\atoum\exceptions\logic')106 ->hasMessage('Array is undefined')107 ->if($asserter->setWith(array(uniqid(), uniqid(), $data = rand(1, PHP_INT_MAX), uniqid(), uniqid())))108 ->object($asserter->atKey(0))->isIdenticalTo($asserter)109 ->object($asserter->atKey('0'))->isIdenticalTo($asserter)110 ->object($asserter->atKey(1))->isIdenticalTo($asserter)111 ->object($asserter->atKey(2))->isIdenticalTo($asserter)112 ->object($asserter->atKey(3))->isIdenticalTo($asserter)113 ->object($asserter->atKey(4))->isIdenticalTo($asserter)114 ->exception(function() use ($asserter, & $key) { $asserter->atKey($key = rand(5, PHP_INT_MAX)); })115 ->isInstanceOf('mageekguy\atoum\asserter\exception')116 ->hasMessage(sprintf($generator->getLocale()->_('%s has no key %s'), $asserter, $asserter->getTypeOf($key)))117 ->exception(function() use ($asserter, & $key, & $message) { $asserter->atKey($key = rand(5, PHP_INT_MAX), $message = uniqid()); })118 ->isInstanceOf('mageekguy\atoum\asserter\exception')119 ->hasMessage($message)120 ;121 }122 public function testContains()123 {124 $this125 ->if($asserter = new testedClass($generator = new asserter\generator()))126 ->then127 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })128 ->isInstanceOf('mageekguy\atoum\exceptions\logic')129 ->hasMessage('Array is undefined')130 ->if($asserter->setWith(array(uniqid(), uniqid(), $data = rand(1, PHP_INT_MAX), uniqid(), uniqid())))131 ->then132 ->exception(function() use ($asserter, & $notInArray) { $asserter->contains($notInArray = uniqid()); })133 ->isInstanceOf('mageekguy\atoum\asserter\exception')134 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain %s'), $asserter, $asserter->getTypeOf($notInArray)))135 ->object($asserter->contains($data))->isIdenticalTo($asserter)136 ->object($asserter->contains((string) $data))->isIdenticalTo($asserter)137 ->exception(function() use ($asserter, $data) { $asserter->atKey(0)->contains($data); })138 ->isInstanceOf('mageekguy\atoum\asserter\exception')139 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain %s at key %s'), $asserter, $asserter->getTypeOf($data), $asserter->getTypeOf(0)))140 ->object($asserter->contains($data))->isIdenticalTo($asserter)141 ->object($asserter->atKey(2)->contains($data))->isIdenticalTo($asserter)142 ;143 }144 public function testNotContains()145 {146 $this147 ->if($asserter = new testedClass($generator = new asserter\generator()))148 ->then149 ->exception(function() use ($asserter) { $asserter->notContains(uniqid()); })150 ->isInstanceOf('mageekguy\atoum\exceptions\logic')151 ->hasMessage('Array is undefined')152 ->if($asserter->setWith(array(uniqid(), uniqid(), $inArray = uniqid(), uniqid(), uniqid())))153 ->then154 ->object($asserter->notContains(uniqid()))->isIdenticalTo($asserter)155 ->exception(function() use ($asserter, $inArray) { $asserter->notContains($inArray); })156 ->isInstanceOf('mageekguy\atoum\asserter\exception')157 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s'), $asserter, $asserter->getTypeOf($inArray)))158 ->exception(function() use ($asserter, $inArray, & $message) { $asserter->notContains($inArray, $message = uniqid()); })159 ->isInstanceOf('mageekguy\atoum\asserter\exception')160 ->hasMessage($message)161 ->exception(function() use($asserter, $inArray){ $asserter->notContains((string) $inArray); })162 ->isInstanceOf('mageekguy\atoum\asserter\exception')163 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s'), $asserter, $asserter->getTypeOf((string) $inArray)))164 ->exception(function() use($asserter, $inArray, & $message){ $asserter->notContains((string) $inArray, $message = uniqid()); })165 ->isInstanceOf('mageekguy\atoum\asserter\exception')166 ->hasMessage($message)167 ->object($asserter->atKey(0)->notContains($inArray))->isIdenticalTo($asserter)168 ->object($asserter->atKey(1)->notContains($inArray))->isIdenticalTo($asserter)169 ->object($asserter->atKey(3)->notContains($inArray))->isIdenticalTo($asserter)170 ->object($asserter->atKey(4)->notContains($inArray))->isIdenticalTo($asserter)171 ->exception(function() use ($asserter, $inArray) { $asserter->notContains($inArray); })172 ->isInstanceOf('mageekguy\atoum\asserter\exception')173 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s'), $asserter, $asserter->getTypeOf($inArray)))174 ->exception(function() use ($asserter, $inArray) { $asserter->atKey(2)->notContains($inArray); })175 ->isInstanceOf('mageekguy\atoum\asserter\exception')176 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s at key %s'), $asserter, $asserter->getTypeOf($inArray), $asserter->getTypeOf(2)))177 ->exception(function() use ($asserter, $inArray) { $asserter->atKey('2')->notContains($inArray); })178 ->isInstanceOf('mageekguy\atoum\asserter\exception')179 ->hasMessage(sprintf($generator->getLocale()->_('%s contains %s at key %s'), $asserter, $asserter->getTypeOf($inArray), $asserter->getTypeOf('2')))180 ;181 }182 public function testStrictlyContains()183 {184 $this185 ->if($asserter = new testedClass($generator = new asserter\generator()))186 ->then187 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })188 ->isInstanceOf('mageekguy\atoum\exceptions\logic')189 ->hasMessage('Array is undefined')190 ->and($asserter->setWith(array(1, 2, 3, 4, 5, '3')))191 ->then192 ->exception(function() use ($asserter) {$asserter->strictlyContains('1'); })193 ->isInstanceOf('mageekguy\atoum\asserter\exception')194 ->hasMessage(sprintf($generator->getLocale()->_('%s does not strictly contain %s'), $asserter, $asserter->getTypeOf('1')))195 ->exception(function() use ($asserter, & $message) {$asserter->strictlyContains('1', $message = uniqid()); })196 ->isInstanceOf('mageekguy\atoum\asserter\exception')197 ->hasMessage($message)198 ->object($asserter->strictlyContains(1))->isIdenticalTo($asserter)199 ->exception(function() use ($asserter) { $asserter->atKey(0)->strictlyContains(2); })200 ->isInstanceOf('mageekguy\atoum\asserter\exception')201 ->hasMessage(sprintf($generator->getLocale()->_('%s does not strictly contain %s at key %s'), $asserter, $asserter->getTypeOf(2), $asserter->getTypeOf(0)))202 ->object($asserter->strictlyContains(2))->isIdenticalTo($asserter)203 ->object($asserter->atKey(2)->strictlyContains(3))->isIdenticalTo($asserter)204 ->exception(function() use ($asserter) { $asserter->atKey(2)->strictlyContains('3'); })205 ->isInstanceOf('mageekguy\atoum\asserter\exception')206 ->hasMessage(sprintf($generator->getLocale()->_('%s does not strictly contain %s at key %s'), $asserter, $asserter->getTypeOf('3'), $asserter->getTypeOf(2)))207 ;208 }209 public function testStrictlyNotContains()210 {211 $this212 ->if($asserter = new testedClass($generator = new asserter\generator()))213 ->then214 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })215 ->isInstanceOf('mageekguy\atoum\exceptions\logic')216 ->hasMessage('Array is undefined')217 ->if($asserter->setWith(array(1, 2, 3, 4, 5, '6')))218 ->then219 ->exception(function() use ($asserter) {$asserter->strictlyNotContains(1); })220 ->isInstanceOf('mageekguy\atoum\asserter\exception')221 ->hasMessage(sprintf($generator->getLocale()->_('%s strictly contains %s'), $asserter, $asserter->getTypeOf(1)))222 ->exception(function() use ($asserter, & $message) {$asserter->strictlyNotContains(1, $message = uniqid()); })223 ->isInstanceOf('mageekguy\atoum\asserter\exception')224 ->hasMessage($message)225 ->object($asserter->strictlyNotContains('1'))->isIdenticalTo($asserter)226 ->object($asserter->atKey(1)->strictlyNotContains(1))->isIdenticalTo($asserter)227 ->object($asserter->atKey(2)->strictlyNotContains(1))->isIdenticalTo($asserter)228 ->object($asserter->atKey(3)->strictlyNotContains(1))->isIdenticalTo($asserter)229 ->object($asserter->atKey(4)->strictlyNotContains(1))->isIdenticalTo($asserter)230 ->exception(function() use ($asserter) { $asserter->strictlyNotContains(1); })231 ->isInstanceOf('mageekguy\atoum\asserter\exception')232 ->hasMessage(sprintf($generator->getLocale()->_('%s strictly contains %s'), $asserter, $asserter->getTypeOf(1)))233 ->exception(function() use ($asserter) { $asserter->atKey(0)->strictlyNotContains(1); })234 ->isInstanceOf('mageekguy\atoum\asserter\exception')235 ->hasMessage(sprintf($generator->getLocale()->_('%s strictly contains %s at key %s'), $asserter, $asserter->getTypeOf(1), $asserter->getTypeOf(0)))236 ->exception(function() use ($asserter) { $asserter->atKey('0')->strictlyNotContains(1); })237 ->isInstanceOf('mageekguy\atoum\asserter\exception')238 ->hasMessage(sprintf($generator->getLocale()->_('%s strictly contains %s at key %s'), $asserter, $asserter->getTypeOf(1), $asserter->getTypeOf('0')))239 ;240 }241 public function testContainsValues()242 {243 $this244 ->if($asserter = new testedClass($generator = new asserter\generator()))245 ->then246 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })247 ->isInstanceOf('mageekguy\atoum\exceptions\logic')248 ->hasMessage('Array is undefined')249 ->if($asserter->setWith(array(1, 2, 3, 4, 5)))250 ->then251 ->exception(function() use ($asserter) { $asserter->containsValues(array(6)); })252 ->isInstanceOf('mageekguy\atoum\asserter\exception')253 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain values %s'), $asserter, $asserter->getTypeOf(array(6))))254 ->exception(function() use ($asserter, & $message) { $asserter->containsValues(array(6), $message = uniqid()); })255 ->isInstanceOf('mageekguy\atoum\asserter\exception')256 ->hasMessage($message)257 ->exception(function() use ($asserter) { $asserter->containsValues(array('6')); })258 ->isInstanceOf('mageekguy\atoum\asserter\exception')259 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain values %s'), $asserter, $asserter->getTypeOf(array('6'))))260 ->exception(function() use ($asserter, & $message) { $asserter->containsValues(array('6'), $message = uniqid()); })261 ->isInstanceOf('mageekguy\atoum\asserter\exception')262 ->hasMessage($message)263 ->object($asserter->containsValues(array(1)))->isIdenticalTo($asserter)264 ->object($asserter->containsValues(array(1, 2, 4)))->isIdenticalTo($asserter)265 ->object($asserter->containsValues(array('1', 2, '4')))->isIdenticalTo($asserter)266 ;267 }268 public function testNotContainsValues()269 {270 $this271 ->if($asserter = new testedClass($generator = new asserter\generator()))272 ->then273 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })274 ->isInstanceOf('mageekguy\atoum\exceptions\logic')275 ->hasMessage('Array is undefined')276 ->if($asserter->setWith(array(1, 2, 3, 4, 5)))277 ->then278 ->exception(function() use ($asserter) { $asserter->notContainsValues(array(1, 6)); })279 ->isInstanceOf('mageekguy\atoum\asserter\exception')280 ->hasMessage(sprintf($generator->getLocale()->_('%s should not contain values %s'), $asserter, $asserter->getTypeOf(array(1))))281 ->exception(function() use ($asserter, & $message) { $asserter->notContainsValues(array(1, 6), $message = uniqid()); })282 ->isInstanceOf('mageekguy\atoum\asserter\exception')283 ->hasMessage($message)284 ->exception(function() use ($asserter, & $message) { $asserter->notContainsValues(array('1', '6'), $message = uniqid()); })285 ->isInstanceOf('mageekguy\atoum\asserter\exception')286 ->hasMessage($message)287 ->object($asserter->containsValues(array(1)))->isIdenticalTo($asserter)288 ->object($asserter->containsValues(array(1, 2, 4)))->isIdenticalTo($asserter)289 ->object($asserter->containsValues(array('1', 2, '4')))->isIdenticalTo($asserter)290 ;291 }292 public function testStrictlyContainsValues()293 {294 $this295 ->if($asserter = new testedClass($generator = new asserter\generator()))296 ->then297 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })298 ->isInstanceOf('mageekguy\atoum\exceptions\logic')299 ->hasMessage('Array is undefined')300 ->if($asserter->setWith(array(1, 2, 3, 4, 5)))301 ->then302 ->exception(function() use ($asserter) { $asserter->strictlyContainsValues(array(6)); })303 ->isInstanceOf('mageekguy\atoum\asserter\exception')304 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain strictly values %s'), $asserter, $asserter->getTypeOf(array(6))))305 ->exception(function() use ($asserter, & $message) { $asserter->strictlyContainsValues(array(6), $message = uniqid()); })306 ->isInstanceOf('mageekguy\atoum\asserter\exception')307 ->hasMessage($message)308 ->exception(function() use ($asserter) { $asserter->strictlyContainsValues(array('6')); })309 ->isInstanceOf('mageekguy\atoum\asserter\exception')310 ->hasMessage(sprintf($generator->getLocale()->_('%s does not contain strictly values %s'), $asserter, $asserter->getTypeOf(array('6'))))311 ->exception(function() use ($asserter, & $message) { $asserter->strictlyContainsValues(array('6'), $message = uniqid()); })312 ->isInstanceOf('mageekguy\atoum\asserter\exception')313 ->hasMessage($message)314 ->exception(function() use ($asserter, & $message) { $asserter->strictlyContainsValues(array('1'), $message = uniqid()); })315 ->isInstanceOf('mageekguy\atoum\asserter\exception')316 ->hasMessage($message)317 ->object($asserter->strictlyContainsValues(array(1)))->isIdenticalTo($asserter)318 ->object($asserter->strictlyContainsValues(array(1, 2, 4)))->isIdenticalTo($asserter)319 ->exception(function() use ($asserter, & $message) { $asserter->strictlyContainsValues(array('1', 2, '4'), $message = uniqid()); })320 ->isInstanceOf('mageekguy\atoum\asserter\exception')321 ->hasMessage($message)322 ;323 }324 public function testStrictlyNotContainsValues()325 {326 $this327 ->if($asserter = new testedClass($generator = new asserter\generator()))328 ->then329 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })330 ->isInstanceOf('mageekguy\atoum\exceptions\logic')331 ->hasMessage('Array is undefined')332 ->if($asserter->setWith(array(1, 2, 3, 4, 5)))333 ->then334 ->exception(function() use ($asserter) { $asserter->strictlyNotContainsValues(array(1)); })335 ->isInstanceOf('mageekguy\atoum\asserter\exception')336 ->hasMessage(sprintf($generator->getLocale()->_('%s should not contain strictly values %s'), $asserter, $asserter->getTypeOf(array(1))))337 ->exception(function() use ($asserter, & $message) { $asserter->strictlyNotContainsValues(array(1), $message = uniqid()); })338 ->isInstanceOf('mageekguy\atoum\asserter\exception')339 ->hasMessage($message)340 ->exception(function() use ($asserter, & $message) { $asserter->strictlyNotContainsValues(array(1, '2', 3), $message = uniqid()); })341 ->isInstanceOf('mageekguy\atoum\asserter\exception')342 ->hasMessage($message)343 ->object($asserter->strictlyNotContainsValues(array('1')))->isIdenticalTo($asserter)344 ->object($asserter->strictlyNotContainsValues(array(6, 7, '2', 8)))->isIdenticalTo($asserter)345 ;346 }347 public function testHasKey()348 {349 $this350 ->if($asserter = new testedClass($generator = new asserter\generator()))351 ->then352 ->exception(function() use ($asserter) { $asserter->hasKey(rand(0, PHP_INT_MAX)); })353 ->isInstanceOf('mageekguy\atoum\exceptions\logic')354 ->hasMessage('Array is undefined')355 ->if($asserter->setWith(array()))356 ->then357 ->exception(function() use ($asserter, & $key) { $asserter->hasKey($key = rand(1, PHP_INT_MAX)); })358 ->isInstanceOf('mageekguy\atoum\asserter\exception')359 ->hasMessage(sprintf($generator->getLocale()->_('%s has no key %s'), $asserter, $asserter->getTypeOf($key)))360 ->exception(function() use ($asserter, & $key, & $message) { $asserter->hasKey($key = rand(1, PHP_INT_MAX), $message = uniqid()); })361 ->isInstanceOf('mageekguy\atoum\asserter\exception')362 ->hasMessage($message)363 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))364 ->then365 ->object($asserter->hasKey(0))->isIdenticalTo($asserter)366 ->object($asserter->hasKey(1))->isIdenticalTo($asserter)367 ->object($asserter->hasKey(2))->isIdenticalTo($asserter)368 ->object($asserter->hasKey(3))->isIdenticalTo($asserter)369 ->object($asserter->hasKey(4))->isIdenticalTo($asserter)370 ->exception(function() use ($asserter) { $asserter->hasKey(5); })371 ->isInstanceOf('mageekguy\atoum\asserter\exception')372 ->hasMessage(sprintf($generator->getLocale()->_('%s has no key %s'), $asserter, $asserter->getTypeOf(5)))373 ->exception(function() use ($asserter, & $message) { $asserter->hasKey(5, $message = uniqid()); })374 ->isInstanceOf('mageekguy\atoum\asserter\exception')375 ->hasMessage($message)376 ;377 }378 public function testNotHasKey()379 {380 $this381 ->if($asserter = new testedClass($generator = new asserter\generator()))382 ->then383 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })384 ->isInstanceOf('mageekguy\atoum\exceptions\logic')385 ->hasMessage('Array is undefined')386 ->if($asserter->setWith(array()))387 ->then388 ->object($asserter->notHasKey(1))->isIdenticalTo($asserter)389 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))390 ->then391 ->exception(function() use ($asserter) { $asserter->notHasKey(0); })392 ->isInstanceOf('mageekguy\atoum\asserter\exception')393 ->hasMessage(sprintf($generator->getLocale()->_('%s has a key %s'), $asserter, $asserter->getTypeOf(0)))394 ->exception(function() use ($asserter, & $message) { $asserter->notHasKey(0, $message = uniqid()); })395 ->isInstanceOf('mageekguy\atoum\asserter\exception')396 ->hasMessage($message)397 ->object($asserter->notHasKey(5))->isIdenticalTo($asserter)398 ;399 }400 public function testNotHasKeys()401 {402 $this403 ->if($asserter = new testedClass($generator = new asserter\generator()))404 ->then405 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })406 ->isInstanceOf('mageekguy\atoum\exceptions\logic')407 ->hasMessage('Array is undefined')408 ->if($asserter->setWith(array()))409 ->then410 ->object($asserter->notHasKeys(array(1)))->isIdenticalTo($asserter)411 ->object($asserter->notHasKeys(array(0, 1)))->isIdenticalTo($asserter)412 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))413 ->then414 ->exception(function() use ($asserter) { $asserter->notHasKeys(array(0, 'premier', 2)); })415 ->isInstanceOf('mageekguy\atoum\asserter\exception')416 ->hasMessage(sprintf($generator->getLocale()->_('%s should not have keys %s'), $asserter, $asserter->getTypeOf(array(0, 2))))417 ->exception(function() use ($asserter, & $message) { $asserter->notHasKeys(array(0, 'premier', 2), $message = uniqid()); })418 ->isInstanceOf('mageekguy\atoum\asserter\exception')419 ->hasMessage($message)420 ->object($asserter->notHasKeys(array(5, '6')))->isIdenticalTo($asserter)421 ;422 }423 public function testHasKeys()424 {425 $this426 ->if($asserter = new testedClass($generator = new asserter\generator()))427 ->then428 ->exception(function() use ($asserter) { $asserter->hasSize(rand(0, PHP_INT_MAX)); })429 ->isInstanceOf('mageekguy\atoum\exceptions\logic')430 ->hasMessage('Array is undefined')431 ->if($asserter->setWith(array()))432 ->then433 ->exception(function() use ($asserter) { $asserter->hasKeys(array(0)); })434 ->isInstanceOf('mageekguy\atoum\asserter\exception')435 ->hasMessage(sprintf($generator->getLocale()->_('%s should have keys %s'), $asserter, $asserter->getTypeOf(array(0))))436 ->exception(function() use ($asserter, & $message) { $asserter->hasKeys(array(0), $message = uniqid()); })437 ->isInstanceOf('mageekguy\atoum\asserter\exception')438 ->hasMessage($message)439 ->if($asserter->setWith(array(uniqid(), uniqid(), uniqid(), uniqid(), uniqid())))440 ->then441 ->exception(function() use ($asserter) { $asserter->hasKeys(array(0, 'first', 2, 'second')); })442 ->isInstanceOf('mageekguy\atoum\asserter\exception')443 ->hasMessage(sprintf($generator->getLocale()->_('%s should have keys %s'), $asserter, $asserter->getTypeOf(array('first', 'second'))))444 ->exception(function() use ($asserter, & $message) { $asserter->hasKeys(array(0, 'first', 2, 'second'), $message = uniqid()); })445 ->isInstanceOf('mageekguy\atoum\asserter\exception')446 ->hasMessage($message)447 ->object($asserter->hasKeys(array(0, 2, 4)))->isIdenticalTo($asserter)448 ;449 }450}...
string.php
Source:string.php
...28 public function test__toString()29 {30 $this31 ->if($asserter = new testedClass($generator = new asserter\generator()))32 ->and($asserter->setWith($value = uniqid()))33 ->then34 ->castToString($asserter)->isEqualTo('string(' . strlen($value) . ') \'' . $value . '\'')35 ->if($asserter->setWith($value = "\010" . uniqid() . "\010", null, $charlist = "\010"))36 ->then37 ->castToString($asserter)->isEqualTo('string(' . strlen($value) . ') \'' . addcslashes($value, "\010") . '\'')38 ;39 }40 public function testSetWith()41 {42 $this43 ->if($asserter = new testedClass($generator = new asserter\generator()))44 ->then45 ->exception(function() use (& $line, $asserter, & $value) { $line = __LINE__; $asserter->setWith($value = rand(- PHP_INT_MAX, PHP_INT_MAX)); })46 ->isInstanceOf('mageekguy\atoum\asserter\exception')47 ->hasMessage(sprintf($generator->getLocale()->_('%s is not a string'), $asserter->getTypeOf($value)))48 ->integer($asserter->getValue())->isEqualTo($value)49 ->variable($asserter->getCharlist())->isNull()50 ->object($asserter->setWith($value = uniqid()))->isIdenticalTo($asserter)51 ->string($asserter->getValue())->isEqualTo($value)52 ->variable($asserter->getCharlist())->isNull()53 ->object($asserter->setWith($value = uniqid(), null, $charlist = "\010"))->isIdenticalTo($asserter)54 ->string($asserter->getValue())->isEqualTo($value)55 ->string($asserter->getCharlist())->isEqualTo($charlist)56 ;57 }58 public function testIsEqualTo()59 {60 $this61 ->if($asserter = new testedClass($generator = new asserter\generator()))62 ->then63 ->boolean($asserter->wasSet())->isFalse()64 ->exception(function() use ($asserter) { $asserter->isEqualTo(uniqid()); })65 ->isInstanceOf('mageekguy\atoum\exceptions\logic')66 ->hasMessage('Value is undefined')67 ->if($asserter->setWith($firstString = uniqid()))68 ->and($diff = new diffs\variable())69 ->then70 ->exception(function() use ($asserter, & $secondString) { $asserter->isEqualTo($secondString = uniqid()); })71 ->isInstanceOf('mageekguy\atoum\asserter\exception')72 ->hasMessage($generator->getLocale()->_('strings are not equals') . PHP_EOL . $diff->setReference($secondString)->setData($firstString))73 ->object($asserter->isEqualTo($firstString))->isIdenticalTo($asserter)74 ;75 }76 public function testIsEqualToFileContents()77 {78 $this79 ->if($asserter = new testedClass($generator = new asserter\generator(), $adapter = new atoum\test\adapter()))80 ->then81 ->boolean($asserter->wasSet())->isFalse()82 ->exception(function() use ($asserter) { $asserter->isEqualToContentsOfFile(uniqid()); })83 ->isInstanceOf('mageekguy\atoum\exceptions\logic')84 ->hasMessage('Value is undefined')85 ->if($asserter->setWith($firstString = uniqid()))86 ->and($adapter->file_get_contents = false)87 ->then88 ->exception(function() use ($asserter, & $path) { $asserter->isEqualToContentsOfFile($path = uniqid()); })89 ->isInstanceOf('mageekguy\atoum\asserter\exception')90 ->hasMessage(sprintf($generator->getLocale()->_('Unable to get contents of file %s'), $path))91 ->if($adapter->file_get_contents = $fileContents = uniqid())92 ->and($diff = new diffs\variable())93 ->then94 ->exception(function() use ($asserter, & $path) { $asserter->isEqualToContentsOfFile($path); })95 ->isInstanceOf('mageekguy\atoum\asserter\exception')96 ->hasMessage(sprintf($generator->getLocale()->_('string is not equals to contents of file %s'), $path) . PHP_EOL . $diff->setReference($fileContents)->setData($firstString))97 ->if($adapter->file_get_contents = $firstString)98 ->then99 ->object($asserter->isEqualToContentsOfFile(uniqid()))->isIdenticalTo($asserter)100 ;101 }102 public function testIsEmpty()103 {104 $this105 ->if($asserter = new testedClass($generator = new asserter\generator()))106 ->then107 ->exception(function() use ($asserter) { $asserter->isEmpty(); })108 ->isInstanceOf('mageekguy\atoum\exceptions\logic')109 ->hasMessage('Value is undefined')110 ->if($asserter->setWith($string = uniqid()))111 ->and($diff = new diffs\variable())112 ->then113 ->exception(function() use ($asserter) { $asserter->isEmpty(); })114 ->isInstanceOf('mageekguy\atoum\asserter\exception')115 ->hasMessage($generator->getLocale()->_('strings are not equals') . PHP_EOL . $diff->setReference('')->setData($string))116 ->if($asserter->setWith(''))117 ->then118 ->object($asserter->isEmpty())->isIdenticalTo($asserter)119 ;120 }121 public function testIsNotEmpty()122 {123 $this124 ->if($asserter = new testedClass($generator = new asserter\generator()))125 ->then126 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })127 ->isInstanceOf('mageekguy\atoum\exceptions\logic')128 ->hasMessage('Value is undefined')129 ->if($asserter->setWith(''))130 ->and($diff = new diffs\variable())131 ->then132 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })133 ->isInstanceOf('mageekguy\atoum\asserter\exception')134 ->hasMessage($generator->getLocale()->_('string is empty'))135 ->if($asserter->setWith($string = uniqid()))136 ->then137 ->object($asserter->isNotEmpty())->isIdenticalTo($asserter)138 ;139 }140 public function testHasLength()141 {142 $this143 ->if($asserter = new testedClass($generator = new asserter\generator()))144 ->then145 ->exception(function() use ($asserter) { $asserter->hasLength(rand(0, PHP_INT_MAX)); })146 ->isInstanceOf('mageekguy\atoum\exceptions\logic')147 ->hasMessage('Value is undefined')148 ->if($asserter->setWith(''))149 ->and($diff = new diffs\variable())150 ->then151 ->exception(function() use ($asserter, & $requiredLength) { $asserter->hasLength($requiredLength = rand(1, PHP_INT_MAX)); })152 ->isInstanceOf('mageekguy\atoum\asserter\exception')153 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not %d'), $asserter->getTypeOf(''), $requiredLength))154 ->object($asserter->hasLength(0))->isIdenticalTo($asserter)155 ->if($asserter->setWith($string = uniqid()))156 ->then157 ->object($asserter->hasLength(strlen($string)))->isIdenticalTo($asserter)158 ;159 }160 public function testHasLengthGreaterThan()161 {162 $this163 ->if($asserter = new testedClass($generator = new asserter\generator()))164 ->then165 ->exception(function() use ($asserter) { $asserter->hasLengthGreaterThan(rand(0, PHP_INT_MAX)); })166 ->isInstanceOf('mageekguy\atoum\exceptions\logic')167 ->hasMessage('Value is undefined')168 ->if($asserter->setWith('Chuck Norris'))169 ->and($diff = new diffs\variable())170 ->then171 ->exception(function() use ($asserter, & $requiredLength) { $asserter->hasLengthGreaterThan($requiredLength = rand(1, PHP_INT_MAX)); })172 ->isInstanceOf('mageekguy\atoum\asserter\exception')173 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not greater than %d'), $asserter->getTypeOf('Chuck Norris'), $requiredLength))174 ->object($asserter->hasLengthGreaterThan(0))->isIdenticalTo($asserter)175 ->if($asserter->setWith($string = uniqid()))176 ->then177 ->object($asserter->hasLengthGreaterThan(strlen($string)-1))->isIdenticalTo($asserter)178 ;179 }180 public function testHasLengthLessThan()181 {182 $this183 ->if($asserter = new testedClass($generator = new asserter\generator()))184 ->then185 ->exception(function() use ($asserter) { $asserter->hasLengthLessThan(rand(0, PHP_INT_MAX)); })186 ->isInstanceOf('mageekguy\atoum\exceptions\logic')187 ->hasMessage('Value is undefined')188 ->if($asserter->setWith('Chuck Norris'))189 ->and($diff = new diffs\variable())190 ->then191 ->exception(function() use ($asserter, & $requiredLength) { $asserter->hasLengthLessThan($requiredLength = 10); })192 ->isInstanceOf('mageekguy\atoum\asserter\exception')193 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not less than %d'), $asserter->getTypeOf('Chuck Norris'), $requiredLength))194 ->object($asserter->hasLengthLessThan(20))->isIdenticalTo($asserter)195 ->if($asserter->setWith($string = uniqid()))196 ->then197 ->object($asserter->hasLengthLessThan(strlen($string)+1))->isIdenticalTo($asserter)198 ;199 }200 public function testContains()201 {202 $this203 ->if($asserter = new testedClass($generator = new asserter\generator()))204 ->then205 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })206 ->isInstanceOf('mageekguy\atoum\exceptions\logic')207 ->hasMessage('Value is undefined')208 ->if($asserter->setWith($string = __METHOD__))209 ->and($diff = new diffs\variable())210 ->then211 ->exception(function() use ($asserter, & $fragment) { $asserter->contains($fragment = uniqid()); })212 ->isInstanceOf('mageekguy\atoum\asserter\exception')213 ->hasMessage(sprintf($this->getLocale()->_('String does not contain %s'), $fragment))214 ->object($asserter->contains($string))->isIdenticalTo($asserter)215 ->if($asserter->setWith(uniqid() . $string . uniqid()))216 ->then217 ->object($asserter->contains($string))->isIdenticalTo($asserter)218 ->exception(function() use ($asserter, $string, & $fragment) { $asserter->contains($fragment = strtoupper($string)); })219 ->isInstanceOf('mageekguy\atoum\asserter\exception')220 ->hasMessage(sprintf($this->getLocale()->_('String does not contain %s'), $fragment))221 ;222 }223}...
stream.php
Source:stream.php
...26 {27 $this28 ->if($asserter = new testedClass(new asserter\generator()))29 ->then30 ->object($asserter->setWith($stream = uniqid()))->isIdenticalTo($asserter)31 ->object($asserter->getStreamController())->isEqualTo(atoum\mock\stream::get($stream))32 ->if(atoum\mock\stream::get($stream = uniqid()))33 ->then34 ->object($asserter->setWith($stream))->isIdenticalTo($asserter)35 ->object($asserter->getStreamController())->isIdenticalTo(atoum\mock\stream::get($stream))36 ;37 }38 public function testIsRead()39 {40 $this41 ->if($asserter = new testedClass($generator = new asserter\generator()))42 ->then43 ->exception(function() use ($asserter) { $asserter->isRead(); })44 ->isInstanceOf('mageekguy\atoum\exceptions\logic')45 ->hasMessage('Stream is undefined')46 ->if($streamController = atoum\mock\stream::get($streamName = uniqid()))47 ->and($streamController->file_get_contents = uniqid())48 ->and($asserter->setWith($streamName))49 ->then50 ->exception(function() use ($asserter) { $asserter->isRead(); })51 ->isInstanceOf('mageekguy\atoum\asserter\exception')52 ->hasMessage($failMessage = sprintf($generator->getLocale()->_('stream %s is not read'), $streamController))53 ->when(function() use ($streamName) { file_get_contents('atoum://' . $streamName); })54 ->object($asserter->isRead())->isIdenticalTo($asserter)55 ;56 }57 public function testIsWrited()58 {59 $this60 ->if($asserter = new testedClass($generator = new asserter\generator()))61 ->then62 ->exception(function() use ($asserter) { $asserter->isWrited(); })63 ->isInstanceOf('mageekguy\atoum\exceptions\logic')64 ->hasMessage('Stream is undefined')65 ->if($streamController = atoum\mock\stream::get($streamName = uniqid()))66 ->and($streamController->file_put_contents = strlen($contents = uniqid()))67 ->and($asserter->setWith($streamName))68 ->then69 ->exception(function() use ($asserter) { $asserter->isWrited(); })70 ->isInstanceOf('mageekguy\atoum\asserter\exception')71 ->hasMessage($failMessage = sprintf($generator->getLocale()->_('stream %s is not writed'), $streamController))72 ->when(function() use ($streamName, $contents) { file_put_contents('atoum://' . $streamName, $contents); })73 ->object($asserter->isWrited())->isIdenticalTo($asserter)74 ->if($streamController = atoum\mock\stream::get(uniqid()))75 ->and($streamController->file_put_contents = strlen($contents = uniqid()))76 ->and($asserter->setWith($streamController))77 ->then78 ->exception(function() use ($asserter) { $asserter->isWrited(); })79 ->isInstanceOf('mageekguy\atoum\asserter\exception')80 ->hasMessage($failMessage = sprintf($generator->getLocale()->_('stream %s is not writed'), $streamController))81 ->when(function() use ($streamController, $contents) { file_put_contents($streamController, $contents); })82 ->object($asserter->isWrited())->isIdenticalTo($asserter)83 ;84 }85}...
setWith
Using AI Code Generation
1$testedClass = new testedClass();2$testedClass->setWith($value);3$testedClass = new testedClass();4$testedClass->setWith($value);5$testedClass = new testedClass();6$testedClass->setWith($value);7$testedClass = new testedClass();8$testedClass->setWith($value);9$testedClass = new testedClass();10$testedClass->setWith($value);11$testedClass = new testedClass();12$testedClass->setWith($value);13$testedClass = new testedClass();14$testedClass->setWith($value);15$testedClass = new testedClass();16$testedClass->setWith($value);17$testedClass = new testedClass();18$testedClass->setWith($value);19$testedClass = new testedClass();20$testedClass->setWith($value);
setWith
Using AI Code Generation
1$testedClass = new testedClass();2$testedClass->setWith('1');3$testedClass = new testedClass();4$testedClass->setWith('2');5$testedClass = new testedClass();6$testedClass->setWith('3');7$testedClass = new testedClass();8$testedClass->setWith('4');9$testedClass = new testedClass();10$testedClass->setWith('5');11$testedClass = new testedClass();12$testedClass->setWith('6');13$testedClass = new testedClass();14$testedClass->setWith('7');15$testedClass = new testedClass();16$testedClass->setWith('8');17$testedClass = new testedClass();18$testedClass->setWith('9');19$testedClass = new testedClass();20$testedClass->setWith('10');21$testedClass = new testedClass();22$testedClass->setWith('11');23$testedClass = new testedClass();24$testedClass->setWith('12');25$testedClass = new testedClass();26$testedClass->setWith('13');27$testedClass = new testedClass();28$testedClass->setWith('14');
setWith
Using AI Code Generation
1$testedClass = new testedClass();2$testedClass->setWith('1', '2', '3');3$testedClass = new testedClass();4$testedClass->setWith('4', '5', '6');5$testedClass = new testedClass();6$testedClass->setWith('7', '8', '9');7$testedClass = new testedClass();8$testedClass->setWith('10', '11', '12');9$testedClass = new testedClass();10$testedClass->setWith('13', '14', '15');11$testedClass = new testedClass();12$testedClass->setWith('16', '17', '18');13$testedClass = new testedClass();14$testedClass->setWith('19', '20', '21');15$testedClass = new testedClass();16$testedClass->setWith('22', '23', '24');17$testedClass = new testedClass();18$testedClass->setWith('25', '26', '27');19$testedClass = new testedClass();20$testedClass->setWith('28', '29', '30');21$testedClass = new testedClass();22$testedClass->setWith('31', '32', '33');23$testedClass = new testedClass();24$testedClass->setWith('34', '35', '36');
setWith
Using AI Code Generation
1$testedClass->setWith('test');2$testedClass->setWith('test2');3$testedClass->setWith('test3');4$testedClass->setWith('test4');5$testedClass->setWith('test5');6$testedClass->setWith('test6');7$testedClass->setWith('test7');8$testedClass->setWith('test8');9$testedClass->setWith('test9');10$testedClass->setWith('test10');11$testedClass->setWith('test11');12$testedClass->setWith('test12');13$testedClass->setWith('test13');14$testedClass->setWith('test14');15$testedClass->setWith('test15');16$testedClass->setWith('test16');17$testedClass->setWith('test17');18$testedClass->setWith('test18');19$testedClass->setWith('test19');20$testedClass->setWith('test20');21$testedClass->setWith('test21');22$testedClass->setWith('test22');23$testedClass->setWith('test23');
setWith
Using AI Code Generation
1$testedClass = new testedClass();2$testedClass->setWith('test');3$testedClass = new testedClass();4$testedClass->setWith('test');5$testedClass = new testedClass();6$testedClass->setWith('test');7$testedClass = new testedClass();8$testedClass->setWith('test');9$testedClass = new testedClass();10$testedClass->setWith('test');11$testedClass = new testedClass();12$testedClass->setWith('test');13$testedClass = new testedClass();14$testedClass->setWith('test');15$testedClass = new testedClass();16$testedClass->setWith('test');17$testedClass = new testedClass();18$testedClass->setWith('test');19$testedClass = new testedClass();20$testedClass->setWith('test');21$testedClass = new testedClass();22$testedClass->setWith('test');
setWith
Using AI Code Generation
1$testedObject = new testedClass();2$testedObject->setWith(array('foo' => 'bar'));3$testedObject = new testedClass();4$testedObject->setWith(array('foo' => 'bar'));5$testedObject = new testedClass();6$testedObject->setWith(array('foo' => 'bar'));7$testedObject = new testedClass();8$testedObject->setWith(array('foo' => 'bar'));9$testedObject = new testedClass();10$testedObject->setWith(array('foo' => 'bar'));11$testedObject = new testedClass();12$testedObject->setWith(array('foo' => 'bar'));13$testedObject = new testedClass();14$testedObject->setWith(array('foo' => 'bar'));15$testedObject = new testedClass();16$testedObject->setWith(array('foo' => 'bar'));17$testedObject = new testedClass();18$testedObject->setWith(array('foo' => 'bar'));19$testedObject = new testedClass();20$testedObject->setWith(array('foo' => 'bar'));21$testedObject = new testedClass();22$testedObject->setWith(array('foo' => 'bar'));23$testedObject = new testedClass();24$testedObject->setWith(array('foo' => 'bar'));
setWith
Using AI Code Generation
1$testedClass = new testedClass();2$testedClass->setWith($value);3$testedClass->getWith();4$testedClass->setWith($value);5$testedClass->getWith();6$testedClass->setWith($value);7$testedClass->getWith();
setWith
Using AI Code Generation
1$testedClass = new testedClass();2$testedClass->setWith('test');3$this->assertEquals('test', $testedClass->getWith());4}5public function testDataProvider($a, $b, $expected)6{7 $this->assertEquals($expected, $a + $b);8}9public static function dataProvider()10{11 return array(12 array(0, 0, 0),13 array(0, 1, 1),14 array(1, 0, 1),15 array(1, 1, 3),16 );17}18assertEquals($expected, $actual, $message = '');19assertNotEquals($expected, $actual, $message = '');
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
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 FreeGet 100 minutes of automation test minutes FREE!!