PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/units/classes/php/call.php

http://github.com/mageekguy/atoum
PHP | 114 lines | 91 code | 23 blank | 0 comment | 0 complexity | 097797cb0c85b39db443f1d813334e5a MD5 | raw file
  1. <?php
  2. namespace mageekguy\atoum\tests\units\php;
  3. use
  4. mageekguy\atoum,
  5. mageekguy\atoum\php
  6. ;
  7. require_once __DIR__ . '/../../runner.php';
  8. class call extends atoum\test
  9. {
  10. public function test__construct()
  11. {
  12. $call = new php\call($function = uniqid());
  13. $this->assert
  14. ->string($call->getFunction())->isEqualTo($function)
  15. ->variable($call->getArguments())->isNull()
  16. ->variable($call->getObject())->isNull()
  17. ;
  18. $call = new php\call($function = uniqid(), $arguments = array($arg = uniqid()));
  19. $this->assert
  20. ->string($call->getFunction())->isEqualTo($function)
  21. ->array($call->getArguments())->isEqualTo($arguments)
  22. ->variable($call->getObject())->isNull()
  23. ;
  24. $call = new php\call($function = uniqid(), $arguments = array($arg = uniqid()), $object = $this);
  25. $this->assert
  26. ->string($call->getFunction())->isEqualTo($function)
  27. ->array($call->getArguments())->isEqualTo($arguments)
  28. ->object($call->getObject())->isIdenticalTo($object)
  29. ;
  30. }
  31. public function testSetFunction()
  32. {
  33. $call = new php\call(uniqid());
  34. $this->assert
  35. ->object($call->setFunction($function = uniqid()))->isIdenticalTo($call)
  36. ->string($call->getFunction())->isEqualTo($function)
  37. ->object($call->setFunction($function = uniqid()))->isIdenticalTo($call)
  38. ->string($call->getFunction())->isEqualTo($function)
  39. ;
  40. }
  41. public function testSetArguments()
  42. {
  43. $call = new php\call(uniqid());
  44. $this->assert
  45. ->object($call->setArguments($args = array(uniqid())))->isIdenticalTo($call)
  46. ->array($call->getArguments())->isEqualTo($args)
  47. ->object($call->setArguments($args = array(uniqid())))->isIdenticalTo($call)
  48. ->array($call->getArguments())->isEqualTo($args)
  49. ;
  50. }
  51. public function testUnsetArguments()
  52. {
  53. $call = new php\call(uniqid());
  54. $this->assert
  55. ->variable($call->getArguments())->isNull()
  56. ->object($call->unsetArguments())->isIdenticalTo($call)
  57. ->variable($call->getArguments())->isNull()
  58. ;
  59. $call->setArguments(array(uniqid()));
  60. $this->assert
  61. ->variable($call->getArguments())->isNotNull()
  62. ->object($call->unsetArguments())->isIdenticalTo($call)
  63. ->variable($call->getArguments())->isNull()
  64. ;
  65. }
  66. public function testSetObject()
  67. {
  68. $call = new php\call(uniqid());
  69. $this->assert
  70. ->object($call->setObject($object = $this))->isIdenticalTo($call)
  71. ->object($call->getObject())->isIdenticalTo($object)
  72. ->object($call->setObject($object = $call))->isIdenticalTo($call)
  73. ->object($call->getObject())->isIdenticalTo($object)
  74. ;
  75. }
  76. public function testSetDecorator()
  77. {
  78. $call = new php\call(uniqid());
  79. $this->assert
  80. ->object($call->setDecorator($decorator = new php\call\decorator()))->isIdenticalTo($call)
  81. ->object($call->getDecorator())->isIdenticalTo($decorator)
  82. ;
  83. }
  84. public function test__toString()
  85. {
  86. $call = new php\call($function = uniqid());
  87. $this->assert
  88. ->castToString($call)->isEqualTo($call->getDecorator()->decorate($call))
  89. ;
  90. }
  91. }