Geen omschrijving

LeavePsyshAlonePassTest.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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\LeavePsyshAlonePass;
  12. class LeavePsyshAlonePassTest extends CodeCleanerTestCase
  13. {
  14. public function setUp()
  15. {
  16. $this->setPass(new LeavePsyshAlonePass());
  17. }
  18. public function testPassesInlineHtmlThroughJustFine()
  19. {
  20. $inline = $this->parse('not php at all!', '');
  21. $this->traverse($inline);
  22. $this->assertTrue(true);
  23. }
  24. /**
  25. * @dataProvider validStatements
  26. */
  27. public function testProcessStatementPasses($code)
  28. {
  29. $this->parseAndTraverse($code);
  30. $this->assertTrue(true);
  31. }
  32. public function validStatements()
  33. {
  34. return [
  35. ['array_merge()'],
  36. ['__psysh__()'],
  37. ['$this'],
  38. ['$psysh'],
  39. ['$__psysh'],
  40. ['$banana'],
  41. ];
  42. }
  43. /**
  44. * @dataProvider invalidStatements
  45. * @expectedException \Psy\Exception\RuntimeException
  46. */
  47. public function testProcessStatementFails($code)
  48. {
  49. $this->parseAndTraverse($code);
  50. }
  51. public function invalidStatements()
  52. {
  53. return [
  54. ['$__psysh__'],
  55. ['var_dump($__psysh__)'],
  56. ['$__psysh__ = "your mom"'],
  57. ['$__psysh__->fakeFunctionCall()'],
  58. ];
  59. }
  60. }