-
-
Notifications
You must be signed in to change notification settings - Fork 145
/
SmartObject.undeclaredMethod.native.phpt
149 lines (107 loc) 路 3 KB
/
SmartObject.undeclaredMethod.native.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
* Test: PHP native error messages for undeclared method.
*/
declare(strict_types=1);
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
class ParentClass
{
public function callPrivate()
{
$this->privateMethod();
}
public function callPrivateStatic()
{
static::privateStaticMethod();
}
private function callPrivateParent()
{
}
}
class InterClass extends ParentClass
{
public function callParents()
{
parent::callParents();
}
}
class ChildClass extends InterClass
{
public function callParents()
{
parent::callParents();
}
public function callMissingParent()
{
parent::callMissingParent();
}
public static function callMissingParentStatic()
{
parent::callMissingParentStatic();
}
public function callPrivateParent()
{
parent::callPrivateParent();
}
protected function protectedMethod()
{
}
protected static function protectedStaticMethod()
{
}
private function privateMethod()
{
}
private static function privateStaticMethod()
{
}
}
Assert::exception(function () {
$obj = new ParentClass;
$obj->undef();
}, Error::class, 'Call to undefined method ParentClass::undef()');
Assert::exception(function () {
$obj = new ChildClass;
$obj->undef();
}, Error::class, 'Call to undefined method ChildClass::undef()');
Assert::exception(function () {
$obj = new ChildClass;
$obj->callParents();
}, Error::class, 'Call to undefined method ParentClass::callParents()');
Assert::exception(function () {
$obj = new ChildClass;
$obj->callMissingParent();
}, Error::class, 'Call to undefined method InterClass::callMissingParent()');
Assert::exception(function () {
$obj = new ChildClass;
$obj->callMissingParentStatic();
}, Error::class, 'Call to undefined method InterClass::callMissingParentStatic()');
Assert::exception(function () {
$obj = new ChildClass;
$obj::callMissingParentStatic();
}, Error::class, 'Call to undefined method InterClass::callMissingParentStatic()');
Assert::exception(function () {
$obj = new ChildClass;
$obj->callPrivateParent();
}, Error::class, 'Call to private method ParentClass::callPrivateParent() from scope ChildClass');
Assert::exception(function () {
$obj = new ChildClass;
$obj->protectedMethod();
}, Error::class, 'Call to protected method ChildClass::protectedMethod() from global scope');
Assert::exception(function () {
$obj = new ChildClass;
$obj->protectedStaticMethod();
}, Error::class, 'Call to protected method ChildClass::protectedStaticMethod() from global scope');
Assert::exception(function () {
$obj = new ChildClass;
$obj::protectedStaticMethod();
}, Error::class, 'Call to protected method ChildClass::protectedStaticMethod() from global scope');
Assert::exception(function () {
$obj = new ChildClass;
$obj->callPrivate();
}, Error::class, 'Call to private method ChildClass::privateMethod() from scope ParentClass');
Assert::exception(function () {
$obj = new ChildClass;
$obj->callPrivateStatic();
}, Error::class, 'Call to private method ChildClass::privateStaticMethod() from scope ParentClass');