LegacyEmptyPassTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2018 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Psy\Test\CodeCleaner;
  11. use Psy\CodeCleaner\LegacyEmptyPass;
  12. class LegacyEmptyPassTest extends CodeCleanerTestCase
  13. {
  14. public function setUp()
  15. {
  16. $this->setPass(new LegacyEmptyPass());
  17. }
  18. /**
  19. * @dataProvider invalidStatements
  20. * @expectedException \Psy\Exception\ParseErrorException
  21. */
  22. public function testProcessInvalidStatement($code)
  23. {
  24. $this->parseAndTraverse($code);
  25. }
  26. public function invalidStatements()
  27. {
  28. if (\version_compare(PHP_VERSION, '5.5', '>=')) {
  29. return [
  30. ['empty()'],
  31. ];
  32. }
  33. return [
  34. ['empty()'],
  35. ['empty(null)'],
  36. ['empty(PHP_EOL)'],
  37. ['empty("wat")'],
  38. ['empty(1.1)'],
  39. ['empty(Foo::$bar)'],
  40. ];
  41. }
  42. /**
  43. * @dataProvider validStatements
  44. */
  45. public function testProcessValidStatement($code)
  46. {
  47. $this->parseAndTraverse($code);
  48. $this->assertTrue(true);
  49. }
  50. public function validStatements()
  51. {
  52. if (\version_compare(PHP_VERSION, '5.5', '<')) {
  53. return [
  54. ['empty($foo)'],
  55. ];
  56. }
  57. return [
  58. ['empty($foo)'],
  59. ['empty(null)'],
  60. ['empty(PHP_EOL)'],
  61. ['empty("wat")'],
  62. ['empty(1.1)'],
  63. ['empty(Foo::$bar)'],
  64. ];
  65. }
  66. }