FlattenExceptionTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  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 Symfony\Tests\Component\HttpKernel\Exception;
  11. use Symfony\Component\HttpKernel\Exception\FlattenException;
  12. class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @dataProvider flattenDataProvider
  16. */
  17. public function testFlattenHttpException(\Exception $exception, $statusCode)
  18. {
  19. $flattened = FlattenException::create($exception);
  20. $this->assertEquals($exception->getMessage(), $flattened->getMessage(), 'The message is copied from the original exception.');
  21. $this->assertEquals($exception->getCode(), $flattened->getCode(), 'The code is copied from the original exception.');
  22. $this->assertEquals(get_class($exception), $flattened->getClass(), 'The class is set to the class of the original exception');
  23. }
  24. public function flattenDataProvider()
  25. {
  26. return array(
  27. array(new \Exception('test', 123), 500),
  28. );
  29. }
  30. }