ExceptionTest.php (1409B)
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\Filesystem\Tests; 13 14 use Symfony\Component\Filesystem\Exception\IOException; 15 use Symfony\Component\Filesystem\Exception\FileNotFoundException; 16 17 /** 18 * Test class for Filesystem. 19 */ 20 class ExceptionTest extends \PHPUnit_Framework_TestCase 21 { 22 public function testGetPath() 23 { 24 $e = new IOException('', 0, null, '/foo'); 25 $this->assertEquals('/foo', $e->getPath(), 'The pass should be returned.'); 26 } 27 28 public function testGeneratedMessage() 29 { 30 $e = new FileNotFoundException(null, 0, null, '/foo'); 31 $this->assertEquals('/foo', $e->getPath()); 32 $this->assertEquals('File "/foo" could not be found.', $e->getMessage(), 'A message should be generated.'); 33 } 34 35 public function testGeneratedMessageWithoutPath() 36 { 37 $e = new FileNotFoundException(); 38 $this->assertEquals('File could not be found.', $e->getMessage(), 'A message should be generated.'); 39 } 40 41 public function testCustomMessage() 42 { 43 $e = new FileNotFoundException('bar', 0, null, '/foo'); 44 $this->assertEquals('bar', $e->getMessage(), 'A custom message should be possible still.'); 45 } 46 }