ExceptionTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Component\Filesystem\Tests;
  11. use Symfony\Component\Filesystem\Exception\IOException;
  12. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  13. /**
  14. * Test class for Filesystem.
  15. */
  16. class ExceptionTest extends \PHPUnit_Framework_TestCase
  17. {
  18. public function testGetPath()
  19. {
  20. $e = new IOException('', 0, null, '/foo');
  21. $this->assertEquals('/foo', $e->getPath(), 'The pass should be returned.');
  22. }
  23. public function testGeneratedMessage()
  24. {
  25. $e = new FileNotFoundException(null, 0, null, '/foo');
  26. $this->assertEquals('/foo', $e->getPath());
  27. $this->assertEquals('File "/foo" could not be found.', $e->getMessage(), 'A message should be generated.');
  28. }
  29. public function testGeneratedMessageWithoutPath()
  30. {
  31. $e = new FileNotFoundException();
  32. $this->assertEquals('File could not be found.', $e->getMessage(), 'A message should be generated.');
  33. }
  34. public function testCustomMessage()
  35. {
  36. $e = new FileNotFoundException('bar', 0, null, '/foo');
  37. $this->assertEquals('bar', $e->getMessage(), 'A custom message should be possible still.');
  38. }
  39. }