PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/units/classes/report/fields/runner/atoum/phing.php

http://github.com/mageekguy/atoum
PHP | 108 lines | 99 code | 9 blank | 0 comment | 0 complexity | ed6cb407648613d9c898943d1a4ab12d MD5 | raw file
  1. <?php
  2. namespace mageekguy\atoum\tests\units\report\fields\runner\atoum;
  3. use
  4. mageekguy\atoum\locale,
  5. mageekguy\atoum\runner,
  6. mageekguy\atoum\runner\score,
  7. mageekguy\atoum\cli\prompt,
  8. mageekguy\atoum\cli\colorizer,
  9. mageekguy\atoum\tests\units,
  10. mageekguy\atoum\report\fields\runner\atoum
  11. ;
  12. require_once __DIR__ . '/../../../../../runner.php';
  13. class phing extends \mageekguy\atoum\test
  14. {
  15. public function testClass()
  16. {
  17. $this->testedClass->extends('mageekguy\atoum\report\field');
  18. }
  19. public function test__construct()
  20. {
  21. $this
  22. ->if($field = new atoum\phing())
  23. ->then
  24. ->object($field->getPrompt())->isEqualTo(new prompt())
  25. ->object($field->getColorizer())->isEqualTo(new colorizer())
  26. ->object($field->getLocale())->isEqualTo(new locale())
  27. ->variable($field->getAuthor())->isNull()
  28. ->variable($field->getPath())->isNull()
  29. ->variable($field->getVersion())->isNull()
  30. ->array($field->getEvents())->isEqualTo(array(runner::runStart))
  31. ;
  32. }
  33. public function testSetPrompt()
  34. {
  35. $this
  36. ->if($field = new atoum\phing())
  37. ->then
  38. ->object($field->setPrompt($prompt = new prompt(uniqid())))->isIdenticalTo($field)
  39. ->object($field->getPrompt())->isIdenticalTo($prompt)
  40. ->object($field->setPrompt())->isIdenticalTo($field)
  41. ->object($field->getPrompt())
  42. ->isNotIdenticalTo($prompt)
  43. ->isEqualTo(new prompt())
  44. ;
  45. }
  46. public function testSetColorizer()
  47. {
  48. $this
  49. ->if($field = new atoum\phing())
  50. ->then
  51. ->object($field->setColorizer($colorizer = new colorizer()))->isIdenticalTo($field)
  52. ->object($field->getColorizer())->isIdenticalTo($colorizer)
  53. ->object($field->setColorizer())->isIdenticalTo($field)
  54. ->object($field->getColorizer())
  55. ->isNotIdenticalTo($colorizer)
  56. ->isEqualTo(new colorizer())
  57. ;
  58. }
  59. public function testHandleEvent()
  60. {
  61. $this
  62. ->if($score = new score())
  63. ->and($score
  64. ->setAtoumPath($atoumPath = uniqid())
  65. ->setAtoumVersion($atoumVersion = uniqid())
  66. )
  67. ->and($runner = new runner())
  68. ->and($runner->setScore($score))
  69. ->and($field = new atoum\phing())
  70. ->then
  71. ->variable($field->getAuthor())->isNull()
  72. ->variable($field->getPath())->isNull()
  73. ->variable($field->getVersion())->isNull()
  74. ->boolean($field->handleEvent(runner::runStart, $runner))->isTrue()
  75. ->string($field->getAuthor())->isEqualTo(\mageekguy\atoum\author)
  76. ->string($field->getPath())->isEqualTo($atoumPath)
  77. ->string($field->getVersion())->isEqualTo($atoumVersion)
  78. ;
  79. }
  80. public function test__toString()
  81. {
  82. $this
  83. ->if($score = new score())
  84. ->and($score
  85. ->setAtoumPath($atoumPath = uniqid())
  86. ->setAtoumVersion($atoumVersion = uniqid())
  87. )
  88. ->and($runner = new runner())
  89. ->and($runner->setScore($score))
  90. ->and($field = new atoum\phing())
  91. ->and($field->handleEvent(runner::runStop, $runner))
  92. ->then
  93. ->castToString($field)->isEmpty()
  94. ->if($field->handleEvent(runner::runStart, $runner))
  95. ->then
  96. ->castToString($field)->isEqualTo($field->getPrompt() . $field->getColorizer()->colorize(sprintf($field->getLocale()->_("Atoum version: %s \nAtoum path: %s \nAtoum author: %s"), $atoumVersion, $atoumPath, \mageekguy\atoum\author)))
  97. ;
  98. }
  99. }