PageRenderTime 34ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/units/classes/report/fields/runner/errors/cli.php

http://github.com/mageekguy/atoum
PHP | 750 lines | 737 code | 13 blank | 0 comment | 0 complexity | 6ecc82199b0d799842cc101829a15a40 MD5 | raw file
  1. <?php
  2. namespace mageekguy\atoum\tests\units\report\fields\runner\errors;
  3. use
  4. mageekguy\atoum,
  5. mageekguy\atoum\locale,
  6. mageekguy\atoum\cli\prompt,
  7. mageekguy\atoum\cli\colorizer,
  8. mageekguy\atoum\report\fields\runner,
  9. mock\mageekguy\atoum as mock
  10. ;
  11. require_once __DIR__ . '/../../../../../runner.php';
  12. class cli extends atoum\test
  13. {
  14. public function testClass()
  15. {
  16. $this->testedClass->extends('mageekguy\atoum\report\fields\runner\errors');
  17. }
  18. public function test__construct()
  19. {
  20. $this
  21. ->if($field = new runner\errors\cli())
  22. ->then
  23. ->object($field->getTitlePrompt())->isEqualTo(new prompt())
  24. ->object($field->getMethodPrompt())->isEqualTo(new prompt())
  25. ->object($field->getTitleColorizer())->isEqualTo(new colorizer())
  26. ->object($field->getMethodColorizer())->isEqualTo(new colorizer())
  27. ->object($field->getErrorPrompt())->isEqualTo(new prompt())
  28. ->object($field->getErrorColorizer())->isEqualTo(new colorizer())
  29. ->object($field->getLocale())->isEqualTo(new locale())
  30. ->variable($field->getRunner())->isNull()
  31. ->array($field->getEvents())->isEqualTo(array(atoum\runner::runStop))
  32. ;
  33. }
  34. public function testSetTitlePrompt()
  35. {
  36. $this
  37. ->if($field = new runner\errors\cli())
  38. ->then
  39. ->object($field->setTitlePrompt($prompt = new prompt(uniqid())))->isIdenticalTo($field)
  40. ->object($field->getTitlePrompt())->isIdenticalTo($prompt)
  41. ->object($field->setTitlePrompt())->isIdenticalTo($field)
  42. ->object($field->getTitlePrompt())
  43. ->isNotIdenticalTo($prompt)
  44. ->isEqualTo(new prompt())
  45. ;
  46. }
  47. public function testSetTitleColorizer()
  48. {
  49. $this
  50. ->if($field = new runner\errors\cli())
  51. ->then
  52. ->object($field->setTitleColorizer($colorizer = new colorizer()))->isIdenticalTo($field)
  53. ->object($field->getTitleColorizer())->isIdenticalTo($colorizer)
  54. ->object($field->setTitleColorizer())->isIdenticalTo($field)
  55. ->object($field->getTitleColorizer())
  56. ->isNotIdenticalTo($colorizer)
  57. ->isEqualTo(new colorizer())
  58. ;
  59. }
  60. public function testSetMethodPrompt()
  61. {
  62. $this
  63. ->if($field = new runner\errors\cli())
  64. ->then
  65. ->object($field->setMethodPrompt($prompt = new prompt(uniqid())))->isIdenticalTo($field)
  66. ->object($field->getMethodPrompt())->isIdenticalTo($prompt)
  67. ->object($field->setMethodPrompt())->isIdenticalTo($field)
  68. ->object($field->getMethodPrompt())
  69. ->isNotIdenticalTo($prompt)
  70. ->isEqualTo(new prompt())
  71. ;
  72. }
  73. public function testSetMethodColorizer()
  74. {
  75. $this
  76. ->if($field = new runner\errors\cli())
  77. ->then
  78. ->object($field->setMethodColorizer($colorizer = new colorizer()))->isIdenticalTo($field)
  79. ->object($field->getMethodColorizer())->isIdenticalTo($colorizer)
  80. ->object($field->setMethodColorizer())->isIdenticalTo($field)
  81. ->object($field->getMethodColorizer())
  82. ->isNotIdenticalTo($colorizer)
  83. ->isEqualTo(new colorizer())
  84. ;
  85. }
  86. public function testSetErrorPrompt()
  87. {
  88. $this
  89. ->if($field = new runner\errors\cli())
  90. ->then
  91. ->object($field->setErrorPrompt($prompt = new prompt(uniqid())))->isIdenticalTo($field)
  92. ->object($field->getErrorPrompt())->isIdenticalTo($prompt)
  93. ->object($field->setErrorPrompt())->isIdenticalTo($field)
  94. ->object($field->getErrorPrompt())
  95. ->isNotIdenticalTo($prompt)
  96. ->isEqualTo(new prompt())
  97. ;
  98. }
  99. public function testSetErrorColorizer()
  100. {
  101. $this
  102. ->if($field = new runner\errors\cli())
  103. ->then
  104. ->object($field->setErrorColorizer($colorizer = new colorizer()))->isIdenticalTo($field)
  105. ->object($field->getErrorColorizer())->isIdenticalTo($colorizer)
  106. ->object($field->setErrorColorizer())->isIdenticalTo($field)
  107. ->object($field->getErrorColorizer())
  108. ->isNotIdenticalTo($colorizer)
  109. ->isEqualTo(new colorizer())
  110. ;
  111. }
  112. public function testHandleEvent()
  113. {
  114. $this
  115. ->if($field = new runner\errors\cli())
  116. ->then
  117. ->boolean($field->handleEvent(atoum\runner::runStart, new atoum\runner()))->isFalse()
  118. ->variable($field->getRunner())->isNull()
  119. ->if($runner = new atoum\runner())
  120. ->then
  121. ->boolean($field->handleEvent(atoum\runner::runStop, $runner))->isTrue()
  122. ->object($field->getRunner())->isIdenticalTo($runner)
  123. ;
  124. }
  125. public function test__toString()
  126. {
  127. $this
  128. ->if($runner = new mock\runner())
  129. ->and($runner->getMockController()->getScore = $score = new mock\score())
  130. ->and($defaultField = new runner\errors\cli())
  131. ->and($customField = new runner\errors\cli($titlePrompt = new prompt(uniqid()), $titleColorizer = new colorizer(uniqid(), uniqid()), $methodPrompt = new prompt(uniqid()), $methodColorizer = new colorizer(uniqid(), uniqid()), $errorPrompt = new prompt(uniqid()), $errorColorizer = new colorizer(uniqid(), uniqid()), $locale = new atoum\locale()))
  132. ->and($score->getMockController()->getErrors = array())
  133. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  134. ->then
  135. ->castToString($defaultField)->isEmpty()
  136. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  137. ->then
  138. ->castToString($defaultField)->isEmpty()
  139. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  140. ->then
  141. ->castToString($defaultField)->isEmpty()
  142. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  143. ->then
  144. ->castToString($defaultField)->isEmpty()
  145. ->if($score->getMockController()->getErrors = $allErrors = array(
  146. array(
  147. 'case' => null,
  148. 'class' => $class = uniqid(),
  149. 'method' => $method = uniqid(),
  150. 'file' => $file = uniqid(),
  151. 'line' => $line = rand(1, PHP_INT_MAX),
  152. 'type' => $type = 'e_fake_error',
  153. 'message' => $message = uniqid(),
  154. 'errorFile' => $errorFile = uniqid(),
  155. 'errorLine' => $errorLine = rand(1, PHP_INT_MAX),
  156. ),
  157. array(
  158. 'case' => null,
  159. 'class' => $otherClass = uniqid(),
  160. 'method' => $otherMethod = uniqid(),
  161. 'file' => $otherFile = uniqid(),
  162. 'line' => $otherLine = rand(1, PHP_INT_MAX),
  163. 'type' => $otherType = 'e_other_fake_error',
  164. 'message' => ($firstOtherMessage = uniqid()) . PHP_EOL . ($secondOtherMessage = uniqid()),
  165. 'errorFile' => $otherErrorFile = uniqid(),
  166. 'errorLine' => $otherErrorLine = rand(1, PHP_INT_MAX),
  167. )
  168. )
  169. )
  170. ->and($defaultField = new runner\errors\cli())
  171. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  172. ->then
  173. ->castToString($defaultField)->isEmpty()
  174. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  175. ->then
  176. ->castToString($defaultField)->isEqualTo(
  177. sprintf('There are %d errors:', sizeof($allErrors)) . PHP_EOL .
  178. $class . '::' . $method . '():' . PHP_EOL .
  179. sprintf('Error %s in %s on line %d, generated by file %s on line %d:', strtoupper($type), $file, $line, $errorFile, $errorLine) . PHP_EOL .
  180. $message . PHP_EOL .
  181. $otherClass . '::' . $otherMethod . '():' . PHP_EOL .
  182. sprintf('Error %s in %s on line %d, generated by file %s on line %d:', strtoupper($otherType), $otherFile, $otherLine, $otherErrorFile, $otherErrorLine) . PHP_EOL .
  183. $firstOtherMessage . PHP_EOL .
  184. $secondOtherMessage . PHP_EOL
  185. )
  186. ->if($customField = new runner\errors\cli())
  187. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  188. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  189. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  190. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  191. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  192. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  193. ->and($customField->setLocale($locale = new atoum\locale()))
  194. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  195. ->then
  196. ->castToString($customField)->isEmpty()
  197. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  198. ->then
  199. ->castToString($customField)->isEqualTo(
  200. $titlePrompt .
  201. sprintf(
  202. $locale->_('%s:'),
  203. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  204. ) .
  205. PHP_EOL .
  206. $methodPrompt .
  207. sprintf(
  208. $locale->_('%s:'),
  209. $methodColorizer->colorize($class . '::' . $method . '()')
  210. ) .
  211. PHP_EOL .
  212. $errorPrompt .
  213. sprintf(
  214. $locale->_('%s:'),
  215. $errorColorizer->colorize(sprintf($locale->_('Error %s in %s on line %d, generated by file %s on line %d'), strtoupper($type), $file, $line, $errorFile, $errorLine))
  216. ) .
  217. PHP_EOL .
  218. $message . PHP_EOL .
  219. $methodPrompt .
  220. sprintf(
  221. $locale->_('%s:'),
  222. $methodColorizer->colorize($otherClass . '::' . $otherMethod . '()')
  223. ) .
  224. PHP_EOL .
  225. $errorPrompt .
  226. sprintf(
  227. $locale->_('%s:'),
  228. $errorColorizer->colorize(sprintf($locale->_('Error %s in %s on line %d, generated by file %s on line %d'), strtoupper($otherType), $otherFile, $otherLine, $otherErrorFile, $otherErrorLine))
  229. ) .
  230. PHP_EOL .
  231. $firstOtherMessage . PHP_EOL .
  232. $secondOtherMessage . PHP_EOL
  233. )
  234. ->if($score->getMockController()->getErrors = $allErrors = array(
  235. array(
  236. 'case' => $case = uniqid(),
  237. 'class' => $class = uniqid(),
  238. 'method' => $method = uniqid(),
  239. 'file' => $file = uniqid(),
  240. 'line' => $line = rand(1, PHP_INT_MAX),
  241. 'type' => $type = rand(1, PHP_INT_MAX),
  242. 'message' => $message = uniqid(),
  243. 'errorFile' => $errorFile = uniqid(),
  244. 'errorLine' => $errorLine = rand(1, PHP_INT_MAX)
  245. ),
  246. array(
  247. 'case' => $otherCase = uniqid(),
  248. 'class' => $otherClass = uniqid(),
  249. 'method' => $otherMethod = uniqid(),
  250. 'file' => $otherFile = uniqid(),
  251. 'line' => $otherLine = rand(1, PHP_INT_MAX),
  252. 'type' => $otherType = rand(1, PHP_INT_MAX),
  253. 'message' => ($firstOtherMessage = uniqid()) . PHP_EOL . ($secondOtherMessage = uniqid()),
  254. 'errorFile' => $otherErrorFile = uniqid(),
  255. 'errorLine' => $otherErrorLine = rand(1, PHP_INT_MAX)
  256. )
  257. )
  258. )
  259. ->and($defaultField = new runner\errors\cli())
  260. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  261. ->then
  262. ->castToString($defaultField)->isEmpty()
  263. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  264. ->then
  265. ->castToString($defaultField)->isEqualTo(sprintf('There are %d errors:', sizeof($allErrors)) . PHP_EOL .
  266. $class . '::' . $method . '():' . PHP_EOL .
  267. sprintf('Error %s in %s on line %d, generated by file %s on line %d in case \'%s\':', strtoupper($type), $file, $line, $errorFile, $errorLine, $case) . PHP_EOL .
  268. $message . PHP_EOL .
  269. $otherClass . '::' . $otherMethod . '():' . PHP_EOL .
  270. sprintf('Error %s in %s on line %d, generated by file %s on line %d in case \'%s\':', strtoupper($otherType), $otherFile, $otherLine, $otherErrorFile, $otherErrorLine, $otherCase) . PHP_EOL .
  271. $firstOtherMessage . PHP_EOL .
  272. $secondOtherMessage . PHP_EOL
  273. )
  274. ->if($customField = new runner\errors\cli())
  275. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  276. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  277. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  278. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  279. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  280. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  281. ->and($customField->setLocale($locale = new atoum\locale()))
  282. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  283. ->then
  284. ->castToString($customField)->isEmpty()
  285. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  286. ->then
  287. ->castToString($customField)->isEqualTo(
  288. $titlePrompt .
  289. sprintf(
  290. $locale->_('%s:'),
  291. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  292. ) .
  293. PHP_EOL .
  294. $methodPrompt .
  295. sprintf(
  296. $locale->_('%s:'),
  297. $methodColorizer->colorize($class . '::' . $method . '()')
  298. ) .
  299. PHP_EOL .
  300. $errorPrompt .
  301. sprintf(
  302. $locale->_('%s:'),
  303. $errorColorizer->colorize(sprintf($locale->_('Error %s in %s on line %d, generated by file %s on line %d in case \'%s\''), strtoupper($type), $file, $line, $errorFile, $errorLine, $case))
  304. ) .
  305. PHP_EOL .
  306. $message . PHP_EOL .
  307. $methodPrompt .
  308. sprintf(
  309. $locale->_('%s:'),
  310. $methodColorizer->colorize($otherClass . '::' . $otherMethod . '()')
  311. ) .
  312. PHP_EOL .
  313. $errorPrompt .
  314. sprintf(
  315. $locale->_('%s:'),
  316. $errorColorizer->colorize(sprintf($locale->_('Error %s in %s on line %d, generated by file %s on line %d in case \'%s\''), strtoupper($otherType), $otherFile, $otherLine, $otherErrorFile, $otherErrorLine, $otherCase))
  317. ) .
  318. PHP_EOL .
  319. $firstOtherMessage . PHP_EOL .
  320. $secondOtherMessage . PHP_EOL
  321. )
  322. ->if($score->getMockController()->getErrors = $allErrors = array(
  323. array(
  324. 'case' => null,
  325. 'class' => $class = uniqid(),
  326. 'method' => $method = uniqid(),
  327. 'file' => null,
  328. 'line' => null,
  329. 'type' => $type = rand(1, PHP_INT_MAX),
  330. 'message' => $message = uniqid(),
  331. 'errorFile' => $errorFile = uniqid(),
  332. 'errorLine' => $errorLine = rand(1, PHP_INT_MAX)
  333. )
  334. )
  335. )
  336. ->and($defaultField = new runner\errors\cli())
  337. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  338. ->then
  339. ->castToString($defaultField)->isEmpty()
  340. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  341. ->then
  342. ->castToString($defaultField)->isEqualTo(sprintf('There is %d error:', sizeof($allErrors)) . PHP_EOL .
  343. $class . '::' . $method . '():' . PHP_EOL .
  344. sprintf('Error %s in unknown file on unknown line, generated by file %s on line %d:', strtoupper($type), $errorFile, $errorLine) . PHP_EOL .
  345. $message . PHP_EOL
  346. )
  347. ->if($customField = new runner\errors\cli())
  348. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  349. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  350. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  351. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  352. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  353. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  354. ->and($customField->setLocale($locale = new atoum\locale()))
  355. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  356. ->then
  357. ->castToString($customField)->isEmpty()
  358. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  359. ->then
  360. ->castToString($customField)->isEqualTo(
  361. $titlePrompt .
  362. sprintf(
  363. $locale->_('%s:'),
  364. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  365. ) .
  366. PHP_EOL .
  367. $methodPrompt .
  368. sprintf(
  369. $locale->_('%s:'),
  370. $methodColorizer->colorize($class . '::' . $method . '()')
  371. ) .
  372. PHP_EOL .
  373. $errorPrompt .
  374. sprintf(
  375. $locale->_('%s:'),
  376. $errorColorizer->colorize(sprintf($locale->_('Error %s in unknown file on unknown line, generated by file %s on line %d'), strtoupper($type), $errorFile, $errorLine))
  377. ) .
  378. PHP_EOL .
  379. $message . PHP_EOL
  380. )
  381. ->if($score->getMockController()->getErrors = $allErrors = array(
  382. array(
  383. 'case' => $case = uniqid(),
  384. 'class' => $class = uniqid(),
  385. 'method' => $method = uniqid(),
  386. 'file' => null,
  387. 'line' => null,
  388. 'type' => $type = rand(1, PHP_INT_MAX),
  389. 'message' => $message = uniqid(),
  390. 'errorFile' => $errorFile = uniqid(),
  391. 'errorLine' => $errorLine = rand(1, PHP_INT_MAX)
  392. )
  393. )
  394. )
  395. ->and($defaultField = new runner\errors\cli())
  396. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  397. ->then
  398. ->castToString($defaultField)->isEmpty()
  399. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  400. ->then
  401. ->castToString($defaultField)->isEqualTo(sprintf('There is %d error:', sizeof($allErrors)) . PHP_EOL .
  402. $class . '::' . $method . '():' . PHP_EOL .
  403. sprintf('Error %s in unknown file on unknown line, generated by file %s on line %d in case \'%s\':', strtoupper($type), $errorFile, $errorLine, $case) . PHP_EOL .
  404. $message . PHP_EOL
  405. )
  406. ->if($customField = new runner\errors\cli())
  407. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  408. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  409. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  410. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  411. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  412. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  413. ->and($customField->setLocale($locale = new atoum\locale()))
  414. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  415. ->then
  416. ->castToString($customField)->isEmpty()
  417. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  418. ->then
  419. ->castToString($customField)->isEqualTo(
  420. $titlePrompt .
  421. sprintf(
  422. $locale->_('%s:'),
  423. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  424. ) .
  425. PHP_EOL .
  426. $methodPrompt .
  427. sprintf(
  428. $locale->_('%s:'),
  429. $methodColorizer->colorize($class . '::' . $method . '()')
  430. ) .
  431. PHP_EOL .
  432. $errorPrompt .
  433. sprintf(
  434. $locale->_('%s:'),
  435. $errorColorizer->colorize(sprintf($locale->_('Error %s in unknown file on unknown line, generated by file %s on line %d in case \'%s\''), strtoupper($type), $errorFile, $errorLine, $case))
  436. ) .
  437. PHP_EOL .
  438. $message . PHP_EOL
  439. )
  440. ->if($score->getMockController()->getErrors = $allErrors = array(
  441. array(
  442. 'case' => null,
  443. 'class' => $class = uniqid(),
  444. 'method' => $method = uniqid(),
  445. 'file' => null,
  446. 'line' => $line = rand(1, PHP_INT_MAX),
  447. 'type' => $type = 'e_fake_error',
  448. 'message' => $message = uniqid(),
  449. 'errorFile' => $errorFile = uniqid(),
  450. 'errorLine' => $errorLine = rand(1, PHP_INT_MAX)
  451. )
  452. )
  453. )
  454. ->and($defaultField = new runner\errors\cli())
  455. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  456. ->then
  457. ->castToString($defaultField)->isEmpty()
  458. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  459. ->then
  460. ->castToString($defaultField)->isEqualTo(sprintf('There is %d error:', sizeof($allErrors)) . PHP_EOL .
  461. $class . '::' . $method . '():' . PHP_EOL .
  462. sprintf('Error %s in unknown file on unknown line, generated by file %s on line %d:', strtoupper($type), $errorFile, $errorLine) . PHP_EOL .
  463. $message . PHP_EOL
  464. )
  465. ->if($customField = new runner\errors\cli())
  466. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  467. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  468. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  469. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  470. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  471. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  472. ->and($customField->setLocale($locale = new atoum\locale()))
  473. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  474. ->then
  475. ->castToString($customField)->isEmpty()
  476. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  477. ->then
  478. ->castToString($customField)->isEqualTo(
  479. $titlePrompt .
  480. sprintf(
  481. $locale->_('%s:'),
  482. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  483. ) .
  484. PHP_EOL .
  485. $methodPrompt .
  486. sprintf(
  487. $locale->_('%s:'),
  488. $methodColorizer->colorize($class . '::' . $method . '()')
  489. ) .
  490. PHP_EOL .
  491. $errorPrompt .
  492. sprintf(
  493. $locale->_('%s:'),
  494. $errorColorizer->colorize(sprintf($locale->_('Error %s in unknown file on unknown line, generated by file %s on line %d'), strtoupper($type), $errorFile, $errorLine))
  495. ) .
  496. PHP_EOL .
  497. $message . PHP_EOL
  498. )
  499. ->if($score->getMockController()->getErrors = $allErrors = array(
  500. array(
  501. 'case' => $case = uniqid(),
  502. 'class' => $class = uniqid(),
  503. 'method' => $method = uniqid(),
  504. 'file' => $file = uniqid(),
  505. 'line' => null,
  506. 'type' => $type = 'e_fake_error',
  507. 'message' => $message = uniqid(),
  508. 'errorFile' => null,
  509. 'errorLine' => null
  510. )
  511. )
  512. )
  513. ->and($defaultField = new runner\errors\cli())
  514. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  515. ->then
  516. ->castToString($defaultField)->isEmpty()
  517. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  518. ->then
  519. ->castToString($defaultField)->isEqualTo(sprintf('There is %d error:', sizeof($allErrors)) . PHP_EOL .
  520. $class . '::' . $method . '():' . PHP_EOL .
  521. sprintf('Error %s in %s on unknown line, generated by unknown file in case \'%s\':', strtoupper($type), $file, $case) . PHP_EOL .
  522. $message . PHP_EOL
  523. )
  524. ->if($customField = new runner\errors\cli())
  525. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  526. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  527. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  528. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  529. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  530. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  531. ->and($customField->setLocale($locale = new atoum\locale()))
  532. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  533. ->then
  534. ->castToString($customField)->isEmpty()
  535. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  536. ->then
  537. ->castToString($customField)->isEqualTo(
  538. $titlePrompt .
  539. sprintf(
  540. $locale->_('%s:'),
  541. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  542. ) .
  543. PHP_EOL .
  544. $methodPrompt .
  545. sprintf(
  546. $locale->_('%s:'),
  547. $methodColorizer->colorize($class . '::' . $method . '()')
  548. ) .
  549. PHP_EOL .
  550. $errorPrompt .
  551. sprintf(
  552. $locale->_('%s:'),
  553. $errorColorizer->colorize(sprintf($locale->_('Error %s in %s on unknown line, generated by unknown file in case \'%s\''), strtoupper($type), $file, $case))
  554. ) .
  555. PHP_EOL .
  556. $message . PHP_EOL
  557. )
  558. ->if($score->getMockController()->getErrors = $allErrors = array(
  559. array(
  560. 'case' => $case = uniqid(),
  561. 'class' => $class = uniqid(),
  562. 'method' => $method = uniqid(),
  563. 'file' => null,
  564. 'line' => $line = rand(1, PHP_INT_MAX),
  565. 'type' => $type = 'e_fake_error',
  566. 'message' => $message = uniqid(),
  567. 'errorFile' => $errorFile = uniqid(),
  568. 'errorLine' => $errorLine = rand(1, PHP_INT_MAX)
  569. )
  570. )
  571. )
  572. ->and($defaultField = new runner\errors\cli())
  573. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  574. ->then
  575. ->castToString($defaultField)->isEmpty()
  576. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  577. ->then
  578. ->castToString($defaultField)->isEqualTo(sprintf('There is %d error:', sizeof($allErrors)) . PHP_EOL .
  579. $class . '::' . $method . '():' . PHP_EOL .
  580. sprintf('Error %s in unknown file on unknown line, generated by file %s on line %d in case \'%s\':', strtoupper($type), $errorFile, $errorLine, $case) . PHP_EOL .
  581. $message . PHP_EOL
  582. )
  583. ->if($customField = new runner\errors\cli())
  584. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  585. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  586. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  587. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  588. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  589. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  590. ->and($customField->setLocale($locale = new atoum\locale()))
  591. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  592. ->then
  593. ->castToString($customField)->isEmpty()
  594. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  595. ->then
  596. ->castToString($customField)->isEqualTo(
  597. $titlePrompt .
  598. sprintf(
  599. $locale->_('%s:'),
  600. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  601. ) .
  602. PHP_EOL .
  603. $methodPrompt .
  604. sprintf(
  605. $locale->_('%s:'),
  606. $methodColorizer->colorize($class . '::' . $method . '()')
  607. ) .
  608. PHP_EOL .
  609. $errorPrompt .
  610. sprintf(
  611. $locale->_('%s:'),
  612. $errorColorizer->colorize(sprintf($locale->_('Error %s in unknown file on unknown line, generated by file %s on line %d in case \'%s\''), strtoupper($type), $errorFile, $errorLine, $case))
  613. ) .
  614. PHP_EOL .
  615. $message . PHP_EOL
  616. )
  617. ->if($score->getMockController()->getErrors = $allErrors = array(
  618. array(
  619. 'case' => null,
  620. 'class' => $class = uniqid(),
  621. 'method' => $method = uniqid(),
  622. 'file' => $file = uniqid(),
  623. 'line' => null,
  624. 'type' => $type = 'e_fake_error',
  625. 'message' => $message = uniqid(),
  626. 'errorFile' => $errorFile = uniqid(),
  627. 'errorLine' => $errorLine = rand(1, PHP_INT_MAX)
  628. )
  629. )
  630. )
  631. ->and($defaultField = new runner\errors\cli())
  632. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  633. ->then
  634. ->castToString($defaultField)->isEmpty()
  635. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  636. ->then
  637. ->castToString($defaultField)->isEqualTo(sprintf('There is %d error:', sizeof($allErrors)) . PHP_EOL .
  638. $class . '::' . $method . '():' . PHP_EOL .
  639. sprintf('Error %s in %s on unknown line, generated by file %s on line %d:', strtoupper($type), $file, $errorFile, $errorLine) . PHP_EOL .
  640. $message . PHP_EOL
  641. )
  642. ->if($customField = new runner\errors\cli())
  643. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  644. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  645. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  646. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  647. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  648. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  649. ->and($customField->setLocale($locale = new atoum\locale()))
  650. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  651. ->then
  652. ->castToString($customField)->isEmpty()
  653. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  654. ->then
  655. ->castToString($customField)->isEqualTo(
  656. $titlePrompt .
  657. sprintf(
  658. $locale->_('%s:'),
  659. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  660. ) .
  661. PHP_EOL .
  662. $methodPrompt .
  663. sprintf(
  664. $locale->_('%s:'),
  665. $methodColorizer->colorize($class . '::' . $method . '()')
  666. ) .
  667. PHP_EOL .
  668. $errorPrompt .
  669. sprintf(
  670. $locale->_('%s:'),
  671. $errorColorizer->colorize(sprintf($locale->_('Error %s in %s on unknown line, generated by file %s on line %d'), strtoupper($type), $file, $errorFile, $errorLine))
  672. ) .
  673. PHP_EOL .
  674. $message . PHP_EOL
  675. )
  676. ->if($score->getMockController()->getErrors = $allErrors = array(
  677. array(
  678. 'case' => $case = uniqid(),
  679. 'class' => $class = uniqid(),
  680. 'method' => $method = uniqid(),
  681. 'file' => $file = uniqid(),
  682. 'line' => null,
  683. 'type' => $type = 'e_fake_error',
  684. 'message' => $message = uniqid(),
  685. 'errorFile' => $errorFile = uniqid(),
  686. 'errorLine' => $errorLine = rand(1, PHP_INT_MAX)
  687. )
  688. )
  689. )
  690. ->and($defaultField = new runner\errors\cli())
  691. ->and($defaultField->handleEvent(atoum\runner::runStart, $runner))
  692. ->then
  693. ->castToString($defaultField)->isEmpty()
  694. ->if($defaultField->handleEvent(atoum\runner::runStop, $runner))
  695. ->then
  696. ->castToString($defaultField)->isEqualTo(sprintf('There is %d error:', sizeof($allErrors)) . PHP_EOL .
  697. $class . '::' . $method . '():' . PHP_EOL .
  698. sprintf('Error %s in %s on unknown line, generated by file %s on line %d in case \'%s\':', strtoupper($type), $file, $errorFile, $errorLine, $case) . PHP_EOL .
  699. $message . PHP_EOL
  700. )
  701. ->if($customField = new runner\errors\cli())
  702. ->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))
  703. ->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))
  704. ->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))
  705. ->and($customField->setMethodColorizer($methodColorizer = new colorizer(uniqid(), uniqid())))
  706. ->and($customField->setErrorPrompt($errorPrompt = new prompt(uniqid())))
  707. ->and($customField->setErrorColorizer($errorColorizer = new colorizer(uniqid(), uniqid())))
  708. ->and($customField->setLocale($locale = new atoum\locale()))
  709. ->and($customField->handleEvent(atoum\runner::runStart, $runner))
  710. ->then
  711. ->castToString($customField)->isEmpty()
  712. ->if($customField->handleEvent(atoum\runner::runStop, $runner))
  713. ->then
  714. ->castToString($customField)->isEqualTo(
  715. $titlePrompt .
  716. sprintf(
  717. $locale->_('%s:'),
  718. $titleColorizer->colorize(sprintf($locale->__('There is %d error', 'There are %d errors', sizeof($allErrors)), sizeof($allErrors)))
  719. ) .
  720. PHP_EOL .
  721. $methodPrompt .
  722. sprintf(
  723. $locale->_('%s:'),
  724. $methodColorizer->colorize($class . '::' . $method . '()')
  725. ) .
  726. PHP_EOL .
  727. $errorPrompt .
  728. sprintf(
  729. $locale->_('%s:'),
  730. $errorColorizer->colorize(sprintf($locale->_('Error %s in %s on unknown line, generated by file %s on line %d in case \'%s\''), strtoupper($type), $file, $errorFile, $errorLine, $case))
  731. ) .
  732. PHP_EOL .
  733. $message . PHP_EOL
  734. )
  735. ;
  736. }
  737. }