PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/units/classes/mock/php/method/argument.php

http://github.com/mageekguy/atoum
PHP | 65 lines | 58 code | 7 blank | 0 comment | 0 complexity | 86eec0fda146344bc20b7c33360380ef MD5 | raw file
  1. <?php
  2. namespace mageekguy\atoum\tests\units\mock\php\method;
  3. use
  4. mageekguy\atoum,
  5. mageekguy\atoum\mock\php
  6. ;
  7. require_once __DIR__ . '/../../../../runner.php';
  8. class argument extends atoum\test
  9. {
  10. public function test__construct()
  11. {
  12. $this
  13. ->if($this->newTestedInstance($name = uniqid()))
  14. ->then
  15. ->string($this->testedInstance->getName())->isEqualTo($name)
  16. ;
  17. }
  18. public function testSetDefaultValue()
  19. {
  20. $this
  21. ->if($this->newTestedInstance(uniqid()))
  22. ->then
  23. ->object($this->testedInstance->setDefaultValue($default = uniqid()))->isTestedInstance
  24. ;
  25. }
  26. public function testIsReference()
  27. {
  28. $this
  29. ->if($this->newTestedInstance(uniqid()))
  30. ->then
  31. ->object($this->testedInstance->isReference())->isTestedInstance
  32. ;
  33. }
  34. public function test__toString()
  35. {
  36. $this
  37. ->if($this->newTestedInstance($name = uniqid()))
  38. ->then
  39. ->castToString($this->testedInstance)->isEqualTo('$' . $name)
  40. ->castToString($this->testedInstance->isArray())->isEqualTo('array $' . $name)
  41. ->castToString($this->testedInstance->isObject($type = uniqid()))->isEqualTo($type . ' $' . $name)
  42. ->castToString($this->testedInstance->isUntyped()->setDefaultValue(__FUNCTION__))->isEqualTo('$' . $name . '=' . var_export(__FUNCTION__, true))
  43. ->castToString($this->testedInstance->setDefaultValue($defaultValue = uniqid()))->isEqualTo('$' . $name . '=' . var_export($defaultValue, true))
  44. ->castToString($this->testedInstance->setDefaultValue(array()))->isEqualTo('$' . $name . '=' . var_export(array(), true))
  45. ->castToString($this->testedInstance->setDefaultValue(null))->isEqualTo('$' . $name . '=' . var_export(null, true))
  46. ->if(
  47. $this->newTestedInstance($name = uniqid()),
  48. $this->testedInstance->isReference()
  49. )
  50. ->then
  51. ->castToString($this->testedInstance)->isEqualTo('& $' . $name)
  52. ->castToString($this->testedInstance->setDefaultValue(__FUNCTION__))->isEqualTo('& $' . $name . '=' . var_export(__FUNCTION__, true))
  53. ->castToString($this->testedInstance->setDefaultValue($defaultValue = uniqid()))->isEqualTo('& $' . $name . '=' . var_export($defaultValue, true))
  54. ->castToString($this->testedInstance->setDefaultValue(array()))->isEqualTo('& $' . $name . '=' . var_export(array(), true))
  55. ->castToString($this->testedInstance->setDefaultValue(null))->isEqualTo('& $' . $name . '=' . var_export(null, true))
  56. ;
  57. }
  58. }