PluginProbe
UpStream: a Project Management Plugin for WordPress / trunk
UpStream: a Project Management Plugin for WordPress vtrunk
trunk 1.39.0 1.39.1 1.39.2 1.39.3 2.0.7 2.1.0
upstream / vendor / symfony / debug / Tests / FatalErrorHandler / UndefinedMethodFatalErrorHandlerTest.php

UndefinedMethodFatalErrorHandlerTest.php in UpStream: a Project Management Plugin for WordPress trunk, at vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php

77 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Debug\Tests\FatalErrorHandler;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Debug\Exception\FatalErrorException;
16 use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
17
18 class UndefinedMethodFatalErrorHandlerTest extends TestCase
19 {
20 /**
21 * @dataProvider provideUndefinedMethodData
22 */
23 public function testUndefinedMethod($error, $translatedMessage)
24 {
25 $handler = new UndefinedMethodFatalErrorHandler();
26 $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
27
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());
33 }
34
35 public function provideUndefinedMethodData()
36 {
37 return [
38 [
39 [
40 'type' => 1,
41 'line' => 12,
42 'file' => 'foo.php',
43 'message' => 'Call to undefined method SplObjectStorage::what()',
44 ],
45 'Attempted to call an undefined method named "what" of class "SplObjectStorage".',
46 ],
47 [
48 [
49 'type' => 1,
50 'line' => 12,
51 'file' => 'foo.php',
52 'message' => 'Call to undefined method SplObjectStorage::walid()',
53 ],
54 "Attempted to call an undefined method named \"walid\" of class \"SplObjectStorage\".\nDid you mean to call \"valid\"?",
55 ],
56 [
57 [
58 'type' => 1,
59 'line' => 12,
60 'file' => 'foo.php',
61 'message' => 'Call to undefined method SplObjectStorage::offsetFet()',
62 ],
63 "Attempted to call an undefined method named \"offsetFet\" of class \"SplObjectStorage\".\nDid you mean to call e.g. \"offsetGet\", \"offsetSet\" or \"offsetUnset\"?",
64 ],
65 [
66 [
67 'type' => 1,
68 'message' => 'Call to undefined method class@anonymous::test()',
69 'file' => '/home/possum/work/symfony/test.php',
70 'line' => 11,
71 ],
72 'Attempted to call an undefined method named "test" of class "class@anonymous".',
73 ],
74 ];
75 }
76 }
77