How to use isEqualTo method of call class

Best Atoum code snippet using call.isEqualTo

controller.php

Source:controller.php Github

copy

Full Screen

...18 ->if($controller = new testedClass(uniqid()))19 ->then20 ->string($controller->getContents())->isEmpty()21 ->integer($controller->getPointer())->isZero()22 ->integer($controller->getPermissions())->isEqualTo(644)23 ->boolean($controller->stream_eof())->isFalse()24 ->array($controller->stream_stat())->isNotEmpty()25 ;26 }27 public function test__set()28 {29 $this30 ->if($controller = new testedClass(uniqid()))31 ->and($controller->stream_open = false)32 ->then33 ->boolean($controller->stream_open(uniqid(), 'r', uniqid()))->isFalse()34 ->exception(function() use ($controller) { $controller->mkdir = true; })35 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')36 ->hasMessage('Unable to override streamWrapper::mkdir() for file')37 ;38 }39 public function testDuplicate()40 {41 $this42 ->if($controller = new testedClass(uniqid()))43 ->then44 ->object($duplicatedController = $controller->duplicate())->isEqualTo($controller)45 ->if($controller->setPath($path = uniqid()))46 ->then47 ->string($duplicatedController->getPath())->isEqualTo($path)48 ->if($controller->stream_lock(LOCK_SH))49 ->then50 ->object($duplicatedController->getCalls())->isEqualTo($controller->getCalls())51 ->if($controller->stream_lock = function() {})52 ->then53 ->array($duplicatedController->getInvokers())->isEqualTo($controller->getInvokers())54 ->if($controller->setContents(uniqid()))55 ->then56 ->string($duplicatedController->getContents())->isEqualTo($controller->getContents())57 ->if($controller->isNotReadable())58 ->and($controller->isNotWritable())59 ->and($controller->isNotExecutable())60 ->then61 ->integer($duplicatedController->getPermissions())->isEqualTo($controller->getPermissions())62 ->if($controller->notExists())63 ->then64 ->boolean($duplicatedController->stream_stat())->isEqualTo($controller->stream_stat())65 ;66 }67 public function testContains()68 {69 $this70 ->if($controller = new testedClass(uniqid()))71 ->then72 ->object($controller->contains('abcdefghijklmnopqrstuvwxyz'))->isIdenticalTo($controller)73 ->if($controller->stream_open(uniqid(), 'r', 0))74 ->then75 ->string($controller->stream_read(1))->isEqualTo('a')76 ->boolean($controller->stream_eof())->isFalse()77 ->string($controller->stream_read(1))->isEqualTo('b')78 ->boolean($controller->stream_eof())->isFalse()79 ->string($controller->stream_read(2))->isEqualTo('cd')80 ->boolean($controller->stream_eof())->isFalse()81 ->string($controller->stream_read(4096))->isEqualTo('efghijklmnopqrstuvwxyz')82 ->boolean($controller->stream_eof())->isFalse()83 ->string($controller->stream_read(1))->isEmpty()84 ->boolean($controller->stream_eof())->isTrue()85 ;86 }87 public function testIsEmpty()88 {89 $this90 ->if($controller = new testedClass(uniqid()))91 ->and($controller->contains('abcdefghijklmnopqrstuvwxyz'))92 ->then93 ->object($controller->isEmpty())->isIdenticalTo($controller)94 ->string($controller->getContents())->isEmpty()95 ;96 }97 public function testExists()98 {99 $this100 ->if($controller = new testedClass(uniqid()))101 ->then102 ->object($controller->exists())->isIdenticalTo($controller)103 ->array($controller->stream_stat())->isNotEmpty()104 ->if($controller->notExists())105 ->then106 ->object($controller->exists())->isIdenticalTo($controller)107 ->array($controller->stream_stat())->isNotEmpty()108 ;109 }110 public function testNotExists()111 {112 $this113 ->if($controller = new testedClass(uniqid()))114 ->then115 ->object($controller->notExists())->isIdenticalTo($controller)116 ->boolean($controller->stream_stat())->isFalse()117 ;118 }119 public function testIsNotReadable()120 {121 $this122 ->if($controller = new testedClass(uniqid()))123 ->then124 ->object($controller->isNotReadable())->isIdenticalTo($controller)125 ->integer($controller->getPermissions())->isEqualTo(200)126 ->object($controller->isNotReadable())->isIdenticalTo($controller)127 ->integer($controller->getPermissions())->isEqualTo(200)128 ;129 }130 public function testIsReadable()131 {132 $this133 ->if($controller = new testedClass(uniqid()))134 ->then135 ->object($controller->isReadable())->isIdenticalTo($controller)136 ->integer($controller->getPermissions())->isEqualTo(644)137 ->object($controller->isReadable())->isIdenticalTo($controller)138 ->integer($controller->getPermissions())->isEqualTo(644)139 ->if($controller->isNotReadable())140 ->then141 ->object($controller->isReadable())->isIdenticalTo($controller)142 ->integer($controller->getPermissions())->isEqualTo(644)143 ->object($controller->isReadable())->isIdenticalTo($controller)144 ->integer($controller->getPermissions())->isEqualTo(644)145 ;146 }147 public function testIsNotWritable()148 {149 $this150 ->if($controller = new testedClass(uniqid()))151 ->then152 ->object($controller->isNotWritable())->isIdenticalTo($controller)153 ->integer($controller->getPermissions())->isEqualTo(444)154 ->object($controller->isNotWritable())->isIdenticalTo($controller)155 ->integer($controller->getPermissions())->isEqualTo(444)156 ;157 }158 public function testIsWritable()159 {160 $this161 ->if($controller = new testedClass(uniqid()))162 ->and($controller->isNotWritable())163 ->then164 ->object($controller->isWritable())->isIdenticalTo($controller)165 ->integer($controller->getPermissions())->isEqualTo(666)166 ->object($controller->isWritable())->isIdenticalTo($controller)167 ->integer($controller->getPermissions())->isEqualTo(666)168 ;169 }170 public function testIsExecutable()171 {172 $this173 ->if($controller = new testedClass(uniqid()))174 ->then175 ->object($controller->isExecutable())->isIdenticalTo($controller)176 ->integer($controller->getPermissions())->isEqualTo(755)177 ->object($controller->isExecutable())->isIdenticalTo($controller)178 ->integer($controller->getPermissions())->isEqualTo(755)179 ;180 }181 public function testIsNotExecutable()182 {183 $this184 ->if($controller = new testedClass(uniqid()))185 ->and($controller->isExecutable())186 ->then187 ->object($controller->isNotExecutable())->isIdenticalTo($controller)188 ->integer($controller->getPermissions())->isEqualTo(644)189 ->object($controller->isNotExecutable())->isIdenticalTo($controller)190 ->integer($controller->getPermissions())->isEqualTo(644)191 ;192 }193 public function testStreamOpen()194 {195 $this196 ->assert('Use r and r+ mode')197 ->if($controller = new testedClass(uniqid()))198 ->and($controller->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))199 ->and($usePath = null)200 ->then201 ->boolean($controller->stream_open($path = uniqid(), 'z', 0))->isFalse()202 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'z', 0)))->once()203 ->boolean($controller->stream_open($path = uniqid(), 'z', STREAM_REPORT_ERRORS))->isFalse()204 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'z', STREAM_REPORT_ERRORS)))->once()205 ->error('Operation timed out', E_USER_WARNING)->exists()206 ->boolean($controller->stream_open($path = uniqid(), 'r', 0))->isTrue()207 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', 0)))->once()208 ->integer($controller->stream_tell())->isZero()209 ->string($controller->stream_read(1))->isEmpty()210 ->integer($controller->stream_write('a'))->isZero()211 ->boolean($controller->stream_open($path = uniqid(), 'r+', 0))->isTrue()212 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', 0)))->once()213 ->integer($controller->stream_tell())->isZero()214 ->string($controller->stream_read(1))->isEmpty()215 ->integer($controller->stream_write('a'))->isEqualTo(1)216 ->boolean($controller->stream_open($path = uniqid(), 'r', STREAM_USE_PATH, $usePath))->isTrue()217 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', STREAM_USE_PATH, null)))->once()218 ->string($usePath)->isEqualTo($controller->getPath())219 ->boolean($controller->stream_open($path = uniqid(), 'r+', STREAM_USE_PATH, $usePath))->isTrue()220 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', STREAM_USE_PATH, $usePath)))->once()221 ->string($usePath)->isEqualTo($controller->getPath())222 ->if($controller->setContents('abcdefghijklmnopqrstuvwxyz'))223 ->and($usePath = null)224 ->then225 ->boolean($controller->stream_open($path = uniqid(), 'r', 0))->isTrue()226 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', 0)))->once()227 ->integer($controller->stream_tell())->isZero()228 ->string($controller->stream_read(1))->isEqualTo('a')229 ->integer($controller->stream_write('a'))->isZero()230 ->boolean($controller->stream_open($path = uniqid(), 'r+', 0))->isTrue()231 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', 0)))->once()232 ->integer($controller->stream_tell())->isZero()233 ->string($controller->stream_read(1))->isEqualTo('a')234 ->integer($controller->stream_write('a'))->isEqualTo(1)235 ->boolean($controller->stream_open($path = uniqid(), 'r', STREAM_USE_PATH, $usePath))->isTrue()236 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', STREAM_USE_PATH, null)))->once()237 ->string($usePath)->isEqualTo($controller->getPath())238 ->boolean($controller->stream_open($path = uniqid(), 'r+', STREAM_USE_PATH, $usePath))->isTrue()239 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', STREAM_USE_PATH, $usePath)))->once()240 ->string($usePath)->isEqualTo($controller->getPath())241 ->if($controller->notExists())242 ->and($usePath = null)243 ->then244 ->boolean($controller->stream_open($path = uniqid(), 'r', 0))->isFalse()245 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', 0)))->once()246 ->boolean($controller->stream_open($path = uniqid(), 'r+', 0))->isFalse()247 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', 0)))->once()248 ->boolean($controller->stream_open($path = uniqid(), 'r', STREAM_REPORT_ERRORS))->isFalse()249 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', STREAM_REPORT_ERRORS)))->once()250 ->error('No such file or directory', E_USER_WARNING)->exists()251 ->boolean($controller->stream_open($path = uniqid(), 'r+', STREAM_REPORT_ERRORS))->isFalse()252 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', STREAM_REPORT_ERRORS)))->once()253 ->error('No such file or directory', E_USER_WARNING)->exists()254 ->boolean($controller->stream_open($path = uniqid(), 'r+', 0))->isFalse()255 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', 0)))->once()256 ->boolean($controller->stream_open($path = uniqid(), 'r', STREAM_USE_PATH, $usePath))->isFalse()257 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', STREAM_USE_PATH, null)))->once()258 ->variable($usePath)->isNull()259 ->boolean($controller->stream_open($path = uniqid(), 'r+', STREAM_USE_PATH, $usePath))->isFalse()260 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', STREAM_USE_PATH, null)))->once()261 ->variable($usePath)->isNull()262 ->if($controller->exists())263 ->and($controller->isNotReadable())264 ->and($usePath = null)265 ->then266 ->boolean($controller->stream_open($path = uniqid(), 'r', 0))->isFalse()267 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', 0)))->once()268 ->boolean($controller->stream_open($path = uniqid(), 'r+', 0))->isFalse()269 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', 0)))->once()270 ->boolean($controller->stream_open($path = uniqid(), 'r', STREAM_REPORT_ERRORS))->isFalse()271 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', STREAM_REPORT_ERRORS)))->once()272 ->error('Permission denied', E_USER_WARNING)->exists()273 ->boolean($controller->stream_open($path = uniqid(), 'r+', STREAM_REPORT_ERRORS))->isFalse()274 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', STREAM_REPORT_ERRORS)))->once()275 ->error('Permission denied', E_USER_WARNING)->exists()276 ->boolean($controller->stream_open($path = uniqid(), 'r', STREAM_USE_PATH, $usePath))->isFalse()277 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', STREAM_USE_PATH, null)))->once()278 ->variable($usePath)->isNull()279 ->boolean($controller->stream_open($path = uniqid(), 'r+', STREAM_USE_PATH, $usePath))->isFalse()280 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', STREAM_USE_PATH, null)))->once()281 ->variable($usePath)->isNull()282 ->if($controller->isReadable())283 ->and($controller->isNotWritable())284 ->and($usePath = null)285 ->boolean($controller->stream_open($path = uniqid(), 'r', 0))->isTrue()286 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', 0)))->once()287 ->boolean($controller->stream_open($path = uniqid(), 'r+', 0))->isFalse()288 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', 0)))->once()289 ->boolean($controller->stream_open($path = uniqid(), 'r+', STREAM_REPORT_ERRORS))->isFalse()290 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', STREAM_REPORT_ERRORS)))->once()291 ->error('Permission denied', E_USER_WARNING)->exists()292 ->boolean($controller->stream_open($path = uniqid(), 'r', STREAM_USE_PATH, $usePath))->isTrue()293 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r', STREAM_USE_PATH, null)))->once()294 ->string($usePath)->isEqualTo($controller->getPath())295 ->if($oldUsePath = $usePath)296 ->then297 ->boolean($controller->stream_open($path = uniqid(), 'r+', STREAM_USE_PATH, $usePath))->isFalse()298 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'r+', STREAM_USE_PATH, $oldUsePath)))->once()299 ->variable($usePath)->isNull()300 ->assert('Use w and w+ mode')301 ->if($controller = new testedClass(uniqid()))302 ->and($controller->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))303 ->and($usePath = null)304 ->then305 ->boolean($controller->stream_open($path = uniqid(), 'w', 0))->isTrue()306 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w', 0)))->once()307 ->integer($controller->stream_tell())->isZero()308 ->string($controller->stream_read(1))->isEmpty()309 ->integer($controller->stream_write('a'))->isEqualTo(1)310 ->boolean($controller->stream_open($path = uniqid(), 'w+', 0))->isTrue()311 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w+', 0)))->once()312 ->integer($controller->stream_tell())->isZero()313 ->string($controller->stream_read(1))->isEmpty()314 ->integer($controller->stream_write('a'))->isEqualTo(1)315 ->boolean($controller->stream_open($path = uniqid(), 'w', STREAM_USE_PATH, $usePath))->isTrue()316 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w', STREAM_USE_PATH, null)))->once()317 ->string($usePath)->isEqualTo($controller->getPath())318 ->boolean($controller->stream_open($path = uniqid(), 'w+', STREAM_USE_PATH, $usePath))->isTrue()319 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w+', STREAM_USE_PATH, $usePath)))->once()320 ->string($usePath)->isEqualTo($controller->getPath())321 ->if($controller->setContents('abcdefghijklmnopqrstuvwxyz'))322 ->then323 ->boolean($controller->stream_open($path = uniqid(), 'w', 0))->isTrue()324 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w', 0)))->once()325 ->integer($controller->stream_tell())->isZero()326 ->string($controller->stream_read(1))->isEmpty()327 ->integer($controller->stream_write('a'))->isEqualTo(1)328 ->boolean($controller->stream_open($path = uniqid(), 'w+', 0))->isTrue()329 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w+', 0)))->once()330 ->integer($controller->stream_tell())->isZero()331 ->string($controller->stream_read(1))->isEmpty()332 ->integer($controller->stream_write('a'))->isEqualTo(1)333 ->if($controller->notExists())334 ->then335 ->boolean($controller->stream_open($path = uniqid(), 'w', 0))->isTrue()336 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w', 0)))->once()337 ->integer($controller->getPermissions())->isEqualTo(644)338 ->if($controller->notExists())339 ->then340 ->boolean($controller->stream_open($path = uniqid(), 'w+', 0))->isTrue()341 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w+', 0)))->once()342 ->integer($controller->getPermissions())->isEqualTo(644)343 ->if($controller->exists())344 ->and($controller->isNotWritable())345 ->then346 ->boolean($controller->stream_open($path = uniqid(), 'w', 0))->isFalse()347 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w', 0)))->once()348 ->boolean($controller->stream_open($path = uniqid(), 'w', STREAM_REPORT_ERRORS))->isFalse()349 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w', STREAM_REPORT_ERRORS)))->once()350 ->error('Permission denied', E_USER_WARNING)->exists()351 ->boolean($controller->stream_open($path = uniqid(), 'w+', 0))->isFalse()352 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w+', 0)))->once()353 ->boolean($controller->stream_open($path = uniqid(), 'w+', STREAM_REPORT_ERRORS))->isFalse()354 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'w+', STREAM_REPORT_ERRORS)))->once()355 ->error('Permission denied', E_USER_WARNING)->exists()356 ->assert('Use c and c+ mode')357 ->if($controller = new testedClass(uniqid()))358 ->and($controller->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))359 ->and($usePath = null)360 ->then361 ->boolean($controller->stream_open($path = uniqid(), 'c', 0))->isTrue()362 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c', 0)))->once()363 ->integer($controller->stream_tell())->isZero()364 ->string($controller->stream_read(1))->isEmpty()365 ->integer($controller->stream_write('a'))->isEqualTo(1)366 ->boolean($controller->stream_open($path = uniqid(), 'c+', 0))->isTrue()367 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c+', 0)))->once()368 ->integer($controller->stream_tell())->isZero()369 ->string($controller->stream_read(1))->isEqualTo('a')370 ->integer($controller->stream_write('a'))->isEqualTo(1)371 ->boolean($controller->stream_open($path = uniqid(), 'c', STREAM_USE_PATH, $usePath))->isTrue()372 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c', STREAM_USE_PATH, null)))->once()373 ->string($usePath)->isEqualTo($controller->getPath())374 ->boolean($controller->stream_open($path = uniqid(), 'c+', STREAM_USE_PATH, $usePath))->isTrue()375 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c+', STREAM_USE_PATH, $usePath)))->once()376 ->string($usePath)->isEqualTo($controller->getPath())377 ->if($controller->setContents('abcdefghijklmnopqrstuvwxyz'))378 ->then379 ->boolean($controller->stream_open($path = uniqid(), 'c', 0))->isTrue()380 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c', 0)))->once()381 ->integer($controller->stream_tell())->isZero()382 ->string($controller->stream_read(1))->isEmpty()383 ->integer($controller->stream_write('a'))->isEqualTo(1)384 ->boolean($controller->stream_open($path = uniqid(), 'c+', 0))->isTrue()385 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c+', 0)))->once()386 ->integer($controller->stream_tell())->isZero()387 ->string($controller->stream_read(1))->isEqualTo('a')388 ->integer($controller->stream_write('a'))->isEqualTo(1)389 ->if($controller->notExists())390 ->then391 ->boolean($controller->stream_open($path = uniqid(), 'c', 0))->isTrue()392 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c', 0)))->once()393 ->integer($controller->getPermissions())->isEqualTo(644)394 ->if($controller->notExists())395 ->then396 ->boolean($controller->stream_open($path = uniqid(), 'c+', 0))->isTrue()397 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c+', 0)))->once()398 ->integer($controller->getPermissions())->isEqualTo(644)399 ->if($controller->exists())400 ->and($controller->isNotWritable())401 ->then402 ->boolean($controller->stream_open($path = uniqid(), 'c', 0))->isFalse()403 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c', 0)))->once()404 ->boolean($controller->stream_open($path = uniqid(), 'c', STREAM_REPORT_ERRORS))->isFalse()405 ->error('Permission denied', E_USER_WARNING)->exists()406 ->boolean($controller->stream_open($path = uniqid(), 'c+', 0))->isFalse()407 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c+', 0)))->once()408 ->boolean($controller->stream_open($path = uniqid(), 'c+', STREAM_REPORT_ERRORS))->isFalse()409 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'c+', STREAM_REPORT_ERRORS)))->once()410 ->error('Permission denied', E_USER_WARNING)->exists()411 ->assert('Use a and a+ mode')412 ->if($controller = new testedClass(uniqid()))413 ->and($controller->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))414 ->then415 ->boolean($controller->stream_open($path = uniqid(), 'a', 0))->isTrue()416 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a', 0)))->once()417 ->integer($controller->stream_tell())->isZero()418 ->string($controller->stream_read(1))->isEmpty()419 ->integer($controller->stream_write('a'))->isEqualTo(1)420 ->string($controller->getContents())->isEqualTo('a')421 ->integer($controller->stream_write('b'))->isEqualTo(1)422 ->string($controller->getContents())->isEqualTo('ab')423 ->boolean($controller->stream_open($path = uniqid(), 'a', 0))->isTrue()424 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a', 0)))->once()425 ->integer($controller->stream_tell())->isZero()426 ->string($controller->stream_read(1))->isEmpty()427 ->integer($controller->stream_write('c'))->isEqualTo(1)428 ->string($controller->getContents())->isEqualTo('ab' . PHP_EOL . 'c')429 ->integer($controller->stream_write('d'))->isEqualTo(1)430 ->string($controller->getContents())->isEqualTo('ab' . PHP_EOL . 'cd')431 ->boolean($controller->stream_open($path = uniqid(), 'a+', 0))->isTrue()432 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a+', 0)))->once()433 ->integer($controller->stream_tell())->isZero()434 ->string($controller->stream_read(1))->isEqualTo('a')435 ->integer($controller->stream_write('e'))->isEqualTo(1)436 ->string($controller->getContents())->isEqualTo('ab' . PHP_EOL . 'cd' . PHP_EOL . 'e')437 ->if($controller->setContents('abcdefghijklmnopqrstuvwxyz'))438 ->then439 ->boolean($controller->stream_open($path = uniqid(), 'a', 0))->isTrue()440 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a', 0)))->once()441 ->integer($controller->stream_tell())->isZero()442 ->string($controller->stream_read(1))->isEmpty()443 ->integer($controller->stream_write('A'))->isEqualTo(1)444 ->string($controller->getContents())->isEqualTo('abcdefghijklmnopqrstuvwxyz' . PHP_EOL . 'A')445 ->boolean($controller->stream_open($path = uniqid(), 'a+', 0))->isTrue()446 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a+', 0)))->once()447 ->integer($controller->stream_tell())->isZero()448 ->string($controller->stream_read(1))->isEqualTo('a')449 ->integer($controller->stream_write('B'))->isEqualTo(1)450 ->string($controller->getContents())->isEqualTo('abcdefghijklmnopqrstuvwxyz' . PHP_EOL . 'A' . PHP_EOL . 'B')451 ->integer($controller->stream_write('C'))->isEqualTo(1)452 ->string($controller->getContents())->isEqualTo('abcdefghijklmnopqrstuvwxyz' . PHP_EOL . 'A' . PHP_EOL . 'BC')453 ->if($controller->notExists())454 ->then455 ->boolean($controller->stream_open($path = uniqid(), 'a', 0))->isTrue()456 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a', 0)))->once()457 ->integer($controller->getPermissions())->isEqualTo(644)458 ->if($controller->notExists())459 ->then460 ->boolean($controller->stream_open($path = uniqid(), 'a+', 0))->isTrue()461 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a+', 0)))->once()462 ->integer($controller->getPermissions())->isEqualTo(644)463 ->if($controller->exists())464 ->and($controller->isNotWritable())465 ->then466 ->boolean($controller->stream_open($path = uniqid(), 'a', 0))->isFalse()467 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a', 0)))->once()468 ->integer($controller->stream_tell())->isZero()469 ->boolean($controller->stream_open($path = uniqid(), 'a+', 0))->isFalse()470 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a+', 0)))->once()471 ->if($controller = new testedClass(uniqid()))472 ->and($controller->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))473 ->and($controller->isWritable())474 ->and($controller->isNotReadable())475 ->then476 ->boolean($controller->stream_open($path = uniqid(), 'a', 0))->isTrue()477 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a', 0)))->once()478 ->integer($controller->stream_tell())->isZero()479 ->boolean($controller->stream_open($path = uniqid(), 'a+', 0))->isFalse()480 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a+', 0)))->once()481 ->boolean($controller->stream_open($path = uniqid(), 'a+', STREAM_REPORT_ERRORS))->isFalse()482 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'a+', STREAM_REPORT_ERRORS)))->once()483 ->error('Permission denied', E_USER_WARNING)->exists()484 ->assert('Use x and x+ mode')485 ->if($controller = new testedClass(uniqid()))486 ->and($controller->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))487 ->then488 ->boolean($controller->stream_open($path = uniqid(), 'x', 0))->isFalse()489 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x', 0)))->once()490 ->integer($controller->stream_tell())->isZero()491 ->boolean($controller->stream_open($path = uniqid(), 'x', STREAM_REPORT_ERRORS))->isFalse()492 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x', STREAM_REPORT_ERRORS)))->once()493 ->error('File exists', E_USER_WARNING)->exists()494 ->boolean($controller->stream_open($path = uniqid(), 'x+', 0))->isFalse()495 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', 0)))->once()496 ->boolean($controller->stream_open($path = uniqid(), 'x+', STREAM_REPORT_ERRORS))->isFalse()497 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', STREAM_REPORT_ERRORS)))->once()498 ->error('File exists', E_USER_WARNING)->exists()499 ->if($controller->notExists())500 ->then501 ->boolean($controller->stream_open($path = uniqid(), 'x', 0))->isTrue()502 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x', 0)))->once()503 ->integer($controller->stream_tell())->isZero()504 ->string($controller->stream_read(1))->isEmpty()505 ->integer($controller->stream_write('a'))->isEqualTo(0)506 ->boolean($controller->stream_open($path = uniqid(), 'x+', 0))->isTrue()507 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', 0)))->once()508 ->integer($controller->stream_tell())->isZero()509 ->string($controller->stream_read(1))->isEmpty()510 ->integer($controller->stream_write('a'))->isEqualTo(1)511 ->if($controller->setContents('abcdefghijklmnopqrstuvwxyz'))512 ->then513 ->boolean($controller->stream_open($path = uniqid(), 'x', 0))->isTrue()514 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x', 0)))->once()515 ->integer($controller->stream_tell())->isZero()516 ->string($controller->stream_read(1))->isEqualTo('a')517 ->integer($controller->stream_write('a'))->isEqualTo(0)518 ->boolean($controller->stream_open($path = uniqid(), 'x+', 0))->isTrue()519 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', 0)))->once()520 ->integer($controller->stream_tell())->isZero()521 ->string($controller->stream_read(1))->isEqualTo('a')522 ->integer($controller->stream_write('a'))->isEqualTo(1)523 ->if($controller->isNotReadable())524 ->then525 ->boolean($controller->stream_open($path = uniqid(), 'x', 0))->isFalse()526 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x', 0)))->once()527 ->boolean($controller->stream_open($path = uniqid(), 'x', STREAM_REPORT_ERRORS))->isFalse()528 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x', STREAM_REPORT_ERRORS)))->once()529 ->error('Permission denied', E_USER_WARNING)->exists()530 ->boolean($controller->stream_open($path = uniqid(), 'x+', 0))->isFalse()531 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', 0)))->once()532 ->boolean($controller->stream_open($path = uniqid(), 'x+', STREAM_REPORT_ERRORS))->isFalse()533 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', STREAM_REPORT_ERRORS)))->once()534 ->error('Permission denied', E_USER_WARNING)->exists()535 ->if($controller->isReadable())536 ->and($controller->isNotWritable())537 ->then538 ->boolean($controller->stream_open($path = uniqid(), 'x', 0))->isTrue()539 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x', 0)))->once()540 ->boolean($controller->stream_open($path = uniqid(), 'x+', 0))->isFalse()541 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', 0)))->once()542 ->boolean($controller->stream_open($path = uniqid(), 'x+', STREAM_REPORT_ERRORS))->isFalse()543 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', STREAM_REPORT_ERRORS)))->once()544 ->error('Permission denied', E_USER_WARNING)->exists()545 ->if($controller->stream_open = false)546 ->then547 ->boolean($controller->stream_open($path = uniqid(), 'x', 0))->isFalse()548 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x', 0)))->once()549 ->boolean($controller->stream_open($path = uniqid(), 'x+', 0))->isFalse()550 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', 0)))->once()551 ->boolean($controller->stream_open($path = uniqid(), 'x+', STREAM_REPORT_ERRORS))->isFalse()552 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call('stream_open', array($path, 'x+', STREAM_REPORT_ERRORS)))->once()553 ->error('Permission denied', E_USER_WARNING)->notExists()554 ;555 }556 public function testStreamSeek()557 {558 $this559 ->if($controller = new testedClass(uniqid()))560 ->then561 ->boolean($controller->stream_seek(0))->isTrue()562 ->boolean($controller->stream_seek(1))->isTrue()563 ->if($controller->contains('abcdefghijklmnopqrstuvwxyz'))564 ->and($controller->stream_open(uniqid(), 'r', 0))565 ->then566 ->boolean($controller->stream_seek(0))->isTrue()567 ->boolean($controller->stream_seek(1))->isTrue()568 ->string($controller->stream_read(1))->isEqualTo('b')569 ->boolean($controller->stream_seek(25))->isTrue()570 ->string($controller->stream_read(1))->isEqualTo('z')571 ->boolean($controller->stream_seek(26))->isTrue()572 ->string($controller->stream_read(1))->isEmpty()573 ->boolean($controller->stream_seek(0))->isTrue()574 ->string($controller->stream_read(1))->isEqualTo('a')575 ->boolean($controller->stream_seek(-1, SEEK_END))->isTrue()576 ->string($controller->stream_read(1))->isEqualTo('z')577 ->boolean($controller->stream_seek(-26, SEEK_END))->isTrue()578 ->string($controller->stream_read(1))->isEqualTo('a')579 ->boolean($controller->stream_seek(-27, SEEK_END))->isTrue()580 ->string($controller->stream_read(1))->isEmpty()581 ->if($controller = new testedClass(uniqid()))582 ->and($controller->contains('abcdefghijklmnopqrstuvwxyz'))583 ->and($controller->stream_open(uniqid(), 'r', 0))584 ->and($controller->stream_read(4096))585 ->then586 ->boolean($controller->stream_eof())->isFalse()587 ->if($controller->stream_read(4096))588 ->then589 ->boolean($controller->stream_eof())->isTrue()590 ->boolean($controller->stream_seek(0))->isTrue()591 ->boolean($controller->stream_eof())->isFalse()592 ;593 }594 public function testStreamEof()595 {596 $this597 ->if($controller = new testedClass(uniqid()))598 ->then599 ->boolean($controller->stream_eof())->isFalse()600 ->if($controller->contains('abcdefghijklmnopqrstuvwxyz'))601 ->then602 ->boolean($controller->stream_eof())->isFalse()603 ->if($controller->stream_seek(26))604 ->then605 ->boolean($controller->stream_eof())->isFalse()606 ->if($controller->stream_seek(27))607 ->then608 ->boolean($controller->stream_eof())->isFalse()609 ->if($controller->stream_open(uniqid(), 'r', 0))610 ->and($controller->stream_seek(27))611 ->and($controller->stream_read(1))612 ->then613 ->boolean($controller->stream_eof())->isTrue()614 ;615 }616 public function testStreamTell()617 {618 $this619 ->if($controller = new testedClass(uniqid()))620 ->then621 ->integer($controller->stream_tell())->isZero()622 ->if($controller->stream_seek($offset = rand(1, 4096)))623 ->then624 ->integer($controller->stream_tell())->isEqualTo($offset)625 ;626 }627 public function testStreamRead()628 {629 $this630 ->if($controller = new testedClass(uniqid()))631 ->and($controller->stream_open(uniqid(), 'r', 0))632 ->then633 ->string($controller->stream_read(1))->isEmpty()634 ->boolean($controller->stream_eof())->isTrue()635 ->if($controller->contains('abcdefghijklmnopqrstuvwxyz'))636 ->then637 ->string($controller->stream_read(1))->isEqualTo('a')638 ->boolean($controller->stream_eof())->isFalse()639 ->if($controller->stream_seek(6))640 ->then641 ->string($controller->stream_read(1))->isEqualTo('g')642 ->string($controller->stream_read(4096))->isEqualTo('hijklmnopqrstuvwxyz')643 ->boolean($controller->stream_eof())->isFalse()644 ->string($controller->stream_read(1))->isEmpty()645 ->boolean($controller->stream_eof())->isTrue()646 ;647 }648 public function testStreamWrite()649 {650 $this651 ->if($controller = new testedClass(uniqid()))652 ->then653 ->integer($controller->stream_write('a'))->isZero()654 ->integer($controller->stream_tell())->isZero()655 ->if($controller->stream_open(uniqid(), 'r', 0))656 ->then657 ->integer($controller->stream_write('a'))->isZero()658 ->integer($controller->stream_tell())->isZero()659 ->if($controller->stream_open(uniqid(), 'w', 0))660 ->then661 ->integer($controller->stream_write('a'))->isEqualTo(1)662 ->integer($controller->stream_tell())->isEqualTo(1)663 ->integer($controller->stream_write('bcdefghijklmnopqrstuvwxyz'))->isEqualTo(25)664 ->integer($controller->stream_tell())->isEqualTo(26)665 ;666 }667 /** @php 5.4 */668 public function testStreamMetadata()669 {670 $this671 ->if($controller = new testedClass(uniqid()))672 ->then673 ->boolean($controller->stream_metadata(uniqid(), STREAM_META_ACCESS, 755))->isTrue()674 ->integer($controller->getPermissions())->isEqualTo(755)675 ;676 }677 public function testStreamStat()678 {679 $this680 ->if($controller = new testedClass(uniqid()))681 ->and($stats = array(682 'dev' => 0,683 'ino' => 0,684 'mode' => 33188,685 'nlink' => 0,686 'uid' => getmyuid(),687 'gid' => getmygid(),688 'rdev' => 0,689 'size' => 0,690 'atime' => 507769200,691 'mtime' => 507769200,692 'ctime' => 507769200,693 'blksize' => 0,694 'blocks' => 0,695 )696 )697 ->and($stats[0] = & $stats['dev'])698 ->and($stats[1] = & $stats['ino'])699 ->and($stats[2] = & $stats['mode'])700 ->and($stats[3] = & $stats['nlink'])701 ->and($stats[4] = & $stats['uid'])702 ->and($stats[5] = & $stats['gid'])703 ->and($stats[6] = & $stats['rdev'])704 ->and($stats[7] = & $stats['size'])705 ->and($stats[8] = & $stats['atime'])706 ->and($stats[9] = & $stats['mtime'])707 ->and($stats[10] = & $stats['ctime'])708 ->and($stats[11] = & $stats['blksize'])709 ->and($stats[12] = & $stats['blocks'])710 ->then711 ->array($controller->stream_stat())->isEqualTo($stats)712 ->if($controller->notExists())713 ->then714 ->boolean($controller->stream_stat())->isFalse()715 ->if($controller = new testedClass(uniqid()))716 ->and($controller->stream_stat[2] = false)717 ->then718 ->array($controller->stream_stat())->isNotEmpty()719 ->boolean($controller->stream_stat())->isFalse()720 ->array($controller->stream_stat())->isNotEmpty()721 ;722 }723 public function testStreamTruncate()724 {725 $this726 ->if($controller = new testedClass(uniqid()))727 ->then728 ->boolean($controller->stream_truncate(0))->isTrue()729 ->string($controller->getContents())->isEmpty()730 ->boolean($controller->stream_truncate($size = rand(1, 10)))->isTrue()731 ->string($controller->getContents())->isEqualTo(str_repeat("\0", $size))732 ->boolean($controller->stream_truncate(0))->isTrue()733 ->string($controller->getContents())->isEmpty()734 ->boolean($controller->stream_truncate($size = rand(5, 10)))->isTrue()735 ->string($controller->getContents())->isEqualTo(str_repeat("\0", $size))736 ->boolean($controller->stream_truncate(4))->isTrue()737 ->string($controller->getContents())->isEqualTo("\0\0\0\0")738 ;739 }740 public function testStreamLock()741 {742 $this743 ->if($controller = new testedClass(uniqid()))744 ->then745 ->boolean($controller->stream_lock(LOCK_SH))->isTrue()746 ->boolean($controller->stream_lock(LOCK_EX))->isTrue()747 ->boolean($controller->stream_lock(LOCK_UN))->isTrue()748 ->boolean($controller->stream_lock(LOCK_SH | LOCK_NB))->isTrue()749 ->boolean($controller->stream_lock(LOCK_EX | LOCK_NB))->isTrue()750 ->if($controller->stream_lock = false)751 ->then752 ->boolean($controller->stream_lock(LOCK_SH))->isFalse()753 ->boolean($controller->stream_lock(LOCK_EX))->isFalse()754 ->boolean($controller->stream_lock(LOCK_UN))->isFalse()755 ->boolean($controller->stream_lock(LOCK_SH | LOCK_NB))->isFalse()756 ->boolean($controller->stream_lock(LOCK_EX | LOCK_NB))->isFalse()757 ;758 }759 public function testStreamClose()760 {761 $this762 ->if($controller = new testedClass(uniqid()))763 ->then764 ->boolean($controller->stream_close())->isTrue()765 ->if($controller->stream_close = false)766 ->then767 ->boolean($controller->stream_close())->isFalse()768 ;769 }770 public function testUrlStat()771 {772 $this773 ->if($controller = new testedClass(uniqid()))774 ->and($stats = array(775 'dev' => 0,776 'ino' => 0,777 'mode' => 33188,778 'nlink' => 0,779 'uid' => getmyuid(),780 'gid' => getmygid(),781 'rdev' => 0,782 'size' => 0,783 'atime' => 507769200,784 'mtime' => 507769200,785 'ctime' => 507769200,786 'blksize' => 0,787 'blocks' => 0,788 )789 )790 ->and($stats[0] = & $stats['dev'])791 ->and($stats[1] = & $stats['ino'])792 ->and($stats[2] = & $stats['mode'])793 ->and($stats[3] = & $stats['nlink'])794 ->and($stats[4] = & $stats['uid'])795 ->and($stats[5] = & $stats['gid'])796 ->and($stats[6] = & $stats['rdev'])797 ->and($stats[7] = & $stats['size'])798 ->and($stats[8] = & $stats['atime'])799 ->and($stats[9] = & $stats['mtime'])800 ->and($stats[10] = & $stats['ctime'])801 ->and($stats[11] = & $stats['blksize'])802 ->and($stats[12] = & $stats['blocks'])803 ->then804 ->array($controller->url_stat(uniqid(), STREAM_URL_STAT_QUIET))->isEqualTo($stats)805 ->if($controller->notExists())806 ->then807 ->boolean($controller->url_stat(uniqid(), STREAM_URL_STAT_QUIET))->isFalse()808 ->if($controller = new testedClass(uniqid()))809 ->and($controller->url_stat[2] = false)810 ->then811 ->array($controller->url_stat(uniqid(), STREAM_URL_STAT_QUIET))->isNotEmpty()812 ->boolean($controller->url_stat(uniqid(), STREAM_URL_STAT_QUIET))->isFalse()813 ->array($controller->url_stat(uniqid(), STREAM_URL_STAT_QUIET))->isNotEmpty()814 ;815 }816 public function testUnlink()817 {818 $this819 ->if($controller = new testedClass(uniqid()))820 ->then821 ->boolean($controller->unlink(uniqid()))->isTrue()822 ->boolean($controller->stream_stat())->isFalse()823 ->boolean($controller->unlink(uniqid()))->isFalse()824 ->boolean($controller->stream_stat())->isFalse()825 ->if($controller->exists())826 ->then827 ->boolean($controller->unlink(uniqid()))->isTrue()828 ->boolean($controller->stream_stat())->isFalse()829 ->boolean($controller->unlink(uniqid()))->isFalse()830 ->boolean($controller->stream_stat())->isFalse()831 ->if($controller->exists())832 ->and($controller->isNotWritable())833 ->then834 ->boolean($controller->unlink(uniqid()))->isFalse()835 ->array($controller->stream_stat())->isNotEmpty()836 ->if($controller->isWritable())837 ->boolean($controller->unlink(uniqid()))->isTrue()838 ->boolean($controller->stream_stat())->isFalse()839 ->boolean($controller->unlink(uniqid()))->isFalse()840 ->boolean($controller->stream_stat())->isFalse()841 ;842 }843 public function testRename()844 {845 $this846 ->if($controller = new testedClass(uniqid()))847 ->then848 ->boolean($controller->rename(uniqid(), $newPath = uniqid()))->isTrue()849 ->string($controller->getPath())->isEqualTo($newPath)850 ->if($controller->rename = false)851 ->then852 ->boolean($controller->rename(uniqid(), uniqid()))->isFalse()853 ->string($controller->getPath())->isEqualTo($newPath)854 ;855 }856 public function testMkdir()857 {858 $this859 ->if($controller = new testedClass(uniqid()))860 ->then861 ->boolean($controller->mkdir(uniqid(), 0777, STREAM_MKDIR_RECURSIVE))->isFalse()862 ;863 }864 public function testRmdir()865 {866 $this867 ->if($controller = new testedClass(uniqid()))...

Full Screen

Full Screen

adapter.php

Source:adapter.php Github

copy

Full Screen

...23 ->if($adapter = new testedClass())24 ->and($storage = new test\adapter\storage())25 ->then26 ->array($adapter->getInvokers())->isEmpty()27 ->object($adapter->getCalls())->isEqualTo(new test\adapter\calls())28 ->boolean($storage->contains($adapter))->isFalse()29 ->if(testedClass::setStorage($storage))30 ->and($otherAdapter = new testedClass())31 ->then32 ->array($otherAdapter->getInvokers())->isEmpty()33 ->object($otherAdapter->getCalls())->isEqualTo(new test\adapter\calls())34 ->boolean($storage->contains($adapter))->isFalse()35 ->boolean($storage->contains($otherAdapter))->isTrue()36 ;37 }38 public function test__clone()39 {40 $this41 ->if($adapter = new testedClass())42 ->and($storage = new test\adapter\storage())43 ->and($clone = clone $adapter)44 ->then45 ->object($clone->getCalls())->isCloneOf($adapter->getCalls())46 ->boolean($storage->contains($clone))->isFalse()47 ->if(testedClass::setStorage($storage))48 ->and($otherClone = clone $adapter)49 ->then50 ->object($otherClone->getCalls())->isCloneOf($adapter->getCalls())51 ->boolean($storage->contains($clone))->isFalse()52 ->boolean($storage->contains($otherClone))->isTrue()53 ;54 }55 public function test__set()56 {57 $this58 ->if($adapter = new testedClass())59 ->and($adapter->md5 = $closure = function() {})60 ->then61 ->object($adapter->md5->getClosure())->isIdenticalTo($closure)62 ->if($adapter->md5 = $return = uniqid())63 ->then64 ->object($adapter->md5)->isInstanceOf('mageekguy\atoum\test\adapter\invoker')65 ->object($adapter->MD5)->isInstanceOf('mageekguy\atoum\test\adapter\invoker')66 ->string($adapter->invoke('md5'))->isEqualTo($return)67 ->string($adapter->invoke('MD5'))->isEqualTo($return)68 ->if($adapter->MD5 = $return = uniqid())69 ->then70 ->object($adapter->md5)->isInstanceOf('mageekguy\atoum\test\adapter\invoker')71 ->object($adapter->MD5)->isInstanceOf('mageekguy\atoum\test\adapter\invoker')72 ->string($adapter->invoke('md5'))->isEqualTo($return)73 ->string($adapter->invoke('MD5'))->isEqualTo($return)74 ;75 }76 public function test__get()77 {78 $this79 ->if($adapter = new testedClass())80 ->and($adapter->md5 = $closure = function() {})81 ->then82 ->object($adapter->md5->getClosure())->isIdenticalTo($closure)83 ->object($adapter->MD5->getClosure())->isIdenticalTo($closure)84 ->if($adapter->md5 = uniqid())85 ->then86 ->object($adapter->md5->getClosure())->isInstanceOf('closure')87 ->object($adapter->MD5->getClosure())->isInstanceOf('closure')88 ;89 }90 public function test__isset()91 {92 $this93 ->if($adapter = new testedClass())94 ->then95 ->boolean(isset($adapter->md5))->isFalse()96 ->if($adapter->{$function = strtolower(uniqid())} = function() {})97 ->then98 ->boolean(isset($adapter->{$function}))->isTrue()99 ->boolean(isset($adapter->{strtoupper($function)}))->isTrue()100 ->if($adapter->{$function = strtoupper(uniqid())} = function() {})101 ->then102 ->boolean(isset($adapter->{strtolower($function)}))->isTrue()103 ->boolean(isset($adapter->{$function}))->isTrue()104 ->if($adapter->{$function = strtolower(uniqid())} = uniqid())105 ->then106 ->boolean(isset($adapter->{$function}))->isTrue()107 ->boolean(isset($adapter->{strtoupper($function)}))->isTrue()108 ->if($adapter->{$function = strtoupper(uniqid())} = uniqid())109 ->then110 ->boolean(isset($adapter->{$function}))->isTrue()111 ->boolean(isset($adapter->{strtolower($function)}))->isTrue()112 ->if($adapter->{$function = 'dummy'}[2] = uniqid())113 ->then114 ->boolean(isset($adapter->{$function}))->isFalse()115 ->if($adapter->{$function}())116 ->then117 ->boolean(isset($adapter->{$function}))->isTrue()118 ->if($adapter->{$function}())119 ->then120 ->boolean(isset($adapter->{$function}))->isFalse()121 ;122 }123 public function test__unset()124 {125 $this126 ->if($adapter = new testedClass())127 ->then128 ->array($adapter->getInvokers())->isEmpty()129 ->array($adapter->getCalls()->toArray())->isEmpty()130 ->when(function() use ($adapter) { unset($adapter->md5); })131 ->array($adapter->getInvokers())->isEmpty()132 ->array($adapter->getCalls()->toArray())->isEmpty()133 ->when(function() use ($adapter) { unset($adapter->MD5); })134 ->array($adapter->getInvokers())->isEmpty()135 ->array($adapter->getCalls()->toArray())->isEmpty()136 ->when(function() use ($adapter) { $adapter->md5 = uniqid(); $adapter->md5(uniqid()); })137 ->array($adapter->getInvokers())->isNotEmpty()138 ->array($adapter->getCalls()->toArray())->isNotEmpty()139 ->when(function() use ($adapter) { unset($adapter->{uniqid()}); })140 ->array($adapter->getInvokers())->isNotEmpty()141 ->array($adapter->getCalls()->toArray())->isNotEmpty()142 ->when(function() use ($adapter) { unset($adapter->md5); })143 ->array($adapter->getInvokers())->isEmpty()144 ->array($adapter->getCalls()->toArray())->isEmpty()145 ->when(function() use ($adapter) { $adapter->MD5 = uniqid(); $adapter->MD5(uniqid()); })146 ->array($adapter->getInvokers())->isNotEmpty()147 ->array($adapter->getCalls()->toArray())->isNotEmpty()148 ->when(function() use ($adapter) { unset($adapter->{uniqid()}); })149 ->array($adapter->getInvokers())->isNotEmpty()150 ->array($adapter->getCalls()->toArray())->isNotEmpty()151 ->when(function() use ($adapter) { unset($adapter->MD5); })152 ->array($adapter->getInvokers())->isEmpty()153 ->array($adapter->getCalls()->toArray())->isEmpty()154 ;155 }156 public function test__call()157 {158 $this159 ->if($adapter = new testedClass())160 ->then161 ->string($adapter->md5($hash = uniqid()))->isEqualTo(md5($hash))162 ->string($adapter->MD5($hash = uniqid()))->isEqualTo(md5($hash))163 ->if($adapter->md5 = $md5 = uniqid())164 ->then165 ->string($adapter->md5($hash))->isEqualTo($md5)166 ->string($adapter->MD5($hash))->isEqualTo($md5)167 ->if($adapter->md5 = $md5 = uniqid())168 ->then169 ->string($adapter->md5($hash))->isEqualTo($md5)170 ->string($adapter->MD5($hash))->isEqualTo($md5)171 ->exception(function() use ($adapter) {172 $adapter->require(uniqid());173 }174 )175 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')176 ->hasMessage('Function \'require()\' is not invokable by an adapter')177 ->exception(function() use ($adapter) {178 $adapter->REQUIRE(uNiqid());179 }180 )181 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')182 ->hasMessage('Function \'REQUIRE()\' is not invokable by an adapter')183 ->if($adapter->md5 = 0)184 ->and($adapter->md5[1] = 1)185 ->and($adapter->md5[2] = 2)186 ->and($adapter->resetCalls())187 ->then188 ->integer($adapter->md5())->isEqualTo(1)189 ->integer($adapter->md5())->isEqualTo(2)190 ->integer($adapter->md5())->isEqualTo(0)191 ->if($adapter->resetCalls())192 ->then193 ->integer($adapter->MD5())->isEqualTo(1)194 ->integer($adapter->MD5())->isEqualTo(2)195 ->integer($adapter->MD5())->isEqualTo(0)196 ->if($adapter->MD5 = 0)197 ->and($adapter->MD5[1] = 1)198 ->and($adapter->MD5[2] = 2)199 ->and($adapter->resetCalls())200 ->then201 ->integer($adapter->md5())->isEqualTo(1)202 ->integer($adapter->md5())->isEqualTo(2)203 ->integer($adapter->md5())->isEqualTo(0)204 ->if($adapter->resetCalls())205 ->then206 ->integer($adapter->MD5())->isEqualTo(1)207 ->integer($adapter->MD5())->isEqualTo(2)208 ->integer($adapter->MD5())->isEqualTo(0)209 ->if($adapter = new testedClass())210 ->and($adapter->sha1[2] = $sha1 = uniqid())211 ->then212 ->string($adapter->sha1($string = uniqid()))->isEqualTo(sha1($string))213 ->string($adapter->sha1(uniqid()))->isEqualTo($sha1)214 ->string($adapter->sha1($otherString = uniqid()))->isEqualTo(sha1($otherString))215 ;216 }217 public function test__sleep()218 {219 $this220 ->if($adapter = new testedClass())221 ->then222 ->array($adapter->__sleep())->isEmpty()223 ;224 }225 public function test__toString()226 {227 $this228 ->if($adapter = new testedClass())229 ->and($calls = new test\adapter\calls())230 ->then231 ->castToString($adapter)->isEqualTo((string) $calls)232 ;233 }234 public function testSerialize()235 {236 $this237 ->if($adapter = new testedClass())238 ->then239 ->string(serialize($adapter))->isNotEmpty()240 ->if($adapter->md5 = function() {})241 ->then242 ->string(serialize($adapter))->isNotEmpty()243 ;244 }245 public function testSetCalls()246 {247 $this248 ->if($adapter = new testedClass())249 ->then250 ->object($adapter->setCalls($calls = new test\adapter\calls()))->isIdenticalTo($adapter)251 ->object($adapter->getCalls())->isIdenticalTo($calls)252 ->object($adapter->setCalls())->isIdenticalTo($adapter)253 ->object($adapter->getCalls())254 ->isNotIdenticalTo($calls)255 ->isEqualTo(new test\adapter\calls())256 ->if($calls = new test\adapter\calls())257 ->and($calls[] = new test\adapter\call(uniqid()))258 ->and($adapter->setCalls($calls))259 ->then260 ->object($adapter->getCalls())261 ->isIdenticalTo($calls)262 ->hasSize(0)263 ;264 }265 public function testGetCalls()266 {267 $this268 ->if($adapter = new testedClass())269 ->and($adapter->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))270 ->and($this->calling($calls)->get = $innerCalls = new test\adapter\calls())271 ->then272 ->object($adapter->getCalls())->isIdenticalTo($calls)273 ->object($adapter->getCalls($call = new test\adapter\call(uniqid())))->isIdenticalTo($innerCalls)274 ->mock($calls)->call('get')->withArguments($call, false)->once()275 ;276 }277 public function testGetCallsEqualTo()278 {279 $this280 ->if($calls = new \mock\mageekguy\atoum\test\adapter\calls())281 ->and($this->calling($calls)->getEqualTo = $equalCalls = new test\adapter\calls())282 ->and($adapter = new testedClass())283 ->and($adapter->setCalls($calls))284 ->then285 ->object($adapter->getCallsEqualTo($call = new call('md5')))->isIdenticalTo($equalCalls)286 ->mock($calls)->call('getEqualTo')->withArguments($call)->once()287 ;288 }289 public function testGetPreviousCalls()290 {291 $this292 ->if($calls = new \mock\mageekguy\atoum\test\adapter\calls())293 ->and($this->calling($calls)->getPrevious = $previousCalls = new test\adapter\calls())294 ->and($adapter = new testedClass())295 ->and($adapter->setCalls($calls))296 ->then297 ->object($adapter->getPreviousCalls($call = new call('md5'), $position = rand(1, PHP_INT_MAX)))->isIdenticalTo($previousCalls)298 ->mock($calls)->call('getPrevious')->withArguments($call, $position, false)->once()299 ->object($adapter->getPreviousCalls($call = new call('md5'), $position = rand(1, PHP_INT_MAX), true))->isIdenticalTo($previousCalls)300 ->mock($calls)->call('getPrevious')->withArguments($call, $position, true)->once()301 ;302 }303 public function testHasPreviousCalls()304 {305 $this306 ->if($calls = new \mock\mageekguy\atoum\test\adapter\calls())307 ->and($this->calling($calls)->hasPrevious = $has = (boolean) rand(0, 1))308 ->and($adapter = new testedClass())309 ->and($adapter->setCalls($calls))310 ->then311 ->boolean($adapter->hasPreviousCalls($call = new call('md5'), $position = rand(1, PHP_INT_MAX)))->isEqualTo($has)312 ->mock($calls)->call('hasPrevious')->withArguments($call, $position, false)->once()313 ->boolean($adapter->hasPreviousCalls($call = new call('md5'), $position = rand(1, PHP_INT_MAX), true))->isEqualTo($has)314 ->mock($calls)->call('hasPrevious')->withArguments($call, $position, true)->once()315 ;316 }317 public function testGetAfterCalls()318 {319 $this320 ->if($calls = new \mock\mageekguy\atoum\test\adapter\calls())321 ->and($this->calling($calls)->getAfter = $afterCalls = new test\adapter\calls())322 ->and($adapter = new testedClass())323 ->and($adapter->setCalls($calls))324 ->then325 ->object($adapter->getAfterCalls($call = new call('md5'), $position = rand(1, PHP_INT_MAX)))->isIdenticalTo($afterCalls)326 ->mock($calls)->call('getAfter')->withArguments($call, $position, false)->once()327 ->object($adapter->getAfterCalls($call = new call('md5'), $position = rand(1, PHP_INT_MAX), true))->isIdenticalTo($afterCalls)328 ->mock($calls)->call('getAfter')->withArguments($call, $position, true)->once()329 ;330 }331 public function testHasAfterCalls()332 {333 $this334 ->if($calls = new \mock\mageekguy\atoum\test\adapter\calls())335 ->and($this->calling($calls)->hasAfter = $has = (boolean) rand(0, 1))336 ->and($adapter = new testedClass())337 ->and($adapter->setCalls($calls))338 ->then339 ->boolean($adapter->hasAfterCalls($call = new call('md5'), $position = rand(1, PHP_INT_MAX)))->isEqualTo($has)340 ->mock($calls)->call('hasAfter')->withArguments($call, $position, false)->once()341 ->boolean($adapter->hasAfterCalls($call = new call('md5'), $position = rand(1, PHP_INT_MAX), true))->isEqualTo($has)342 ->mock($calls)->call('hasAfter')->withArguments($call, $position, true)->once()343 ;344 }345 public function testGetCallsIdenticalTo()346 {347 $this348 ->if($calls = new \mock\mageekguy\atoum\test\adapter\calls())349 ->and($this->calling($calls)->getIdenticalTo = $identicalCalls = new test\adapter\calls())350 ->and($adapter = new testedClass())351 ->and($adapter->setCalls($calls))352 ->then353 ->object($adapter->getCallsIdenticalTo($call = new call('md5')))->isIdenticalTo($identicalCalls)354 ->mock($calls)->call('getIdenticalTo')->withArguments($call)->once()355 ;356 }357 public function testGetCallNumber()358 {359 $this360 ->if($calls = new \mock\mageekguy\atoum\test\adapter\calls())361 ->and($this->calling($calls)->count = 0)362 ->and($adapter = new testedClass())363 ->and($adapter->setCalls($calls))364 ->then365 ->integer($adapter->getCallNumber())->isZero()366 ->and($this->calling($calls)->count = $callNumber = rand(1, PHP_INT_MAX))367 ->then368 ->integer($adapter->getCallNumber())->isEqualTo($callNumber)369 ;370 }371 public function testGetTimeline()372 {373 $this374 ->if($adapter = new testedClass())375 ->and($adapter->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))376 ->and($this->calling($calls)->getTimeline = array())377 ->then378 ->array($adapter->getTimeline())->isEmpty()379 ->mock($calls)->call('getTimeline')->withArguments(null, false)->once()380 ;381 }382 public function testAddCall()383 {384 $this385 ->if($adapter = new testedClass())386 ->and($adapter->setCalls($calls = new \mock\mageekguy\atoum\test\adapter\calls()))387 ->and($this->calling($calls)->addCall = $calls)388 ->then389 ->object($adapter->addCall($method = uniqid(), $args = array(uniqid())))->isIdenticalTo($adapter)390 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call($method, $args))->once()391 ->object($adapter->addCall($otherMethod = uniqid(), $otherArgs = array(uniqid(), uniqid())))->isIdenticalTo($adapter)392 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call($otherMethod, $otherArgs))->once()393 ->object($adapter->addCall($method, $anotherArgs = array(uniqid())))->isIdenticalTo($adapter)394 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call($method, $anotherArgs))->once()395 ->if($arg = 'foo')396 ->and($arguments = array(& $arg))397 ->then398 ->object($adapter->addCall($method, $arguments))->isIdenticalTo($adapter)399 ->mock($calls)->call('addCall')->withArguments(new test\adapter\call($method, $arguments))->once()400 ;401 }402 public function testResetCalls()403 {404 $this405 ->if(406 $adapter = new testedClass(),407 $adapter->md5(uniqid()),408 $adapter->sha1(uniqid())409 )410 ->then411 ->sizeof($adapter->getCalls())->isEqualTo(2)412 ->sizeof($adapter->getCalls(new call('md5')))->isEqualTo(1)413 ->sizeof($adapter->getCalls(new call('sha1')))->isEqualTo(1)414 ->object($adapter->resetCalls())->isIdenticalTo($adapter)415 ->sizeof($adapter->getCalls())->isZero416 ->if(417 $adapter->md5(uniqid()),418 $adapter->sha1(uniqid())419 )420 ->then421 ->sizeof($adapter->getCalls())->isEqualTo(2)422 ->sizeof($adapter->getCalls(new call('md5')))->isEqualTo(1)423 ->sizeof($adapter->getCalls(new call('sha1')))->isEqualTo(1)424 ->object($adapter->resetCalls('md5'))->isIdenticalTo($adapter)425 ->sizeof($adapter->getCalls())->isEqualTo(1)426 ->sizeof($adapter->getCalls(new call('md5')))->isZero427 ->sizeof($adapter->getCalls(new call('sha1')))->isEqualTo(1)428 ->object($adapter->resetCalls('sha1'))->isIdenticalTo($adapter)429 ->sizeof($adapter->getCalls(new call('md5')))->isZero430 ->sizeof($adapter->getCalls(new call('sha1')))->isZero431 ->sizeof($adapter->getCalls())->isZero432 ;433 }434 public function testReset()435 {436 $this437 ->if($adapter = new testedClass())438 ->then439 ->array($adapter->getInvokers())->isEmpty()440 ->sizeof($adapter->getCalls())->isZero()441 ->object($adapter->reset())->isIdenticalTo($adapter)442 ->array($adapter->getInvokers())->isEmpty()443 ->sizeof($adapter->getCalls())->isZero()444 ->if($adapter->md5(uniqid()))445 ->then446 ->array($adapter->getInvokers())->isEmpty()447 ->sizeof($adapter->getCalls())->isGreaterThan(0)448 ->object($adapter->reset())->isIdenticalTo($adapter)449 ->array($adapter->getInvokers())->isEmpty()450 ->sizeof($adapter->getCalls())->isZero()451 ->if($adapter->md5 = uniqid())452 ->then453 ->array($adapter->getInvokers())->isNotEmpty()454 ->sizeof($adapter->getCalls())->isZero(0)455 ->object($adapter->reset())->isIdenticalTo($adapter)456 ->array($adapter->getInvokers())->isEmpty()457 ->sizeof($adapter->getCalls())->isZero()458 ->if($adapter->md5 = uniqid())459 ->and($adapter->md5(uniqid()))460 ->then461 ->array($adapter->getInvokers())->isNotEmpty()462 ->sizeof($adapter->getCalls())->isGreaterThan(0)463 ->object($adapter->reset())->isIdenticalTo($adapter)464 ->array($adapter->getInvokers())->isEmpty()465 ->sizeof($adapter->getCalls())->isZero()466 ;467 }468 public function testGetCallsNumber()469 {470 $this471 ->given($this->newTestedInstance)472 ->then473 ->integer($this->testedInstance->getCallsNumber(new call('md5')))->isZero474 ->if(475 $this->testedInstance->md5(uniqid()),476 $this->testedInstance->sha1(uniqid())477 )478 ->then479 ->integer($this->testedInstance->getCallsNumber())->isEqualTo(2)480 ->integer($this->testedInstance->getCallsNumber(new call('md5')))->isEqualTo(1)481 ->integer($this->testedInstance->getCallsNumber(new call('sha1')))->isEqualTo(1)482 ->given(483 $castable = new \mock\castable,484 $this->calling($castable)->__toString = $string = uniqid()485 )486 ->if(487 $this->testedInstance->resetCalls(),488 $this->testedInstance->md5(1),489 $this->testedInstance->md5('1')490 )491 ->then492 ->integer($this->testedInstance->getCallsNumber())->isEqualTo(2)493 ->integer($this->testedInstance->getCallsNumber(new call('md5')))->isEqualTo(2)494 ->integer($this->testedInstance->getCallsNumber(new call('md5'), true))->isEqualTo(2)495 ->integer($this->testedInstance->getCallsNumber(new call('md5', array(1))))->isEqualTo(2)496 ->integer($this->testedInstance->getCallsNumber(new call('md5', array(1)), true))->isEqualTo(1)497 ->integer($this->testedInstance->getCallsNumber(new call('md5', array('1')), true))->isEqualTo(1)498 ;499 }500 public function testGetCallsNumberEqualTo()501 {502 $this503 ->given($this->newTestedInstance)504 ->then505 ->integer($this->testedInstance->getCallsNumber(new call('md5')))->isZero506 ->if(507 $this->testedInstance->md5(uniqid()),508 $this->testedInstance->md5(1),509 $this->testedInstance->md5('1')510 )511 ->then512 ->integer($this->testedInstance->getCallsNumberEqualTo(new call('md5')))->isEqualTo(3)513 ->integer($this->testedInstance->getCallsNumberEqualTo(new call('md5', array(1))))->isEqualTo(2)514 ->integer($this->testedInstance->getCallsNumberEqualTo(new call('md5', array('1'))))->isEqualTo(2)515 ;516 }517 }518}...

Full Screen

Full Screen

call.php

Source:call.php Github

copy

Full Screen

...15 ->if($call = new testedClass())16 ->then17 ->variable($call->getFunction())->isNull()18 ->variable($call->getArguments())->isNull()19 ->object($call->getDecorator())->isEqualTo(new decorator())20 ->if($call = new testedClass($function = uniqid()))21 ->then22 ->string($call->getFunction())->isEqualTo($function)23 ->variable($call->getArguments())->isNull()24 ->object($call->getDecorator())->isEqualTo(new decorator())25 ->if($call = new testedClass($function = uniqid(), $arguments = array()))26 ->then27 ->string($call->getFunction())->isEqualTo($function)28 ->array($call->getArguments())->isEqualTo($arguments)29 ->object($call->getDecorator())->isEqualTo(new decorator())30 ->if($call = new testedClass('MD5'))31 ->then32 ->string($call->getFunction())->isEqualTo('MD5')33 ->variable($call->getArguments())->isNull()34 ->object($call->getDecorator())->isEqualTo(new decorator())35 ->exception(function() { new testedClass(''); })36 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')37 ->hasMessage('Function must not be empty')38 ;39 }40 public function test__toString()41 {42 $this43 ->if($call = new testedClass())44 ->then45 ->castToString($call)->isEmpty()46 ;47 }48 public function testIsFullyQualified()49 {50 $this51 ->if($call = new testedClass())52 ->then53 ->boolean($call->isFullyQualified())->isFalse()54 ->if($call = new testedClass(uniqid()))55 ->then56 ->boolean($call->isFullyQualified())->isFalse()57 ->if($call = new testedClass(null, array()))58 ->then59 ->boolean($call->isFullyQualified())->isFalse()60 ->if($call = new testedClass(uniqid(), array()))61 ->then62 ->boolean($call->isFullyQualified())->isTrue()63 ;64 }65 public function testSetFunction()66 {67 $this68 ->if($call = new testedClass())69 ->then70 ->object($call->setFunction($function = uniqid()))->isIdenticalTo($call)71 ->string($call->getFunction())->isEqualTo($function)72 ->object($call->setFunction('foo'))->isIdenticalTo($call)73 ->string($call->getFunction())->isEqualTo('foo')74 ->object($call->setFunction('FOo'))->isIdenticalTo($call)75 ->string($call->getFunction())->isEqualTo('FOo')76 ;77 }78 public function testSetArguments()79 {80 $this81 ->if($call = new testedClass())82 ->then83 ->object($call->setArguments($arguments = array()))->isIdenticalTo($call)84 ->array($call->getArguments())->isEqualTo($arguments)85 ;86 }87 public function testUnsetArguments()88 {89 $this90 ->if($call = new testedClass())91 ->then92 ->object($call->unsetArguments())->isIdenticalTo($call)93 ->variable($call->getArguments())->isNull()94 ->if($call->setArguments(array()))95 ->then96 ->object($call->unsetArguments())->isIdenticalTo($call)97 ->variable($call->getArguments())->isNull()98 ;99 }100 public function testSetDecorator()101 {102 $this103 ->if($call = new testedClass())104 ->then105 ->object($call->setDecorator($decorator = new decorator()))->isIdenticalTo($call)106 ->object($call->getDecorator())->isIdenticalTo($decorator)107 ->object($call->setDecorator())->isIdenticalTo($call)108 ->object($call->getDecorator())109 ->isNotIdenticalTo($decorator)110 ->isEqualTo(new decorator())111 ;112 }113 public function testIsEqualTo()114 {115 $this116 ->if($call1 = new testedClass())117 ->and($call2 = new testedClass())118 ->then119 ->boolean($call1->isEqualTo($call2))->isFalse()120 ->boolean($call2->isEqualTo($call1))->isFalse()121 ->if($call1 = new testedClass(uniqid()))122 ->then123 ->boolean($call1->isEqualTo($call2))->isFalse()124 ->boolean($call2->isEqualTo($call1))->isFalse()125 ->if($call2 = new testedClass(uniqid()))126 ->then127 ->boolean($call1->isEqualTo($call2))->isFalse()128 ->boolean($call2->isEqualTo($call1))->isFalse()129 ->if($call1 = new testedClass())130 ->then131 ->boolean($call1->isEqualTo($call2))->isFalse()132 ->boolean($call2->isEqualTo($call1))->isFalse()133 ->if($call1 = new testedClass($function = uniqid()))134 ->and($call2 = new testedClass($function))135 ->then136 ->boolean($call1->isEqualTo($call2))->isTrue()137 ->boolean($call2->isEqualTo($call1))->isTrue()138 ->if($call2 = new testedClass(strtoupper($function)))139 ->then140 ->boolean($call1->isEqualTo($call2))->isTrue()141 ->boolean($call2->isEqualTo($call1))->isTrue()142 ->if($call1 = new testedClass($function, array()))143 ->then144 ->boolean($call1->isEqualTo($call2))->isFalse()145 ->boolean($call2->isEqualTo($call1))->isTrue()146 ->if($call2 = new testedClass($function, array()))147 ->then148 ->boolean($call1->isEqualTo($call2))->isTrue()149 ->boolean($call2->isEqualTo($call1))->isTrue()150 ->if($call1 = new testedClass($function, array($argument = uniqid())))151 ->then152 ->boolean($call1->isEqualTo($call2))->isFalse()153 ->boolean($call2->isEqualTo($call1))->isFalse()154 ->if($call2 = new testedClass($function, array($argument)))155 ->then156 ->boolean($call1->isEqualTo($call2))->isTrue()157 ->boolean($call2->isEqualTo($call1))->isTrue()158 ->if($call1 = new testedClass($function, $arguments = array(uniqid(), uniqid())))159 ->then160 ->boolean($call1->isEqualTo($call2))->isFalse()161 ->boolean($call2->isEqualTo($call1))->isFalse()162 ->if($call2 = new testedClass($function, $arguments))163 ->then164 ->boolean($call1->isEqualTo($call2))->isTrue()165 ->boolean($call2->isEqualTo($call1))->isTrue()166 ->if($call1 = new testedClass($function, $arguments = array($arg1 = uniqid(), $arg2 = uniqid(), $arg3 = new \mock\object())))167 ->then168 ->boolean($call1->isEqualTo($call2))->isFalse()169 ->boolean($call2->isEqualTo($call1))->isFalse()170 ->if($call2 = new testedClass($function, $arguments))171 ->then172 ->boolean($call1->isEqualTo($call2))->isTrue()173 ->boolean($call2->isEqualTo($call1))->isTrue()174 ->if($call2 = new testedClass($function, array($arg1, $arg2, clone $arg3)))175 ->then176 ->boolean($call1->isEqualTo($call2))->isTrue()177 ->boolean($call2->isEqualTo($call1))->isTrue()178 ->if($call2 = new testedClass($function, array($arg3, $arg2, $arg1)))179 ->then180 ->boolean($call1->isEqualTo($call2))->isFalse()181 ->boolean($call2->isEqualTo($call1))->isFalse()182 ->if($call1 = new testedClass($function = uniqid(), array($arg1 = uniqid(), $arg2 = uniqid(), $arg3 = new \mock\object())))183 ->and($call2 = new testedClass($function, array($arg1, $arg2)))184 ->then185 ->boolean($call1->isEqualTo($call2))->isFalse()186 ->boolean($call2->isEqualTo($call1))->isTrue()187 ->if($call1 = new testedClass($function))188 ->and($call2 = new testedClass($function, array($object = new \mock\object())))189 ->then190 ->boolean($call1->isEqualTo($call2))->isTrue()191 ->boolean($call2->isEqualTo($call1))->isFalse()192 ;193 }194 public function testIsIdenticalTo()195 {196 $this197 ->if($call1 = new testedClass())198 ->and($call2 = new testedClass())199 ->then200 ->boolean($call1->isIdenticalTo($call2))->isFalse()201 ->boolean($call2->isIdenticalTo($call1))->isFalse()202 ->if($call1 = new testedClass(uniqid()))203 ->then204 ->boolean($call1->isIdenticalTo($call2))->isFalse()205 ->boolean($call2->isIdenticalTo($call1))->isFalse()...

Full Screen

Full Screen

isEqualTo

Using AI Code Generation

copy

Full Screen

1require_once('Call.php');2$call = new Call();3$call->isEqualTo(1,1);4$call->isEqualTo(1,2);5$call->isEqualTo(1,3);6$call->isEqualTo(1,4);7$call->isEqualTo(1,5);8$call->isEqualTo(1,6);9$call->isEqualTo(1,7);10$call->isEqualTo(1,8);11$call->isEqualTo(1,9);12$call->isEqualTo(1,10);13$call->isEqualTo(1,11);14$call->isEqualTo(1,12);15$call->isEqualTo(1,13);16$call->isEqualTo(1,14);17$call->isEqualTo(1,15);18$call->isEqualTo(1,16);19$call->isEqualTo(1,17);20$call->isEqualTo(1,18);21$call->isEqualTo(1,19);22$call->isEqualTo(1,20);23$call->isEqualTo(1,21);24$call->isEqualTo(1,22);25$call->isEqualTo(1,23);26$call->isEqualTo(1,24);27$call->isEqualTo(1,25);28$call->isEqualTo(1,26);29$call->isEqualTo(1,27);30$call->isEqualTo(1,28);31$call->isEqualTo(1,29);32$call->isEqualTo(1,30);33$call->isEqualTo(1,31);34$call->isEqualTo(1,32);35$call->isEqualTo(1,33);36$call->isEqualTo(1,34);37$call->isEqualTo(1,35);38$call->isEqualTo(1,36);39$call->isEqualTo(1,37);40$call->isEqualTo(1,38);41$call->isEqualTo(1,39);42$call->isEqualTo(1,40);43$call->isEqualTo(1,41);44$call->isEqualTo(1,42);45$call->isEqualTo(1,43);46$call->isEqualTo(1,44);47$call->isEqualTo(1,45);48$call->isEqualTo(1,46);49$call->isEqualTo(1,47);50$call->isEqualTo(1,48);51$call->isEqualTo(1,49);52$call->isEqualTo(1,50);53$call->isEqualTo(1,51);54$call->isEqualTo(1,52);55$call->isEqualTo(1,53);56$call->isEqualTo(1,54);

Full Screen

Full Screen

isEqualTo

Using AI Code Generation

copy

Full Screen

1$call = new call();2$call->setNumber("123456789");3$call->setDate("2011-05-05");4$call->setTime("12:00:00");5$call->setDuration("30");6$call->setCallType("incoming");7$call->setCallStatus("answered");8$call->setCallCost("0.12");9$call->setCallId("123456789");10$call->setCallDirection("inbound");11if($call->isEqualTo($call1))12{13 echo "Equal";14}15{16 echo "Not Equal";17}18$call1 = new call();19$call1->setNumber("123456789");20$call1->setDate("2011-05-05");21$call1->setTime("12:00:00");22$call1->setDuration("30");23$call1->setCallType("incoming");24$call1->setCallStatus("answered");25$call1->setCallCost("0.12");26$call1->setCallId("123456789");27$call1->setCallDirection("inbound");28include '1.php';

Full Screen

Full Screen

isEqualTo

Using AI Code Generation

copy

Full Screen

1 $x = 5;2 $y = 10;3 $z = 15;4 $a = 20;5 $b = 25;6 $c = 30;7 $d = 35;8 $e = 40;9 $f = 45;10 $g = 50;11 $h = 55;12 $i = 60;13 $j = 65;14 $k = 70;15 $l = 75;16 $m = 80;17 $n = 85;18 $o = 90;19 $p = 95;20 $q = 100;21 if (call("isEqualTo", $x, 5)) {22 echo "The value of \$x is 5";23 }24 else {25 echo "The value of \$x is not 5";26 }27 $x = 5;28 $y = 10;29 $z = 15;30 $a = 20;31 $b = 25;32 $c = 30;33 $d = 35;34 $e = 40;35 $f = 45;36 $g = 50;37 $h = 55;38 $i = 60;39 $j = 65;40 $k = 70;41 $l = 75;42 $m = 80;43 $n = 85;44 $o = 90;45 $p = 95;46 $q = 100;47 if (call("isEqualTo", $x

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful