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\Debug\Tests\FatalErrorHandler;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Debug\Exception\FatalErrorException;
16 use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
18 class UndefinedMethodFatalErrorHandlerTest extends TestCase
21 * @dataProvider provideUndefinedMethodData
23 public function testUndefinedMethod($error, $translatedMessage)
25 $handler = new UndefinedMethodFatalErrorHandler();
26 $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
28 $this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedMethodException', $exception);
29 $this->assertSame($translatedMessage, $exception->getMessage());
30 $this->assertSame($error['type'], $exception->getSeverity());
31 $this->assertSame($error['file'], $exception->getFile());
32 $this->assertSame($error['line'], $exception->getLine());
35 public function provideUndefinedMethodData()
43 'message' => 'Call to undefined method SplObjectStorage::what()',
45 'Attempted to call an undefined method named "what" of class "SplObjectStorage".',
52 'message' => 'Call to undefined method SplObjectStorage::walid()',
54 "Attempted to call an undefined method named \"walid\" of class \"SplObjectStorage\".\nDid you mean to call \"valid\"?",
61 'message' => 'Call to undefined method SplObjectStorage::offsetFet()',
63 "Attempted to call an undefined method named \"offsetFet\" of class \"SplObjectStorage\".\nDid you mean to call e.g. \"offsetGet\", \"offsetSet\" or \"offsetUnset\"?",
68 'message' => 'Call to undefined method class@anonymous::test()',
69 'file' => '/home/possum/work/symfony/test.php',
72 'Attempted to call an undefined method named "test" of class "class@anonymous".',