PageRenderTime 48ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

/tests/units/classes/mock/stream/controller.php

http://github.com/mageekguy/atoum
PHP | 788 lines | 774 code | 14 blank | 0 comment | 0 complexity | 3298bcb2acd619a48d1a6fb074941f35 MD5 | raw file
  1. <?php
  2. namespace mageekguy\atoum\tests\units\mock\stream;
  3. use
  4. mageekguy\atoum,
  5. mageekguy\atoum\test,
  6. mageekguy\atoum\dependence,
  7. mageekguy\atoum\dependencies,
  8. mageekguy\atoum\mock\stream,
  9. mageekguy\atoum\mock\stream\controller as testedClass
  10. ;
  11. require_once __DIR__ . '/../../../runner.php';
  12. class controller extends atoum\test
  13. {
  14. public function testClass()
  15. {
  16. $this
  17. ->testedClass->isSubclassOf('mageekguy\atoum\test\adapter')
  18. ;
  19. }
  20. public function test__construct()
  21. {
  22. $this
  23. ->if($streamController = new testedClass($stream = uniqid()))
  24. ->then
  25. ->string($streamController->getPath())->isEqualTo($stream)
  26. ->variable($streamController->invoke('__construct'))->isNull()
  27. ->variable($streamController->invoke('dir_closedir'))->isNull()
  28. ->variable($streamController->invoke('dir_opendir'))->isNull()
  29. ->variable($streamController->invoke('dir_readdir'))->isNull()
  30. ->variable($streamController->invoke('dir_rewinddir'))->isNull()
  31. ->variable($streamController->invoke('mkdir'))->isNull()
  32. ->variable($streamController->invoke('rename'))->isNull()
  33. ->variable($streamController->invoke('rmdir'))->isNull()
  34. ->variable($streamController->invoke('stream_cast'))->isNull()
  35. ->variable($streamController->invoke('stream_close'))->isNull()
  36. ->variable($streamController->invoke('stream_eof'))->isNull()
  37. ->variable($streamController->invoke('stream_flush'))->isNull()
  38. ->variable($streamController->invoke('stream_lock'))->isNull()
  39. ->variable($streamController->invoke('stream_metadata'))->isNull()
  40. ->variable($streamController->invoke('stream_open'))->isNull()
  41. ->variable($streamController->invoke('stream_read'))->isNull()
  42. ->variable($streamController->invoke('stream_seek'))->isNull()
  43. ->variable($streamController->invoke('stream_set_option'))->isNull()
  44. ->variable($streamController->invoke('stream_stat'))->isNull()
  45. ->variable($streamController->invoke('stream_tell'))->isNull()
  46. ->variable($streamController->invoke('stream_write'))->isNull()
  47. ->variable($streamController->invoke('unlink'))->isNull()
  48. ->variable($streamController->invoke('url_stat'))->isNull()
  49. ;
  50. }
  51. public function test__toString()
  52. {
  53. $this
  54. ->if($streamController = new testedClass($stream = uniqid()))
  55. ->then
  56. ->castToString($streamController)->isEqualTo($stream)
  57. ;
  58. }
  59. public function test__get()
  60. {
  61. $this
  62. ->if($streamController = new testedClass(uniqid()))
  63. ->then
  64. ->object($streamController->__construct)->isEqualTo(new stream\invoker('__construct'))
  65. ->object($streamController->dir_closedir)->isEqualTo(new stream\invoker('dir_closedir'))
  66. ->object($streamController->closedir)->isEqualTo(new stream\invoker('dir_closedir'))
  67. ->object($streamController->dir_opendir)->isEqualTo(new stream\invoker('dir_opendir'))
  68. ->object($streamController->opendir)->isEqualTo(new stream\invoker('dir_opendir'))
  69. ->object($streamController->dir_readdir)->isEqualTo(new stream\invoker('dir_readdir'))
  70. ->object($streamController->readdir)->isEqualTo(new stream\invoker('dir_readdir'))
  71. ->object($streamController->dir_rewinddir)->isEqualTo(new stream\invoker('dir_rewinddir'))
  72. ->object($streamController->rewinddir)->isEqualTo(new stream\invoker('dir_rewinddir'))
  73. ->object($streamController->mkdir)->isEqualTo(new stream\invoker('mkdir'))
  74. ->object($streamController->rename)->isEqualTo(new stream\invoker('rename'))
  75. ->object($streamController->rmdir)->isEqualTo(new stream\invoker('rmdir'))
  76. ->object($streamController->stream_cast)->isEqualTo(new stream\invoker('stream_cast'))
  77. ->object($streamController->select)->isEqualTo(new stream\invoker('stream_cast'))
  78. ->object($streamController->stream_close)->isEqualTo(new stream\invoker('stream_close'))
  79. ->object($streamController->fclose)->isEqualTo(new stream\invoker('stream_close'))
  80. ->object($streamController->stream_eof)->isEqualTo(new stream\invoker('stream_eof'))
  81. ->object($streamController->feof)->isEqualTo(new stream\invoker('stream_eof'))
  82. ->object($streamController->stream_flush)->isEqualTo(new stream\invoker('stream_flush'))
  83. ->object($streamController->fflush)->isEqualTo(new stream\invoker('stream_flush'))
  84. ->object($streamController->stream_lock)->isEqualTo(new stream\invoker('stream_lock'))
  85. ->object($streamController->flock)->isEqualTo(new stream\invoker('stream_lock'))
  86. ->object($streamController->stream_metadata)->isEqualTo(new stream\invoker('stream_metadata'))
  87. ->object($streamController->touch)->isEqualTo(new stream\invoker('stream_metadata'))
  88. ->object($streamController->chmod)->isEqualTo(new stream\invoker('stream_metadata'))
  89. ->object($streamController->chown)->isEqualTo(new stream\invoker('stream_metadata'))
  90. ->object($streamController->chgrp)->isEqualTo(new stream\invoker('stream_metadata'))
  91. ->object($streamController->stream_open)->isEqualTo(new stream\invoker('stream_open'))
  92. ->object($streamController->fopen)->isEqualTo(new stream\invoker('stream_open'))
  93. ->object($streamController->stream_read)->isEqualTo(new stream\invoker('stream_read'))
  94. ->object($streamController->fread)->isEqualTo(new stream\invoker('stream_read'))
  95. ->object($streamController->stream_seek)->isEqualTo(new stream\invoker('stream_seek'))
  96. ->object($streamController->fseek)->isEqualTo(new stream\invoker('stream_seek'))
  97. ->object($streamController->stream_set_option)->isEqualTo(new stream\invoker('stream_set_option'))
  98. ->object($streamController->stream_stat)->isEqualTo(new stream\invoker('stream_stat'))
  99. ->object($streamController->fstat)->isEqualTo(new stream\invoker('stream_stat'))
  100. ->object($streamController->stream_tell)->isEqualTo(new stream\invoker('stream_tell'))
  101. ->object($streamController->ftell)->isEqualTo(new stream\invoker('stream_tell'))
  102. ->object($streamController->stream_write)->isEqualTo(new stream\invoker('stream_write'))
  103. ->object($streamController->fwrite)->isEqualTo(new stream\invoker('stream_write'))
  104. ->object($streamController->unlink)->isEqualTo(new stream\invoker('unlink'))
  105. ->object($streamController->url_stat)->isEqualTo(new stream\invoker('url_stat'))
  106. ->object($streamController->stat)->isEqualTo(new stream\invoker('url_stat'))
  107. ->if($method = uniqid())
  108. ->then
  109. ->exception(function() use ($streamController, $method) {
  110. $streamController->{$method};
  111. }
  112. )
  113. ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')
  114. ->hasMessage('Method streamWrapper::' . $method . '() does not exist')
  115. ;
  116. }
  117. public function test__set()
  118. {
  119. $this
  120. ->if($streamController = new testedClass(uniqid()))
  121. ->and($streamController->__construct = $__construct = uniqid())
  122. ->then
  123. ->string($streamController->invoke('__construct'))->isEqualTo($__construct)
  124. ->if($streamController->dir_closedir = $dir_closedir = uniqid())
  125. ->then
  126. ->string($streamController->invoke('dir_closedir'))->isEqualTo($dir_closedir)
  127. ->if($streamController->closedir = $closedir = uniqid())
  128. ->then
  129. ->string($streamController->invoke('closedir'))->isEqualTo($closedir)
  130. ->if($streamController->dir_opendir = $dir_opendir = uniqid())
  131. ->then
  132. ->string($streamController->invoke('dir_opendir'))->isEqualTo($dir_opendir)
  133. ->if($streamController->opendir = $opendir = uniqid())
  134. ->then
  135. ->string($streamController->invoke('opendir'))->isEqualTo($opendir)
  136. ->if($streamController->dir_readdir = $dir_readdir = uniqid())
  137. ->then
  138. ->string($streamController->invoke('dir_readdir'))->isEqualTo($dir_readdir)
  139. ->if($streamController->readdir = $readdir = uniqid())
  140. ->then
  141. ->string($streamController->invoke('readdir'))->isEqualTo($readdir)
  142. ->if($streamController->dir_rewinddir = $dir_rewinddir = uniqid())
  143. ->then
  144. ->string($streamController->invoke('dir_rewinddir'))->isEqualTo($dir_rewinddir)
  145. ->if($streamController->rewinddir = $rewinddir = uniqid())
  146. ->then
  147. ->string($streamController->invoke('rewinddir'))->isEqualTo($rewinddir)
  148. ->if($streamController->mkdir = $mkdir = uniqid())
  149. ->then
  150. ->string($streamController->invoke('mkdir'))->isEqualTo($mkdir)
  151. ->if($streamController->rename = $rename = uniqid())
  152. ->then
  153. ->string($streamController->invoke('rename'))->isEqualTo($rename)
  154. ->if($streamController->rmdir = $rmdir = uniqid())
  155. ->then
  156. ->string($streamController->invoke('rmdir'))->isEqualTo($rmdir)
  157. ->if($streamController->stream_cast = $stream_cast = uniqid())
  158. ->then
  159. ->string($streamController->invoke('stream_cast'))->isEqualTo($stream_cast)
  160. ->if($streamController->select = $select = uniqid())
  161. ->then
  162. ->string($streamController->invoke('select'))->isEqualTo($select)
  163. ->if($streamController->stream_close = $stream_close = uniqid())
  164. ->then
  165. ->string($streamController->invoke('stream_close'))->isEqualTo($stream_close)
  166. ->if($streamController->fclose = $fclose = uniqid())
  167. ->then
  168. ->string($streamController->invoke('fclose'))->isEqualTo($fclose)
  169. ->if($streamController->stream_eof = $stream_eof = uniqid())
  170. ->then
  171. ->string($streamController->invoke('stream_eof'))->isEqualTo($stream_eof)
  172. ->if($streamController->feof = $feof = uniqid())
  173. ->then
  174. ->string($streamController->invoke('feof'))->isEqualTo($feof)
  175. ->if($streamController->stream_flush = $stream_flush = uniqid())
  176. ->then
  177. ->string($streamController->invoke('stream_flush'))->isEqualTo($stream_flush)
  178. ->if($streamController->fflush = $fflush = uniqid())
  179. ->then
  180. ->string($streamController->invoke('fflush'))->isEqualTo($fflush)
  181. ->if($streamController->stream_lock = $stream_lock = uniqid())
  182. ->then
  183. ->string($streamController->invoke('stream_lock'))->isEqualTo($stream_lock)
  184. ->if($streamController->flock = $flock = uniqid())
  185. ->then
  186. ->string($streamController->invoke('flock'))->isEqualTo($flock)
  187. ->if($streamController->stream_metadata = $stream_metadata = uniqid())
  188. ->then
  189. ->string($streamController->invoke('stream_metadata'))->isEqualTo($stream_metadata)
  190. ->if($streamController->touch = $touch = uniqid())
  191. ->then
  192. ->string($streamController->invoke('touch'))->isEqualTo($touch)
  193. ->if($streamController->chmod = $chmod = uniqid())
  194. ->then
  195. ->string($streamController->invoke('chmod'))->isEqualTo($chmod)
  196. ->if($streamController->chown = $chown = uniqid())
  197. ->then
  198. ->string($streamController->invoke('chown'))->isEqualTo($chown)
  199. ->if($streamController->chgrp = $chgrp = uniqid())
  200. ->then
  201. ->string($streamController->invoke('chgrp'))->isEqualTo($chgrp)
  202. ->if($streamController->stream_open = $stream_open = uniqid())
  203. ->then
  204. ->string($streamController->invoke('stream_open'))->isEqualTo($stream_open)
  205. ->if($streamController->fopen = $fopen = uniqid())
  206. ->then
  207. ->string($streamController->invoke('fopen'))->isEqualTo($fopen)
  208. ->if($streamController->stream_read = $stream_read = uniqid())
  209. ->then
  210. ->string($streamController->invoke('stream_read'))->isEqualTo($stream_read)
  211. ->if($streamController->fread = $fread = uniqid())
  212. ->then
  213. ->string($streamController->invoke('fread'))->isEqualTo($fread)
  214. ->if($streamController->stream_seek = $stream_seek = uniqid())
  215. ->then
  216. ->string($streamController->invoke('stream_seek'))->isEqualTo($stream_seek)
  217. ->if($streamController->fseek = $fseek = uniqid())
  218. ->then
  219. ->string($streamController->invoke('fseek'))->isEqualTo($fseek)
  220. ->if($streamController->stream_set_option = $stream_set_option = uniqid())
  221. ->then
  222. ->string($streamController->invoke('stream_set_option'))->isEqualTo($stream_set_option)
  223. ->if($streamController->stream_stat = $stream_stat = uniqid())
  224. ->then
  225. ->string($streamController->invoke('stream_stat'))->isEqualTo($stream_stat)
  226. ->if($streamController->fstat = $fstat = uniqid())
  227. ->then
  228. ->string($streamController->invoke('fstat'))->isEqualTo($fstat)
  229. ->if($streamController->stream_tell = $stream_tell = uniqid())
  230. ->then
  231. ->string($streamController->invoke('stream_tell'))->isEqualTo($stream_tell)
  232. ->if($streamController->ftell = $ftell = uniqid())
  233. ->then
  234. ->string($streamController->invoke('ftell'))->isEqualTo($ftell)
  235. ->if($streamController->stream_write = $stream_write = uniqid())
  236. ->then
  237. ->string($streamController->invoke('stream_write'))->isEqualTo($stream_write)
  238. ->if($streamController->fwrite = $fwrite = uniqid())
  239. ->then
  240. ->string($streamController->invoke('fwrite'))->isEqualTo($fwrite)
  241. ->if($streamController->unlink = $unlink = uniqid())
  242. ->then
  243. ->string($streamController->invoke('unlink'))->isEqualTo($unlink)
  244. ->if($streamController->url_stat = $url_stat = uniqid())
  245. ->then
  246. ->string($streamController->invoke('url_stat'))->isEqualTo($url_stat)
  247. ->if($streamController->stat = $stat = uniqid())
  248. ->then
  249. ->string($streamController->invoke('stat'))->isEqualTo($stat)
  250. ->if($streamController->resetCalls()->file_get_contents = $contents = uniqid())
  251. ->then
  252. ->boolean($streamController->invoke('fopen'))->isTrue()
  253. ->string($streamController->invoke('fread'))->isEqualTo($contents)
  254. ->boolean($streamController->invoke('fread'))->isFalse()
  255. ->boolean($streamController->invoke('fclose'))->isTrue()
  256. ->if($streamController->resetCalls()->file_put_contents = true)
  257. ->then
  258. ->boolean($streamController->invoke('fopen'))->isTrue()
  259. ->boolean($streamController->invoke('fwrite'))->isTrue()
  260. ->boolean($streamController->invoke('fclose'))->isTrue()
  261. ->if($streamController->resetCalls()->file_put_contents = false)
  262. ->then
  263. ->boolean($streamController->invoke('fopen'))->isTrue()
  264. ->boolean($streamController->invoke('fwrite'))->isFalse()
  265. ->boolean($streamController->invoke('fclose'))->isTrue()
  266. ->if($method = uniqid())
  267. ->then
  268. ->exception(function() use ($streamController, $method) {
  269. $streamController->{$method} = uniqid();
  270. }
  271. )
  272. ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')
  273. ->hasMessage('Method streamWrapper::' . $method . '() does not exist')
  274. ;
  275. }
  276. public function test__isset()
  277. {
  278. $this
  279. ->if($streamController = new testedClass(uniqid()))
  280. ->then
  281. ->boolean(isset($streamController->__construct))->isFalse()
  282. ->boolean(isset($streamController->dir_closedir))->isFalse()
  283. ->boolean(isset($streamController->closedir))->isFalse()
  284. ->boolean(isset($streamController->dir_opendir))->isFalse()
  285. ->boolean(isset($streamController->opendir))->isFalse()
  286. ->boolean(isset($streamController->dir_readdir))->isFalse()
  287. ->boolean(isset($streamController->readdir))->isFalse()
  288. ->boolean(isset($streamController->dir_rewinddir))->isFalse()
  289. ->boolean(isset($streamController->rewinddir))->isFalse()
  290. ->boolean(isset($streamController->mkdir))->isFalse()
  291. ->boolean(isset($streamController->rename))->isFalse()
  292. ->boolean(isset($streamController->rmdir))->isFalse()
  293. ->boolean(isset($streamController->stream_cast))->isFalse()
  294. ->boolean(isset($streamController->select))->isFalse()
  295. ->boolean(isset($streamController->stream_close))->isFalse()
  296. ->boolean(isset($streamController->fclose))->isFalse()
  297. ->boolean(isset($streamController->stream_eof))->isFalse()
  298. ->boolean(isset($streamController->feof))->isFalse()
  299. ->boolean(isset($streamController->stream_flush))->isFalse()
  300. ->boolean(isset($streamController->fflush))->isFalse()
  301. ->boolean(isset($streamController->stream_lock))->isFalse()
  302. ->boolean(isset($streamController->flock))->isFalse()
  303. ->boolean(isset($streamController->stream_metadata))->isFalse()
  304. ->boolean(isset($streamController->touch))->isFalse()
  305. ->boolean(isset($streamController->chmod))->isFalse()
  306. ->boolean(isset($streamController->chown))->isFalse()
  307. ->boolean(isset($streamController->chgrp))->isFalse()
  308. ->boolean(isset($streamController->stream_open))->isFalse()
  309. ->boolean(isset($streamController->fopen))->isFalse()
  310. ->boolean(isset($streamController->stream_read))->isFalse()
  311. ->boolean(isset($streamController->fread))->isFalse()
  312. ->boolean(isset($streamController->stream_seek))->isFalse()
  313. ->boolean(isset($streamController->fseek))->isFalse()
  314. ->boolean(isset($streamController->stream_set_option))->isFalse()
  315. ->boolean(isset($streamController->stream_stat))->isFalse()
  316. ->boolean(isset($streamController->fstat))->isFalse()
  317. ->boolean(isset($streamController->stream_tell))->isFalse()
  318. ->boolean(isset($streamController->ftell))->isFalse()
  319. ->boolean(isset($streamController->stream_write))->isFalse()
  320. ->boolean(isset($streamController->fwrite))->isFalse()
  321. ->boolean(isset($streamController->unlink))->isFalse()
  322. ->boolean(isset($streamController->url_stat))->isFalse()
  323. ->boolean(isset($streamController->stat))->isFalse()
  324. ->if($streamController->__construct = uniqid())
  325. ->and($streamController->dir_closedir = uniqid())
  326. ->and($streamController->closedir = uniqid())
  327. ->and($streamController->dir_opendir = uniqid())
  328. ->and($streamController->opendir = uniqid())
  329. ->and($streamController->dir_readdir = uniqid())
  330. ->and($streamController->readdir = uniqid())
  331. ->and($streamController->dir_rewinddir = uniqid())
  332. ->and($streamController->rewinddir = uniqid())
  333. ->and($streamController->mkdir = uniqid())
  334. ->and($streamController->rename = uniqid())
  335. ->and($streamController->rmdir = uniqid())
  336. ->and($streamController->stream_cast = uniqid())
  337. ->and($streamController->select = uniqid())
  338. ->and($streamController->stream_close = uniqid())
  339. ->and($streamController->fclose = uniqid())
  340. ->and($streamController->stream_eof = uniqid())
  341. ->and($streamController->feof = uniqid())
  342. ->and($streamController->stream_flush = uniqid())
  343. ->and($streamController->fflush = uniqid())
  344. ->and($streamController->stream_lock = uniqid())
  345. ->and($streamController->flock = uniqid())
  346. ->and($streamController->stream_metadata = uniqid())
  347. ->and($streamController->touch = uniqid())
  348. ->and($streamController->chown = uniqid())
  349. ->and($streamController->chmod = uniqid())
  350. ->and($streamController->chgrp = uniqid())
  351. ->and($streamController->stream_open = uniqid())
  352. ->and($streamController->fopen = uniqid())
  353. ->and($streamController->stream_read = uniqid())
  354. ->and($streamController->fread = uniqid())
  355. ->and($streamController->stream_seek = uniqid())
  356. ->and($streamController->fseek = uniqid())
  357. ->and($streamController->stream_set_option = uniqid())
  358. ->and($streamController->stream_stat = uniqid())
  359. ->and($streamController->fstat = uniqid())
  360. ->and($streamController->stream_tell = uniqid())
  361. ->and($streamController->ftell = uniqid())
  362. ->and($streamController->stream_write = uniqid())
  363. ->and($streamController->fwrite = uniqid())
  364. ->and($streamController->unlink = uniqid())
  365. ->and($streamController->url_stat = uniqid())
  366. ->and($streamController->stat = uniqid())
  367. ->then
  368. ->boolean(isset($streamController->__construct))->isTrue()
  369. ->boolean(isset($streamController->dir_closedir))->isTrue()
  370. ->boolean(isset($streamController->closedir))->isTrue()
  371. ->boolean(isset($streamController->dir_opendir))->isTrue()
  372. ->boolean(isset($streamController->opendir))->isTrue()
  373. ->boolean(isset($streamController->dir_readdir))->isTrue()
  374. ->boolean(isset($streamController->readdir))->isTrue()
  375. ->boolean(isset($streamController->dir_rewinddir))->isTrue()
  376. ->boolean(isset($streamController->rewinddir))->isTrue()
  377. ->boolean(isset($streamController->mkdir))->isTrue()
  378. ->boolean(isset($streamController->rename))->isTrue()
  379. ->boolean(isset($streamController->rmdir))->isTrue()
  380. ->boolean(isset($streamController->stream_cast))->isTrue()
  381. ->boolean(isset($streamController->select))->isTrue()
  382. ->boolean(isset($streamController->stream_close))->isTrue()
  383. ->boolean(isset($streamController->fclose))->isTrue()
  384. ->boolean(isset($streamController->stream_eof))->isTrue()
  385. ->boolean(isset($streamController->feof))->isTrue()
  386. ->boolean(isset($streamController->stream_flush))->isTrue()
  387. ->boolean(isset($streamController->fflush))->isTrue()
  388. ->boolean(isset($streamController->stream_lock))->isTrue()
  389. ->boolean(isset($streamController->flock))->isTrue()
  390. ->boolean(isset($streamController->stream_metadata))->isTrue()
  391. ->boolean(isset($streamController->touch))->isTrue()
  392. ->boolean(isset($streamController->chmod))->isTrue()
  393. ->boolean(isset($streamController->chown))->isTrue()
  394. ->boolean(isset($streamController->chgrp))->isTrue()
  395. ->boolean(isset($streamController->stream_open))->isTrue()
  396. ->boolean(isset($streamController->fopen))->isTrue()
  397. ->boolean(isset($streamController->stream_read))->isTrue()
  398. ->boolean(isset($streamController->fread))->isTrue()
  399. ->boolean(isset($streamController->stream_seek))->isTrue()
  400. ->boolean(isset($streamController->fseek))->isTrue()
  401. ->boolean(isset($streamController->stream_set_option))->isTrue()
  402. ->boolean(isset($streamController->stream_stat))->isTrue()
  403. ->boolean(isset($streamController->fstat))->isTrue()
  404. ->boolean(isset($streamController->stream_tell))->isTrue()
  405. ->boolean(isset($streamController->ftell))->isTrue()
  406. ->boolean(isset($streamController->stream_write))->isTrue()
  407. ->boolean(isset($streamController->fwrite))->isTrue()
  408. ->boolean(isset($streamController->unlink))->isTrue()
  409. ->boolean(isset($streamController->url_stat))->isTrue()
  410. ->boolean(isset($streamController->stat))->isTrue()
  411. ->if($method = uniqid())
  412. ->then
  413. ->exception(function() use ($streamController, $method) {
  414. isset($streamController->{$method});
  415. }
  416. )
  417. ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')
  418. ->hasMessage('Method streamWrapper::' . $method . '() does not exist')
  419. ;
  420. }
  421. public function test__unset()
  422. {
  423. $this
  424. ->if($streamController = new testedClass(uniqid()))
  425. ->then
  426. ->boolean(isset($streamController->__construct))->isFalse()
  427. ->when(function() use ($streamController) { unset($streamController->__construct); })
  428. ->boolean(isset($streamController->__construct))->isFalse()
  429. ->boolean(isset($streamController->dir_closedir))->isFalse()
  430. ->when(function() use ($streamController) { unset($streamController->dir_closedir); })
  431. ->boolean(isset($streamController->dir_closedir))->isFalse()
  432. ->boolean(isset($streamController->closedir))->isFalse()
  433. ->when(function() use ($streamController) { unset($streamController->closedir); })
  434. ->boolean(isset($streamController->closedir))->isFalse()
  435. ->boolean(isset($streamController->dir_opendir))->isFalse()
  436. ->when(function() use ($streamController) { unset($streamController->dir_opendir); })
  437. ->boolean(isset($streamController->dir_opendir))->isFalse()
  438. ->boolean(isset($streamController->opendir))->isFalse()
  439. ->when(function() use ($streamController) { unset($streamController->opendir); })
  440. ->boolean(isset($streamController->opendir))->isFalse()
  441. ->boolean(isset($streamController->dir_readdir))->isFalse()
  442. ->when(function() use ($streamController) { unset($streamController->dir_readdir); })
  443. ->boolean(isset($streamController->dir_readdir))->isFalse()
  444. ->boolean(isset($streamController->readdir))->isFalse()
  445. ->when(function() use ($streamController) { unset($streamController->readdir); })
  446. ->boolean(isset($streamController->readdir))->isFalse()
  447. ->boolean(isset($streamController->dir_rewinddir))->isFalse()
  448. ->when(function() use ($streamController) { unset($streamController->dir_rewinddir); })
  449. ->boolean(isset($streamController->dir_rewinddir))->isFalse()
  450. ->boolean(isset($streamController->rewinddir))->isFalse()
  451. ->when(function() use ($streamController) { unset($streamController->rewinddir); })
  452. ->boolean(isset($streamController->rewinddir))->isFalse()
  453. ->boolean(isset($streamController->mkdir))->isFalse()
  454. ->when(function() use ($streamController) { unset($streamController->mkdir); })
  455. ->boolean(isset($streamController->mkdir))->isFalse()
  456. ->boolean(isset($streamController->rename))->isFalse()
  457. ->when(function() use ($streamController) { unset($streamController->rename); })
  458. ->boolean(isset($streamController->rename))->isFalse()
  459. ->boolean(isset($streamController->rmdir))->isFalse()
  460. ->when(function() use ($streamController) { unset($streamController->rmdir); })
  461. ->boolean(isset($streamController->rmdir))->isFalse()
  462. ->boolean(isset($streamController->stream_cast))->isFalse()
  463. ->when(function() use ($streamController) { unset($streamController->stream_cast); })
  464. ->boolean(isset($streamController->stream_cast))->isFalse()
  465. ->boolean(isset($streamController->select))->isFalse()
  466. ->when(function() use ($streamController) { unset($streamController->select); })
  467. ->boolean(isset($streamController->select))->isFalse()
  468. ->boolean(isset($streamController->stream_close))->isFalse()
  469. ->when(function() use ($streamController) { unset($streamController->stream_close); })
  470. ->boolean(isset($streamController->stream_close))->isFalse()
  471. ->boolean(isset($streamController->fclose))->isFalse()
  472. ->when(function() use ($streamController) { unset($streamController->fclose); })
  473. ->boolean(isset($streamController->fclose))->isFalse()
  474. ->boolean(isset($streamController->stream_eof))->isFalse()
  475. ->when(function() use ($streamController) { unset($streamController->stream_eof); })
  476. ->boolean(isset($streamController->stream_eof))->isFalse()
  477. ->boolean(isset($streamController->feof))->isFalse()
  478. ->when(function() use ($streamController) { unset($streamController->feof); })
  479. ->boolean(isset($streamController->feof))->isFalse()
  480. ->boolean(isset($streamController->stream_flush))->isFalse()
  481. ->when(function() use ($streamController) { unset($streamController->stream_flush); })
  482. ->boolean(isset($streamController->stream_flush))->isFalse()
  483. ->boolean(isset($streamController->fflush))->isFalse()
  484. ->when(function() use ($streamController) { unset($streamController->fflush); })
  485. ->boolean(isset($streamController->fflush))->isFalse()
  486. ->boolean(isset($streamController->stream_lock))->isFalse()
  487. ->when(function() use ($streamController) { unset($streamController->stream_lock); })
  488. ->boolean(isset($streamController->stream_lock))->isFalse()
  489. ->boolean(isset($streamController->flock))->isFalse()
  490. ->when(function() use ($streamController) { unset($streamController->flock); })
  491. ->boolean(isset($streamController->flock))->isFalse()
  492. ->boolean(isset($streamController->stream_metadata))->isFalse()
  493. ->when(function() use ($streamController) { unset($streamController->stream_metadata); })
  494. ->boolean(isset($streamController->stream_metadata))->isFalse()
  495. ->boolean(isset($streamController->touch))->isFalse()
  496. ->when(function() use ($streamController) { unset($streamController->touch); })
  497. ->boolean(isset($streamController->touch))->isFalse()
  498. ->boolean(isset($streamController->chmod))->isFalse()
  499. ->when(function() use ($streamController) { unset($streamController->chmod); })
  500. ->boolean(isset($streamController->chmod))->isFalse()
  501. ->boolean(isset($streamController->chown))->isFalse()
  502. ->when(function() use ($streamController) { unset($streamController->chown); })
  503. ->boolean(isset($streamController->chown))->isFalse()
  504. ->boolean(isset($streamController->chgrp))->isFalse()
  505. ->when(function() use ($streamController) { unset($streamController->chgrp); })
  506. ->boolean(isset($streamController->chgrp))->isFalse()
  507. ->boolean(isset($streamController->stream_open))->isFalse()
  508. ->when(function() use ($streamController) { unset($streamController->stream_open); })
  509. ->boolean(isset($streamController->stream_open))->isFalse()
  510. ->boolean(isset($streamController->fopen))->isFalse()
  511. ->when(function() use ($streamController) { unset($streamController->fopen); })
  512. ->boolean(isset($streamController->fopen))->isFalse()
  513. ->boolean(isset($streamController->stream_read))->isFalse()
  514. ->when(function() use ($streamController) { unset($streamController->stream_read); })
  515. ->boolean(isset($streamController->stream_read))->isFalse()
  516. ->boolean(isset($streamController->fread))->isFalse()
  517. ->when(function() use ($streamController) { unset($streamController->fread); })
  518. ->boolean(isset($streamController->fread))->isFalse()
  519. ->boolean(isset($streamController->stream_seek))->isFalse()
  520. ->when(function() use ($streamController) { unset($streamController->stream_seek); })
  521. ->boolean(isset($streamController->stream_seek))->isFalse()
  522. ->boolean(isset($streamController->fseek))->isFalse()
  523. ->when(function() use ($streamController) { unset($streamController->fseek); })
  524. ->boolean(isset($streamController->fseek))->isFalse()
  525. ->boolean(isset($streamController->stream_set_option))->isFalse()
  526. ->when(function() use ($streamController) { unset($streamController->stream_set_option); })
  527. ->boolean(isset($streamController->stream_set_option))->isFalse()
  528. ->boolean(isset($streamController->stream_stat))->isFalse()
  529. ->when(function() use ($streamController) { unset($streamController->stream_stat); })
  530. ->boolean(isset($streamController->stream_stat))->isFalse()
  531. ->boolean(isset($streamController->fstat))->isFalse()
  532. ->when(function() use ($streamController) { unset($streamController->fstat); })
  533. ->boolean(isset($streamController->fstat))->isFalse()
  534. ->boolean(isset($streamController->stream_tell))->isFalse()
  535. ->when(function() use ($streamController) { unset($streamController->stream_tell); })
  536. ->boolean(isset($streamController->stream_tell))->isFalse()
  537. ->boolean(isset($streamController->ftell))->isFalse()
  538. ->when(function() use ($streamController) { unset($streamController->ftell); })
  539. ->boolean(isset($streamController->ftell))->isFalse()
  540. ->boolean(isset($streamController->stream_write))->isFalse()
  541. ->when(function() use ($streamController) { unset($streamController->stream_write); })
  542. ->boolean(isset($streamController->stream_write))->isFalse()
  543. ->boolean(isset($streamController->fwrite))->isFalse()
  544. ->when(function() use ($streamController) { unset($streamController->fwrite); })
  545. ->boolean(isset($streamController->fwrite))->isFalse()
  546. ->boolean(isset($streamController->unlink))->isFalse()
  547. ->when(function() use ($streamController) { unset($streamController->unlink); })
  548. ->boolean(isset($streamController->unlink))->isFalse()
  549. ->boolean(isset($streamController->url_stat))->isFalse()
  550. ->when(function() use ($streamController) { unset($streamController->url_stat); })
  551. ->boolean(isset($streamController->url_stat))->isFalse()
  552. ->boolean(isset($streamController->stat))->isFalse()
  553. ->when(function() use ($streamController) { unset($streamController->stat); })
  554. ->boolean(isset($streamController->stat))->isFalse()
  555. ->if($streamController->__construct = uniqid())
  556. ->and($streamController->dir_closedir = uniqid())
  557. ->and($streamController->closedir = uniqid())
  558. ->and($streamController->dir_opendir = uniqid())
  559. ->and($streamController->opendir = uniqid())
  560. ->and($streamController->dir_readdir = uniqid())
  561. ->and($streamController->readdir = uniqid())
  562. ->and($streamController->dir_rewinddir = uniqid())
  563. ->and($streamController->rewinddir = uniqid())
  564. ->and($streamController->mkdir = uniqid())
  565. ->and($streamController->rename = uniqid())
  566. ->and($streamController->rmdir = uniqid())
  567. ->and($streamController->stream_cast = uniqid())
  568. ->and($streamController->select = uniqid())
  569. ->and($streamController->stream_close = uniqid())
  570. ->and($streamController->fclose = uniqid())
  571. ->and($streamController->stream_eof = uniqid())
  572. ->and($streamController->feof = uniqid())
  573. ->and($streamController->stream_flush = uniqid())
  574. ->and($streamController->fflush = uniqid())
  575. ->and($streamController->stream_lock = uniqid())
  576. ->and($streamController->flock = uniqid())
  577. ->and($streamController->stream_metadata = uniqid())
  578. ->and($streamController->touch = uniqid())
  579. ->and($streamController->chown = uniqid())
  580. ->and($streamController->chmod = uniqid())
  581. ->and($streamController->chgrp = uniqid())
  582. ->and($streamController->stream_open = uniqid())
  583. ->and($streamController->fopen = uniqid())
  584. ->and($streamController->stream_read = uniqid())
  585. ->and($streamController->fread = uniqid())
  586. ->and($streamController->stream_seek = uniqid())
  587. ->and($streamController->fseek = uniqid())
  588. ->and($streamController->stream_set_option = uniqid())
  589. ->and($streamController->stream_stat = uniqid())
  590. ->and($streamController->fstat = uniqid())
  591. ->and($streamController->stream_tell = uniqid())
  592. ->and($streamController->ftell = uniqid())
  593. ->and($streamController->stream_write = uniqid())
  594. ->and($streamController->fwrite = uniqid())
  595. ->and($streamController->unlink = uniqid())
  596. ->and($streamController->url_stat = uniqid())
  597. ->and($streamController->stat = uniqid())
  598. ->then
  599. ->boolean(isset($streamController->__construct))->isTrue()
  600. ->when(function() use ($streamController) { unset($streamController->__construct); })
  601. ->boolean(isset($streamController->__construct))->isFalse()
  602. ->when(function() use ($streamController) { unset($streamController->dir_closedir); })
  603. ->boolean(isset($streamController->dir_closedir))->isFalse()
  604. ->boolean(isset($streamController->closedir))->isFalse()
  605. ->when(function() use ($streamController) { unset($streamController->dir_opendir); })
  606. ->boolean(isset($streamController->dir_opendir))->isFalse()
  607. ->boolean(isset($streamController->opendir))->isFalse()
  608. ->when(function() use ($streamController) { unset($streamController->dir_readdir); })
  609. ->boolean(isset($streamController->dir_readdir))->isFalse()
  610. ->boolean(isset($streamController->readdir))->isFalse()
  611. ->when(function() use ($streamController) { unset($streamController->dir_rewinddir); })
  612. ->boolean(isset($streamController->dir_rewinddir))->isFalse()
  613. ->boolean(isset($streamController->rewinddir))->isFalse()
  614. ->when(function() use ($streamController) { unset($streamController->mkdir); })
  615. ->boolean(isset($streamController->mkdir))->isFalse()
  616. ->when(function() use ($streamController) { unset($streamController->rename); })
  617. ->boolean(isset($streamController->rename))->isFalse()
  618. ->when(function() use ($streamController) { unset($streamController->rmdir); })
  619. ->boolean(isset($streamController->rmdir))->isFalse()
  620. ->when(function() use ($streamController) { unset($streamController->stream_cast); })
  621. ->boolean(isset($streamController->stream_cast))->isFalse()
  622. ->boolean(isset($streamController->select))->isFalse()
  623. ->when(function() use ($streamController) { unset($streamController->stream_close); })
  624. ->boolean(isset($streamController->stream_close))->isFalse()
  625. ->boolean(isset($streamController->fclose))->isFalse()
  626. ->when(function() use ($streamController) { unset($streamController->stream_eof); })
  627. ->boolean(isset($streamController->stream_eof))->isFalse()
  628. ->boolean(isset($streamController->feof))->isFalse()
  629. ->when(function() use ($streamController) { unset($streamController->stream_flush); })
  630. ->boolean(isset($streamController->stream_flush))->isFalse()
  631. ->boolean(isset($streamController->fflush))->isFalse()
  632. ->when(function() use ($streamController) { unset($streamController->stream_lock); })
  633. ->boolean(isset($streamController->stream_lock))->isFalse()
  634. ->boolean(isset($streamController->flock))->isFalse()
  635. ->when(function() use ($streamController) { unset($streamController->stream_metadata); })
  636. ->boolean(isset($streamController->stream_metadata))->isFalse()
  637. ->boolean(isset($streamController->touch))->isFalse()
  638. ->boolean(isset($streamController->chmod))->isFalse()
  639. ->boolean(isset($streamController->chown))->isFalse()
  640. ->boolean(isset($streamController->chgrp))->isFalse()
  641. ->when(function() use ($streamController) { unset($streamController->stream_open); })
  642. ->boolean(isset($streamController->stream_open))->isFalse()
  643. ->boolean(isset($streamController->fopen))->isFalse()
  644. ->when(function() use ($streamController) { unset($streamController->stream_read); })
  645. ->boolean(isset($streamController->stream_read))->isFalse()
  646. ->boolean(isset($streamController->fread))->isFalse()
  647. ->when(function() use ($streamController) { unset($streamController->stream_seek); })
  648. ->boolean(isset($streamController->stream_seek))->isFalse()
  649. ->boolean(isset($streamController->fseek))->isFalse()
  650. ->when(function() use ($streamController) { unset($streamController->stream_set_option); })
  651. ->boolean(isset($streamController->stream_set_option))->isFalse()
  652. ->when(function() use ($streamController) { unset($streamController->stream_stat); })
  653. ->boolean(isset($streamController->stream_stat))->isFalse()
  654. ->boolean(isset($streamController->fstat))->isFalse()
  655. ->when(function() use ($streamController) { unset($streamController->stream_tell); })
  656. ->boolean(isset($streamController->stream_tell))->isFalse()
  657. ->boolean(isset($streamController->ftell))->isFalse()
  658. ->when(function() use ($streamController) { unset($streamController->stream_write); })
  659. ->boolean(isset($streamController->stream_write))->isFalse()
  660. ->boolean(isset($streamController->fwrite))->isFalse()
  661. ->when(function() use ($streamController) { unset($streamController->unlink); })
  662. ->boolean(isset($streamController->unlink))->isFalse()
  663. ->when(function() use ($streamController) { unset($streamController->url_stat); })
  664. ->boolean(isset($streamController->url_stat))->isFalse()
  665. ->boolean(isset($streamController->stat))->isFalse()
  666. ->if($method = uniqid())
  667. ->then
  668. ->exception(function() use ($streamController, $method) {
  669. unset($streamController->{$method});
  670. }
  671. )
  672. ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')
  673. ->hasMessage('Method streamWrapper::' . $method . '() does not exist')
  674. ;
  675. }
  676. public function testSetPath()
  677. {
  678. $this
  679. ->if($streamController = new testedClass(uniqid()))
  680. ->then
  681. ->object($streamController->setPath($newName = uniqid()))->isIdenticalTo($streamController)
  682. ->string($streamController->getPath())->isEqualTo($newName)
  683. ;
  684. }
  685. public function testGetBasename()
  686. {
  687. $this
  688. ->if($streamController = new testedClass($basename = uniqid()))
  689. ->then
  690. ->string($streamController->getBasename())->isEqualTo($basename)
  691. ->if($streamController = new testedClass(uniqid() . '://' . ($basename = uniqid())))
  692. ->then
  693. ->string($streamController->getBasename())->isEqualTo($basename)
  694. ->if($streamController = new testedClass(uniqid() . '://' . uniqid() . DIRECTORY_SEPARATOR . ($basename = uniqid())))
  695. ->then
  696. ->string($streamController->getBasename())->isEqualTo($basename)
  697. ;
  698. }
  699. public function testInvoke()
  700. {
  701. $this
  702. ->if($streamController = new testedClass(uniqid()))
  703. ->then
  704. ->variable($streamController->invoke('__construct'))->isNull()
  705. ->variable($streamController->invoke('dir_closedir'))->isNull()
  706. ->variable($streamController->invoke('closedir'))->isNull()
  707. ->variable($streamController->invoke('dir_opendir'))->isNull()
  708. ->variable($streamController->invoke('opendir'))->isNull()
  709. ->variable($streamController->invoke('dir_readdir'))->isNull()
  710. ->variable($streamController->invoke('readdir'))->isNull()
  711. ->variable($streamController->invoke('dir_rewinddir'))->isNull()
  712. ->variable($streamController->invoke('rewinddir'))->isNull()
  713. ->variable($streamController->invoke('mkdir'))->isNull()
  714. ->variable($streamController->invoke('rename'))->isNull()
  715. ->variable($streamController->invoke('rmdir'))->isNull()
  716. ->variable($streamController->invoke('stream_cast'))->isNull()
  717. ->variable($streamController->invoke('select'))->isNull()
  718. ->variable($streamController->invoke('stream_close'))->isNull()
  719. ->variable($streamController->invoke('fclose'))->isNull()
  720. ->variable($streamController->invoke('stream_eof'))->isNull()
  721. ->variable($streamController->invoke('feof'))->isNull()
  722. ->variable($streamController->invoke('stream_flush'))->isNull()
  723. ->variable($streamController->invoke('fflush'))->isNull()
  724. ->variable($streamController->invoke('stream_lock'))->isNull()
  725. ->variable($streamController->invoke('flock'))->isNull()
  726. ->variable($streamController->invoke('stream_metadata'))->isNull()
  727. ->variable($streamController->invoke('touch'))->isNull()
  728. ->variable($streamController->invoke('chown'))->isNull()
  729. ->variable($streamController->invoke('chmod'))->isNull()
  730. ->variable($streamController->invoke('chgrp'))->isNull()
  731. ->variable($streamController->invoke('stream_open'))->isNull()
  732. ->variable($streamController->invoke('fopen'))->isNull()
  733. ->variable($streamController->invoke('stream_read'))->isNull()
  734. ->variable($streamController->invoke('fread'))->isNull()
  735. ->variable($streamController->invoke('stream_seek'))->isNull()
  736. ->variable($streamController->invoke('fseek'))->isNull()
  737. ->variable($streamController->invoke('stream_set_option'))->isNull()
  738. ->variable($streamController->invoke('stream_stat'))->isNull()
  739. ->variable($streamController->invoke('fstat'))->isNull()
  740. ->variable($streamController->invoke('stream_tell'))->isNull()
  741. ->variable($streamController->invoke('ftell'))->isNull()
  742. ->variable($streamController->invoke('stream_write'))->isNull()
  743. ->variable($streamController->invoke('fwrite'))->isNull()
  744. ->variable($streamController->invoke('unlink'))->isNull()
  745. ->variable($streamController->invoke('url_stat'))->isNull()
  746. ->variable($streamController->invoke('stat'))->isNull()
  747. ->if($method = uniqid())
  748. ->then
  749. ->exception(function() use ($streamController, $method) {
  750. $streamController->invoke($method);
  751. }
  752. )
  753. ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')
  754. ->hasMessage('Method streamWrapper::' . $method . '() does not exist')
  755. ;
  756. }
  757. public function testDuplicate()
  758. {
  759. $this
  760. ->if($streamController = new testedClass(uniqid()))
  761. ->then
  762. ->object($duplicatedController = $streamController->duplicate())->isCloneOf($streamController)
  763. ->if($streamController->setPath($path = uniqid()))
  764. ->then
  765. ->string($duplicatedController->getPath())->isEqualTo($path)
  766. ->if($streamController->stream_lock())
  767. ->then
  768. ->object($duplicatedController->getCalls())->isEqualTo($streamController->getCalls())
  769. ->if($streamController->stream_lock = function() {})
  770. ->then
  771. ->array($duplicatedController->getInvokers())->isEqualTo($streamController->getInvokers())
  772. ;
  773. }
  774. }