4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Filesystem\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Filesystem\Exception\FileNotFoundException;
16 use Symfony\Component\Filesystem\Exception\IOException;
19 * Test class for Filesystem.
21 class ExceptionTest extends TestCase
23 public function testGetPath()
25 $e = new IOException('', 0, null, '/foo');
26 $this->assertEquals('/foo', $e->getPath(), 'The pass should be returned.');
29 public function testGeneratedMessage()
31 $e = new FileNotFoundException(null, 0, null, '/foo');
32 $this->assertEquals('/foo', $e->getPath());
33 $this->assertEquals('File "/foo" could not be found.', $e->getMessage(), 'A message should be generated.');
36 public function testGeneratedMessageWithoutPath()
38 $e = new FileNotFoundException();
39 $this->assertEquals('File could not be found.', $e->getMessage(), 'A message should be generated.');
42 public function testCustomMessage()
44 $e = new FileNotFoundException('bar', 0, null, '/foo');
45 $this->assertEquals('bar', $e->getMessage(), 'A custom message should be possible still.');