PHPUnit_Framework_TestCase.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\Tests\Helpers;
  11. /**
  12. * This is helpers class for supporting old and new PHPUnit versions.
  13. *
  14. * @todo NEXT_MAJOR: Remove this class when dropping support for < PHPUnit 5.4
  15. *
  16. * @author Oleksandr Savchenko <savchenko.oleksandr.ua@gmail.com>
  17. */
  18. class PHPUnit_Framework_TestCase extends \PHPUnit_Framework_TestCase
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function expectException($exception, $message = '', $code = null)
  24. {
  25. if (is_callable('parent::expectException')) {
  26. parent::expectException($exception);
  27. if ($message !== '') {
  28. parent::expectExceptionMessage($message);
  29. }
  30. if ($code !== null) {
  31. parent::expectExceptionCode($code);
  32. }
  33. }
  34. return parent::setExpectedException($exception, $message, $code);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. protected function createMock($originalClassName)
  40. {
  41. if (is_callable('parent::createMock')) {
  42. return parent::createMock($originalClassName);
  43. }
  44. return parent::getMockBuilder($originalClassName)
  45. ->disableOriginalConstructor()
  46. ->disableOriginalClone()
  47. ->disableArgumentCloning()
  48. ->getMock();
  49. }
  50. }