AbstractClassPassTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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\AbstractClassPass;
  12. class AbstractClassPassTest extends CodeCleanerTestCase
  13. {
  14. public function setUp()
  15. {
  16. $this->setPass(new AbstractClassPass());
  17. }
  18. /**
  19. * @dataProvider invalidStatements
  20. * @expectedException \Psy\Exception\FatalErrorException
  21. */
  22. public function testProcessStatementFails($code)
  23. {
  24. $this->parseAndTraverse($code);
  25. }
  26. public function invalidStatements()
  27. {
  28. return [
  29. ['class A { abstract function a(); }'],
  30. ['abstract class B { abstract function b() {} }'],
  31. ['abstract class B { abstract function b() { echo "yep"; } }'],
  32. ];
  33. }
  34. /**
  35. * @dataProvider validStatements
  36. */
  37. public function testProcessStatementPasses($code)
  38. {
  39. $this->parseAndTraverse($code);
  40. $this->assertTrue(true);
  41. }
  42. public function validStatements()
  43. {
  44. return [
  45. ['abstract class C { function c() {} }'],
  46. ['abstract class D { abstract function d(); }'],
  47. ];
  48. }
  49. }