PageRenderTime 64ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/units/classes/php/tokenizer/iterators/phpClass.php

https://github.com/Hywan/atoum
PHP | 81 lines | 73 code | 8 blank | 0 comment | 0 complexity | 60709045d76406bb98704100d98da02c MD5 | raw file
  1. <?php
  2. namespace mageekguy\atoum\tests\units\php\tokenizer\iterators;
  3. use mageekguy\atoum;
  4. use mageekguy\atoum\php\tokenizer;
  5. use mageekguy\atoum\php\tokenizer\iterators;
  6. require_once __DIR__ . '/../../../../runner.php';
  7. class phpClass extends atoum\test
  8. {
  9. public function testClass()
  10. {
  11. $this
  12. ->testedClass
  13. ->extends(atoum\php\tokenizer\iterator::class)
  14. ;
  15. }
  16. public function test__construct()
  17. {
  18. $this
  19. ->if($this->newTestedInstance)
  20. ->then
  21. ->array($this->testedInstance->getConstants())->isEmpty()
  22. ->array($this->testedInstance->getMethods())->isEmpty()
  23. ;
  24. }
  25. public function testAppendConstant()
  26. {
  27. $this
  28. ->if(
  29. $this->newTestedInstance,
  30. $constantIterator = new iterators\phpConstant(),
  31. $constantIterator
  32. ->append($token1 = new tokenizer\token(uniqid()))
  33. ->append($token2 = new tokenizer\token(uniqid()))
  34. )
  35. ->then
  36. ->object($this->testedInstance->appendConstant($constantIterator))->isTestedInstance
  37. ->array($this->testedInstance->getConstants())->isEqualTo([$constantIterator])
  38. ->castToString($this->testedInstance)->isEqualTo($token1 . $token2)
  39. ;
  40. }
  41. public function testAppendMethod()
  42. {
  43. $this
  44. ->if(
  45. $this->newTestedInstance,
  46. $methodIterator = new iterators\phpMethod(),
  47. $methodIterator
  48. ->append($token1 = new tokenizer\token(uniqid()))
  49. ->append($token2 = new tokenizer\token(uniqid()))
  50. )
  51. ->then
  52. ->object($this->testedInstance->appendMethod($methodIterator))->isTestedInstance
  53. ->array($this->testedInstance->getMethods())->isEqualTo([$methodIterator])
  54. ->castToString($this->testedInstance)->isEqualTo($token1 . $token2)
  55. ;
  56. }
  57. public function testAppendProperty()
  58. {
  59. $this
  60. ->if(
  61. $this->newTestedInstance,
  62. $propertyIterator = new iterators\phpProperty(),
  63. $propertyIterator
  64. ->append($token1 = new tokenizer\token(uniqid()))
  65. ->append($token2 = new tokenizer\token(uniqid()))
  66. )
  67. ->then
  68. ->object($this->testedInstance->appendProperty($propertyIterator))->isTestedInstance
  69. ->array($this->testedInstance->getProperties())->isEqualTo([$propertyIterator])
  70. ->castToString($this->testedInstance)->isEqualTo($token1 . $token2)
  71. ;
  72. }
  73. }