compatibility.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. * Ensures compatibility with PHPUnit < 6.x
  4. */
  5. namespace PHPUnit\Framework\Constraint {
  6. if (!class_exists('PHPUnit\Framework\Constraint\Constraint') && class_exists('PHPUnit_Framework_Constraint')) {
  7. abstract class Constraint extends \PHPUnit_Framework_Constraint {}
  8. }
  9. }
  10. namespace PHPUnit\Framework {
  11. if (!class_exists('PHPUnit\Framework\TestCase') && class_exists('PHPUnit_Framework_TestCase')) {
  12. abstract class TestCase extends \PHPUnit_Framework_TestCase {
  13. /**
  14. * @param string $exception
  15. */
  16. public function expectException($exception)
  17. {
  18. $this->setExpectedException($exception);
  19. }
  20. /**
  21. * @param string $message
  22. */
  23. public function expectExceptionMessage($message)
  24. {
  25. $parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase');
  26. if (in_array('expectExceptionMessage', $parentClassMethods)) {
  27. parent::expectExceptionMessage($message);
  28. return;
  29. }
  30. $this->setExpectedException($this->getExpectedException(), $message);
  31. }
  32. /**
  33. * @param string $messageRegExp
  34. */
  35. public function expectExceptionMessageRegExp($messageRegExp)
  36. {
  37. $parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase');
  38. if (in_array('expectExceptionMessageRegExp', $parentClassMethods)) {
  39. parent::expectExceptionMessageRegExp($messageRegExp);
  40. return;
  41. }
  42. $this->setExpectedExceptionRegExp($this->getExpectedException(), $messageRegExp);
  43. }
  44. }
  45. }
  46. }