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\UndefinedFunctionFatalErrorHandler;
18 class UndefinedFunctionFatalErrorHandlerTest extends TestCase
21 * @dataProvider provideUndefinedFunctionData
23 public function testUndefinedFunction($error, $translatedMessage)
25 $handler = new UndefinedFunctionFatalErrorHandler();
26 $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
28 $this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception);
29 // class names are case insensitive and PHP/HHVM do not return the same
30 $this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage()));
31 $this->assertSame($error['type'], $exception->getSeverity());
32 $this->assertSame($error['file'], $exception->getFile());
33 $this->assertSame($error['line'], $exception->getLine());
36 public function provideUndefinedFunctionData()
44 'message' => 'Call to undefined function test_namespaced_function()',
46 "Attempted to call function \"test_namespaced_function\" from the global namespace.\nDid you mean to call \"\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function\"?",
53 'message' => 'Call to undefined function Foo\\Bar\\Baz\\test_namespaced_function()',
55 "Attempted to call function \"test_namespaced_function\" from namespace \"Foo\\Bar\\Baz\".\nDid you mean to call \"\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function\"?",
62 'message' => 'Call to undefined function foo()',
64 'Attempted to call function "foo" from the global namespace.',
71 'message' => 'Call to undefined function Foo\\Bar\\Baz\\foo()',
73 'Attempted to call function "foo" from namespace "Foo\Bar\Baz".',
79 function test_namespaced_function()